@wayke-se/components-react 5.1.0-beta.0 → 5.1.0-beta.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 +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5170,7 +5170,7 @@ and ensure you are accounting for this risk.
|
|
|
5170
5170
|
`,Jt=Iu.div`
|
|
5171
5171
|
flex: 1 0 50%;
|
|
5172
5172
|
padding: ${m(1)};
|
|
5173
|
-
`;var yy=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],RN=(e,t)=>{switch(t){case"monday":return e("common.mondayShort");case"tuesday":return e("common.tuesdayShort");case"wednesday":return e("common.wednesdayShort");case"thursday":return e("common.thursdayShort");case"friday":return e("common.fridayShort");case"saturday":return e("common.saturdayShort");case"sunday":return e("common.sundayShort")}},_N=[],HN=(e,t)=>yy.reduce((r,i)=>{let n=RN(e,i),o=t[i],a=r?.[r.length-1];return a&&a.from==o?.from&&a.until===o?.until?r[r.length-1].titleTo=n:r.push({titleFrom:n,from:o?.from,until:o?.until}),r},_N.slice()),GN=(e,t)=>{let r=new Date().getDay(),i=yy[r===0?6:r-1],n=t[i];return{title:e(n?"item.openingHoursToday":"item.closedToday"),from:n?.from,until:n?.until}},gy=e=>{let t=e.split(":").map(r=>parseInt(r,10));return new Date().setHours(t[0],t[1]).valueOf()},UN=({openingHours:e})=>{let{t}=FN(),r=Cu(()=>e?GN(t,e):null,[e]),i=Cu(()=>{try{if(r?.from&&r?.until){let o=new Date().valueOf(),a=gy(r.from),s=gy(r.until);return o>=a&&o<=s}}catch{return!1}},[r]),n=Cu(()=>e?HN(t,e):null,[e]);return n?yt.createElement(yt.Fragment,null,yt.createElement(Re,null,yt.createElement(fy,{label:t(i?"item.open":"item.closed"),severity:i?"positive":"negative"})),yt.createElement(Re,null,yt.createElement(Ts,null,yt.createElement(Gi,null,yt.createElement(Jt,null,yt.createElement(Si,null,r?.title)),yt.createElement(Jt,null,yt.createElement(Si,null,r?.from?`${r.from} - ${r.until}`:t("item.closed")))),n.map(o=>yt.createElement(Gi,{key:o.titleFrom},yt.createElement(Jt,null,o.titleTo?`${o.titleFrom} - ${o.titleTo}`:o.titleFrom),yt.createElement(Jt,null,o.from?`${o.from} - ${o.until}`:t("item.closed"))))))):null},by=UN;import Ui,{useCallback as QN,useState as jN}from"react";import{useTranslation as YN}from"react-i18next";var WN=({phoneNumber:e})=>{let{t}=YN(),[r,i]=jN(!1),n=QN(()=>!r&&i(!0),[r]);return Ui.createElement(Gi,null,Ui.createElement(Jt,null,t("other.phoneNumber")),Ui.createElement(Jt,null,r?Ui.createElement(eo,{as:"a",href:`tel:${e}`,title:t("other.callPhoneNumber",{phoneNumber:e})||""},Ui.createElement(ie,null,e)):Ui.createElement(eo,{onClick:n,title:t("other.showPhoneNumber")||""},Ui.createElement(ie,null,t("other.showPhoneNumber")))))},ky=WN;import{parsePhoneNumberFromString as VN}from"libphonenumber-js/core";var vy={version:4,country_calling_codes:{"46":["SE"],"47":["NO"]},countries:{NO:["47","00","(?:0|[2-9]\\d{3})\\d{4}",[5,8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]"]]],0,0,0,0,0,"[02-689]|7[0-8]",[["(?:2[1-4]|3[1-3578]|5[1-35-7]|6[1-4679]|7[0-8])\\d{6}",[8]],["(?:4[015-8]|9\\d)\\d{6}",[8]],["80[01]\\d{5}",[8]],["82[09]\\d{5}",[8]],["880\\d{5}",[8]],0,["(?:0[2-9]|81(?:0(?:0[7-9]|1\\d)|5\\d\\d))\\d{3}"],0,["85[0-5]\\d{5}",[8]],["810(?:0[0-6]|[2-8]\\d)\\d{3}",[8]]]],SE:["46","00","(?:[26]\\d\\d|9)\\d{9}|[1-9]\\d{8}|[1-689]\\d{7}|[1-4689]\\d{6}|2\\d{5}",[6,7,8,9,10],[["(\\d{2})(\\d{2,3})(\\d{2})","$1-$2 $3",["20"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{4})","$1-$2",["9(?:00|39|44|9)"],"0$1",0,"$1 $2"],["(\\d{2})(\\d{3})(\\d{2})","$1-$2 $3",["[12][136]|3[356]|4[0246]|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3"],["(\\d)(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2,3})(\\d{2})","$1-$2 $3",["1[2457]|2(?:[247-9]|5[0138])|3[0247-9]|4[1357-9]|5[0-35-9]|6(?:[125689]|4[02-57]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{2,3})(\\d{3})","$1-$2 $3",["9(?:00|39|44)"],"0$1",0,"$1 $2 $3"],["(\\d{2})(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["1[13689]|2[0136]|3[1356]|4[0246]|54|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3 $4"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["10|7"],"0$1",0,"$1 $2 $3 $4"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1-$2 $3 $4",["[13-5]|2(?:[247-9]|5[0138])|6(?:[124-689]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{3})","$1-$2 $3 $4",["9"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4 $5",["[26]"],"0$1",0,"$1 $2 $3 $4 $5"]],"0",0,0,0,0,0,[["(?:(?:[12][136]|3[356]|4[0246]|6[03]|8\\d)\\d|90[1-9])\\d{4,6}|(?:1(?:2[0-35]|4[0-4]|5[0-25-9]|7[13-6]|[89]\\d)|2(?:2[0-7]|4[0136-8]|5[0138]|7[018]|8[01]|9[0-57])|3(?:0[0-4]|1\\d|2[0-25]|4[056]|7[0-2]|8[0-3]|9[023])|4(?:1[013-8]|3[0135]|5[14-79]|7[0-246-9]|8[0156]|9[0-689])|5(?:0[0-6]|[15][0-5]|2[0-68]|3[0-4]|4\\d|6[03-5]|7[013]|8[0-79]|9[01])|6(?:1[1-3]|2[0-4]|4[02-57]|5[0-37]|6[0-3]|7[0-2]|8[0247]|9[0-356])|9(?:1[0-68]|2\\d|3[02-5]|4[0-3]|5[0-4]|[68][01]|7[0135-8]))\\d{5,6}",[7,8,9]],["7[02369]\\d{7}",[9]],["20\\d{4,7}",[6,7,8,9]],["649\\d{6}|99[1-59]\\d{4}(?:\\d{3})?|9(?:00|39|44)[1-8]\\d{3,6}",[7,8,9,10]],["75[1-8]\\d{6}",[9]],0,["10[1-8]\\d{6}",[9]],["74[02-9]\\d{6}",[9]],0,["77[0-7]\\d{6}",[9]]]]},nonGeographic:{}};var JN=vy,KN=JN,Ms=e=>{try{return VN(e.replace("-","").replace(/ /g,""),KN)?.formatNational()||e}catch{return e}};import Kt,{useCallback as wy,useContext as qN,useState as zN}from"react";import{useTranslation as ZN}from"react-i18next";var XN=({loading:e,connections:t,onClose:r})=>{let{t:i}=ZN(),{centralStorageId:n,setCentralStorageId:o}=qN(Nn),[a,s]=zN(n),l=wy(d=>{d&&o(d)},[]),u=wy(d=>s(d.currentTarget.value),[]);return a?Kt.createElement(Ee,{title:i("item.switchBranch"),onClose:r},Kt.createElement(T,null,Kt.createElement(pe,null,Kt.createElement(ne,null,Kt.createElement("p",null,i("item.switchBranchDescription")))),Kt.createElement(pe,null,Kt.createElement(ni,null,i("item.chooseBranch")),Kt.createElement(ks,{value:a,onChange:u,options:t?.map(d=>({value:d.id,displayName:d.name})),title:i("item.chooseBranch")}))),Kt.createElement(T,null,Kt.createElement(st,{disabled:e,fullWidth:!0,onClick:()=>l(a),title:i("item.chooseSelectedBranch")||""},Kt.createElement(ie,null,i("common.choose"))))):null},Bs=XN;var iD=({branch:e,loading:t,displayBranchName:r})=>{let{t:i}=rD(),[n,o]=tD(!1),a=xy(()=>o(!0),[]),s=xy(()=>o(!1),[]);return eD(()=>{e&&n&&o(!1)},[e]),e?Le.createElement(Le.Fragment,null,n&&Le.createElement(Bs,{loading:t,connections:e?.connections,onClose:s}),Le.createElement(T,null,Le.createElement(Ke,{noMargin:!0},r?`${i("item.thisCarsIsLocatedAt")} ${e.name}`:e?.location?.city?i("item.thisCarIsAvailableAtOurBranch",{location:e?.location?.city}):i("item.contact"))),Le.createElement(T,null,Le.createElement(hy,{position:e?.location?.position})),(e?.connections?.length||0)>1&&Le.createElement(T,null,Le.createElement(ne,null,Le.createElement("p",null,i("item.centralWarehouseCarDescriptionShort")," ",Le.createElement(we,{as:"span",role:"button",onClick:a,inline:!0,title:i("item.clickHereToShowContactToAnotherBranch")||""},i("item.clickHereToShowContactToAnotherBranch")),"."))),Le.createElement(T,null,Le.createElement(Tg,null,Le.createElement(T,null,Le.createElement(Ts,null,e?.location?.streetAddress&&e?.location?.city&&Le.createElement(Gi,null,Le.createElement(Jt,null,i("common.address")),Le.createElement(Jt,null,Le.createElement(eo,null,Le.createElement(ie,null,`${e?.location?.streetAddress}, ${e?.location?.city}`)))),e?.contact?.phonenumber&&Le.createElement(ky,{phoneNumber:Ms(e.contact.phonenumber)}))),e?.openingHours&&Le.createElement(T,null,Le.createElement(by,{openingHours:e.openingHours}))))):null},Ey=iD;import{format as LD}from"date-fns";import{nb as FD,sv as RD}from"date-fns/locale";import fe,{useCallback as Hs,useEffect as _D,useState as ib}from"react";import{useTranslation as HD}from"react-i18next";import oi,{useCallback as Qi,useMemo as _y,useState as xD}from"react";import{useTranslation as ED}from"react-i18next";var Iy=[{type:"ecom"},{type:"email"},{type:"phone"}];import Ae,{useCallback as Nu,useId as mD,useMemo as pD,useState as Ps}from"react";import{useTranslation as hD}from"react-i18next";import{useCallback as oD,useState as Cy}from"react";var Bn={name:"@wayke-se/components-react",version:"5.1.0-beta.0",description:"",module:"dist/index.mjs",main:"dist/index.js",types:"dist/index.d.ts",type:"module",files:["dist"],scripts:{prebuild:"npm run clean",test:"npm run lint && npm run typecheck",lint:"npx @biomejs/biome check","lint:fix":"npx @biomejs/biome check --write",typecheck:"tsc --noEmit --skipLibCheck",gen:"graphql-codegen --config ./codegen.yml","generate-libphonenumber-metadata":"libphonenumber-metadata-generator src/utils/metadata.min.json --countries SE,NO --extended",prepare:"husky",start:"node ./esbuild/start.js",build:"npm run clean && node ./esbuild/lib.js",clean:"rimraf build && rimraf dist && rimraf dist-cdn","build:types":"tsc --emitDeclarationOnly --declaration --project tsconfig.build.json"},repository:{type:"git",url:"git+https://github.com/wayke-se/components-react.git"},author:"Ourstudio",license:"MIT",peerDependencies:{react:"^18 || ^19","react-dom":"^18 || ^19","styled-components":"^6"},devDependencies:{"@biomejs/biome":"2.4.16","@graphql-codegen/cli":"^7.1.2","@graphql-codegen/typescript":"^6.0.2","@types/googlemaps":"^3.43.3","@types/node":"^25.9.2","@types/react":"^19.2.17","@types/react-dom":"^19.2.3","@types/react-slick":"^0.23.13","@wayke-se/ecom-web":"^2.1.0",dotenv:"^17.4.2",esbuild:"^0.28.0","esbuild-plugin-copy":"^2.1.1",husky:"^9.1.7","libphonenumber-metadata-generator":"^2.0.6","lint-staged":"^17.0.7","npm-dts":"^1.3.13",react:"^19.2.7","react-dom":"^19.2.7","react-router-dom":"^7.17.0",rimraf:"^6.1.3","styled-components":"^6.4.2",typescript:"^6.0.3"},dependencies:{"@apollo/client":"^4.2.3","@emotion/is-prop-valid":"^1.4.0","@photo-sphere-viewer/core":"^5.14.1","date-fns":"^4.4.0",graphql:"^16.14.2",i18next:"^26.3.1","libphonenumber-js":"^1.13.6",marked:"^18.0.5","react-compound-slider":"^3.4.0","react-i18next":"^17.0.8","react-slick":"^0.31.0","scroll-into-view-if-needed":"^3.1.0"}};var aD=(e,t="SE")=>{let[r,i]=Cy(!1),[n,o]=Cy(null),a=oD(async({itemId:s,branchId:l,communication:u,firstName:d,lastName:h,phoneNumber:p,email:f,message:v,tradeInCarRegNo:k,tradeInCarMileage:A})=>{if(!e)throw new Error("Missing apiUrl, cannot submit lead");i(!0),o(null);let y={firstName:d,lastName:h,phoneNumber:p,email:f,branchId:l,type:"registrationOfInterestToBuy",metaData:[{key:"source",value:window.location.hostname.replace(/^www\./,"")},{key:"sourceMechanism",value:`cta.${u}`},{key:"client",value:"components-react"},{key:"clientVersion",value:Bn.version},{key:"itemForSaleId",value:s},...k?[{key:"registrationNumber",value:k}]:[],...A?[{key:"tradeInCarMileage",value:A},{key:"readingUnit",value:t==="NO"?"Kilometer":"ScandinavianMile"}]:[],{key:"message",value:v||""}]};try{let g=`${new URL(e).origin}/lead`,w=await fetch(g,{method:"POST",body:JSON.stringify(y),headers:{"Content-Type":"application/json; charset=UTF-8"}});if(!w.ok)throw new Error(`Request failed with status ${w.status}`);return await w.json()}catch(g){throw o(g instanceof Error?g.message:"Something went wrong"),g}finally{i(!1)}},[e,t]);return{isLoading:r,error:n,submitLead:a}},Sy=aD;import lD from"react";import sD from"styled-components";var Ny=sD.div`
|
|
5173
|
+
`;var yy=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],RN=(e,t)=>{switch(t){case"monday":return e("common.mondayShort");case"tuesday":return e("common.tuesdayShort");case"wednesday":return e("common.wednesdayShort");case"thursday":return e("common.thursdayShort");case"friday":return e("common.fridayShort");case"saturday":return e("common.saturdayShort");case"sunday":return e("common.sundayShort")}},_N=[],HN=(e,t)=>yy.reduce((r,i)=>{let n=RN(e,i),o=t[i],a=r?.[r.length-1];return a&&a.from==o?.from&&a.until===o?.until?r[r.length-1].titleTo=n:r.push({titleFrom:n,from:o?.from,until:o?.until}),r},_N.slice()),GN=(e,t)=>{let r=new Date().getDay(),i=yy[r===0?6:r-1],n=t[i];return{title:e(n?"item.openingHoursToday":"item.closedToday"),from:n?.from,until:n?.until}},gy=e=>{let t=e.split(":").map(r=>parseInt(r,10));return new Date().setHours(t[0],t[1]).valueOf()},UN=({openingHours:e})=>{let{t}=FN(),r=Cu(()=>e?GN(t,e):null,[e]),i=Cu(()=>{try{if(r?.from&&r?.until){let o=new Date().valueOf(),a=gy(r.from),s=gy(r.until);return o>=a&&o<=s}}catch{return!1}},[r]),n=Cu(()=>e?HN(t,e):null,[e]);return n?yt.createElement(yt.Fragment,null,yt.createElement(Re,null,yt.createElement(fy,{label:t(i?"item.open":"item.closed"),severity:i?"positive":"negative"})),yt.createElement(Re,null,yt.createElement(Ts,null,yt.createElement(Gi,null,yt.createElement(Jt,null,yt.createElement(Si,null,r?.title)),yt.createElement(Jt,null,yt.createElement(Si,null,r?.from?`${r.from} - ${r.until}`:t("item.closed")))),n.map(o=>yt.createElement(Gi,{key:o.titleFrom},yt.createElement(Jt,null,o.titleTo?`${o.titleFrom} - ${o.titleTo}`:o.titleFrom),yt.createElement(Jt,null,o.from?`${o.from} - ${o.until}`:t("item.closed"))))))):null},by=UN;import Ui,{useCallback as QN,useState as jN}from"react";import{useTranslation as YN}from"react-i18next";var WN=({phoneNumber:e})=>{let{t}=YN(),[r,i]=jN(!1),n=QN(()=>!r&&i(!0),[r]);return Ui.createElement(Gi,null,Ui.createElement(Jt,null,t("other.phoneNumber")),Ui.createElement(Jt,null,r?Ui.createElement(eo,{as:"a",href:`tel:${e}`,title:t("other.callPhoneNumber",{phoneNumber:e})||""},Ui.createElement(ie,null,e)):Ui.createElement(eo,{onClick:n,title:t("other.showPhoneNumber")||""},Ui.createElement(ie,null,t("other.showPhoneNumber")))))},ky=WN;import{parsePhoneNumberFromString as VN}from"libphonenumber-js/core";var vy={version:4,country_calling_codes:{"46":["SE"],"47":["NO"]},countries:{NO:["47","00","(?:0|[2-9]\\d{3})\\d{4}",[5,8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]"]]],0,0,0,0,0,"[02-689]|7[0-8]",[["(?:2[1-4]|3[1-3578]|5[1-35-7]|6[1-4679]|7[0-8])\\d{6}",[8]],["(?:4[015-8]|9\\d)\\d{6}",[8]],["80[01]\\d{5}",[8]],["82[09]\\d{5}",[8]],["880\\d{5}",[8]],0,["(?:0[2-9]|81(?:0(?:0[7-9]|1\\d)|5\\d\\d))\\d{3}"],0,["85[0-5]\\d{5}",[8]],["810(?:0[0-6]|[2-8]\\d)\\d{3}",[8]]]],SE:["46","00","(?:[26]\\d\\d|9)\\d{9}|[1-9]\\d{8}|[1-689]\\d{7}|[1-4689]\\d{6}|2\\d{5}",[6,7,8,9,10],[["(\\d{2})(\\d{2,3})(\\d{2})","$1-$2 $3",["20"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{4})","$1-$2",["9(?:00|39|44|9)"],"0$1",0,"$1 $2"],["(\\d{2})(\\d{3})(\\d{2})","$1-$2 $3",["[12][136]|3[356]|4[0246]|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3"],["(\\d)(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2,3})(\\d{2})","$1-$2 $3",["1[2457]|2(?:[247-9]|5[0138])|3[0247-9]|4[1357-9]|5[0-35-9]|6(?:[125689]|4[02-57]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{2,3})(\\d{3})","$1-$2 $3",["9(?:00|39|44)"],"0$1",0,"$1 $2 $3"],["(\\d{2})(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["1[13689]|2[0136]|3[1356]|4[0246]|54|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3 $4"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["10|7"],"0$1",0,"$1 $2 $3 $4"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1-$2 $3 $4",["[13-5]|2(?:[247-9]|5[0138])|6(?:[124-689]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{3})","$1-$2 $3 $4",["9"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4 $5",["[26]"],"0$1",0,"$1 $2 $3 $4 $5"]],"0",0,0,0,0,0,[["(?:(?:[12][136]|3[356]|4[0246]|6[03]|8\\d)\\d|90[1-9])\\d{4,6}|(?:1(?:2[0-35]|4[0-4]|5[0-25-9]|7[13-6]|[89]\\d)|2(?:2[0-7]|4[0136-8]|5[0138]|7[018]|8[01]|9[0-57])|3(?:0[0-4]|1\\d|2[0-25]|4[056]|7[0-2]|8[0-3]|9[023])|4(?:1[013-8]|3[0135]|5[14-79]|7[0-246-9]|8[0156]|9[0-689])|5(?:0[0-6]|[15][0-5]|2[0-68]|3[0-4]|4\\d|6[03-5]|7[013]|8[0-79]|9[01])|6(?:1[1-3]|2[0-4]|4[02-57]|5[0-37]|6[0-3]|7[0-2]|8[0247]|9[0-356])|9(?:1[0-68]|2\\d|3[02-5]|4[0-3]|5[0-4]|[68][01]|7[0135-8]))\\d{5,6}",[7,8,9]],["7[02369]\\d{7}",[9]],["20\\d{4,7}",[6,7,8,9]],["649\\d{6}|99[1-59]\\d{4}(?:\\d{3})?|9(?:00|39|44)[1-8]\\d{3,6}",[7,8,9,10]],["75[1-8]\\d{6}",[9]],0,["10[1-8]\\d{6}",[9]],["74[02-9]\\d{6}",[9]],0,["77[0-7]\\d{6}",[9]]]]},nonGeographic:{}};var JN=vy,KN=JN,Ms=e=>{try{return VN(e.replace("-","").replace(/ /g,""),KN)?.formatNational()||e}catch{return e}};import Kt,{useCallback as wy,useContext as qN,useState as zN}from"react";import{useTranslation as ZN}from"react-i18next";var XN=({loading:e,connections:t,onClose:r})=>{let{t:i}=ZN(),{centralStorageId:n,setCentralStorageId:o}=qN(Nn),[a,s]=zN(n),l=wy(d=>{d&&o(d)},[]),u=wy(d=>s(d.currentTarget.value),[]);return a?Kt.createElement(Ee,{title:i("item.switchBranch"),onClose:r},Kt.createElement(T,null,Kt.createElement(pe,null,Kt.createElement(ne,null,Kt.createElement("p",null,i("item.switchBranchDescription")))),Kt.createElement(pe,null,Kt.createElement(ni,null,i("item.chooseBranch")),Kt.createElement(ks,{value:a,onChange:u,options:t?.map(d=>({value:d.id,displayName:d.name})),title:i("item.chooseBranch")}))),Kt.createElement(T,null,Kt.createElement(st,{disabled:e,fullWidth:!0,onClick:()=>l(a),title:i("item.chooseSelectedBranch")||""},Kt.createElement(ie,null,i("common.choose"))))):null},Bs=XN;var iD=({branch:e,loading:t,displayBranchName:r})=>{let{t:i}=rD(),[n,o]=tD(!1),a=xy(()=>o(!0),[]),s=xy(()=>o(!1),[]);return eD(()=>{e&&n&&o(!1)},[e]),e?Le.createElement(Le.Fragment,null,n&&Le.createElement(Bs,{loading:t,connections:e?.connections,onClose:s}),Le.createElement(T,null,Le.createElement(Ke,{noMargin:!0},r?`${i("item.thisCarsIsLocatedAt")} ${e.name}`:e?.location?.city?i("item.thisCarIsAvailableAtOurBranch",{location:e?.location?.city}):i("item.contact"))),Le.createElement(T,null,Le.createElement(hy,{position:e?.location?.position})),(e?.connections?.length||0)>1&&Le.createElement(T,null,Le.createElement(ne,null,Le.createElement("p",null,i("item.centralWarehouseCarDescriptionShort")," ",Le.createElement(we,{as:"span",role:"button",onClick:a,inline:!0,title:i("item.clickHereToShowContactToAnotherBranch")||""},i("item.clickHereToShowContactToAnotherBranch")),"."))),Le.createElement(T,null,Le.createElement(Tg,null,Le.createElement(T,null,Le.createElement(Ts,null,e?.location?.streetAddress&&e?.location?.city&&Le.createElement(Gi,null,Le.createElement(Jt,null,i("common.address")),Le.createElement(Jt,null,Le.createElement(eo,null,Le.createElement(ie,null,`${e?.location?.streetAddress}, ${e?.location?.city}`)))),e?.contact?.phonenumber&&Le.createElement(ky,{phoneNumber:Ms(e.contact.phonenumber)}))),e?.openingHours&&Le.createElement(T,null,Le.createElement(by,{openingHours:e.openingHours}))))):null},Ey=iD;import{format as LD}from"date-fns";import{nb as FD,sv as RD}from"date-fns/locale";import fe,{useCallback as Hs,useEffect as _D,useState as ib}from"react";import{useTranslation as HD}from"react-i18next";import oi,{useCallback as Qi,useMemo as _y,useState as xD}from"react";import{useTranslation as ED}from"react-i18next";var Iy=[{type:"ecom"},{type:"email"},{type:"phone"}];import Ae,{useCallback as Nu,useId as mD,useMemo as pD,useState as Ps}from"react";import{useTranslation as hD}from"react-i18next";import{useCallback as oD,useState as Cy}from"react";var Bn={name:"@wayke-se/components-react",version:"5.1.0-beta.1",description:"",module:"dist/index.mjs",main:"dist/index.js",types:"dist/index.d.ts",type:"module",files:["dist"],scripts:{prebuild:"npm run clean",test:"npm run lint && npm run typecheck",lint:"npx @biomejs/biome check","lint:fix":"npx @biomejs/biome check --write",typecheck:"tsc --noEmit --skipLibCheck",gen:"graphql-codegen --config ./codegen.yml","generate-libphonenumber-metadata":"libphonenumber-metadata-generator src/utils/metadata.min.json --countries SE,NO --extended",prepare:"husky",start:"node ./esbuild/start.js",build:"npm run clean && node ./esbuild/lib.js",clean:"rimraf build && rimraf dist && rimraf dist-cdn","build:types":"tsc --emitDeclarationOnly --declaration --project tsconfig.build.json"},repository:{type:"git",url:"git+https://github.com/wayke-se/components-react.git"},author:"Ourstudio",license:"MIT",peerDependencies:{react:"^18 || ^19","react-dom":"^18 || ^19","styled-components":"^6"},devDependencies:{"@biomejs/biome":"2.4.16","@graphql-codegen/cli":"^7.1.2","@graphql-codegen/typescript":"^6.0.2","@types/googlemaps":"^3.43.3","@types/node":"^25.9.2","@types/react":"^19.2.17","@types/react-dom":"^19.2.3","@types/react-slick":"^0.23.13","@wayke-se/ecom-web":"^2.1.0",dotenv:"^17.4.2",esbuild:"^0.28.0","esbuild-plugin-copy":"^2.1.1",husky:"^9.1.7","libphonenumber-metadata-generator":"^2.0.6","lint-staged":"^17.0.7","npm-dts":"^1.3.13",react:"^19.2.7","react-dom":"^19.2.7","react-router-dom":"^7.17.0",rimraf:"^6.1.3","styled-components":"^6.4.2",typescript:"^6.0.3"},dependencies:{"@apollo/client":"^4.2.3","@emotion/is-prop-valid":"^1.4.0","@photo-sphere-viewer/core":"^5.14.1","date-fns":"^4.4.0",graphql:"^16.14.2",i18next:"^26.3.1","libphonenumber-js":"^1.13.6",marked:"^18.0.5","react-compound-slider":"^3.4.0","react-i18next":"^17.0.8","react-slick":"^0.31.0","scroll-into-view-if-needed":"^3.1.0"}};var aD=(e,t="SE")=>{let[r,i]=Cy(!1),[n,o]=Cy(null),a=oD(async({itemId:s,branchId:l,communication:u,firstName:d,lastName:h,phoneNumber:p,email:f,message:v,tradeInCarRegNo:k,tradeInCarMileage:A})=>{if(!e)throw new Error("Missing apiUrl, cannot submit lead");i(!0),o(null);let y={firstName:d,lastName:h,phoneNumber:p,email:f,branchId:l,type:"registrationOfInterestToBuy",metaData:[{key:"source",value:window.location.hostname.replace(/^www\./,"")},{key:"sourceMechanism",value:`cta.${u}`},{key:"client",value:"components-react"},{key:"clientVersion",value:Bn.version},{key:"itemForSaleId",value:s},...k?[{key:"registrationNumber",value:k}]:[],...A?[{key:"tradeInCarMileage",value:A},{key:"readingUnit",value:t==="NO"?"Kilometer":"ScandinavianMile"}]:[],{key:"message",value:v||""}]};try{let g=`${new URL(e).origin}/lead`,w=await fetch(g,{method:"POST",body:JSON.stringify(y),headers:{"Content-Type":"application/json; charset=UTF-8"}});if(!w.ok)throw new Error(`Request failed with status ${w.status}`);return await w.json()}catch(g){throw o(g instanceof Error?g.message:"Something went wrong"),g}finally{i(!1)}},[e,t]);return{isLoading:r,error:n,submitLead:a}},Sy=aD;import lD from"react";import sD from"styled-components";var Ny=sD.div`
|
|
5174
5174
|
margin-top: ${m(.5)};
|
|
5175
5175
|
font-size: 0.875rem;
|
|
5176
5176
|
color: ${e=>e.theme.color.ui.negative};
|