@mapfirst.ai/react 0.0.36 → 0.0.37
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/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1587 -3
- package/dist/index.mjs +1546 -3
- package/package.json +8 -7
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,1549 @@
|
|
|
1
|
-
import R from"react";import{MapFirstCore as Ge}from"@mapfirst.ai/core";import{processApiFilters as Dr,convertToApiFilters as Hr}from"@mapfirst.ai/core";import{useCallback as re}from"react";import de from"react";import he from"react";import{jsx as M,jsxs as V}from"react/jsx-runtime";var ne=({className:e,style:t})=>V("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:[M("circle",{cx:"11",cy:"11",r:"8"}),M("path",{d:"m21 21-4.35-4.35"})]}),oe=({className:e,style:t})=>V("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:[M("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),M("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),D=({className:e,style:t})=>V("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:[M("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),M("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),Q=({className:e,style:t})=>M("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:M("polyline",{points:"9 18 15 12 9 6"})}),ie=({className:e,style:t,fill:p="none"})=>M("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:p,stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:M("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})});import{jsx as ae}from"react/jsx-runtime";var be={position:"absolute",top:"-8px",right:"-8px",padding:"2px",borderRadius:"50%",backgroundColor:"white",border:"1px solid #03852e",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background-color 0.2s"},Ce={width:"17px",height:"17px"},E=({onClick:e,style:t})=>{let[p,i]=he.useState(!1);return ae("button",{style:{...be,backgroundColor:p?"#e5e5e5":"white",...t},onClick:e,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),"aria-label":"Remove filter",children:ae(oe,{style:Ce})})};import{jsx as q,jsxs as ve}from"react/jsx-runtime";var xe={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"8px",flexShrink:0,height:"34px"},K=({label:e,icon:t,remove:p,style:i})=>ve("div",{style:{...xe,...i},children:[t&&q("span",{style:{display:"flex",alignItems:"center"},children:t}),q("span",{style:{whiteSpace:"nowrap"},children:e}),q(E,{onClick:p})]});import{useState as Le}from"react";import{useCallback as se,useState as Se}from"react";var ke={"smartFilter.typingPrompt":"Search for hotels, restaurants, or attractions...","smartFilter.nav.previous":"Previous filters","smartFilter.nav.next":"Next filters","smartFilter.toast.locationRequired":"Please select a location first","smartFilter.clearAll":"Clear all","smartFilter.minRating.suffix":"+","smartFilter.minRating.label":"{{value}}+","smartFilter.minRating.remove":"Remove rating filter","smartFilter.minRating.setTo":"Set rating to {{rating}}","smartFilter.priceRange.label":"Price Range","smartFilter.priceRange.remove":"Remove price filter","smartFilter.priceRange.edit":"Edit price","smartFilter.transformedQuery.remove":"Remove search query","smartFilter.transformedQuery.edit":"Edit search query","smartFilter.restaurantPriceLevel.label":"Price Level","smartFilter.restaurantPriceLevel.remove":"Remove price level filter","smartFilter.restaurantPriceLevel.none":"Any","smartFilter.restaurantPriceLevel.options.cheapEats":"Cheap Eats","smartFilter.restaurantPriceLevel.options.midRange":"Mid Range","smartFilter.restaurantPriceLevel.options.fineDining":"Fine Dining"},Fe=(e,t="USD")=>new Intl.NumberFormat("en-US",{style:"currency",currency:t,minimumFractionDigits:0,maximumFractionDigits:0}).format(e),w=(e,t)=>{let[p,i]=Se("en"),c=se((h,s)=>{let m={...ke,...e}[h]||h;return s&&Object.keys(s).forEach(g=>{m=m.replace(new RegExp(`{{${g}}}`,"g"),String(s[g]))}),m},[e]),y=se((h,s)=>t?t(h,s):Fe(h,s),[t]);return{t:c,locale:p,setLocale:i,formatCurrency:y}};import{jsx as H,jsxs as Pe}from"react/jsx-runtime";var Re=e=>{let t=[],p=Math.floor(e),i=e%1!==0,c={display:"block",width:"12px",height:"12px",borderRadius:"50%",border:"1px solid #03852e",pointerEvents:"none"},y={...c,backgroundColor:"#03852e"},h={...c,background:"linear-gradient(90deg, #03852e 50%, transparent 50%)"};for(let a=0;a<p;a+=1)t.push(H("span",{style:y},`full-${a}`));i&&t.push(H("span",{style:h},"half"));let s=Math.max(0,5-Math.ceil(e));for(let a=0;a<s;a+=1)t.push(H("span",{style:c},`empty-${a}`));return t},st=(e,t)=>Pe("span",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[H("span",{style:{display:"flex",gap:"1px",userSelect:"none"},children:Re(e)})," ",t]}),$=e=>e.toFixed(1),lt=(e,t,p,i)=>`${i(e,p)} - ${i(t!=null?t:0,p)}`;import{jsx as T,jsxs as O}from"react/jsx-runtime";var we={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",gap:"8px",alignItems:"center",justifyContent:"center",flexShrink:0,height:"34px"},Me={display:"flex",gap:"1px",userSelect:"none"},U={display:"block",width:"12px",height:"12px",borderRadius:"50%",border:"1px solid #03852e",pointerEvents:"none"},z={position:"absolute",top:0,height:"100%",cursor:"pointer",backgroundColor:"transparent",border:"none",padding:0},_=({rating:e,onChange:t,onRemove:p,star:i=!1})=>{let[c,y]=Le(null),{t:h}=w(),s=c!=null?c:e,a=b=>i&&b?b.toString():h("smartFilter.minRating.label",{value:$(b)}),m=h("smartFilter.minRating.remove"),g=b=>h("smartFilter.minRating.setTo",{rating:$(b)}),x=b=>{let C=b+1;return s>=C?"full":s>=C-.5?"half":"empty"},f=b=>{y(null),b!==e&&t(b)},k=b=>{var v;let C=b.relatedTarget;(!C||!((v=b.currentTarget.closest("[data-min-rating-chip]"))!=null&&v.contains(C)))&&y(null)};return O("div",{style:we,"data-min-rating-chip":!0,children:[O("div",{style:{display:"flex",alignItems:"center",gap:"4px"},onMouseLeave:()=>y(null),children:[T("div",{style:Me,children:Array.from({length:5}).map((b,C)=>{let v=x(C),l=C+1,n=l-.5;if(i)return O("div",{style:{position:"relative",width:"16px",height:"16px"},children:[T(ie,{fill:s>=l?"#03852e":"none",style:{width:"16px",height:"16px",pointerEvents:"none"}}),T("button",{type:"button",style:{...z,left:0,width:"50%",borderRadius:"50% 0 0 50%"},onMouseEnter:()=>y(n),onFocus:()=>y(n),onBlur:k,onClick:()=>f(n),"aria-label":g(n),title:a(n)}),T("button",{type:"button",style:{...z,left:"50%",width:"50%",borderRadius:"0 50% 50% 0"},onMouseEnter:()=>y(l),onFocus:()=>y(l),onBlur:k,onClick:()=>f(l),"aria-label":g(l),title:a(l)})]},C);let S=v==="full"?{...U,backgroundColor:"#03852e"}:U,u={...U,background:"linear-gradient(90deg, #03852e 50%, transparent 50%)"};return O("div",{style:{position:"relative",width:"12px",height:"12px"},children:[T("span",{style:v==="half"?u:S}),T("button",{type:"button",style:{...z,left:0,width:"50%",borderRadius:"50% 0 0 50%",outline:"2px solid transparent",outlineOffset:"1px"},onMouseEnter:()=>y(n),onFocus:()=>y(n),onBlur:k,onClick:()=>f(n),"aria-label":g(n),title:a(n)}),T("button",{type:"button",style:{...z,left:"50%",width:"50%",borderRadius:"0 50% 50% 0",outline:"2px solid transparent",outlineOffset:"1px"},onMouseEnter:()=>y(l),onFocus:()=>y(l),onBlur:k,onClick:()=>f(l),"aria-label":g(l),title:a(l)})]},C)})}),T("span",{style:{whiteSpace:"nowrap"},children:a(s)})]}),T(E,{onClick:p})]})};import{useEffect as Ee,useState as G}from"react";import{Fragment as Ne,jsx as I,jsxs as Y}from"react/jsx-runtime";var Ie={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"8px",flexShrink:0,height:"34px"},Te={outline:"none",fontSize:"16px",backgroundColor:"transparent",borderRadius:"2px",padding:"2px 8px",width:"64px",textAlign:"center",border:"none"},Be={padding:"4px",borderRadius:"50%",cursor:"pointer",transition:"background-color 0.2s",border:"none",backgroundColor:"transparent",color:"#737373",display:"flex",alignItems:"center",justifyContent:"center"},le=({boundary:e,label:t,value:p,placeholder:i,currency:c,isOptional:y=!1,showRemoveButton:h=!1,removeLabel:s,editLabel:a,showAddWhenEmpty:m=!1,onCommit:g,onRemove:x})=>{let[f,k]=G(p!==void 0?String(p):""),[b,C]=G(!1),[v,l]=G(!1),n=p!==void 0;Ee(()=>{k(p!==void 0?String(p):""),C(!1)},[p]);let S=()=>{k(p!==void 0?String(p):"")},u=()=>{if(f.trim()===""){if(y){g(void 0),k("");return}S();return}let r=Number(f);if(!Number.isFinite(r)){S();return}let F=Math.max(0,r);if(F===p){S();return}g(F)};return Y("div",{style:Ie,children:[I("span",{style:{fontSize:"10px",textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},children:t}),b?I("input",{value:f,onChange:r=>{let F=r.target.value.replace(/[^\d]/g,"");k(F)},onBlur:()=>{u(),C(!1)},onKeyDown:r=>{if(r.key==="Enter"){r.preventDefault(),r.currentTarget.blur(),C(!1);return}if(r.key==="Escape"){r.preventDefault(),S(),r.currentTarget.blur(),C(!1);return}r.key.length===1&&/[0-9]/.test(r.key)||r.key==="Backspace"||r.key==="Delete"||r.key==="Tab"||r.key==="ArrowLeft"||r.key==="ArrowRight"||r.key==="Home"||r.key==="End"||r.preventDefault()},placeholder:i,inputMode:"numeric",pattern:"[0-9]*","aria-label":t,style:Te,autoFocus:!0}):n?Y("span",{style:{fontSize:"16px"},children:[c,p]}):m?I("button",{type:"button",style:{fontSize:"16px",color:"#737373",cursor:"pointer",border:"none",backgroundColor:"transparent",padding:0},onClick:()=>C(!0),"aria-label":a,children:"+"}):I("span",{style:{fontSize:"16px",color:"#737373"},children:"-"}),(!m||m&&b)&&I("span",{style:{color:"#737373",fontSize:"12px"},children:c}),!b&&(!m||n)&&I("button",{type:"button",style:{...Be,backgroundColor:v?"#e5e5e5":"transparent"},"aria-label":a,title:a,onClick:()=>C(!0),onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:I(D,{})}),h&&I(E,{onClick:x})]})},Z=({priceRange:e,currency:t,onChange:p,onRemove:i})=>{let{t:c}=w(),y="Min",h="Max",s=c("smartFilter.priceRange.remove"),a=c("smartFilter.priceRange.edit"),m=(g,x)=>{let f={min:e.min,max:e.max};g==="min"?(f.min=x,x!==void 0&&e.max!==void 0&&x>e.max&&(f.max=x)):(f.max=x,x!==void 0&&e.min!==void 0&&x<e.min&&(f.min=x)),(f.min!==e.min||f.max!==e.max)&&p(f)};return Y(Ne,{children:[I(le,{boundary:"min",label:y,value:e.min,currency:t,editLabel:a,showRemoveButton:e.min!==void 0&&e.min!==0,onCommit:g=>m("min",g),onRemove:i}),I(le,{boundary:"max",label:h,value:e.max,currency:t,isOptional:!0,showRemoveButton:e.max!==void 0,removeLabel:s,editLabel:a,showAddWhenEmpty:!0,onCommit:g=>m("max",g),onRemove:i})]})};import{jsx as A,jsxs as W}from"react/jsx-runtime";var Ae={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"16px",flexShrink:0,height:"34px"},ce=[{value:"Cheap Eats",key:"cheapEats"},{value:"Mid Range",key:"midRange"},{value:"Fine Dining",key:"fineDining"}],j=({values:e,onChange:t,onRemove:p})=>{let{t:i}=w(),c=i("smartFilter.restaurantPriceLevel.label"),y=i("smartFilter.restaurantPriceLevel.remove"),h=i("smartFilter.restaurantPriceLevel.none"),s=a=>{let{value:m,checked:g}=a.target,x=m,f=new Set(e);g?f.add(x):f.delete(x);let k=ce.filter(b=>f.has(b.value)).map(b=>b.value);t(k)};return W("div",{style:Ae,children:[W("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"},children:[A("span",{style:{fontSize:"10px",textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},children:c}),W("div",{style:{display:"flex",gap:"12px"},children:[ce.map(a=>{let m=i(`smartFilter.restaurantPriceLevel.options.${a.key}`),g=`price-level-${a.key}`;return W("label",{htmlFor:g,style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",cursor:"pointer"},children:[A("input",{id:g,type:"checkbox",value:a.value,checked:e.includes(a.value),onChange:s,style:{accentColor:"#03852e",cursor:"pointer"}}),A("span",{children:m})]},a.value)}),e.length===0&&A("span",{style:{fontSize:"12px",color:"#737373"},children:h})]})]}),A(E,{onClick:p})]})};import{useEffect as De,useRef as He,useState as X}from"react";import{jsx as N,jsxs as We}from"react/jsx-runtime";var ze={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"8px",flexShrink:0,userSelect:"none",height:"34px"},Oe={backgroundColor:"#ececec",borderRadius:"2px",padding:"2px 8px",outline:"none",fontSize:"16px",minWidth:"8ch",border:"none"},_e={padding:"4px",borderRadius:"50%",cursor:"pointer",transition:"background-color 0.2s",color:"#737373",border:"none",backgroundColor:"transparent",display:"flex",alignItems:"center",justifyContent:"center"},J=({value:e,onChange:t,onRemove:p})=>{let i=He(null),[c,y]=X(e),[h,s]=X(!1),[a,m]=X(!1),{t:g}=w(),x=g("smartFilter.transformedQuery.remove"),f=g("smartFilter.transformedQuery.edit");De(()=>{y(e),s(!1)},[e]);let k=()=>{let v=c.trim();if(!v.length){y(e);return}v!==e&&t(v)};return We("div",{style:ze,children:[N(ne,{style:{width:"16px",height:"16px",color:"#03852e"}}),h?N("input",{ref:i,value:c,onChange:v=>{y(v.target.value)},onBlur:()=>{k(),s(!1)},onKeyDown:v=>{if(v.key==="Enter"){v.preventDefault(),v.currentTarget.blur();return}if(v.key==="Escape"){v.preventDefault(),y(e),v.currentTarget.blur();return}},"aria-label":f,style:Oe,autoFocus:!0}):N("span",{style:{fontSize:"16px"},children:e}),!h&&N("button",{type:"button",style:{..._e,backgroundColor:a?"#e5e5e5":"transparent"},"aria-label":f,title:f,onClick:()=>s(!0),onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),children:N(D,{})}),N(E,{onClick:p})]})};import{useCallback as pe,useEffect as Qe,useRef as Ve,useState as ue}from"react";var ee=e=>{let t=Ve(null),[p,i]=ue(!0),[c,y]=ue(!0),h=pe(()=>{let a=t.current;if(!a){i(!0),y(!0);return}let{scrollLeft:m,scrollWidth:g,clientWidth:x}=a;i(m<=0),y(m+x>=g-1)},[]);Qe(()=>{let a=t.current;if(h(),!a)return;let m=()=>h();return a.addEventListener("scroll",m,{passive:!0}),window.addEventListener("resize",h),()=>{a.removeEventListener("scroll",m),window.removeEventListener("resize",h)}},[e,h]);let s=pe(a=>{let m=t.current;if(!m)return;let g=m.clientWidth*.7;m.scrollBy({left:a==="next"?g:-g,behavior:"smooth"})},[]);return{scrollerRef:t,atStart:p,atEnd:c,scrollByDir:s}};import{jsx as L,jsxs as ye}from"react/jsx-runtime";var qe={position:"relative",width:"100%"},Ke={display:"flex",gap:"8px",overflowX:"auto",alignItems:"center",width:"100%",scrollbarWidth:"none",msOverflowStyle:"none"},me={pointerEvents:"none",position:"absolute",top:0,bottom:0,width:"40px"},ge={position:"absolute",top:"50%",transform:"translateY(-50%)",backgroundColor:"white",color:"#003c30",border:"1px solid #003c30",padding:"4px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",cursor:"pointer"},te=({filters:e,currency:t,minRatingSuffix:p,clearAllLabel:i,previousFiltersLabel:c,nextFiltersLabel:y,formatCurrency:h,onFilterChange:s,onResetFilters:a,onClearAll:m})=>{let{scrollerRef:g,atStart:x,atEnd:f,scrollByDir:k}=ee(e.length),[b,C]=de.useState(null),[v,l]=de.useState(!1);return ye("div",{style:qe,children:[ye("div",{ref:g,style:{...Ke,padding:"8px",WebkitOverflowScrolling:"touch"},children:[L("style",{children:`
|
|
1
|
+
// src/index.tsx
|
|
2
|
+
import React6 from "react";
|
|
3
|
+
import {
|
|
4
|
+
MapFirstCore
|
|
5
|
+
} from "@mapfirst.ai/core";
|
|
6
|
+
import {
|
|
7
|
+
processApiFilters,
|
|
8
|
+
convertToApiFilters,
|
|
9
|
+
PropertiesFetchError,
|
|
10
|
+
fetchImages,
|
|
11
|
+
fetchProperties,
|
|
12
|
+
MapFirstCore as MapFirstCore2
|
|
13
|
+
} from "@mapfirst.ai/core";
|
|
14
|
+
|
|
15
|
+
// src/components/SmartFilter.tsx
|
|
16
|
+
import { useCallback as useCallback3 } from "react";
|
|
17
|
+
|
|
18
|
+
// src/components/smart-filter/FilterChips.tsx
|
|
19
|
+
import React5 from "react";
|
|
20
|
+
|
|
21
|
+
// src/components/smart-filter/CloseButton.tsx
|
|
22
|
+
import React from "react";
|
|
23
|
+
|
|
24
|
+
// src/components/Icons.tsx
|
|
25
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
26
|
+
var SearchIcon = ({ className, style }) => /* @__PURE__ */ jsxs(
|
|
27
|
+
"svg",
|
|
28
|
+
{
|
|
29
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
30
|
+
viewBox: "0 0 24 24",
|
|
31
|
+
fill: "none",
|
|
32
|
+
stroke: "currentColor",
|
|
33
|
+
strokeWidth: "2",
|
|
34
|
+
strokeLinecap: "round",
|
|
35
|
+
strokeLinejoin: "round",
|
|
36
|
+
className,
|
|
37
|
+
style: { width: "1em", height: "1em", ...style },
|
|
38
|
+
children: [
|
|
39
|
+
/* @__PURE__ */ jsx("circle", { cx: "11", cy: "11", r: "8" }),
|
|
40
|
+
/* @__PURE__ */ jsx("path", { d: "m21 21-4.35-4.35" })
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
var CloseIcon = ({ className, style }) => /* @__PURE__ */ jsxs(
|
|
45
|
+
"svg",
|
|
46
|
+
{
|
|
47
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
48
|
+
viewBox: "0 0 24 24",
|
|
49
|
+
fill: "none",
|
|
50
|
+
stroke: "currentColor",
|
|
51
|
+
strokeWidth: "2",
|
|
52
|
+
strokeLinecap: "round",
|
|
53
|
+
strokeLinejoin: "round",
|
|
54
|
+
className,
|
|
55
|
+
style: { width: "1em", height: "1em", ...style },
|
|
56
|
+
children: [
|
|
57
|
+
/* @__PURE__ */ jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
58
|
+
/* @__PURE__ */ jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
var EditIcon = ({ className, style }) => /* @__PURE__ */ jsxs(
|
|
63
|
+
"svg",
|
|
64
|
+
{
|
|
65
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
66
|
+
viewBox: "0 0 24 24",
|
|
67
|
+
fill: "none",
|
|
68
|
+
stroke: "currentColor",
|
|
69
|
+
strokeWidth: "2",
|
|
70
|
+
strokeLinecap: "round",
|
|
71
|
+
strokeLinejoin: "round",
|
|
72
|
+
className,
|
|
73
|
+
style: { width: "1em", height: "1em", ...style },
|
|
74
|
+
children: [
|
|
75
|
+
/* @__PURE__ */ jsx("path", { d: "M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" }),
|
|
76
|
+
/* @__PURE__ */ jsx("path", { d: "M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" })
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
var NextIcon = ({ className, style }) => /* @__PURE__ */ jsx(
|
|
81
|
+
"svg",
|
|
82
|
+
{
|
|
83
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
84
|
+
viewBox: "0 0 24 24",
|
|
85
|
+
fill: "none",
|
|
86
|
+
stroke: "currentColor",
|
|
87
|
+
strokeWidth: "2",
|
|
88
|
+
strokeLinecap: "round",
|
|
89
|
+
strokeLinejoin: "round",
|
|
90
|
+
className,
|
|
91
|
+
style: { width: "1em", height: "1em", ...style },
|
|
92
|
+
children: /* @__PURE__ */ jsx("polyline", { points: "9 18 15 12 9 6" })
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
var StarIcon = ({
|
|
96
|
+
className,
|
|
97
|
+
style,
|
|
98
|
+
fill = "none"
|
|
99
|
+
}) => /* @__PURE__ */ jsx(
|
|
100
|
+
"svg",
|
|
101
|
+
{
|
|
102
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
103
|
+
viewBox: "0 0 24 24",
|
|
104
|
+
fill,
|
|
105
|
+
stroke: "currentColor",
|
|
106
|
+
strokeWidth: "2",
|
|
107
|
+
strokeLinecap: "round",
|
|
108
|
+
strokeLinejoin: "round",
|
|
109
|
+
className,
|
|
110
|
+
style: { width: "1em", height: "1em", ...style },
|
|
111
|
+
children: /* @__PURE__ */ jsx("polygon", { points: "12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" })
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
// src/components/smart-filter/CloseButton.tsx
|
|
116
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
117
|
+
var closeButtonStyles = {
|
|
118
|
+
position: "absolute",
|
|
119
|
+
top: "-8px",
|
|
120
|
+
right: "-8px",
|
|
121
|
+
padding: "2px",
|
|
122
|
+
borderRadius: "50%",
|
|
123
|
+
backgroundColor: "white",
|
|
124
|
+
border: "1px solid #03852e",
|
|
125
|
+
cursor: "pointer",
|
|
126
|
+
display: "flex",
|
|
127
|
+
alignItems: "center",
|
|
128
|
+
justifyContent: "center",
|
|
129
|
+
transition: "background-color 0.2s"
|
|
130
|
+
};
|
|
131
|
+
var iconStyles = {
|
|
132
|
+
width: "17px",
|
|
133
|
+
height: "17px"
|
|
134
|
+
};
|
|
135
|
+
var CloseButton = ({ onClick, style }) => {
|
|
136
|
+
const [isHovering, setIsHovering] = React.useState(false);
|
|
137
|
+
return /* @__PURE__ */ jsx2(
|
|
138
|
+
"button",
|
|
139
|
+
{
|
|
140
|
+
style: {
|
|
141
|
+
...closeButtonStyles,
|
|
142
|
+
backgroundColor: isHovering ? "#e5e5e5" : "white",
|
|
143
|
+
...style
|
|
144
|
+
},
|
|
145
|
+
onClick,
|
|
146
|
+
onMouseEnter: () => setIsHovering(true),
|
|
147
|
+
onMouseLeave: () => setIsHovering(false),
|
|
148
|
+
"aria-label": "Remove filter",
|
|
149
|
+
children: /* @__PURE__ */ jsx2(CloseIcon, { style: iconStyles })
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// src/components/smart-filter/Chip.tsx
|
|
155
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
156
|
+
var chipStyles = {
|
|
157
|
+
position: "relative",
|
|
158
|
+
backgroundColor: "white",
|
|
159
|
+
color: "black",
|
|
160
|
+
fontSize: "14px",
|
|
161
|
+
borderRadius: "9999px",
|
|
162
|
+
padding: "0 16px",
|
|
163
|
+
paddingRight: "20px",
|
|
164
|
+
border: "1px solid #03852e",
|
|
165
|
+
display: "flex",
|
|
166
|
+
alignItems: "center",
|
|
167
|
+
gap: "8px",
|
|
168
|
+
flexShrink: 0,
|
|
169
|
+
height: "34px"
|
|
170
|
+
};
|
|
171
|
+
var Chip = ({ label, icon, remove, style }) => {
|
|
172
|
+
return /* @__PURE__ */ jsxs2("div", { style: { ...chipStyles, ...style }, children: [
|
|
173
|
+
icon && /* @__PURE__ */ jsx3("span", { style: { display: "flex", alignItems: "center" }, children: icon }),
|
|
174
|
+
/* @__PURE__ */ jsx3("span", { style: { whiteSpace: "nowrap" }, children: label }),
|
|
175
|
+
/* @__PURE__ */ jsx3(CloseButton, { onClick: remove })
|
|
176
|
+
] });
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
// src/components/smart-filter/MinRatingFilterChip.tsx
|
|
180
|
+
import {
|
|
181
|
+
useState as useState2
|
|
182
|
+
} from "react";
|
|
183
|
+
|
|
184
|
+
// src/hooks/useTranslation.ts
|
|
185
|
+
import { useCallback, useMemo, useState } from "react";
|
|
186
|
+
var defaultTranslations = {
|
|
187
|
+
"smartFilter.typingPrompt": "Search for hotels, restaurants, or attractions...",
|
|
188
|
+
"smartFilter.nav.previous": "Previous filters",
|
|
189
|
+
"smartFilter.nav.next": "Next filters",
|
|
190
|
+
"smartFilter.toast.locationRequired": "Please select a location first",
|
|
191
|
+
"smartFilter.clearAll": "Clear all",
|
|
192
|
+
"smartFilter.minRating.suffix": "+",
|
|
193
|
+
"smartFilter.minRating.label": "{{value}}+",
|
|
194
|
+
"smartFilter.minRating.remove": "Remove rating filter",
|
|
195
|
+
"smartFilter.minRating.setTo": "Set rating to {{rating}}",
|
|
196
|
+
"smartFilter.priceRange.label": "Price Range",
|
|
197
|
+
"smartFilter.priceRange.remove": "Remove price filter",
|
|
198
|
+
"smartFilter.priceRange.edit": "Edit price",
|
|
199
|
+
"smartFilter.transformedQuery.remove": "Remove search query",
|
|
200
|
+
"smartFilter.transformedQuery.edit": "Edit search query",
|
|
201
|
+
"smartFilter.restaurantPriceLevel.label": "Price Level",
|
|
202
|
+
"smartFilter.restaurantPriceLevel.remove": "Remove price level filter",
|
|
203
|
+
"smartFilter.restaurantPriceLevel.none": "Any",
|
|
204
|
+
"smartFilter.restaurantPriceLevel.options.cheapEats": "Cheap Eats",
|
|
205
|
+
"smartFilter.restaurantPriceLevel.options.midRange": "Mid Range",
|
|
206
|
+
"smartFilter.restaurantPriceLevel.options.fineDining": "Fine Dining"
|
|
207
|
+
};
|
|
208
|
+
var formatCurrencyDefault = (value, currency = "USD") => {
|
|
209
|
+
return new Intl.NumberFormat("en-US", {
|
|
210
|
+
style: "currency",
|
|
211
|
+
currency,
|
|
212
|
+
minimumFractionDigits: 0,
|
|
213
|
+
maximumFractionDigits: 0
|
|
214
|
+
}).format(value);
|
|
215
|
+
};
|
|
216
|
+
var useTranslation = (customTranslations, customFormatCurrency) => {
|
|
217
|
+
const [locale, setLocale] = useState("en");
|
|
218
|
+
const translations = useMemo(
|
|
219
|
+
() => ({ ...defaultTranslations, ...customTranslations }),
|
|
220
|
+
[customTranslations]
|
|
221
|
+
);
|
|
222
|
+
const t = useCallback(
|
|
223
|
+
(key, params) => {
|
|
224
|
+
let translation = translations[key] || key;
|
|
225
|
+
if (params) {
|
|
226
|
+
Object.keys(params).forEach((paramKey) => {
|
|
227
|
+
translation = translation.replace(
|
|
228
|
+
new RegExp(`{{${paramKey}}}`, "g"),
|
|
229
|
+
String(params[paramKey])
|
|
230
|
+
);
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return translation;
|
|
234
|
+
},
|
|
235
|
+
[translations]
|
|
236
|
+
);
|
|
237
|
+
const formatCurrency = useCallback(
|
|
238
|
+
(value, currency) => {
|
|
239
|
+
if (customFormatCurrency) {
|
|
240
|
+
return customFormatCurrency(value, currency);
|
|
241
|
+
}
|
|
242
|
+
return formatCurrencyDefault(value, currency);
|
|
243
|
+
},
|
|
244
|
+
[customFormatCurrency]
|
|
245
|
+
);
|
|
246
|
+
return {
|
|
247
|
+
t,
|
|
248
|
+
locale,
|
|
249
|
+
setLocale,
|
|
250
|
+
formatCurrency
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
// src/components/smart-filter/utils.tsx
|
|
255
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
256
|
+
var STAR_BASE_STYLES = {
|
|
257
|
+
display: "block",
|
|
258
|
+
width: "12px",
|
|
259
|
+
height: "12px",
|
|
260
|
+
borderRadius: "50%",
|
|
261
|
+
border: "1px solid #03852e",
|
|
262
|
+
pointerEvents: "none"
|
|
263
|
+
};
|
|
264
|
+
var STAR_FULL_STYLES = {
|
|
265
|
+
...STAR_BASE_STYLES,
|
|
266
|
+
backgroundColor: "#03852e"
|
|
267
|
+
};
|
|
268
|
+
var STAR_HALF_STYLES = {
|
|
269
|
+
...STAR_BASE_STYLES,
|
|
270
|
+
background: "linear-gradient(90deg, #03852e 50%, transparent 50%)"
|
|
271
|
+
};
|
|
272
|
+
var MIN_RATING_LABEL_STYLES = {
|
|
273
|
+
display: "flex",
|
|
274
|
+
alignItems: "center",
|
|
275
|
+
gap: "4px"
|
|
276
|
+
};
|
|
277
|
+
var MIN_RATING_STARS_WRAPPER_STYLES = {
|
|
278
|
+
display: "flex",
|
|
279
|
+
gap: "1px",
|
|
280
|
+
userSelect: "none"
|
|
281
|
+
};
|
|
282
|
+
var renderStars = (rating) => {
|
|
283
|
+
const stars = [];
|
|
284
|
+
const fullStars = Math.floor(rating);
|
|
285
|
+
const hasHalfStar = rating % 1 !== 0;
|
|
286
|
+
for (let i = 0; i < fullStars; i += 1) {
|
|
287
|
+
stars.push(/* @__PURE__ */ jsx4("span", { style: STAR_FULL_STYLES }, `full-${i}`));
|
|
288
|
+
}
|
|
289
|
+
if (hasHalfStar) {
|
|
290
|
+
stars.push(/* @__PURE__ */ jsx4("span", { style: STAR_HALF_STYLES }, "half"));
|
|
291
|
+
}
|
|
292
|
+
const remainingStars = Math.max(0, 5 - Math.ceil(rating));
|
|
293
|
+
for (let i = 0; i < remainingStars; i += 1) {
|
|
294
|
+
stars.push(/* @__PURE__ */ jsx4("span", { style: STAR_BASE_STYLES }, `empty-${i}`));
|
|
295
|
+
}
|
|
296
|
+
return stars;
|
|
297
|
+
};
|
|
298
|
+
var createMinRatingFilterLabel = (rating, suffix) => /* @__PURE__ */ jsxs3("span", { style: MIN_RATING_LABEL_STYLES, children: [
|
|
299
|
+
/* @__PURE__ */ jsx4("span", { style: MIN_RATING_STARS_WRAPPER_STYLES, children: renderStars(rating) }),
|
|
300
|
+
" ",
|
|
301
|
+
suffix
|
|
302
|
+
] });
|
|
303
|
+
var formatRatingValue = (rating) => rating.toFixed(1);
|
|
304
|
+
var createPriceRangeFilterLabel = (min, max, currency, formatCurrencyFn) => `${formatCurrencyFn(min, currency)} - ${formatCurrencyFn(
|
|
305
|
+
max != null ? max : 0,
|
|
306
|
+
currency
|
|
307
|
+
)}`;
|
|
308
|
+
|
|
309
|
+
// src/components/smart-filter/MinRatingFilterChip.tsx
|
|
310
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
311
|
+
var chipContainerStyles = {
|
|
312
|
+
position: "relative",
|
|
313
|
+
backgroundColor: "white",
|
|
314
|
+
color: "black",
|
|
315
|
+
fontSize: "14px",
|
|
316
|
+
borderRadius: "9999px",
|
|
317
|
+
padding: "0 16px",
|
|
318
|
+
paddingRight: "20px",
|
|
319
|
+
border: "1px solid #03852e",
|
|
320
|
+
display: "flex",
|
|
321
|
+
gap: "8px",
|
|
322
|
+
alignItems: "center",
|
|
323
|
+
justifyContent: "center",
|
|
324
|
+
flexShrink: 0,
|
|
325
|
+
height: "34px"
|
|
326
|
+
};
|
|
327
|
+
var starContainerStyles = {
|
|
328
|
+
display: "flex",
|
|
329
|
+
gap: "1px",
|
|
330
|
+
userSelect: "none"
|
|
331
|
+
};
|
|
332
|
+
var circleBaseStyles = {
|
|
333
|
+
display: "block",
|
|
334
|
+
width: "12px",
|
|
335
|
+
height: "12px",
|
|
336
|
+
borderRadius: "50%",
|
|
337
|
+
border: "1px solid #03852e",
|
|
338
|
+
pointerEvents: "none"
|
|
339
|
+
};
|
|
340
|
+
var buttonBaseStyles = {
|
|
341
|
+
position: "absolute",
|
|
342
|
+
top: 0,
|
|
343
|
+
height: "100%",
|
|
344
|
+
cursor: "pointer",
|
|
345
|
+
backgroundColor: "transparent",
|
|
346
|
+
border: "none",
|
|
347
|
+
padding: 0
|
|
348
|
+
};
|
|
349
|
+
var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false }) => {
|
|
350
|
+
const [hoverRating, setHoverRating] = useState2(null);
|
|
351
|
+
const { t } = useTranslation();
|
|
352
|
+
const displayRating = hoverRating != null ? hoverRating : rating;
|
|
353
|
+
const formatLabel = (value) => star && value ? value.toString() : t("smartFilter.minRating.label", { value: formatRatingValue(value) });
|
|
354
|
+
const removeLabel = t("smartFilter.minRating.remove");
|
|
355
|
+
const setLabel = (value) => t("smartFilter.minRating.setTo", { rating: formatRatingValue(value) });
|
|
356
|
+
const getFillForStar = (index) => {
|
|
357
|
+
const starNumber = index + 1;
|
|
358
|
+
if (displayRating >= starNumber) {
|
|
359
|
+
return "full";
|
|
360
|
+
}
|
|
361
|
+
if (displayRating >= starNumber - 0.5) {
|
|
362
|
+
return "half";
|
|
363
|
+
}
|
|
364
|
+
return "empty";
|
|
365
|
+
};
|
|
366
|
+
const handleSelect = (nextRating) => {
|
|
367
|
+
setHoverRating(null);
|
|
368
|
+
if (nextRating === rating) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
onChange(nextRating);
|
|
372
|
+
};
|
|
373
|
+
const handleBlur = (event) => {
|
|
374
|
+
var _a;
|
|
375
|
+
const related = event.relatedTarget;
|
|
376
|
+
if (!related || !((_a = event.currentTarget.closest("[data-min-rating-chip]")) == null ? void 0 : _a.contains(related))) {
|
|
377
|
+
setHoverRating(null);
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
return /* @__PURE__ */ jsxs4("div", { style: chipContainerStyles, "data-min-rating-chip": true, children: [
|
|
381
|
+
/* @__PURE__ */ jsxs4(
|
|
382
|
+
"div",
|
|
383
|
+
{
|
|
384
|
+
style: { display: "flex", alignItems: "center", gap: "4px" },
|
|
385
|
+
onMouseLeave: () => setHoverRating(null),
|
|
386
|
+
children: [
|
|
387
|
+
/* @__PURE__ */ jsx5("div", { style: starContainerStyles, children: Array.from({ length: 5 }).map((_, index) => {
|
|
388
|
+
const fillState = getFillForStar(index);
|
|
389
|
+
const starNumber = index + 1;
|
|
390
|
+
const halfValue = starNumber - 0.5;
|
|
391
|
+
if (star) {
|
|
392
|
+
return /* @__PURE__ */ jsxs4(
|
|
393
|
+
"div",
|
|
394
|
+
{
|
|
395
|
+
style: {
|
|
396
|
+
position: "relative",
|
|
397
|
+
width: "16px",
|
|
398
|
+
height: "16px"
|
|
399
|
+
},
|
|
400
|
+
children: [
|
|
401
|
+
/* @__PURE__ */ jsx5(
|
|
402
|
+
StarIcon,
|
|
403
|
+
{
|
|
404
|
+
fill: displayRating >= starNumber ? "#03852e" : "none",
|
|
405
|
+
style: {
|
|
406
|
+
width: "16px",
|
|
407
|
+
height: "16px",
|
|
408
|
+
pointerEvents: "none"
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
),
|
|
412
|
+
/* @__PURE__ */ jsx5(
|
|
413
|
+
"button",
|
|
414
|
+
{
|
|
415
|
+
type: "button",
|
|
416
|
+
style: {
|
|
417
|
+
...buttonBaseStyles,
|
|
418
|
+
left: 0,
|
|
419
|
+
width: "50%",
|
|
420
|
+
borderRadius: "50% 0 0 50%"
|
|
421
|
+
},
|
|
422
|
+
onMouseEnter: () => setHoverRating(halfValue),
|
|
423
|
+
onFocus: () => setHoverRating(halfValue),
|
|
424
|
+
onBlur: handleBlur,
|
|
425
|
+
onClick: () => handleSelect(halfValue),
|
|
426
|
+
"aria-label": setLabel(halfValue),
|
|
427
|
+
title: formatLabel(halfValue)
|
|
428
|
+
}
|
|
429
|
+
),
|
|
430
|
+
/* @__PURE__ */ jsx5(
|
|
431
|
+
"button",
|
|
432
|
+
{
|
|
433
|
+
type: "button",
|
|
434
|
+
style: {
|
|
435
|
+
...buttonBaseStyles,
|
|
436
|
+
left: "50%",
|
|
437
|
+
width: "50%",
|
|
438
|
+
borderRadius: "0 50% 50% 0"
|
|
439
|
+
},
|
|
440
|
+
onMouseEnter: () => setHoverRating(starNumber),
|
|
441
|
+
onFocus: () => setHoverRating(starNumber),
|
|
442
|
+
onBlur: handleBlur,
|
|
443
|
+
onClick: () => handleSelect(starNumber),
|
|
444
|
+
"aria-label": setLabel(starNumber),
|
|
445
|
+
title: formatLabel(starNumber)
|
|
446
|
+
}
|
|
447
|
+
)
|
|
448
|
+
]
|
|
449
|
+
},
|
|
450
|
+
index
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
const circleStyles = fillState === "full" ? { ...circleBaseStyles, backgroundColor: "#03852e" } : circleBaseStyles;
|
|
454
|
+
const halfCircleStyles = {
|
|
455
|
+
...circleBaseStyles,
|
|
456
|
+
background: "linear-gradient(90deg, #03852e 50%, transparent 50%)"
|
|
457
|
+
};
|
|
458
|
+
return /* @__PURE__ */ jsxs4(
|
|
459
|
+
"div",
|
|
460
|
+
{
|
|
461
|
+
style: { position: "relative", width: "12px", height: "12px" },
|
|
462
|
+
children: [
|
|
463
|
+
/* @__PURE__ */ jsx5(
|
|
464
|
+
"span",
|
|
465
|
+
{
|
|
466
|
+
style: fillState === "half" ? halfCircleStyles : circleStyles
|
|
467
|
+
}
|
|
468
|
+
),
|
|
469
|
+
/* @__PURE__ */ jsx5(
|
|
470
|
+
"button",
|
|
471
|
+
{
|
|
472
|
+
type: "button",
|
|
473
|
+
style: {
|
|
474
|
+
...buttonBaseStyles,
|
|
475
|
+
left: 0,
|
|
476
|
+
width: "50%",
|
|
477
|
+
borderRadius: "50% 0 0 50%",
|
|
478
|
+
outline: "2px solid transparent",
|
|
479
|
+
outlineOffset: "1px"
|
|
480
|
+
},
|
|
481
|
+
onMouseEnter: () => setHoverRating(halfValue),
|
|
482
|
+
onFocus: () => setHoverRating(halfValue),
|
|
483
|
+
onBlur: handleBlur,
|
|
484
|
+
onClick: () => handleSelect(halfValue),
|
|
485
|
+
"aria-label": setLabel(halfValue),
|
|
486
|
+
title: formatLabel(halfValue)
|
|
487
|
+
}
|
|
488
|
+
),
|
|
489
|
+
/* @__PURE__ */ jsx5(
|
|
490
|
+
"button",
|
|
491
|
+
{
|
|
492
|
+
type: "button",
|
|
493
|
+
style: {
|
|
494
|
+
...buttonBaseStyles,
|
|
495
|
+
left: "50%",
|
|
496
|
+
width: "50%",
|
|
497
|
+
borderRadius: "0 50% 50% 0",
|
|
498
|
+
outline: "2px solid transparent",
|
|
499
|
+
outlineOffset: "1px"
|
|
500
|
+
},
|
|
501
|
+
onMouseEnter: () => setHoverRating(starNumber),
|
|
502
|
+
onFocus: () => setHoverRating(starNumber),
|
|
503
|
+
onBlur: handleBlur,
|
|
504
|
+
onClick: () => handleSelect(starNumber),
|
|
505
|
+
"aria-label": setLabel(starNumber),
|
|
506
|
+
title: formatLabel(starNumber)
|
|
507
|
+
}
|
|
508
|
+
)
|
|
509
|
+
]
|
|
510
|
+
},
|
|
511
|
+
index
|
|
512
|
+
);
|
|
513
|
+
}) }),
|
|
514
|
+
/* @__PURE__ */ jsx5("span", { style: { whiteSpace: "nowrap" }, children: formatLabel(displayRating) })
|
|
515
|
+
]
|
|
516
|
+
}
|
|
517
|
+
),
|
|
518
|
+
/* @__PURE__ */ jsx5(CloseButton, { onClick: onRemove })
|
|
519
|
+
] });
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
// src/components/smart-filter/PriceRangeFilterChip.tsx
|
|
523
|
+
import {
|
|
524
|
+
useEffect,
|
|
525
|
+
useState as useState3
|
|
526
|
+
} from "react";
|
|
527
|
+
import { Fragment, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
528
|
+
var chipStyles2 = {
|
|
529
|
+
position: "relative",
|
|
530
|
+
backgroundColor: "white",
|
|
531
|
+
color: "black",
|
|
532
|
+
fontSize: "14px",
|
|
533
|
+
borderRadius: "9999px",
|
|
534
|
+
padding: "0 16px",
|
|
535
|
+
border: "1px solid #03852e",
|
|
536
|
+
display: "flex",
|
|
537
|
+
alignItems: "center",
|
|
538
|
+
gap: "8px",
|
|
539
|
+
flexShrink: 0,
|
|
540
|
+
height: "34px"
|
|
541
|
+
};
|
|
542
|
+
var inputStyles = {
|
|
543
|
+
outline: "none",
|
|
544
|
+
fontSize: "16px",
|
|
545
|
+
backgroundColor: "transparent",
|
|
546
|
+
borderRadius: "2px",
|
|
547
|
+
padding: "2px 8px",
|
|
548
|
+
width: "64px",
|
|
549
|
+
textAlign: "center",
|
|
550
|
+
border: "none"
|
|
551
|
+
};
|
|
552
|
+
var editButtonStyles = {
|
|
553
|
+
padding: "4px",
|
|
554
|
+
borderRadius: "50%",
|
|
555
|
+
cursor: "pointer",
|
|
556
|
+
transition: "background-color 0.2s",
|
|
557
|
+
border: "none",
|
|
558
|
+
backgroundColor: "transparent",
|
|
559
|
+
color: "#737373",
|
|
560
|
+
display: "flex",
|
|
561
|
+
alignItems: "center",
|
|
562
|
+
justifyContent: "center"
|
|
563
|
+
};
|
|
564
|
+
var PriceBoundaryChip = ({
|
|
565
|
+
label,
|
|
566
|
+
value,
|
|
567
|
+
placeholder,
|
|
568
|
+
currency,
|
|
569
|
+
isOptional = false,
|
|
570
|
+
showRemoveButton = false,
|
|
571
|
+
editLabel,
|
|
572
|
+
showAddWhenEmpty = false,
|
|
573
|
+
onCommit,
|
|
574
|
+
onRemove
|
|
575
|
+
}) => {
|
|
576
|
+
const [draft, setDraft] = useState3(
|
|
577
|
+
value !== void 0 ? String(value) : ""
|
|
578
|
+
);
|
|
579
|
+
const [isEditing, setIsEditing] = useState3(false);
|
|
580
|
+
const [editHover, setEditHover] = useState3(false);
|
|
581
|
+
const hasValue = value !== void 0;
|
|
582
|
+
useEffect(() => {
|
|
583
|
+
setDraft(value !== void 0 ? String(value) : "");
|
|
584
|
+
setIsEditing(false);
|
|
585
|
+
}, [value]);
|
|
586
|
+
const resetDraft = () => {
|
|
587
|
+
setDraft(value !== void 0 ? String(value) : "");
|
|
588
|
+
};
|
|
589
|
+
const commitValue = () => {
|
|
590
|
+
if (draft.trim() === "") {
|
|
591
|
+
if (isOptional) {
|
|
592
|
+
onCommit(void 0);
|
|
593
|
+
setDraft("");
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
resetDraft();
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
const parsed = Number(draft);
|
|
600
|
+
if (!Number.isFinite(parsed)) {
|
|
601
|
+
resetDraft();
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
const normalized = Math.max(0, parsed);
|
|
605
|
+
if (normalized === value) {
|
|
606
|
+
resetDraft();
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
onCommit(normalized);
|
|
610
|
+
};
|
|
611
|
+
const handleChange = (event) => {
|
|
612
|
+
const next = event.target.value.replace(/[^\d]/g, "");
|
|
613
|
+
setDraft(next);
|
|
614
|
+
};
|
|
615
|
+
const handleKeyDown = (event) => {
|
|
616
|
+
if (event.key === "Enter") {
|
|
617
|
+
event.preventDefault();
|
|
618
|
+
event.currentTarget.blur();
|
|
619
|
+
setIsEditing(false);
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
if (event.key === "Escape") {
|
|
623
|
+
event.preventDefault();
|
|
624
|
+
resetDraft();
|
|
625
|
+
event.currentTarget.blur();
|
|
626
|
+
setIsEditing(false);
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
const allowed = event.key.length === 1 && /[0-9]/.test(event.key) || event.key === "Backspace" || event.key === "Delete" || event.key === "Tab" || event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End";
|
|
630
|
+
if (!allowed) {
|
|
631
|
+
event.preventDefault();
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
return /* @__PURE__ */ jsxs5("div", { style: chipStyles2, children: [
|
|
635
|
+
/* @__PURE__ */ jsx6(
|
|
636
|
+
"span",
|
|
637
|
+
{
|
|
638
|
+
style: {
|
|
639
|
+
fontSize: "10px",
|
|
640
|
+
textTransform: "uppercase",
|
|
641
|
+
fontWeight: 600,
|
|
642
|
+
letterSpacing: "0.05em"
|
|
643
|
+
},
|
|
644
|
+
children: label
|
|
645
|
+
}
|
|
646
|
+
),
|
|
647
|
+
isEditing ? /* @__PURE__ */ jsx6(
|
|
648
|
+
"input",
|
|
649
|
+
{
|
|
650
|
+
value: draft,
|
|
651
|
+
onChange: handleChange,
|
|
652
|
+
onBlur: () => {
|
|
653
|
+
commitValue();
|
|
654
|
+
setIsEditing(false);
|
|
655
|
+
},
|
|
656
|
+
onKeyDown: handleKeyDown,
|
|
657
|
+
placeholder,
|
|
658
|
+
inputMode: "numeric",
|
|
659
|
+
pattern: "[0-9]*",
|
|
660
|
+
"aria-label": label,
|
|
661
|
+
style: inputStyles,
|
|
662
|
+
autoFocus: true
|
|
663
|
+
}
|
|
664
|
+
) : hasValue ? /* @__PURE__ */ jsxs5("span", { style: { fontSize: "16px" }, children: [
|
|
665
|
+
currency,
|
|
666
|
+
value
|
|
667
|
+
] }) : showAddWhenEmpty ? /* @__PURE__ */ jsx6(
|
|
668
|
+
"button",
|
|
669
|
+
{
|
|
670
|
+
type: "button",
|
|
671
|
+
style: {
|
|
672
|
+
fontSize: "16px",
|
|
673
|
+
color: "#737373",
|
|
674
|
+
cursor: "pointer",
|
|
675
|
+
border: "none",
|
|
676
|
+
backgroundColor: "transparent",
|
|
677
|
+
padding: 0
|
|
678
|
+
},
|
|
679
|
+
onClick: () => setIsEditing(true),
|
|
680
|
+
"aria-label": editLabel,
|
|
681
|
+
children: "+"
|
|
682
|
+
}
|
|
683
|
+
) : /* @__PURE__ */ jsx6("span", { style: { fontSize: "16px", color: "#737373" }, children: "-" }),
|
|
684
|
+
(!showAddWhenEmpty || showAddWhenEmpty && isEditing) && /* @__PURE__ */ jsx6("span", { style: { color: "#737373", fontSize: "12px" }, children: currency }),
|
|
685
|
+
!isEditing && (!showAddWhenEmpty || hasValue) && /* @__PURE__ */ jsx6(
|
|
686
|
+
"button",
|
|
687
|
+
{
|
|
688
|
+
type: "button",
|
|
689
|
+
style: {
|
|
690
|
+
...editButtonStyles,
|
|
691
|
+
backgroundColor: editHover ? "#e5e5e5" : "transparent"
|
|
692
|
+
},
|
|
693
|
+
"aria-label": editLabel,
|
|
694
|
+
title: editLabel,
|
|
695
|
+
onClick: () => setIsEditing(true),
|
|
696
|
+
onMouseEnter: () => setEditHover(true),
|
|
697
|
+
onMouseLeave: () => setEditHover(false),
|
|
698
|
+
children: /* @__PURE__ */ jsx6(EditIcon, {})
|
|
699
|
+
}
|
|
700
|
+
),
|
|
701
|
+
showRemoveButton && /* @__PURE__ */ jsx6(CloseButton, { onClick: onRemove })
|
|
702
|
+
] });
|
|
703
|
+
};
|
|
704
|
+
var PriceRangeFilterChip = ({ priceRange, currency, onChange, onRemove }) => {
|
|
705
|
+
const { t } = useTranslation();
|
|
706
|
+
const minLabel = "Min";
|
|
707
|
+
const maxChipLabel = "Max";
|
|
708
|
+
const editLabel = t("smartFilter.priceRange.edit");
|
|
709
|
+
const handleBoundaryCommit = (boundary, nextValue) => {
|
|
710
|
+
const nextRange = {
|
|
711
|
+
min: priceRange.min,
|
|
712
|
+
max: priceRange.max
|
|
713
|
+
};
|
|
714
|
+
if (boundary === "min") {
|
|
715
|
+
nextRange.min = nextValue;
|
|
716
|
+
if (nextValue !== void 0 && priceRange.max !== void 0 && nextValue > priceRange.max) {
|
|
717
|
+
nextRange.max = nextValue;
|
|
718
|
+
}
|
|
719
|
+
} else {
|
|
720
|
+
nextRange.max = nextValue;
|
|
721
|
+
if (nextValue !== void 0 && priceRange.min !== void 0 && nextValue < priceRange.min) {
|
|
722
|
+
nextRange.min = nextValue;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
if (nextRange.min !== priceRange.min || nextRange.max !== priceRange.max) {
|
|
726
|
+
onChange(nextRange);
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
return /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
730
|
+
/* @__PURE__ */ jsx6(
|
|
731
|
+
PriceBoundaryChip,
|
|
732
|
+
{
|
|
733
|
+
label: minLabel,
|
|
734
|
+
value: priceRange.min,
|
|
735
|
+
currency,
|
|
736
|
+
editLabel,
|
|
737
|
+
showRemoveButton: priceRange.min !== void 0 && priceRange.min !== 0,
|
|
738
|
+
onCommit: (value) => handleBoundaryCommit("min", value),
|
|
739
|
+
onRemove
|
|
740
|
+
}
|
|
741
|
+
),
|
|
742
|
+
/* @__PURE__ */ jsx6(
|
|
743
|
+
PriceBoundaryChip,
|
|
744
|
+
{
|
|
745
|
+
label: maxChipLabel,
|
|
746
|
+
value: priceRange.max,
|
|
747
|
+
currency,
|
|
748
|
+
isOptional: true,
|
|
749
|
+
showRemoveButton: priceRange.max !== void 0,
|
|
750
|
+
editLabel,
|
|
751
|
+
showAddWhenEmpty: true,
|
|
752
|
+
onCommit: (value) => handleBoundaryCommit("max", value),
|
|
753
|
+
onRemove
|
|
754
|
+
}
|
|
755
|
+
)
|
|
756
|
+
] });
|
|
757
|
+
};
|
|
758
|
+
|
|
759
|
+
// src/components/smart-filter/RestaurantPriceLevelChip.tsx
|
|
760
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
761
|
+
var chipStyles3 = {
|
|
762
|
+
position: "relative",
|
|
763
|
+
backgroundColor: "white",
|
|
764
|
+
color: "black",
|
|
765
|
+
fontSize: "14px",
|
|
766
|
+
borderRadius: "9999px",
|
|
767
|
+
padding: "0 16px",
|
|
768
|
+
paddingRight: "20px",
|
|
769
|
+
border: "1px solid #03852e",
|
|
770
|
+
display: "flex",
|
|
771
|
+
alignItems: "center",
|
|
772
|
+
gap: "16px",
|
|
773
|
+
flexShrink: 0,
|
|
774
|
+
height: "34px"
|
|
775
|
+
};
|
|
776
|
+
var PRICE_LEVEL_OPTIONS = [
|
|
777
|
+
{ value: "Cheap Eats", key: "cheapEats" },
|
|
778
|
+
{ value: "Mid Range", key: "midRange" },
|
|
779
|
+
{ value: "Fine Dining", key: "fineDining" }
|
|
780
|
+
];
|
|
781
|
+
var RestaurantPriceLevelChip = ({ values, onChange, onRemove }) => {
|
|
782
|
+
const { t } = useTranslation();
|
|
783
|
+
const label = t("smartFilter.restaurantPriceLevel.label");
|
|
784
|
+
const removeLabel = t("smartFilter.restaurantPriceLevel.remove");
|
|
785
|
+
const noneSelectedLabel = t("smartFilter.restaurantPriceLevel.none");
|
|
786
|
+
const handleChange = (event) => {
|
|
787
|
+
const { value, checked } = event.target;
|
|
788
|
+
const valueAsPriceLevel = value;
|
|
789
|
+
const selection = new Set(values);
|
|
790
|
+
if (checked) {
|
|
791
|
+
selection.add(valueAsPriceLevel);
|
|
792
|
+
} else {
|
|
793
|
+
selection.delete(valueAsPriceLevel);
|
|
794
|
+
}
|
|
795
|
+
const orderedSelection = PRICE_LEVEL_OPTIONS.filter(
|
|
796
|
+
(option) => selection.has(option.value)
|
|
797
|
+
).map((option) => option.value);
|
|
798
|
+
onChange(orderedSelection);
|
|
799
|
+
};
|
|
800
|
+
return /* @__PURE__ */ jsxs6("div", { style: chipStyles3, children: [
|
|
801
|
+
/* @__PURE__ */ jsxs6(
|
|
802
|
+
"div",
|
|
803
|
+
{
|
|
804
|
+
style: {
|
|
805
|
+
display: "flex",
|
|
806
|
+
alignItems: "center",
|
|
807
|
+
gap: "8px",
|
|
808
|
+
flexWrap: "wrap"
|
|
809
|
+
},
|
|
810
|
+
children: [
|
|
811
|
+
/* @__PURE__ */ jsx7(
|
|
812
|
+
"span",
|
|
813
|
+
{
|
|
814
|
+
style: {
|
|
815
|
+
fontSize: "10px",
|
|
816
|
+
textTransform: "uppercase",
|
|
817
|
+
fontWeight: 600,
|
|
818
|
+
letterSpacing: "0.05em"
|
|
819
|
+
},
|
|
820
|
+
children: label
|
|
821
|
+
}
|
|
822
|
+
),
|
|
823
|
+
/* @__PURE__ */ jsxs6("div", { style: { display: "flex", gap: "12px" }, children: [
|
|
824
|
+
PRICE_LEVEL_OPTIONS.map((option) => {
|
|
825
|
+
const optionLabel = t(
|
|
826
|
+
`smartFilter.restaurantPriceLevel.options.${option.key}`
|
|
827
|
+
);
|
|
828
|
+
const checkboxId = `price-level-${option.key}`;
|
|
829
|
+
return /* @__PURE__ */ jsxs6(
|
|
830
|
+
"label",
|
|
831
|
+
{
|
|
832
|
+
htmlFor: checkboxId,
|
|
833
|
+
style: {
|
|
834
|
+
display: "flex",
|
|
835
|
+
alignItems: "center",
|
|
836
|
+
gap: "4px",
|
|
837
|
+
fontSize: "12px",
|
|
838
|
+
cursor: "pointer"
|
|
839
|
+
},
|
|
840
|
+
children: [
|
|
841
|
+
/* @__PURE__ */ jsx7(
|
|
842
|
+
"input",
|
|
843
|
+
{
|
|
844
|
+
id: checkboxId,
|
|
845
|
+
type: "checkbox",
|
|
846
|
+
value: option.value,
|
|
847
|
+
checked: values.includes(option.value),
|
|
848
|
+
onChange: handleChange,
|
|
849
|
+
style: { accentColor: "#03852e", cursor: "pointer" }
|
|
850
|
+
}
|
|
851
|
+
),
|
|
852
|
+
/* @__PURE__ */ jsx7("span", { children: optionLabel })
|
|
853
|
+
]
|
|
854
|
+
},
|
|
855
|
+
option.value
|
|
856
|
+
);
|
|
857
|
+
}),
|
|
858
|
+
values.length === 0 && /* @__PURE__ */ jsx7("span", { style: { fontSize: "12px", color: "#737373" }, children: noneSelectedLabel })
|
|
859
|
+
] })
|
|
860
|
+
]
|
|
861
|
+
}
|
|
862
|
+
),
|
|
863
|
+
/* @__PURE__ */ jsx7(CloseButton, { onClick: onRemove })
|
|
864
|
+
] });
|
|
865
|
+
};
|
|
866
|
+
|
|
867
|
+
// src/components/smart-filter/TransformedQueryChip.tsx
|
|
868
|
+
import {
|
|
869
|
+
useEffect as useEffect2,
|
|
870
|
+
useRef,
|
|
871
|
+
useState as useState4
|
|
872
|
+
} from "react";
|
|
873
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
874
|
+
var chipStyles4 = {
|
|
875
|
+
position: "relative",
|
|
876
|
+
backgroundColor: "white",
|
|
877
|
+
color: "black",
|
|
878
|
+
fontSize: "14px",
|
|
879
|
+
borderRadius: "9999px",
|
|
880
|
+
padding: "0 16px",
|
|
881
|
+
paddingRight: "20px",
|
|
882
|
+
border: "1px solid #03852e",
|
|
883
|
+
display: "flex",
|
|
884
|
+
alignItems: "center",
|
|
885
|
+
gap: "8px",
|
|
886
|
+
flexShrink: 0,
|
|
887
|
+
userSelect: "none",
|
|
888
|
+
height: "34px"
|
|
889
|
+
};
|
|
890
|
+
var inputStyles2 = {
|
|
891
|
+
backgroundColor: "#ececec",
|
|
892
|
+
borderRadius: "2px",
|
|
893
|
+
padding: "2px 8px",
|
|
894
|
+
outline: "none",
|
|
895
|
+
fontSize: "16px",
|
|
896
|
+
minWidth: "8ch",
|
|
897
|
+
border: "none"
|
|
898
|
+
};
|
|
899
|
+
var editButtonStyles2 = {
|
|
900
|
+
padding: "4px",
|
|
901
|
+
borderRadius: "50%",
|
|
902
|
+
cursor: "pointer",
|
|
903
|
+
transition: "background-color 0.2s",
|
|
904
|
+
color: "#737373",
|
|
905
|
+
border: "none",
|
|
906
|
+
backgroundColor: "transparent",
|
|
907
|
+
display: "flex",
|
|
908
|
+
alignItems: "center",
|
|
909
|
+
justifyContent: "center"
|
|
910
|
+
};
|
|
911
|
+
var TransformedQueryChip = ({ value, onChange, onRemove }) => {
|
|
912
|
+
const inputRef = useRef(null);
|
|
913
|
+
const [draft, setDraft] = useState4(value);
|
|
914
|
+
const [isEditing, setIsEditing] = useState4(false);
|
|
915
|
+
const [editHover, setEditHover] = useState4(false);
|
|
916
|
+
const { t } = useTranslation();
|
|
917
|
+
const removeLabel = t("smartFilter.transformedQuery.remove");
|
|
918
|
+
const editLabel = t("smartFilter.transformedQuery.edit");
|
|
919
|
+
useEffect2(() => {
|
|
920
|
+
setDraft(value);
|
|
921
|
+
setIsEditing(false);
|
|
922
|
+
}, [value]);
|
|
923
|
+
const applyChanges = () => {
|
|
924
|
+
const nextValue = draft.trim();
|
|
925
|
+
if (!nextValue.length) {
|
|
926
|
+
setDraft(value);
|
|
927
|
+
return;
|
|
928
|
+
}
|
|
929
|
+
if (nextValue === value) {
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
onChange(nextValue);
|
|
933
|
+
};
|
|
934
|
+
const handleChange = (event) => {
|
|
935
|
+
setDraft(event.target.value);
|
|
936
|
+
};
|
|
937
|
+
const handleKeyDown = (event) => {
|
|
938
|
+
if (event.key === "Enter") {
|
|
939
|
+
event.preventDefault();
|
|
940
|
+
event.currentTarget.blur();
|
|
941
|
+
return;
|
|
942
|
+
}
|
|
943
|
+
if (event.key === "Escape") {
|
|
944
|
+
event.preventDefault();
|
|
945
|
+
setDraft(value);
|
|
946
|
+
event.currentTarget.blur();
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
949
|
+
};
|
|
950
|
+
return /* @__PURE__ */ jsxs7("div", { style: chipStyles4, children: [
|
|
951
|
+
/* @__PURE__ */ jsx8(SearchIcon, { style: { width: "16px", height: "16px", color: "#03852e" } }),
|
|
952
|
+
isEditing ? /* @__PURE__ */ jsx8(
|
|
953
|
+
"input",
|
|
954
|
+
{
|
|
955
|
+
ref: inputRef,
|
|
956
|
+
value: draft,
|
|
957
|
+
onChange: handleChange,
|
|
958
|
+
onBlur: () => {
|
|
959
|
+
applyChanges();
|
|
960
|
+
setIsEditing(false);
|
|
961
|
+
},
|
|
962
|
+
onKeyDown: handleKeyDown,
|
|
963
|
+
"aria-label": editLabel,
|
|
964
|
+
style: inputStyles2,
|
|
965
|
+
autoFocus: true
|
|
966
|
+
}
|
|
967
|
+
) : /* @__PURE__ */ jsx8("span", { style: { fontSize: "16px" }, children: value }),
|
|
968
|
+
!isEditing && /* @__PURE__ */ jsx8(
|
|
969
|
+
"button",
|
|
970
|
+
{
|
|
971
|
+
type: "button",
|
|
972
|
+
style: {
|
|
973
|
+
...editButtonStyles2,
|
|
974
|
+
backgroundColor: editHover ? "#e5e5e5" : "transparent"
|
|
975
|
+
},
|
|
976
|
+
"aria-label": editLabel,
|
|
977
|
+
title: editLabel,
|
|
978
|
+
onClick: () => setIsEditing(true),
|
|
979
|
+
onMouseEnter: () => setEditHover(true),
|
|
980
|
+
onMouseLeave: () => setEditHover(false),
|
|
981
|
+
children: /* @__PURE__ */ jsx8(EditIcon, {})
|
|
982
|
+
}
|
|
983
|
+
),
|
|
984
|
+
/* @__PURE__ */ jsx8(CloseButton, { onClick: onRemove })
|
|
985
|
+
] });
|
|
986
|
+
};
|
|
987
|
+
|
|
988
|
+
// src/hooks/useFilterScroll.ts
|
|
989
|
+
import { useCallback as useCallback2, useEffect as useEffect3, useRef as useRef2, useState as useState5 } from "react";
|
|
990
|
+
var useFilterScroll = (dependency) => {
|
|
991
|
+
const scrollerRef = useRef2(null);
|
|
992
|
+
const [atStart, setAtStart] = useState5(true);
|
|
993
|
+
const [atEnd, setAtEnd] = useState5(true);
|
|
994
|
+
const updateScrollButtons = useCallback2(() => {
|
|
995
|
+
const el = scrollerRef.current;
|
|
996
|
+
if (!el) {
|
|
997
|
+
setAtStart(true);
|
|
998
|
+
setAtEnd(true);
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
const { scrollLeft, scrollWidth, clientWidth } = el;
|
|
1002
|
+
setAtStart(scrollLeft <= 0);
|
|
1003
|
+
setAtEnd(scrollLeft + clientWidth >= scrollWidth - 1);
|
|
1004
|
+
}, []);
|
|
1005
|
+
useEffect3(() => {
|
|
1006
|
+
const el = scrollerRef.current;
|
|
1007
|
+
updateScrollButtons();
|
|
1008
|
+
if (!el) {
|
|
1009
|
+
return;
|
|
1010
|
+
}
|
|
1011
|
+
const handleScroll = () => updateScrollButtons();
|
|
1012
|
+
el.addEventListener("scroll", handleScroll, { passive: true });
|
|
1013
|
+
window.addEventListener("resize", updateScrollButtons);
|
|
1014
|
+
return () => {
|
|
1015
|
+
el.removeEventListener("scroll", handleScroll);
|
|
1016
|
+
window.removeEventListener("resize", updateScrollButtons);
|
|
1017
|
+
};
|
|
1018
|
+
}, [dependency, updateScrollButtons]);
|
|
1019
|
+
const scrollByDir = useCallback2((dir) => {
|
|
1020
|
+
const el = scrollerRef.current;
|
|
1021
|
+
if (!el) {
|
|
1022
|
+
return;
|
|
1023
|
+
}
|
|
1024
|
+
const delta = el.clientWidth * 0.7;
|
|
1025
|
+
el.scrollBy({
|
|
1026
|
+
left: dir === "next" ? delta : -delta,
|
|
1027
|
+
behavior: "smooth"
|
|
1028
|
+
});
|
|
1029
|
+
}, []);
|
|
1030
|
+
return {
|
|
1031
|
+
scrollerRef,
|
|
1032
|
+
atStart,
|
|
1033
|
+
atEnd,
|
|
1034
|
+
scrollByDir
|
|
1035
|
+
};
|
|
1036
|
+
};
|
|
1037
|
+
|
|
1038
|
+
// src/components/smart-filter/FilterChips.tsx
|
|
1039
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1040
|
+
var containerStyles = {
|
|
1041
|
+
position: "relative",
|
|
1042
|
+
width: "100%"
|
|
1043
|
+
};
|
|
1044
|
+
var scrollContainerBase = {
|
|
1045
|
+
display: "flex",
|
|
1046
|
+
gap: "8px",
|
|
1047
|
+
overflowX: "auto",
|
|
1048
|
+
alignItems: "center",
|
|
1049
|
+
width: "100%",
|
|
1050
|
+
scrollbarWidth: "none",
|
|
1051
|
+
msOverflowStyle: "none"
|
|
1052
|
+
};
|
|
1053
|
+
var gradientStyles = {
|
|
1054
|
+
pointerEvents: "none",
|
|
1055
|
+
position: "absolute",
|
|
1056
|
+
top: 0,
|
|
1057
|
+
bottom: 0,
|
|
1058
|
+
width: "40px"
|
|
1059
|
+
};
|
|
1060
|
+
var navButtonStyles = {
|
|
1061
|
+
position: "absolute",
|
|
1062
|
+
top: "50%",
|
|
1063
|
+
transform: "translateY(-50%)",
|
|
1064
|
+
backgroundColor: "white",
|
|
1065
|
+
color: "#003c30",
|
|
1066
|
+
border: "1px solid #003c30",
|
|
1067
|
+
padding: "4px",
|
|
1068
|
+
borderRadius: "50%",
|
|
1069
|
+
display: "flex",
|
|
1070
|
+
alignItems: "center",
|
|
1071
|
+
justifyContent: "center",
|
|
1072
|
+
boxShadow: "0 1px 3px rgba(0,0,0,0.1)",
|
|
1073
|
+
cursor: "pointer"
|
|
1074
|
+
};
|
|
1075
|
+
var FilterChips = ({
|
|
1076
|
+
filters,
|
|
1077
|
+
currency,
|
|
1078
|
+
minRatingSuffix: _minRatingSuffix,
|
|
1079
|
+
clearAllLabel,
|
|
1080
|
+
previousFiltersLabel,
|
|
1081
|
+
nextFiltersLabel,
|
|
1082
|
+
formatCurrency: _formatCurrency,
|
|
1083
|
+
onFilterChange,
|
|
1084
|
+
onResetFilters: _onResetFilters,
|
|
1085
|
+
onClearAll
|
|
1086
|
+
}) => {
|
|
1087
|
+
const { scrollerRef, atStart, atEnd, scrollByDir } = useFilterScroll(
|
|
1088
|
+
filters.length
|
|
1089
|
+
);
|
|
1090
|
+
const [navHover, setNavHover] = React5.useState(null);
|
|
1091
|
+
const [clearHover, setClearHover] = React5.useState(false);
|
|
1092
|
+
const removeFilter = React5.useCallback(
|
|
1093
|
+
(filterId) => {
|
|
1094
|
+
void onFilterChange(filters.filter((f) => f.id !== filterId));
|
|
1095
|
+
},
|
|
1096
|
+
[filters, onFilterChange]
|
|
1097
|
+
);
|
|
1098
|
+
const patchFilter = React5.useCallback(
|
|
1099
|
+
(filterId, patch) => {
|
|
1100
|
+
const nextFilters = filters.map(
|
|
1101
|
+
(f) => f.id === filterId ? { ...f, ...patch } : f
|
|
1102
|
+
);
|
|
1103
|
+
void onFilterChange(nextFilters);
|
|
1104
|
+
},
|
|
1105
|
+
[filters, onFilterChange]
|
|
1106
|
+
);
|
|
1107
|
+
return /* @__PURE__ */ jsxs8("div", { style: containerStyles, children: [
|
|
1108
|
+
/* @__PURE__ */ jsxs8(
|
|
1109
|
+
"div",
|
|
1110
|
+
{
|
|
1111
|
+
ref: scrollerRef,
|
|
1112
|
+
style: {
|
|
1113
|
+
...scrollContainerBase,
|
|
1114
|
+
padding: "8px",
|
|
1115
|
+
// Hide scrollbar for webkit browsers
|
|
1116
|
+
WebkitOverflowScrolling: "touch"
|
|
1117
|
+
},
|
|
1118
|
+
children: [
|
|
1119
|
+
/* @__PURE__ */ jsx9("style", { children: `
|
|
2
1120
|
div::-webkit-scrollbar {
|
|
3
1121
|
display: none;
|
|
4
1122
|
}
|
|
5
|
-
`
|
|
6
|
-
|
|
1123
|
+
` }),
|
|
1124
|
+
filters.map((filter) => {
|
|
1125
|
+
var _a, _b;
|
|
1126
|
+
const renderStandardChip = () => /* @__PURE__ */ jsx9(
|
|
1127
|
+
Chip,
|
|
1128
|
+
{
|
|
1129
|
+
label: filter.label,
|
|
1130
|
+
icon: filter.icon,
|
|
1131
|
+
remove: () => removeFilter(filter.id)
|
|
1132
|
+
},
|
|
1133
|
+
filter.id
|
|
1134
|
+
);
|
|
1135
|
+
if (filter.type === "minRating" || filter.type === "starRating") {
|
|
1136
|
+
const currentRating = (_a = filter.numericValue) != null ? _a : Number(filter.value);
|
|
1137
|
+
if (!Number.isFinite(currentRating)) {
|
|
1138
|
+
return renderStandardChip();
|
|
1139
|
+
}
|
|
1140
|
+
return /* @__PURE__ */ jsx9(
|
|
1141
|
+
MinRatingFilterChip,
|
|
1142
|
+
{
|
|
1143
|
+
star: filter.type === "starRating",
|
|
1144
|
+
rating: currentRating,
|
|
1145
|
+
onChange: (nextRating) => {
|
|
1146
|
+
patchFilter(filter.id, {
|
|
1147
|
+
numericValue: nextRating,
|
|
1148
|
+
value: String(nextRating)
|
|
1149
|
+
});
|
|
1150
|
+
},
|
|
1151
|
+
onRemove: () => removeFilter(filter.id)
|
|
1152
|
+
},
|
|
1153
|
+
filter.id
|
|
1154
|
+
);
|
|
1155
|
+
}
|
|
1156
|
+
if (filter.type === "priceRange" && filter.priceRange) {
|
|
1157
|
+
return /* @__PURE__ */ jsx9(
|
|
1158
|
+
PriceRangeFilterChip,
|
|
1159
|
+
{
|
|
1160
|
+
priceRange: filter.priceRange,
|
|
1161
|
+
currency,
|
|
1162
|
+
onChange: (nextRange) => {
|
|
1163
|
+
patchFilter(filter.id, { priceRange: nextRange });
|
|
1164
|
+
},
|
|
1165
|
+
onRemove: () => removeFilter(filter.id)
|
|
1166
|
+
},
|
|
1167
|
+
filter.id
|
|
1168
|
+
);
|
|
1169
|
+
}
|
|
1170
|
+
if (filter.type === "transformed_query") {
|
|
1171
|
+
return /* @__PURE__ */ jsx9(
|
|
1172
|
+
TransformedQueryChip,
|
|
1173
|
+
{
|
|
1174
|
+
value: filter.value,
|
|
1175
|
+
onChange: (nextValue) => {
|
|
1176
|
+
patchFilter(filter.id, { value: nextValue });
|
|
1177
|
+
},
|
|
1178
|
+
onRemove: () => removeFilter(filter.id)
|
|
1179
|
+
},
|
|
1180
|
+
filter.id
|
|
1181
|
+
);
|
|
1182
|
+
}
|
|
1183
|
+
if (filter.type === "selected_restaurant_price_levels") {
|
|
1184
|
+
return /* @__PURE__ */ jsx9(
|
|
1185
|
+
RestaurantPriceLevelChip,
|
|
1186
|
+
{
|
|
1187
|
+
values: (_b = filter.priceLevels) != null ? _b : [],
|
|
1188
|
+
onChange: (nextLevels) => {
|
|
1189
|
+
patchFilter(filter.id, { priceLevels: nextLevels });
|
|
1190
|
+
},
|
|
1191
|
+
onRemove: () => removeFilter(filter.id)
|
|
1192
|
+
},
|
|
1193
|
+
filter.id
|
|
1194
|
+
);
|
|
1195
|
+
}
|
|
1196
|
+
return renderStandardChip();
|
|
1197
|
+
}),
|
|
1198
|
+
/* @__PURE__ */ jsx9(
|
|
1199
|
+
"button",
|
|
1200
|
+
{
|
|
1201
|
+
style: {
|
|
1202
|
+
flexShrink: 0,
|
|
1203
|
+
padding: "4px 16px",
|
|
1204
|
+
borderRadius: "9999px",
|
|
1205
|
+
cursor: "pointer",
|
|
1206
|
+
fontSize: "14px",
|
|
1207
|
+
userSelect: "none",
|
|
1208
|
+
backgroundColor: clearHover ? "#eee" : "white",
|
|
1209
|
+
color: "black",
|
|
1210
|
+
border: "1px solid #03852e"
|
|
1211
|
+
},
|
|
1212
|
+
onClick: onClearAll,
|
|
1213
|
+
onMouseEnter: () => setClearHover(true),
|
|
1214
|
+
onMouseLeave: () => setClearHover(false),
|
|
1215
|
+
children: clearAllLabel
|
|
1216
|
+
}
|
|
1217
|
+
)
|
|
1218
|
+
]
|
|
1219
|
+
}
|
|
1220
|
+
),
|
|
1221
|
+
!atStart && /* @__PURE__ */ jsx9(
|
|
1222
|
+
"div",
|
|
1223
|
+
{
|
|
1224
|
+
"aria-hidden": "true",
|
|
1225
|
+
style: {
|
|
1226
|
+
...gradientStyles,
|
|
1227
|
+
left: 0,
|
|
1228
|
+
background: "linear-gradient(to right, white, transparent)"
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
),
|
|
1232
|
+
!atEnd && /* @__PURE__ */ jsx9(
|
|
1233
|
+
"div",
|
|
1234
|
+
{
|
|
1235
|
+
"aria-hidden": "true",
|
|
1236
|
+
style: {
|
|
1237
|
+
...gradientStyles,
|
|
1238
|
+
right: 0,
|
|
1239
|
+
background: "linear-gradient(to left, white, transparent)"
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
),
|
|
1243
|
+
!atStart && /* @__PURE__ */ jsx9(
|
|
1244
|
+
"button",
|
|
1245
|
+
{
|
|
1246
|
+
type: "button",
|
|
1247
|
+
"aria-label": previousFiltersLabel,
|
|
1248
|
+
style: {
|
|
1249
|
+
...navButtonStyles,
|
|
1250
|
+
left: "4px",
|
|
1251
|
+
transform: "translateY(-50%) rotate(180deg)",
|
|
1252
|
+
backgroundColor: navHover === "prev" ? "#e5e5e5" : "white"
|
|
1253
|
+
},
|
|
1254
|
+
onClick: () => scrollByDir("prev"),
|
|
1255
|
+
onMouseEnter: () => setNavHover("prev"),
|
|
1256
|
+
onMouseLeave: () => setNavHover(null),
|
|
1257
|
+
children: /* @__PURE__ */ jsx9(NextIcon, { style: { width: "20px", height: "20px" } })
|
|
1258
|
+
}
|
|
1259
|
+
),
|
|
1260
|
+
!atEnd && /* @__PURE__ */ jsx9(
|
|
1261
|
+
"button",
|
|
1262
|
+
{
|
|
1263
|
+
type: "button",
|
|
1264
|
+
"aria-label": nextFiltersLabel,
|
|
1265
|
+
style: {
|
|
1266
|
+
...navButtonStyles,
|
|
1267
|
+
right: "4px",
|
|
1268
|
+
backgroundColor: navHover === "next" ? "#e5e5e5" : "white"
|
|
1269
|
+
},
|
|
1270
|
+
onClick: () => scrollByDir("next"),
|
|
1271
|
+
onMouseEnter: () => setNavHover("next"),
|
|
1272
|
+
onMouseLeave: () => setNavHover(null),
|
|
1273
|
+
children: /* @__PURE__ */ jsx9(NextIcon, { style: { width: "20px", height: "20px" } })
|
|
1274
|
+
}
|
|
1275
|
+
)
|
|
1276
|
+
] });
|
|
1277
|
+
};
|
|
1278
|
+
|
|
1279
|
+
// src/components/SmartFilter.tsx
|
|
1280
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
1281
|
+
var containerStyles2 = {
|
|
1282
|
+
position: "relative",
|
|
1283
|
+
display: "flex",
|
|
1284
|
+
flexDirection: "column",
|
|
1285
|
+
gap: "8px",
|
|
1286
|
+
width: "100%"
|
|
1287
|
+
};
|
|
1288
|
+
var SmartFilter = ({
|
|
1289
|
+
filters,
|
|
1290
|
+
isSearching = false,
|
|
1291
|
+
onFilterChange,
|
|
1292
|
+
customTranslations,
|
|
1293
|
+
currency = "USD",
|
|
1294
|
+
containerStyle,
|
|
1295
|
+
style
|
|
1296
|
+
}) => {
|
|
1297
|
+
const { t, formatCurrency } = useTranslation(customTranslations);
|
|
1298
|
+
const minRatingSuffix = t("smartFilter.minRating.suffix");
|
|
1299
|
+
const previousFiltersLabel = t("smartFilter.nav.previous");
|
|
1300
|
+
const nextFiltersLabel = t("smartFilter.nav.next");
|
|
1301
|
+
const clearAllLabel = t("smartFilter.clearAll");
|
|
1302
|
+
const handleFilterChange = useCallback3(
|
|
1303
|
+
async (nextFilters, clearAll) => {
|
|
1304
|
+
if (isSearching) {
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
try {
|
|
1308
|
+
await onFilterChange(nextFilters);
|
|
1309
|
+
} catch (error) {
|
|
1310
|
+
console.error("Filter change error:", error);
|
|
1311
|
+
}
|
|
1312
|
+
},
|
|
1313
|
+
[isSearching, onFilterChange]
|
|
1314
|
+
);
|
|
1315
|
+
const resetFilters = useCallback3(() => {
|
|
1316
|
+
void handleFilterChange([]);
|
|
1317
|
+
}, [handleFilterChange]);
|
|
1318
|
+
const clearAllFilters = useCallback3(() => {
|
|
1319
|
+
void handleFilterChange([], true);
|
|
1320
|
+
}, [handleFilterChange]);
|
|
1321
|
+
return /* @__PURE__ */ jsx10("div", { style: { ...containerStyles2, ...containerStyle, ...style }, children: filters.length > 0 && /* @__PURE__ */ jsx10(
|
|
1322
|
+
FilterChips,
|
|
1323
|
+
{
|
|
1324
|
+
filters,
|
|
1325
|
+
currency,
|
|
1326
|
+
minRatingSuffix,
|
|
1327
|
+
clearAllLabel,
|
|
1328
|
+
previousFiltersLabel,
|
|
1329
|
+
nextFiltersLabel,
|
|
1330
|
+
formatCurrency,
|
|
1331
|
+
onFilterChange: handleFilterChange,
|
|
1332
|
+
onResetFilters: resetFilters,
|
|
1333
|
+
onClearAll: clearAllFilters
|
|
1334
|
+
}
|
|
1335
|
+
) });
|
|
1336
|
+
};
|
|
1337
|
+
|
|
1338
|
+
// src/index.tsx
|
|
1339
|
+
function updateStateField(setState, key, value) {
|
|
1340
|
+
setState((prev) => prev ? { ...prev, [key]: value } : null);
|
|
1341
|
+
}
|
|
1342
|
+
function forwardCallback(optionsRef, key, ...args) {
|
|
1343
|
+
var _a;
|
|
1344
|
+
const callback = (_a = optionsRef.current.callbacks) == null ? void 0 : _a[key];
|
|
1345
|
+
callback == null ? void 0 : callback(...args);
|
|
1346
|
+
}
|
|
1347
|
+
function attachMapOnce(instanceRef, attachedRef, map, config) {
|
|
1348
|
+
if (!instanceRef.current || !map || attachedRef.current) {
|
|
1349
|
+
return;
|
|
1350
|
+
}
|
|
1351
|
+
instanceRef.current.attachMap(map, config);
|
|
1352
|
+
attachedRef.current = true;
|
|
1353
|
+
}
|
|
1354
|
+
function useMapFirst(options) {
|
|
1355
|
+
const instanceRef = React6.useRef(null);
|
|
1356
|
+
const [state, setState] = React6.useState(null);
|
|
1357
|
+
const optionsRef = React6.useRef(options);
|
|
1358
|
+
React6.useEffect(() => {
|
|
1359
|
+
optionsRef.current = options;
|
|
1360
|
+
});
|
|
1361
|
+
React6.useEffect(() => {
|
|
1362
|
+
const opts = optionsRef.current;
|
|
1363
|
+
const coreOptions = {
|
|
1364
|
+
adapter: null,
|
|
1365
|
+
// Will be set when attachMap is called
|
|
1366
|
+
...opts,
|
|
1367
|
+
callbacks: {
|
|
1368
|
+
...opts.callbacks,
|
|
1369
|
+
// Add internal callbacks to trigger React re-renders
|
|
1370
|
+
onPropertiesChange: (properties) => {
|
|
1371
|
+
updateStateField(setState, "properties", properties);
|
|
1372
|
+
forwardCallback(optionsRef, "onPropertiesChange", properties);
|
|
1373
|
+
},
|
|
1374
|
+
onSelectedPropertyChange: (id) => {
|
|
1375
|
+
updateStateField(setState, "selectedPropertyId", id);
|
|
1376
|
+
forwardCallback(optionsRef, "onSelectedPropertyChange", id);
|
|
1377
|
+
},
|
|
1378
|
+
onPrimaryTypeChange: (type) => {
|
|
1379
|
+
updateStateField(setState, "primary", type);
|
|
1380
|
+
forwardCallback(optionsRef, "onPrimaryTypeChange", type);
|
|
1381
|
+
},
|
|
1382
|
+
onFiltersChange: (filters) => {
|
|
1383
|
+
updateStateField(setState, "filters", filters);
|
|
1384
|
+
forwardCallback(optionsRef, "onFiltersChange", filters);
|
|
1385
|
+
},
|
|
1386
|
+
onBoundsChange: (bounds) => {
|
|
1387
|
+
updateStateField(setState, "bounds", bounds);
|
|
1388
|
+
forwardCallback(optionsRef, "onBoundsChange", bounds);
|
|
1389
|
+
},
|
|
1390
|
+
onPendingBoundsChange: (pendingBounds) => {
|
|
1391
|
+
updateStateField(setState, "pendingBounds", pendingBounds);
|
|
1392
|
+
forwardCallback(optionsRef, "onPendingBoundsChange", pendingBounds);
|
|
1393
|
+
},
|
|
1394
|
+
onCenterChange: (center, zoom) => {
|
|
1395
|
+
setState((prev) => prev ? { ...prev, center, zoom } : null);
|
|
1396
|
+
forwardCallback(optionsRef, "onCenterChange", center, zoom);
|
|
1397
|
+
},
|
|
1398
|
+
onZoomChange: (zoom) => {
|
|
1399
|
+
updateStateField(setState, "zoom", zoom);
|
|
1400
|
+
forwardCallback(optionsRef, "onZoomChange", zoom);
|
|
1401
|
+
},
|
|
1402
|
+
onActiveLocationChange: (location) => {
|
|
1403
|
+
updateStateField(setState, "activeLocation", location);
|
|
1404
|
+
forwardCallback(optionsRef, "onActiveLocationChange", location);
|
|
1405
|
+
},
|
|
1406
|
+
onLoadingStateChange: (loading) => {
|
|
1407
|
+
updateStateField(setState, "initialLoading", loading);
|
|
1408
|
+
forwardCallback(optionsRef, "onLoadingStateChange", loading);
|
|
1409
|
+
},
|
|
1410
|
+
onSearchingStateChange: (searching) => {
|
|
1411
|
+
updateStateField(setState, "isSearching", searching);
|
|
1412
|
+
forwardCallback(optionsRef, "onSearchingStateChange", searching);
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
};
|
|
1416
|
+
const instance = new MapFirstCore(coreOptions);
|
|
1417
|
+
instanceRef.current = instance;
|
|
1418
|
+
setState(instance.getState());
|
|
1419
|
+
return () => {
|
|
1420
|
+
instance.destroy();
|
|
1421
|
+
instanceRef.current = null;
|
|
1422
|
+
setState(null);
|
|
1423
|
+
};
|
|
1424
|
+
}, []);
|
|
1425
|
+
const setPrimaryType = React6.useCallback((type) => {
|
|
1426
|
+
if (instanceRef.current) {
|
|
1427
|
+
instanceRef.current.setPrimaryType(type);
|
|
1428
|
+
}
|
|
1429
|
+
}, []);
|
|
1430
|
+
const setSelectedMarker = React6.useCallback((id) => {
|
|
1431
|
+
if (instanceRef.current) {
|
|
1432
|
+
instanceRef.current.setSelectedMarker(id);
|
|
1433
|
+
}
|
|
1434
|
+
}, []);
|
|
1435
|
+
const setUseApi = React6.useCallback(
|
|
1436
|
+
(useApi, autoLoad = true) => {
|
|
1437
|
+
if (instanceRef.current) {
|
|
1438
|
+
instanceRef.current.setUseApi(useApi, autoLoad);
|
|
1439
|
+
}
|
|
1440
|
+
},
|
|
1441
|
+
[]
|
|
1442
|
+
);
|
|
1443
|
+
const propertiesSearch = React6.useMemo(
|
|
1444
|
+
() => ({
|
|
1445
|
+
search: async (options2) => {
|
|
1446
|
+
if (!instanceRef.current) {
|
|
1447
|
+
throw new Error("MapFirst instance not available");
|
|
1448
|
+
}
|
|
1449
|
+
return await instanceRef.current.runPropertiesSearch(options2);
|
|
1450
|
+
}
|
|
1451
|
+
}),
|
|
1452
|
+
[]
|
|
1453
|
+
);
|
|
1454
|
+
const smartFilterSearch = React6.useMemo(
|
|
1455
|
+
() => ({
|
|
1456
|
+
search: async (options2) => {
|
|
1457
|
+
if (!instanceRef.current) {
|
|
1458
|
+
throw new Error("MapFirst instance not available");
|
|
1459
|
+
}
|
|
1460
|
+
return await instanceRef.current.runSmartFilterSearch(options2);
|
|
1461
|
+
}
|
|
1462
|
+
}),
|
|
1463
|
+
[]
|
|
1464
|
+
);
|
|
1465
|
+
const boundsSearch = React6.useMemo(
|
|
1466
|
+
() => ({
|
|
1467
|
+
perform: async () => {
|
|
1468
|
+
if (!instanceRef.current) {
|
|
1469
|
+
return null;
|
|
1470
|
+
}
|
|
1471
|
+
return await instanceRef.current.performBoundsSearch();
|
|
1472
|
+
}
|
|
1473
|
+
}),
|
|
1474
|
+
[]
|
|
1475
|
+
);
|
|
1476
|
+
const mapLibreAttachedRef = React6.useRef(false);
|
|
1477
|
+
const attachMapLibre = React6.useCallback(
|
|
1478
|
+
(map, maplibregl, options2) => {
|
|
1479
|
+
attachMapOnce(instanceRef, mapLibreAttachedRef, map, {
|
|
1480
|
+
platform: "maplibre",
|
|
1481
|
+
maplibregl,
|
|
1482
|
+
onMarkerClick: options2 == null ? void 0 : options2.onMarkerClick
|
|
1483
|
+
});
|
|
1484
|
+
},
|
|
1485
|
+
[]
|
|
1486
|
+
);
|
|
1487
|
+
const googleMapsAttachedRef = React6.useRef(false);
|
|
1488
|
+
const attachGoogle = React6.useCallback(
|
|
1489
|
+
(map, google, options2) => {
|
|
1490
|
+
attachMapOnce(instanceRef, googleMapsAttachedRef, map, {
|
|
1491
|
+
platform: "google",
|
|
1492
|
+
google,
|
|
1493
|
+
onMarkerClick: options2 == null ? void 0 : options2.onMarkerClick
|
|
1494
|
+
});
|
|
1495
|
+
},
|
|
1496
|
+
[]
|
|
1497
|
+
);
|
|
1498
|
+
const mapboxAttachedRef = React6.useRef(false);
|
|
1499
|
+
const attachMapbox = React6.useCallback(
|
|
1500
|
+
(map, mapboxgl, options2) => {
|
|
1501
|
+
attachMapOnce(instanceRef, mapboxAttachedRef, map, {
|
|
1502
|
+
platform: "mapbox",
|
|
1503
|
+
mapboxgl,
|
|
1504
|
+
onMarkerClick: options2 == null ? void 0 : options2.onMarkerClick
|
|
1505
|
+
});
|
|
1506
|
+
},
|
|
1507
|
+
[]
|
|
1508
|
+
);
|
|
1509
|
+
return {
|
|
1510
|
+
instance: instanceRef.current,
|
|
1511
|
+
state,
|
|
1512
|
+
setPrimaryType,
|
|
1513
|
+
setSelectedMarker,
|
|
1514
|
+
setUseApi,
|
|
1515
|
+
propertiesSearch,
|
|
1516
|
+
smartFilterSearch,
|
|
1517
|
+
boundsSearch,
|
|
1518
|
+
attachMapLibre,
|
|
1519
|
+
attachGoogle,
|
|
1520
|
+
attachMapbox
|
|
1521
|
+
};
|
|
1522
|
+
}
|
|
1523
|
+
export {
|
|
1524
|
+
Chip,
|
|
1525
|
+
CloseIcon,
|
|
1526
|
+
EditIcon,
|
|
1527
|
+
FilterChips,
|
|
1528
|
+
MapFirstCore2 as MapFirstCore,
|
|
1529
|
+
MinRatingFilterChip,
|
|
1530
|
+
NextIcon,
|
|
1531
|
+
PriceRangeFilterChip,
|
|
1532
|
+
PropertiesFetchError,
|
|
1533
|
+
RestaurantPriceLevelChip,
|
|
1534
|
+
SearchIcon,
|
|
1535
|
+
SmartFilter,
|
|
1536
|
+
StarIcon,
|
|
1537
|
+
TransformedQueryChip,
|
|
1538
|
+
convertToApiFilters,
|
|
1539
|
+
createMinRatingFilterLabel,
|
|
1540
|
+
createPriceRangeFilterLabel,
|
|
1541
|
+
fetchImages,
|
|
1542
|
+
fetchProperties,
|
|
1543
|
+
formatRatingValue,
|
|
1544
|
+
processApiFilters,
|
|
1545
|
+
renderStars,
|
|
1546
|
+
useFilterScroll,
|
|
1547
|
+
useMapFirst,
|
|
1548
|
+
useTranslation
|
|
1549
|
+
};
|