mottled-library
Advanced tools
Comparing version 0.0.16 to 0.0.17
import { useClickedOutside, useDebounce, useIsMounted, useMountedState, useLocalStorage } from "./hooks"; | ||
export { useClickedOutside, useDebounce, useIsMounted, useMountedState, useLocalStorage, }; | ||
export declare type Network = "polkadot" | "kusama" | "westend" | "rococo" | "statemine" | "statemint"; | ||
export declare type Network = "polkadot" | "kusama" | "westend" | "rococo" | "statemine" | "statemint" | "westmint"; | ||
export interface NetworkDetails { | ||
@@ -5,0 +5,0 @@ id: string; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../../core/index.js"),o=require("../../components/Button/Button.js"),n=require("../../components/NetworkIcon/NetworkIcon.js");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("../../components/Accordion/Accordion.js");var l=r(e);const c=(e,t,o,n,r=!1)=>({backgroundColor:e,hover:{backgroundColor:t,border:`0.1rem solid ${e}`},display:r?n>0?"flex":"none":o?"none":"flex"}),u=l.default.memo((({network:e,active:t,cb:r,type:c,leftPosition:u,primary:a})=>{const s=Object.assign({},{left:`${u}px`},t?{backgroundColor:"#ffffff",color:a,hover:{backgroundColor:"#ffffff",color:a}}:{});return l.default.createElement(o.Button,{cName:"positioning _mottled_button_ow",st:s,onClick:()=>r(e)},l.default.createElement(n.NetworkIcon,{size:"2xl",network:e,show:c}))}));exports.NetworkSlider=({networks:n,defaultNetwork:r,setNetwork:a,type:s="both"})=>{const[i,d]=e.useState(r||n&&n[0].toString()||"polkadot"),[f,k]=e.useState(190),m=n||t.defaultChains,p=e.useRef(null),[w,h]=e.useState(0),[v,g]=e.useState(!0),[b,C]=e.useState({}),[N,_]=e.useState(m.length);return e.useEffect((()=>{"icon"===s?k(50):"name"===s&&k(130)}),[s]),e.useEffect((()=>{if(p.current){const e=(null==p?void 0:p.current).offsetWidth,t=Math.trunc(e/f);_(m.length-t);const o=m.length*f;g(o<=e||N===w)}}),[m.length,w,f,p]),e.useEffect((()=>{const e=t.getChain(i);C(e||t.unknownNetwork(i)),a(e||t.unknownNetwork(i))}),[i]),l.default.createElement("div",{"data-testid":"NetworkSlider",ref:p,style:{background:null==b?void 0:b.secColor},className:"_mottled_SliderButtons"},l.default.createElement(o.Button,{cName:"_mottled_handle",st:c(null==b?void 0:b.color,null==b?void 0:b.secColor,v,w,!0),onClick:()=>h(w-1)},"<"),l.default.createElement(o.Button,{st:c(null==b?void 0:b.color,null==b?void 0:b.secColor,v,w),cName:"_mottled_handle handle_right",onClick:()=>h(w+1)},">"),m.map((e=>l.default.createElement(u,{primary:null==b?void 0:b.color,secondary:null==b?void 0:b.secColor,leftPosition:-w*f,key:e,network:e,type:s,active:i===e,cb:d}))))}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../../core/index.js"),o=require("../../components/Button/Button.js"),n=require("../../components/NetworkIcon/NetworkIcon.js");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("../../components/Accordion/Accordion.js");var l=r(e);const c=(e,t,o,n,r=!1)=>({backgroundColor:e,hover:{backgroundColor:t,border:`0.1rem solid ${e}`},display:r?n>0?"flex":"none":o?"none":"flex"}),u=l.default.memo((({network:e,active:t,cb:r,type:c,leftPosition:u,primary:s})=>{const a=Object.assign({},{left:`${u}px`},t?{backgroundColor:"#ffffff",color:s,hover:{backgroundColor:"#ffffff",color:s}}:{});return l.default.createElement(o.Button,{cName:"positioning _mottled_button_ow",st:a,onClick:()=>r(e)},l.default.createElement(n.NetworkIcon,{size:"2xl",network:e,show:c}))}));exports.NetworkSlider=({networks:n,defaultNetwork:r,setNetwork:s,type:a="both"})=>{const i="icon"===a?50:"name"===a?130:190,d=n||t.defaultChains,[f,k]=e.useState(r||n&&n[0].toString()||"polkadot"),m=e.useRef(null),[v,w]=e.useState(0),[h,p]=e.useState(!0),[g,N]=e.useState({}),[b,C]=e.useState(d.length);return e.useEffect((()=>{const e=(null==m?void 0:m.current).offsetWidth,t=Math.trunc(e/i);if(r){const e=null==d?void 0:d.findIndex((e=>e===r));e<0?console.log("defaultNetwork",e):e+1-t>0&&w(e+1-t)}}),[r,m]),e.useEffect((()=>{if(m.current){const e=(null==m?void 0:m.current).offsetWidth,t=Math.trunc(e/i);C(d.length-t);const o=d.length*i;p(o<=e||b===v)}}),[d,v,i,m]),e.useEffect((()=>{const e=t.getChain(f);N(e||t.unknownNetwork(f)),s(e||t.unknownNetwork(f))}),[f]),l.default.createElement("div",{"data-testid":"NetworkSlider",ref:m,style:{background:null==g?void 0:g.secColor},className:"_mottled_SliderButtons"},l.default.createElement(o.Button,{cName:"_mottled_handle",st:c(null==g?void 0:g.color,null==g?void 0:g.secColor,h,v,!0),onClick:()=>w(v-1)},"<"),l.default.createElement(o.Button,{st:c(null==g?void 0:g.color,null==g?void 0:g.secColor,h,v),cName:"_mottled_handle handle_right",onClick:()=>w(v+1)},">"),d.map((e=>l.default.createElement(u,{primary:null==g?void 0:g.color,secondary:null==g?void 0:g.secColor,leftPosition:-v*i,key:e,network:e,type:a,active:f===e,cb:k}))))}; |
{ | ||
"name": "mottled-library", | ||
"version": "0.0.16", | ||
"version": "0.0.17", | ||
"author": "Parity Team <admin@parity.io>", | ||
@@ -5,0 +5,0 @@ "maintainers": [ |
Sorry, the diff of this file is not supported yet
4108844