react-listing-engine 0.7.3 → 0.7.4
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/CHANGELOG.md +9 -0
- package/dist/chunk-PG33Q2EN.js +2 -0
- package/dist/chunk-SR7UMK4U.cjs +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +28 -4
- package/dist/index.d.ts +28 -4
- package/dist/index.js +1 -1
- package/dist/{listing-app-DHFJtnKI.d.ts → listing-app-CKWKPJrW.d.ts} +20 -5
- package/dist/{listing-app-C7EeHlmP.d.cts → listing-app-S7zz1ovr.d.cts} +20 -5
- package/dist/styled/index.cjs +1 -1
- package/dist/styled/index.d.cts +2 -2
- package/dist/styled/index.d.ts +2 -2
- package/dist/styled/index.js +1 -1
- package/dist/styles.css +31 -0
- package/package.json +1 -1
- package/dist/chunk-TX6KIOD7.js +0 -2
- package/dist/chunk-X4LBPNOS.cjs +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# react-listing-engine
|
|
2
2
|
|
|
3
|
+
## 0.7.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Mobile filters bottom-sheet improvements:
|
|
8
|
+
|
|
9
|
+
- The sheet's "Show N results" apply button now shows a loading spinner (and is disabled) while a filter refetch is in flight.
|
|
10
|
+
- The sheet now **defers** filter application: changing a control buffers into a draft instead of applying live, and only the "Show results" button commits the draft to the engine (the list + map update then, and the sheet closes once the refetch settles). `ListingFilters` gains optional `draft` / `onDraftChange` props to drive this deferred mode; the desktop filter bar is unchanged (still applies live).
|
|
11
|
+
|
|
3
12
|
## 0.7.3
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var X=class{state;listeners=new Set;constructor(e){this.state=this.freezeState({filters:{...e.filters},results:{items:[],nextCursor:null},bounds:null,selection:null,hovered:null,pagination:{mode:e.mode??"paged",loading:!1},layers:{},points:{}})}getState(){return this.state}setFilters(e){this.setState({filters:{...this.state.filters,...e}})}setResults(e){this.setState({results:{items:[...e.items],nextCursor:e.nextCursor,total:e.total}})}appendResults(e){this.setState({results:{items:[...this.state.results.items,...e.items],nextCursor:e.nextCursor,total:e.total}})}setBounds(e){this.setState({bounds:e?{...e}:null})}setSelection(e){this.setState({selection:e})}setHovered(e){this.setState({hovered:e})}setLayerVisible(e,i){this.setState({layers:{...this.state.layers,[e]:i}})}setLoading(e){this.setState({pagination:{...this.state.pagination,loading:e}})}setPoints(e,i){this.setState({points:{...this.state.points,[e]:[...i]}})}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setState(e){this.state=this.freezeState({...this.state,...e}),this.notify()}notify(){for(let e of this.listeners)e()}freezeState(e){Object.freeze(e.filters),Object.freeze(e.results.items),Object.freeze(e.results),e.bounds&&Object.freeze(e.bounds),Object.freeze(e.pagination),Object.freeze(e.layers);for(let i of Object.values(e.points))Object.freeze(i);return Object.freeze(e.points),Object.freeze(e)}};var z=class{defs=new Map;add(e){if(this.defs.has(e.key))throw new Error(`FilterRegistry: filter "${e.key}" is already registered`);return this.defs.set(e.key,{...e}),this}remove(e){return this.defs.delete(e),this}replace(e,i){if(!this.defs.has(e))throw new Error(`FilterRegistry: cannot replace unregistered filter "${e}"`);return this.defs.set(e,{...i,key:e}),this}reorder(e){let i=this.list(),r=e.filter(s=>this.defs.has(s));r.forEach((s,o)=>{this.defs.get(s).order=o});let n=new Set(r);return i.filter(s=>!n.has(s.key)).forEach((s,o)=>{s.order=r.length+o}),this}list(){return[...this.defs.values()].sort((e,i)=>e.order-i.order)}has(e){return this.defs.has(e)}toFilters(e){return this.list().filter(r=>Object.hasOwn(e,r.key)).map(r=>r.toParams(e[r.key])).reduce((r,n)=>({...r,...n}),{})}activeKeys(e){return this.list().filter(i=>i.isActive?.(e)).map(i=>i.key)}clearedParams(){return this.list().reduce((e,i)=>Object.assign(e,i.toParams(i.fromParams({}))),{})}};var J=class{defs=new Map;add(e){if(this.defs.has(e.id))throw new Error(`DatasetRegistry: dataset "${e.id}" is already registered`);return this.defs.set(e.id,{...e}),this}get(e){return this.defs.get(e)}has(e){return this.defs.has(e)}list(){return[...this.defs.values()]}visibleIds(){return this.list().filter(e=>e.visible?.()!==!1).map(e=>e.id)}};var Y=class{map=new Map;dispose(){this.map.clear()}emit(e){let i=this.map.get(e.type);if(i)for(let n of[...i])n(e);let r=this.map.get("*");if(r)for(let n of[...r])n(e)}on(e,i){let r=this.map.get(e);return r||(r=new Set,this.map.set(e,r)),r.add(i),()=>{r.delete(i)}}};var Ie={pagination:"paged",pageSize:20,debounceMs:250};var ee=class{options;constructor(e){this.options=Object.freeze({...Ie,...e})}};var te=class{filters;map;datasets;primaryDatasetId;store;emitter=new Y;config;debounceTimer=null;debounceResolve=null;queryToken=0;pointsToken=0;constructor(e){this.datasets=e.datasets,this.filters=e.filters??new z,this.map=e.map,this.config=new ee(e.config);let i=e.primaryDatasetId??this.datasets.list()[0]?.id;if(i==null||!this.datasets.has(i))throw new Error(`ListingEngine: primary dataset "${i??""}" is not registered \u2014 pass a valid primaryDatasetId or register at least one dataset`);this.primaryDatasetId=i,this.store=new X({filters:e.initialFilters??{},mode:this.config.options.pagination})}get state(){return this.store.getState()}get options(){return this.config.options}applyFilters(e){this.store.setFilters(e),this.emitter.emit({type:"FiltersChanged",filters:this.currentFilters()}),this.clearDebounce();let i=++this.queryToken,r=this.config.options.debounceMs;return r<=0?this.runQuery(i):new Promise(n=>{this.debounceResolve=n,this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.debounceResolve=null,n(this.runQuery(i))},r)})}async loadPage(){let e=this.state.results.nextCursor;if(e===null)return;let i=++this.queryToken,r=this.primaryDataset();this.store.setLoading(!0);try{let n=await r.adapter.list(this.currentFilters(),{cursor:e,limit:this.config.options.pageSize});if(i!==this.queryToken)return;this.config.options.pagination==="infinite"?this.store.appendResults(n):this.store.setResults(n),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:n.items.length})}finally{i===this.queryToken&&this.store.setLoading(!1)}}async loadPoints(e){this.store.setBounds(e),this.emitter.emit({type:"BoundsChanged",bounds:e});let i=this.currentFilters(),r=++this.pointsToken;await Promise.allSettled(this.datasets.visibleIds().map(async n=>{let s=this.datasets.get(n);if(!s)return;let o=await s.adapter.getPoints(i,e);r===this.pointsToken&&this.store.setPoints(n,o)}))}selectPoint(e,i){this.store.setSelection(i);let r=this.state.points[e]?.find(n=>n.id===i);r&&this.emitter.emit({type:"PointClicked",datasetId:e,id:r.id,entity:r.entity})}setHovered(e,i){this.store.setHovered(i)}toggleLayer(e){let r=!(this.state.layers[e]??!0);this.store.setLayerVisible(e,r),this.emitter.emit({type:"LayerToggled",datasetId:e,visible:r})}subscribe(e){return this.store.subscribe(e)}on(e,i){return this.emitter.on(e,i)}dispose(){this.clearDebounce(),this.emitter.dispose()}async runQuery(e){if(e!==this.queryToken)return;let i=this.primaryDataset();this.store.setLoading(!0);try{let r=await i.adapter.list(this.currentFilters(),{cursor:null,limit:this.config.options.pageSize});if(e!==this.queryToken)return;this.store.setResults(r),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:r.items.length})}finally{e===this.queryToken&&this.store.setLoading(!1)}}primaryDataset(){return this.datasets.get(this.primaryDatasetId)}currentFilters(){return this.store.getState().filters}clearDebounce(){this.debounceTimer!==null&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.debounceResolve!==null&&(this.debounceResolve(),this.debounceResolve=null)}};function Ee(...t){let e={config:{},filters:new z,datasets:new J};for(let i of t)i(e);return e}var xe=t=>e=>{e.config={...e.config,...t}},Ne=t=>e=>{e.map=t},Re=t=>e=>{e.datasets.add(t)},Me=t=>e=>{t(e.filters)},wi=t=>e=>{e.urlSync=t},De=t=>e=>{e.initialFilters=t},ki=t=>e=>{e.primaryDatasetId=t};import{createContext as ct,useContext as ut}from"react";import{jsx as E,jsxs as Ft}from"react/jsx-runtime";function mt(t){return String(t?.title??"")}var ft=({item:t})=>E("div",{children:mt(t)}),gt=()=>E("div",{}),ce=()=>E("div",{}),yt=({children:t})=>E("div",{children:t}),vt=({children:t})=>E("div",{children:t}),ht=({value:t,onChange:e,placeholder:i})=>E("input",{type:"search",value:t,placeholder:i,onChange:r=>e(r.target.value),"aria-label":i??"Search"}),Lt=()=>E("div",{role:"status",children:"No results"}),bt=()=>E("div",{role:"status","aria-busy":"true",children:"Loading\u2026"}),Pt=({count:t})=>Ft("div",{children:[t," results"]}),Tt=({children:t})=>E("div",{children:t}),S={Card:ft,Marker:gt,Popup:ce,Sidebar:yt,FilterPanel:vt,Search:ht,Empty:Lt,Loading:bt,ResultHeader:Pt,Toolbar:Tt},Oe=ct(S);function _e(t){let{Card:e,Marker:i,Popup:r,Sidebar:n,FilterPanel:s,Search:o,Empty:l,Loading:p,ResultHeader:d,Toolbar:a,children:g}=t,m={Card:e??S.Card,Marker:i??S.Marker,Popup:r??S.Popup,Sidebar:n??S.Sidebar,FilterPanel:s??S.FilterPanel,Search:o??S.Search,Empty:l??S.Empty,Loading:p??S.Loading,ResultHeader:d??S.ResultHeader,Toolbar:a??S.Toolbar};return E(Oe.Provider,{value:m,children:g})}function T(){return ut(Oe)}import{createContext as Ct}from"react";var ie=Ct(null);import{useContext as wt}from"react";function v(){let t=wt(ie);if(t===null)throw new Error("useListing must be used within a <ListingProvider>");return t}import{useCallback as Be,useSyncExternalStore as kt}from"react";function F(){let t=v(),e=Be(r=>t.subscribe(r),[t]),i=Be(()=>t.state,[t]);return kt(e,i,i)}import{useCallback as Ae}from"react";function re(){let t=v(),e=F(),i=Ae(n=>t.applyFilters(n),[t]),r=Ae((n,s)=>t.applyFilters({[n]:s}),[t]);return{filters:e.filters,set:i,setField:r}}import{jsx as q,jsxs as St}from"react/jsx-runtime";function ue({className:t,groupClassName:e,hideLabels:i,draft:r,onDraftChange:n}={}){let s=v(),{FilterPanel:o}=T(),{filters:l}=re(),p=r!==void 0&&n!==void 0,d=p?r:l;return q(o,{children:q("div",{className:t??"space-y-5",children:s.filters.list().map(a=>{if(typeof a.render=="string")return q("div",{"data-filter":a.key,className:e},a.key);let g=a.render;return St("div",{className:e,children:[a.label&&!i&&q("div",{className:"mb-1.5 text-[13px] font-medium text-foreground",children:a.label}),q(g,{value:a.fromParams(d),onChange:m=>p?n(a.toParams(m)):void s.applyFilters(a.toParams(m))})]},a.key)})})})}function U(){return F().results}import{jsx as ne}from"react/jsx-runtime";function It(t,e){if(t&&typeof t=="object"&&"id"in t){let i=t.id;if(typeof i=="string"||typeof i=="number")return i}return e}function He({className:t}={}){let e=v(),{items:i}=U(),{pagination:r,selection:n}=F(),{Card:s,Empty:o,Loading:l}=T();return r.loading&&i.length===0?ne(l,{}):i.length===0?ne(o,{}):ne("div",{role:"list",className:t,children:i.map((p,d)=>{let a=It(p,d);return ne(s,{item:p,selected:n===a,onSelect:()=>e.selectPoint(e.primaryDatasetId,a)},a)})})}import{useEffect as j,useRef as _,useState as ze}from"react";import{createPortal as Et}from"react-dom";import{jsx as me,jsxs as Ve}from"react/jsx-runtime";var xt={west:-179.9,south:-85,east:179.9,north:85},Ue=.1,Ke=.02;function Nt(t){if(t.length===0)return null;let e=t[0].lng,i=t[0].lng,r=t[0].lat,n=t[0].lat;for(let{lat:l,lng:p}of t)p<e&&(e=p),p>i&&(i=p),l<r&&(r=l),l>n&&(n=l);let s=n>r?(n-r)*Ue:Ke,o=i>e?(i-e)*Ue:Ke;return{west:e-o,east:i+o,south:r-s,north:n+s}}function $e(t){let{center:e,zoom:i,fallback:r,mapControls:n}=t,s=v(),o=F(),l=_(null),p=_(null),d=_(null),[a,g]=ze(!1),m=_(!1),D=_(!1),I=_(!1),c=s.map;j(()=>{let h=d.current;if(!c||!h)return;let y=[];for(let f of Object.keys(o.points)){if(o.layers[f]===!1)continue;let L=s.datasets.get(f),w=o.points[f]??[],H={id:f,markers:w.map(k=>({id:k.id,position:k.position,iconUrl:L?.marker.iconUrl?.(k.entity),element:L?.marker.element?.(k.entity)})),clustering:L?.clustering,onMarkerClick:k=>s.selectPoint(f,k)};y.push(c.renderLayer(h,H))}return()=>{y.forEach(f=>f())}},[s,c,a,o.points,o.layers]),j(()=>{if(!l.current||!c)return;let h=l.current,y=!1,f=null;return(async()=>{let L=await c.mount(h,{center:e,zoom:i,fullscreenTarget:p.current??void 0});if(y){c.destroy(L);return}d.current=L,f=c.onBoundsChange(L,w=>{I.current?I.current=!1:D.current=!0,s.loadPoints(w)}),g(!0),s.loadPoints(xt)})(),()=>{y=!0,f?.(),d.current&&(c.destroy(d.current),d.current=null),g(!1)}},[s,c]),j(()=>{let h=d.current;if(!c||!h||e||m.current||D.current)return;let y=[];for(let L of Object.keys(o.points))if(o.layers[L]!==!1)for(let w of o.points[L]??[])y.push(w.position);let f=Nt(y);f&&(m.current=!0,I.current=!0,c.fitBounds(h,f))},[c,e,a,o.points,o.layers]),j(()=>{c?.updateMarkerStates(o.selection,o.hovered)},[c,a,o.selection,o.hovered]);let{Popup:P}=T(),O=P!==ce,x=o.points[s.primaryDatasetId]??[],N=o.selection!=null?x.find(h=>h.id===o.selection):void 0,[$,G]=ze(null),Z=_(N);return Z.current=N,j(()=>{let h=d.current;if(!c||!h||!O)return;let y=Z.current;if(!y)return;let f=c.mountOverlay(y.position);G({entity:y.entity,position:y.position,container:f.container});let L=()=>s.selectPoint(s.primaryDatasetId,null),w=k=>{k.key==="Escape"&&L()};document.addEventListener("keydown",w);let H=c.onMapClick(L);return()=>{document.removeEventListener("keydown",w),H(),f.unmount(),G(null)}},[s,c,a,o.selection,O]),Ve("div",{ref:p,className:"relative h-full min-h-0 w-full",children:[Ve("div",{ref:l,className:!c&&r?"flex h-full min-h-0 w-full items-center justify-center":"h-full min-h-0 w-full",children:[!c&&r,O&&$?Et(me(P,{entity:$.entity,onClose:()=>s.selectPoint(s.primaryDatasetId,null)}),$.container):null]}),n!=null&&me("div",{className:"pointer-events-none absolute inset-0",children:me("div",{className:"pointer-events-auto",children:n})})]})}import{jsx as Rt}from"react/jsx-runtime";function We(){let t=v(),{results:e,pagination:i}=F();return e.nextCursor==null?null:Rt("button",{type:"button",disabled:i.loading,onClick:()=>{t.loadPage()},children:"Load more"})}import{jsx as Mt}from"react/jsx-runtime";function qe(){let{items:t,total:e}=U(),{ResultHeader:i}=T();return Mt(i,{count:t.length,total:e})}import{useEffect as Dt,useRef as Ot}from"react";function je(t,e){let i=v(),r=Ot(e);r.current=e,Dt(()=>i.on(t,n=>r.current(n)),[i,t])}import{useEffect as _t,useState as Qe}from"react";import{jsx as Bt}from"react/jsx-runtime";function Ge(t){let{children:e,...i}=t,[r]=Qe(()=>i),[n,s]=Qe(null);return _t(()=>{let o=new te({datasets:r.datasets,filters:r.filters,config:r.config,map:r.map,initialFilters:r.initialFilters,primaryDatasetId:r.primaryDatasetId});return r.urlSync&&r.urlSync.start(o),s(o),()=>{r.urlSync&&r.urlSync.stop(),o.dispose(),s(l=>l===o?null:l)}},[r]),n?Bt(ie.Provider,{value:n,children:e}):null}function K(t){return typeof t!="number"?t:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t)}import{Fragment as Ht,jsx as R,jsxs as Ze}from"react/jsx-runtime";function At(t){return t?"rle-card rle-card--selected":"rle-card"}function fe({item:t,selected:e,onSelect:i}){let r=t??{},n=At(e),s=Ze(Ht,{children:[r.imageUrl?R("img",{src:r.imageUrl,alt:r.title??"",className:"rle-card-media"}):R("div",{className:"rle-card-media rle-card-media--placeholder","aria-hidden":"true"}),Ze("div",{className:"rle-card-body",children:[r.title&&R("span",{className:"rle-card-title",children:r.title}),r.subtitle&&R("span",{className:"rle-card-address",children:r.subtitle}),r.badge&&R("div",{className:"rle-card-info",children:R("span",{className:"rle-card-info-item",children:r.badge})}),r.price!=null&&R("span",{className:"rle-card-price",children:K(r.price)})]})]});return i?R("button",{type:"button",onClick:i,"aria-pressed":e??!1,className:n,children:s}):R("article",{className:n,children:s})}import{jsx as se,jsxs as Xe}from"react/jsx-runtime";function ge(t){return Xe("div",{role:"status",className:"rle-empty",children:[Xe("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",className:"rle-empty-icon","aria-hidden":"true",children:[se("circle",{cx:"11",cy:"11",r:"7"}),se("path",{d:"m21 21-4.3-4.3"})]}),se("p",{className:"rle-empty-title",children:"No results"}),se("p",{className:"rle-empty-hint",children:"Try adjusting your filters or search terms."})]})}import{jsx as zt}from"react/jsx-runtime";function ye({children:t}){return zt("div",{className:"rle-filter-panel",children:t})}import{jsx as oe,jsxs as Ut}from"react/jsx-runtime";function ve(t){return oe("div",{className:"rle-loading",role:"status","aria-busy":"true","aria-label":"Loading results",children:Array.from({length:3}).map((e,i)=>Ut("div",{className:"rle-loading-item",children:[oe("div",{className:"rle-skeleton",style:{aspectRatio:"4 / 3",width:"100%"}}),oe("div",{className:"rle-skeleton",style:{height:16,width:"65%"}}),oe("div",{className:"rle-skeleton",style:{height:12,width:"35%"}})]},i))})}import{jsx as Kt}from"react/jsx-runtime";function he({point:t}){let e=t.entity??{};return Kt("span",{className:"rle-pin",children:e.price!=null?K(e.price):""})}import{jsx as V,jsxs as Le}from"react/jsx-runtime";function be({entity:t,onClose:e}){let i=t??{};return Le("div",{className:"rle-popup",role:"group","aria-label":"Location details",children:[V("button",{type:"button",onClick:e,"aria-label":"Close",className:"rle-popup-close",children:Le("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[V("path",{d:"M18 6 6 18"}),V("path",{d:"m6 6 12 12"})]})}),Le("div",{children:[i.title&&V("div",{className:"rle-card-title",children:i.title}),i.subtitle&&V("div",{className:"rle-card-address",children:i.subtitle}),i.price!=null&&V("div",{className:"rle-card-price",children:K(i.price)})]})]})}import{jsx as Vt}from"react/jsx-runtime";function Pe({count:t,total:e}){let i=e!=null&&e!==t?`${t} of ${e} results`:`${t} results`;return Vt("div",{className:"rle-result-header",children:i})}import{jsx as $t}from"react/jsx-runtime";function Te({value:t,onChange:e,placeholder:i}){return $t("input",{type:"search",value:t,placeholder:i,onChange:r=>e(r.target.value),"aria-label":i??"Search",className:"rle-input"})}import{jsx as Wt}from"react/jsx-runtime";function Fe({children:t}){return Wt("aside",{className:"rle-sidebar",children:t})}import{jsx as qt}from"react/jsx-runtime";function Ce({children:t}){return qt("div",{className:"rle-toolbar",children:t})}var Je={Card:fe,Marker:he,Popup:be,Sidebar:Fe,FilterPanel:ye,Search:Te,Empty:ge,Loading:ve,ResultHeader:Pe,Toolbar:Ce};import{jsx as C,jsxs as Q}from"react/jsx-runtime";function Ye({view:t,onViewChange:e}){return C("nav",{className:"rle-bottom-nav","aria-label":"Listing navigation",children:Q("div",{className:"rle-viewtoggle",role:"group","aria-label":"View",children:[Q("button",{type:"button",className:`rle-viewtoggle__btn${t==="list"?" rle-viewtoggle__btn--active":""}`,"aria-pressed":t==="list",onClick:()=>e("list"),children:[C(jt,{}),"List"]}),Q("button",{type:"button",className:`rle-viewtoggle__btn${t==="map"?" rle-viewtoggle__btn--active":""}`,"aria-pressed":t==="map",onClick:()=>e("map"),children:[C(Qt,{}),"Map"]})]})})}function jt(){return Q("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[C("line",{x1:"8",y1:"6",x2:"20",y2:"6"}),C("line",{x1:"8",y1:"12",x2:"20",y2:"12"}),C("line",{x1:"8",y1:"18",x2:"20",y2:"18"}),C("line",{x1:"4",y1:"6",x2:"4.01",y2:"6"}),C("line",{x1:"4",y1:"12",x2:"4.01",y2:"12"}),C("line",{x1:"4",y1:"18",x2:"4.01",y2:"18"})]})}function Qt(){return Q("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[C("polygon",{points:"1 6 8 3 16 6 23 3 23 18 16 21 8 18 1 21 1 6"}),C("line",{x1:"8",y1:"3",x2:"8",y2:"18"}),C("line",{x1:"16",y1:"6",x2:"16",y2:"21"})]})}import{useEffect as we,useRef as Gt,useState as et}from"react";import{createPortal as Zt}from"react-dom";import{Fragment as Jt,jsx as M,jsxs as ae}from"react/jsx-runtime";function tt({open:t,onOpenChange:e,title:i,children:r,footer:n}){let s=Gt(null),[o,l]=et(!1),[p,d]=et(!1);return we(()=>{if(!t){d(!1),l(!1);return}l(!0);let a=requestAnimationFrame(()=>d(!0));return()=>cancelAnimationFrame(a)},[t]),we(()=>{if(!o)return;let a=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=a}},[o]),we(()=>{if(!o)return;s.current?.focus();function a(g){g.key==="Escape"&&e(!1)}return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[o,e]),!o||typeof document>"u"?null:Zt(ae(Jt,{children:[M("div",{className:`rle-sheet-backdrop${p?" rle-sheet-backdrop--open":""}`,onClick:()=>e(!1),"aria-hidden":"true"}),ae("div",{ref:s,className:`rle-sheet${p?" rle-sheet--open":""}`,role:"dialog","aria-modal":"true","aria-label":i,tabIndex:-1,children:[M("div",{className:"rle-sheet__handle","aria-hidden":"true"}),ae("div",{className:"rle-sheet__header",children:[i&&M("div",{className:"rle-sheet__title",children:i}),M("button",{type:"button",className:"rle-sheet__close",onClick:()=>e(!1),"aria-label":"Close",children:M(Xt,{})})]}),M("div",{className:"rle-sheet__body",children:r}),n&&M("div",{className:"rle-sheet__footer",children:n})]})]}),document.body)}function Xt(){return ae("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[M("path",{d:"M18 6 6 18"}),M("path",{d:"m6 6 12 12"})]})}import{useEffect as ke,useRef as rt,useState as A}from"react";import{jsx as b,jsxs as le}from"react/jsx-runtime";function it({search:t,onFiltersClick:e,filterCount:i=0,action:r}){let{Search:n}=T();return le("header",{className:"rle-mobile-header",children:[t&&b("div",{className:"rle-mobile-header__search",children:b(n,{value:t.value,onChange:t.onChange,placeholder:t.placeholder})}),le("button",{type:"button",className:"rle-btn rle-mobile-header__btn",onClick:e,children:[b(Yt,{}),b("span",{children:"Filters"}),i>0&&b("span",{className:"rle-mobile-header__count",children:i})]}),r&&b("button",{type:"button",className:"rle-btn rle-mobile-header__btn rle-mobile-header__btn--icon",onClick:r.onClick,"aria-label":r.label,children:r.icon??b(ei,{})})]})}function Yt(){return le("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[b("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),b("circle",{cx:"9",cy:"6",r:"2",fill:"currentColor",stroke:"none"}),b("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),b("circle",{cx:"15",cy:"12",r:"2",fill:"currentColor",stroke:"none"}),b("line",{x1:"4",y1:"18",x2:"20",y2:"18"}),b("circle",{cx:"11",cy:"18",r:"2",fill:"currentColor",stroke:"none"})]})}function ei(){return le("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[b("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),b("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}import{Fragment as ni,jsx as u,jsxs as B}from"react/jsx-runtime";var ti=u("div",{className:"rle-empty",children:"Map unavailable"});function ii(){let t=rt(null),[e,i]=A(!0),[r,n]=A(!0);return ke(()=>{let s=t.current;if(!s)return;let o=()=>{let{clientWidth:g,scrollLeft:m,scrollWidth:D}=s;i(m<=0),n(m+g>=D-1)},l=0,p=()=>{l||(l=requestAnimationFrame(()=>{l=0,o()}))};o(),s.addEventListener("scroll",o,{passive:!0});let d,a;return typeof ResizeObserver<"u"&&(d=new ResizeObserver(o),d.observe(s)),typeof MutationObserver<"u"&&(a=new MutationObserver(p),a.observe(s,{characterData:!0,childList:!0,subtree:!0})),()=>{s.removeEventListener("scroll",o),d?.disconnect(),a?.disconnect(),l&&cancelAnimationFrame(l)}},[]),{atEnd:r,atStart:e,ref:t}}function ri(t,e){if(t===e)return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;let i=t,r=e,n=new Set([...Object.keys(i),...Object.keys(r)]);for(let s of n)if(i[s]!==r[s])return!1;return!0}function nt({search:t,toolbarEnd:e,mobileAction:i,autoFetch:r=!0,hasMap:n,mapCenter:s,mapZoom:o,mapControls:l,className:p}){let d=v(),{Search:a}=T(),g=U(),{filters:m,set:D}=re(),{pagination:I}=F(),c=n??d.map!=null,[P,O]=A("list"),[x,N]=A(!1),{atEnd:$,atStart:G,ref:Z}=ii(),[h,y]=A(m),[f,L]=A(x);x!==f&&(L(x),x&&y(m));let w=pe=>y(pt=>({...pt,...pe})),[H,k]=A(!1),de=rt(!1);ke(()=>{if(H){if(I.loading){de.current=!0;return}de.current&&(de.current=!1,k(!1),N(!1))}},[H,I.loading]);let W=t?{value:String(m[t.filterKey]??""),onChange:pe=>{D({[t.filterKey]:pe||void 0})},placeholder:t.placeholder}:void 0;ke(()=>{r!==!1&&d.applyFilters({})},[d,r]);let ot=()=>{w(d.filters.clearedParams())},at=()=>{if(ri(h,m)){N(!1);return}k(!0),d.applyFilters(h)},lt=d.filters.activeKeys(m).length,dt=g.total??g.items.length;return B("div",{className:p?`rle-app ${p}`:"rle-app",children:[B("div",{className:"rle-filter-bar",children:[B("div",{className:"rle-filter-bar__scroll",ref:Z,children:[W&&u("div",{className:"rle-filter-bar__search",children:u(a,{value:W.value,onChange:W.onChange,placeholder:W.placeholder})}),u(ue,{className:"rle-filters-row",groupClassName:"rle-filter-group",hideLabels:!0})]}),!G&&u("div",{className:"rle-filter-bar__fade rle-filter-bar__fade--start","aria-hidden":"true"}),!$&&u("div",{className:"rle-filter-bar__fade rle-filter-bar__fade--end","aria-hidden":"true"})]}),u(it,{search:W,onFiltersClick:()=>N(!0),filterCount:lt,action:i}),B("div",{className:`rle-body ${c?"rle-split":"rle-body--list-only"}`,"data-mobile-view":P,children:[B("div",{className:"rle-list",children:[B("div",{className:"rle-list-header",children:[u(qe,{}),e&&u("div",{className:"rle-list-header__toolbar",children:e})]}),u(He,{className:"rle-list-grid"}),u(We,{})]}),c&&u("div",{className:"rle-map",children:u($e,{center:s,zoom:o,fallback:ti,mapControls:l})})]}),c&&u(Ye,{view:P,onViewChange:O}),u(tt,{title:"Filters",open:x,onOpenChange:N,footer:B(ni,{children:[u("button",{type:"button",className:"rle-btn rle-btn--ghost",onClick:ot,children:"Clear all"}),u("button",{type:"button",className:"rle-btn rle-btn--primary rle-sheet__apply",disabled:I.loading,onClick:at,children:I.loading?u("span",{className:"rle-spinner","aria-label":"Updating results"}):`Show ${dt} results`})]}),children:u(ue,{className:"rle-filter-stack",groupClassName:"rle-filter-group",draft:h,onDraftChange:w})})]})}import{useEffect as si,useRef as oi,useState as ai}from"react";import{jsx as Se,jsxs as pi}from"react/jsx-runtime";function st(t){return"provider"in t}function li(t){let e=t!=null&&!st(t),i=e?t.apiKey:void 0,r=e?t.mapId:void 0,n=e?t.mapOptions:void 0,s=e?t.styles:void 0,[o,l]=ai(()=>!t||st(t)?{ready:!0,provider:t?.provider}:{ready:!1});return si(()=>{if(!i)return;let p=!1;return import("./maps/google/index.js").then(({googleProvider:d})=>{p||l({ready:!0,provider:d({apiKey:i,mapId:r,mapOptions:n,styles:s})})}),()=>{p=!0}},[i,r]),o}function di({onFiltersChange:t}){let e=oi(t);return e.current=t,je("FiltersChanged",i=>{i.type==="FiltersChanged"&&e.current(i.filters)}),null}function xn(t){let{datasets:e,filters:i,map:r,components:n,initialFilters:s,onFiltersChange:o,mobileAction:l,search:p,toolbarEnd:d,mapControls:a,config:g,autoFetch:m,className:D}=t,{ready:I,provider:c}=li(r);if(!I)return null;let P=[];for(let N of e)P.push(Re(N));i&&P.push(Me(i)),c&&P.push(Ne(c)),s&&P.push(De(s)),g&&P.push(xe(g));let O=Ee(...P),x={...Je,...n};return pi(Ge,{...O,children:[o&&Se(di,{onFiltersChange:o}),Se(_e,{...x,children:Se(nt,{className:D,search:p,toolbarEnd:d,mobileAction:l,autoFetch:m,mapCenter:r?.center,mapZoom:r?.zoom,mapControls:a})})]})}export{X as a,z as b,J as c,Y as d,Ie as e,ee as f,te as g,Ee as h,xe as i,Ne as j,Re as k,Me as l,wi as m,De as n,ki as o,ce as p,_e as q,T as r,ie as s,v as t,F as u,re as v,ue as w,U as x,He as y,$e as z,We as A,qe as B,je as C,Ge as D,fe as E,ge as F,ye as G,ve as H,he as I,be as J,Pe as K,Te as L,Fe as M,Ce as N,Je as O,Ye as P,tt as Q,nt as R,xn as S};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5;"use client";
|
|
2
|
+
var X= (_class =class{__init() {this.listeners=new Set}constructor(e){;_class.prototype.__init.call(this);this.state=this.freezeState({filters:{...e.filters},results:{items:[],nextCursor:null},bounds:null,selection:null,hovered:null,pagination:{mode:_nullishCoalesce(e.mode, () => ("paged")),loading:!1},layers:{},points:{}})}getState(){return this.state}setFilters(e){this.setState({filters:{...this.state.filters,...e}})}setResults(e){this.setState({results:{items:[...e.items],nextCursor:e.nextCursor,total:e.total}})}appendResults(e){this.setState({results:{items:[...this.state.results.items,...e.items],nextCursor:e.nextCursor,total:e.total}})}setBounds(e){this.setState({bounds:e?{...e}:null})}setSelection(e){this.setState({selection:e})}setHovered(e){this.setState({hovered:e})}setLayerVisible(e,i){this.setState({layers:{...this.state.layers,[e]:i}})}setLoading(e){this.setState({pagination:{...this.state.pagination,loading:e}})}setPoints(e,i){this.setState({points:{...this.state.points,[e]:[...i]}})}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setState(e){this.state=this.freezeState({...this.state,...e}),this.notify()}notify(){for(let e of this.listeners)e()}freezeState(e){Object.freeze(e.filters),Object.freeze(e.results.items),Object.freeze(e.results),e.bounds&&Object.freeze(e.bounds),Object.freeze(e.pagination),Object.freeze(e.layers);for(let i of Object.values(e.points))Object.freeze(i);return Object.freeze(e.points),Object.freeze(e)}}, _class);var z= (_class2 =class{constructor() { _class2.prototype.__init2.call(this); }__init2() {this.defs=new Map}add(e){if(this.defs.has(e.key))throw new Error(`FilterRegistry: filter "${e.key}" is already registered`);return this.defs.set(e.key,{...e}),this}remove(e){return this.defs.delete(e),this}replace(e,i){if(!this.defs.has(e))throw new Error(`FilterRegistry: cannot replace unregistered filter "${e}"`);return this.defs.set(e,{...i,key:e}),this}reorder(e){let i=this.list(),r=e.filter(s=>this.defs.has(s));r.forEach((s,o)=>{this.defs.get(s).order=o});let n=new Set(r);return i.filter(s=>!n.has(s.key)).forEach((s,o)=>{s.order=r.length+o}),this}list(){return[...this.defs.values()].sort((e,i)=>e.order-i.order)}has(e){return this.defs.has(e)}toFilters(e){return this.list().filter(r=>Object.hasOwn(e,r.key)).map(r=>r.toParams(e[r.key])).reduce((r,n)=>({...r,...n}),{})}activeKeys(e){return this.list().filter(i=>_optionalChain([i, 'access', _2 => _2.isActive, 'optionalCall', _3 => _3(e)])).map(i=>i.key)}clearedParams(){return this.list().reduce((e,i)=>Object.assign(e,i.toParams(i.fromParams({}))),{})}}, _class2);var J= (_class3 =class{constructor() { _class3.prototype.__init3.call(this); }__init3() {this.defs=new Map}add(e){if(this.defs.has(e.id))throw new Error(`DatasetRegistry: dataset "${e.id}" is already registered`);return this.defs.set(e.id,{...e}),this}get(e){return this.defs.get(e)}has(e){return this.defs.has(e)}list(){return[...this.defs.values()]}visibleIds(){return this.list().filter(e=>_optionalChain([e, 'access', _4 => _4.visible, 'optionalCall', _5 => _5()])!==!1).map(e=>e.id)}}, _class3);var Y= (_class4 =class{constructor() { _class4.prototype.__init4.call(this); }__init4() {this.map=new Map}dispose(){this.map.clear()}emit(e){let i=this.map.get(e.type);if(i)for(let n of[...i])n(e);let r=this.map.get("*");if(r)for(let n of[...r])n(e)}on(e,i){let r=this.map.get(e);return r||(r=new Set,this.map.set(e,r)),r.add(i),()=>{r.delete(i)}}}, _class4);var Ie={pagination:"paged",pageSize:20,debounceMs:250};var ee=class{constructor(e){this.options=Object.freeze({...Ie,...e})}};var te= (_class5 =class{__init5() {this.emitter=new Y}__init6() {this.debounceTimer=null}__init7() {this.debounceResolve=null}__init8() {this.queryToken=0}__init9() {this.pointsToken=0}constructor(e){;_class5.prototype.__init5.call(this);_class5.prototype.__init6.call(this);_class5.prototype.__init7.call(this);_class5.prototype.__init8.call(this);_class5.prototype.__init9.call(this);this.datasets=e.datasets,this.filters=_nullishCoalesce(e.filters, () => (new z)),this.map=e.map,this.config=new ee(e.config);let i=_nullishCoalesce(e.primaryDatasetId, () => (_optionalChain([this, 'access', _6 => _6.datasets, 'access', _7 => _7.list, 'call', _8 => _8(), 'access', _9 => _9[0], 'optionalAccess', _10 => _10.id])));if(i==null||!this.datasets.has(i))throw new Error(`ListingEngine: primary dataset "${_nullishCoalesce(i, () => (""))}" is not registered \u2014 pass a valid primaryDatasetId or register at least one dataset`);this.primaryDatasetId=i,this.store=new X({filters:_nullishCoalesce(e.initialFilters, () => ({})),mode:this.config.options.pagination})}get state(){return this.store.getState()}get options(){return this.config.options}applyFilters(e){this.store.setFilters(e),this.emitter.emit({type:"FiltersChanged",filters:this.currentFilters()}),this.clearDebounce();let i=++this.queryToken,r=this.config.options.debounceMs;return r<=0?this.runQuery(i):new Promise(n=>{this.debounceResolve=n,this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.debounceResolve=null,n(this.runQuery(i))},r)})}async loadPage(){let e=this.state.results.nextCursor;if(e===null)return;let i=++this.queryToken,r=this.primaryDataset();this.store.setLoading(!0);try{let n=await r.adapter.list(this.currentFilters(),{cursor:e,limit:this.config.options.pageSize});if(i!==this.queryToken)return;this.config.options.pagination==="infinite"?this.store.appendResults(n):this.store.setResults(n),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:n.items.length})}finally{i===this.queryToken&&this.store.setLoading(!1)}}async loadPoints(e){this.store.setBounds(e),this.emitter.emit({type:"BoundsChanged",bounds:e});let i=this.currentFilters(),r=++this.pointsToken;await Promise.allSettled(this.datasets.visibleIds().map(async n=>{let s=this.datasets.get(n);if(!s)return;let o=await s.adapter.getPoints(i,e);r===this.pointsToken&&this.store.setPoints(n,o)}))}selectPoint(e,i){this.store.setSelection(i);let r=_optionalChain([this, 'access', _11 => _11.state, 'access', _12 => _12.points, 'access', _13 => _13[e], 'optionalAccess', _14 => _14.find, 'call', _15 => _15(n=>n.id===i)]);r&&this.emitter.emit({type:"PointClicked",datasetId:e,id:r.id,entity:r.entity})}setHovered(e,i){this.store.setHovered(i)}toggleLayer(e){let r=!(_nullishCoalesce(this.state.layers[e], () => (!0)));this.store.setLayerVisible(e,r),this.emitter.emit({type:"LayerToggled",datasetId:e,visible:r})}subscribe(e){return this.store.subscribe(e)}on(e,i){return this.emitter.on(e,i)}dispose(){this.clearDebounce(),this.emitter.dispose()}async runQuery(e){if(e!==this.queryToken)return;let i=this.primaryDataset();this.store.setLoading(!0);try{let r=await i.adapter.list(this.currentFilters(),{cursor:null,limit:this.config.options.pageSize});if(e!==this.queryToken)return;this.store.setResults(r),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:r.items.length})}finally{e===this.queryToken&&this.store.setLoading(!1)}}primaryDataset(){return this.datasets.get(this.primaryDatasetId)}currentFilters(){return this.store.getState().filters}clearDebounce(){this.debounceTimer!==null&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.debounceResolve!==null&&(this.debounceResolve(),this.debounceResolve=null)}}, _class5);function Ee(...t){let e={config:{},filters:new z,datasets:new J};for(let i of t)i(e);return e}var xe=t=>e=>{e.config={...e.config,...t}},Ne= exports.j =t=>e=>{e.map=t},Re= exports.k =t=>e=>{e.datasets.add(t)},Me= exports.l =t=>e=>{t(e.filters)},wi= exports.m =t=>e=>{e.urlSync=t},De= exports.n =t=>e=>{e.initialFilters=t},ki= exports.o =t=>e=>{e.primaryDatasetId=t};var _react = require('react');var _jsxruntime = require('react/jsx-runtime');function mt(t){return String(_nullishCoalesce(_optionalChain([t, 'optionalAccess', _16 => _16.title]), () => ("")))}var ft=({item:t})=>_jsxruntime.jsx.call(void 0, "div",{children:mt(t)}),gt=()=>_jsxruntime.jsx.call(void 0, "div",{}),ce= exports.p =()=>_jsxruntime.jsx.call(void 0, "div",{}),yt=({children:t})=>_jsxruntime.jsx.call(void 0, "div",{children:t}),vt=({children:t})=>_jsxruntime.jsx.call(void 0, "div",{children:t}),ht=({value:t,onChange:e,placeholder:i})=>_jsxruntime.jsx.call(void 0, "input",{type:"search",value:t,placeholder:i,onChange:r=>e(r.target.value),"aria-label":_nullishCoalesce(i, () => ("Search"))}),Lt=()=>_jsxruntime.jsx.call(void 0, "div",{role:"status",children:"No results"}),bt=()=>_jsxruntime.jsx.call(void 0, "div",{role:"status","aria-busy":"true",children:"Loading\u2026"}),Pt=({count:t})=>_jsxruntime.jsxs.call(void 0, "div",{children:[t," results"]}),Tt=({children:t})=>_jsxruntime.jsx.call(void 0, "div",{children:t}),S={Card:ft,Marker:gt,Popup:ce,Sidebar:yt,FilterPanel:vt,Search:ht,Empty:Lt,Loading:bt,ResultHeader:Pt,Toolbar:Tt},Oe=_react.createContext.call(void 0, S);function _e(t){let{Card:e,Marker:i,Popup:r,Sidebar:n,FilterPanel:s,Search:o,Empty:l,Loading:p,ResultHeader:d,Toolbar:a,children:g}=t,m={Card:_nullishCoalesce(e, () => (S.Card)),Marker:_nullishCoalesce(i, () => (S.Marker)),Popup:_nullishCoalesce(r, () => (S.Popup)),Sidebar:_nullishCoalesce(n, () => (S.Sidebar)),FilterPanel:_nullishCoalesce(s, () => (S.FilterPanel)),Search:_nullishCoalesce(o, () => (S.Search)),Empty:_nullishCoalesce(l, () => (S.Empty)),Loading:_nullishCoalesce(p, () => (S.Loading)),ResultHeader:_nullishCoalesce(d, () => (S.ResultHeader)),Toolbar:_nullishCoalesce(a, () => (S.Toolbar))};return _jsxruntime.jsx.call(void 0, Oe.Provider,{value:m,children:g})}function T(){return _react.useContext.call(void 0, Oe)}var ie=_react.createContext.call(void 0, null);function v(){let t=_react.useContext.call(void 0, ie);if(t===null)throw new Error("useListing must be used within a <ListingProvider>");return t}function F(){let t=v(),e=_react.useCallback.call(void 0, r=>t.subscribe(r),[t]),i=_react.useCallback.call(void 0, ()=>t.state,[t]);return _react.useSyncExternalStore.call(void 0, e,i,i)}function re(){let t=v(),e=F(),i=_react.useCallback.call(void 0, n=>t.applyFilters(n),[t]),r=_react.useCallback.call(void 0, (n,s)=>t.applyFilters({[n]:s}),[t]);return{filters:e.filters,set:i,setField:r}}function ue({className:t,groupClassName:e,hideLabels:i,draft:r,onDraftChange:n}={}){let s=v(),{FilterPanel:o}=T(),{filters:l}=re(),p=r!==void 0&&n!==void 0,d=p?r:l;return _jsxruntime.jsx.call(void 0, o,{children:_jsxruntime.jsx.call(void 0, "div",{className:_nullishCoalesce(t, () => ("space-y-5")),children:s.filters.list().map(a=>{if(typeof a.render=="string")return _jsxruntime.jsx.call(void 0, "div",{"data-filter":a.key,className:e},a.key);let g=a.render;return _jsxruntime.jsxs.call(void 0, "div",{className:e,children:[a.label&&!i&&_jsxruntime.jsx.call(void 0, "div",{className:"mb-1.5 text-[13px] font-medium text-foreground",children:a.label}),_jsxruntime.jsx.call(void 0, g,{value:a.fromParams(d),onChange:m=>p?n(a.toParams(m)):void s.applyFilters(a.toParams(m))})]},a.key)})})})}function U(){return F().results}function It(t,e){if(t&&typeof t=="object"&&"id"in t){let i=t.id;if(typeof i=="string"||typeof i=="number")return i}return e}function He({className:t}={}){let e=v(),{items:i}=U(),{pagination:r,selection:n}=F(),{Card:s,Empty:o,Loading:l}=T();return r.loading&&i.length===0?_jsxruntime.jsx.call(void 0, l,{}):i.length===0?_jsxruntime.jsx.call(void 0, o,{}):_jsxruntime.jsx.call(void 0, "div",{role:"list",className:t,children:i.map((p,d)=>{let a=It(p,d);return _jsxruntime.jsx.call(void 0, s,{item:p,selected:n===a,onSelect:()=>e.selectPoint(e.primaryDatasetId,a)},a)})})}var _reactdom = require('react-dom');var xt={west:-179.9,south:-85,east:179.9,north:85},Ue=.1,Ke=.02;function Nt(t){if(t.length===0)return null;let e=t[0].lng,i=t[0].lng,r=t[0].lat,n=t[0].lat;for(let{lat:l,lng:p}of t)p<e&&(e=p),p>i&&(i=p),l<r&&(r=l),l>n&&(n=l);let s=n>r?(n-r)*Ue:Ke,o=i>e?(i-e)*Ue:Ke;return{west:e-o,east:i+o,south:r-s,north:n+s}}function $e(t){let{center:e,zoom:i,fallback:r,mapControls:n}=t,s=v(),o=F(),l=_react.useRef.call(void 0, null),p=_react.useRef.call(void 0, null),d=_react.useRef.call(void 0, null),[a,g]=_react.useState.call(void 0, !1),m=_react.useRef.call(void 0, !1),D=_react.useRef.call(void 0, !1),I=_react.useRef.call(void 0, !1),c=s.map;_react.useEffect.call(void 0, ()=>{let h=d.current;if(!c||!h)return;let y=[];for(let f of Object.keys(o.points)){if(o.layers[f]===!1)continue;let L=s.datasets.get(f),w=_nullishCoalesce(o.points[f], () => ([])),H={id:f,markers:w.map(k=>({id:k.id,position:k.position,iconUrl:_optionalChain([L, 'optionalAccess', _17 => _17.marker, 'access', _18 => _18.iconUrl, 'optionalCall', _19 => _19(k.entity)]),element:_optionalChain([L, 'optionalAccess', _20 => _20.marker, 'access', _21 => _21.element, 'optionalCall', _22 => _22(k.entity)])})),clustering:_optionalChain([L, 'optionalAccess', _23 => _23.clustering]),onMarkerClick:k=>s.selectPoint(f,k)};y.push(c.renderLayer(h,H))}return()=>{y.forEach(f=>f())}},[s,c,a,o.points,o.layers]),_react.useEffect.call(void 0, ()=>{if(!l.current||!c)return;let h=l.current,y=!1,f=null;return(async()=>{let L=await c.mount(h,{center:e,zoom:i,fullscreenTarget:_nullishCoalesce(p.current, () => (void 0))});if(y){c.destroy(L);return}d.current=L,f=c.onBoundsChange(L,w=>{I.current?I.current=!1:D.current=!0,s.loadPoints(w)}),g(!0),s.loadPoints(xt)})(),()=>{y=!0,_optionalChain([f, 'optionalCall', _24 => _24()]),d.current&&(c.destroy(d.current),d.current=null),g(!1)}},[s,c]),_react.useEffect.call(void 0, ()=>{let h=d.current;if(!c||!h||e||m.current||D.current)return;let y=[];for(let L of Object.keys(o.points))if(o.layers[L]!==!1)for(let w of _nullishCoalesce(o.points[L], () => ([])))y.push(w.position);let f=Nt(y);f&&(m.current=!0,I.current=!0,c.fitBounds(h,f))},[c,e,a,o.points,o.layers]),_react.useEffect.call(void 0, ()=>{_optionalChain([c, 'optionalAccess', _25 => _25.updateMarkerStates, 'call', _26 => _26(o.selection,o.hovered)])},[c,a,o.selection,o.hovered]);let{Popup:P}=T(),O=P!==ce,x=_nullishCoalesce(o.points[s.primaryDatasetId], () => ([])),N=o.selection!=null?x.find(h=>h.id===o.selection):void 0,[$,G]=_react.useState.call(void 0, null),Z=_react.useRef.call(void 0, N);return Z.current=N,_react.useEffect.call(void 0, ()=>{let h=d.current;if(!c||!h||!O)return;let y=Z.current;if(!y)return;let f=c.mountOverlay(y.position);G({entity:y.entity,position:y.position,container:f.container});let L=()=>s.selectPoint(s.primaryDatasetId,null),w=k=>{k.key==="Escape"&&L()};document.addEventListener("keydown",w);let H=c.onMapClick(L);return()=>{document.removeEventListener("keydown",w),H(),f.unmount(),G(null)}},[s,c,a,o.selection,O]),_jsxruntime.jsxs.call(void 0, "div",{ref:p,className:"relative h-full min-h-0 w-full",children:[_jsxruntime.jsxs.call(void 0, "div",{ref:l,className:!c&&r?"flex h-full min-h-0 w-full items-center justify-center":"h-full min-h-0 w-full",children:[!c&&r,O&&$?_reactdom.createPortal.call(void 0, _jsxruntime.jsx.call(void 0, P,{entity:$.entity,onClose:()=>s.selectPoint(s.primaryDatasetId,null)}),$.container):null]}),n!=null&&_jsxruntime.jsx.call(void 0, "div",{className:"pointer-events-none absolute inset-0",children:_jsxruntime.jsx.call(void 0, "div",{className:"pointer-events-auto",children:n})})]})}function We(){let t=v(),{results:e,pagination:i}=F();return e.nextCursor==null?null:_jsxruntime.jsx.call(void 0, "button",{type:"button",disabled:i.loading,onClick:()=>{t.loadPage()},children:"Load more"})}function qe(){let{items:t,total:e}=U(),{ResultHeader:i}=T();return _jsxruntime.jsx.call(void 0, i,{count:t.length,total:e})}function je(t,e){let i=v(),r=_react.useRef.call(void 0, e);r.current=e,_react.useEffect.call(void 0, ()=>i.on(t,n=>r.current(n)),[i,t])}function Ge(t){let{children:e,...i}=t,[r]=_react.useState.call(void 0, ()=>i),[n,s]=_react.useState.call(void 0, null);return _react.useEffect.call(void 0, ()=>{let o=new te({datasets:r.datasets,filters:r.filters,config:r.config,map:r.map,initialFilters:r.initialFilters,primaryDatasetId:r.primaryDatasetId});return r.urlSync&&r.urlSync.start(o),s(o),()=>{r.urlSync&&r.urlSync.stop(),o.dispose(),s(l=>l===o?null:l)}},[r]),n?_jsxruntime.jsx.call(void 0, ie.Provider,{value:n,children:e}):null}function K(t){return typeof t!="number"?t:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t)}function At(t){return t?"rle-card rle-card--selected":"rle-card"}function fe({item:t,selected:e,onSelect:i}){let r=_nullishCoalesce(t, () => ({})),n=At(e),s=_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[r.imageUrl?_jsxruntime.jsx.call(void 0, "img",{src:r.imageUrl,alt:_nullishCoalesce(r.title, () => ("")),className:"rle-card-media"}):_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-media rle-card-media--placeholder","aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{className:"rle-card-body",children:[r.title&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-title",children:r.title}),r.subtitle&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-address",children:r.subtitle}),r.badge&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-info",children:_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-info-item",children:r.badge})}),r.price!=null&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-price",children:K(r.price)})]})]});return i?_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:i,"aria-pressed":_nullishCoalesce(e, () => (!1)),className:n,children:s}):_jsxruntime.jsx.call(void 0, "article",{className:n,children:s})}function ge(t){return _jsxruntime.jsxs.call(void 0, "div",{role:"status",className:"rle-empty",children:[_jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",className:"rle-empty-icon","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "circle",{cx:"11",cy:"11",r:"7"}),_jsxruntime.jsx.call(void 0, "path",{d:"m21 21-4.3-4.3"})]}),_jsxruntime.jsx.call(void 0, "p",{className:"rle-empty-title",children:"No results"}),_jsxruntime.jsx.call(void 0, "p",{className:"rle-empty-hint",children:"Try adjusting your filters or search terms."})]})}function ye({children:t}){return _jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-panel",children:t})}function ve(t){return _jsxruntime.jsx.call(void 0, "div",{className:"rle-loading",role:"status","aria-busy":"true","aria-label":"Loading results",children:Array.from({length:3}).map((e,i)=>_jsxruntime.jsxs.call(void 0, "div",{className:"rle-loading-item",children:[_jsxruntime.jsx.call(void 0, "div",{className:"rle-skeleton",style:{aspectRatio:"4 / 3",width:"100%"}}),_jsxruntime.jsx.call(void 0, "div",{className:"rle-skeleton",style:{height:16,width:"65%"}}),_jsxruntime.jsx.call(void 0, "div",{className:"rle-skeleton",style:{height:12,width:"35%"}})]},i))})}function he({point:t}){let e=_nullishCoalesce(t.entity, () => ({}));return _jsxruntime.jsx.call(void 0, "span",{className:"rle-pin",children:e.price!=null?K(e.price):""})}function be({entity:t,onClose:e}){let i=_nullishCoalesce(t, () => ({}));return _jsxruntime.jsxs.call(void 0, "div",{className:"rle-popup",role:"group","aria-label":"Location details",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:e,"aria-label":"Close",className:"rle-popup-close",children:_jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M18 6 6 18"}),_jsxruntime.jsx.call(void 0, "path",{d:"m6 6 12 12"})]})}),_jsxruntime.jsxs.call(void 0, "div",{children:[i.title&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-title",children:i.title}),i.subtitle&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-address",children:i.subtitle}),i.price!=null&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-price",children:K(i.price)})]})]})}function Pe({count:t,total:e}){let i=e!=null&&e!==t?`${t} of ${e} results`:`${t} results`;return _jsxruntime.jsx.call(void 0, "div",{className:"rle-result-header",children:i})}function Te({value:t,onChange:e,placeholder:i}){return _jsxruntime.jsx.call(void 0, "input",{type:"search",value:t,placeholder:i,onChange:r=>e(r.target.value),"aria-label":_nullishCoalesce(i, () => ("Search")),className:"rle-input"})}function Fe({children:t}){return _jsxruntime.jsx.call(void 0, "aside",{className:"rle-sidebar",children:t})}function Ce({children:t}){return _jsxruntime.jsx.call(void 0, "div",{className:"rle-toolbar",children:t})}var Je={Card:fe,Marker:he,Popup:be,Sidebar:Fe,FilterPanel:ye,Search:Te,Empty:ge,Loading:ve,ResultHeader:Pe,Toolbar:Ce};function Ye({view:t,onViewChange:e}){return _jsxruntime.jsx.call(void 0, "nav",{className:"rle-bottom-nav","aria-label":"Listing navigation",children:_jsxruntime.jsxs.call(void 0, "div",{className:"rle-viewtoggle",role:"group","aria-label":"View",children:[_jsxruntime.jsxs.call(void 0, "button",{type:"button",className:`rle-viewtoggle__btn${t==="list"?" rle-viewtoggle__btn--active":""}`,"aria-pressed":t==="list",onClick:()=>e("list"),children:[_jsxruntime.jsx.call(void 0, jt,{}),"List"]}),_jsxruntime.jsxs.call(void 0, "button",{type:"button",className:`rle-viewtoggle__btn${t==="map"?" rle-viewtoggle__btn--active":""}`,"aria-pressed":t==="map",onClick:()=>e("map"),children:[_jsxruntime.jsx.call(void 0, Qt,{}),"Map"]})]})})}function jt(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "line",{x1:"8",y1:"6",x2:"20",y2:"6"}),_jsxruntime.jsx.call(void 0, "line",{x1:"8",y1:"12",x2:"20",y2:"12"}),_jsxruntime.jsx.call(void 0, "line",{x1:"8",y1:"18",x2:"20",y2:"18"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"6",x2:"4.01",y2:"6"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"12",x2:"4.01",y2:"12"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"18",x2:"4.01",y2:"18"})]})}function Qt(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "polygon",{points:"1 6 8 3 16 6 23 3 23 18 16 21 8 18 1 21 1 6"}),_jsxruntime.jsx.call(void 0, "line",{x1:"8",y1:"3",x2:"8",y2:"18"}),_jsxruntime.jsx.call(void 0, "line",{x1:"16",y1:"6",x2:"16",y2:"21"})]})}function tt({open:t,onOpenChange:e,title:i,children:r,footer:n}){let s=_react.useRef.call(void 0, null),[o,l]=_react.useState.call(void 0, !1),[p,d]=_react.useState.call(void 0, !1);return _react.useEffect.call(void 0, ()=>{if(!t){d(!1),l(!1);return}l(!0);let a=requestAnimationFrame(()=>d(!0));return()=>cancelAnimationFrame(a)},[t]),_react.useEffect.call(void 0, ()=>{if(!o)return;let a=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=a}},[o]),_react.useEffect.call(void 0, ()=>{if(!o)return;_optionalChain([s, 'access', _27 => _27.current, 'optionalAccess', _28 => _28.focus, 'call', _29 => _29()]);function a(g){g.key==="Escape"&&e(!1)}return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[o,e]),!o||typeof document>"u"?null:_reactdom.createPortal.call(void 0, _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "div",{className:`rle-sheet-backdrop${p?" rle-sheet-backdrop--open":""}`,onClick:()=>e(!1),"aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{ref:s,className:`rle-sheet${p?" rle-sheet--open":""}`,role:"dialog","aria-modal":"true","aria-label":i,tabIndex:-1,children:[_jsxruntime.jsx.call(void 0, "div",{className:"rle-sheet__handle","aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{className:"rle-sheet__header",children:[i&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-sheet__title",children:i}),_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-sheet__close",onClick:()=>e(!1),"aria-label":"Close",children:_jsxruntime.jsx.call(void 0, Xt,{})})]}),_jsxruntime.jsx.call(void 0, "div",{className:"rle-sheet__body",children:r}),n&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-sheet__footer",children:n})]})]}),document.body)}function Xt(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M18 6 6 18"}),_jsxruntime.jsx.call(void 0, "path",{d:"m6 6 12 12"})]})}function it({search:t,onFiltersClick:e,filterCount:i=0,action:r}){let{Search:n}=T();return _jsxruntime.jsxs.call(void 0, "header",{className:"rle-mobile-header",children:[t&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-mobile-header__search",children:_jsxruntime.jsx.call(void 0, n,{value:t.value,onChange:t.onChange,placeholder:t.placeholder})}),_jsxruntime.jsxs.call(void 0, "button",{type:"button",className:"rle-btn rle-mobile-header__btn",onClick:e,children:[_jsxruntime.jsx.call(void 0, Yt,{}),_jsxruntime.jsx.call(void 0, "span",{children:"Filters"}),i>0&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-mobile-header__count",children:i})]}),r&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-btn rle-mobile-header__btn rle-mobile-header__btn--icon",onClick:r.onClick,"aria-label":r.label,children:_nullishCoalesce(r.icon, () => (_jsxruntime.jsx.call(void 0, ei,{})))})]})}function Yt(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"6",x2:"20",y2:"6"}),_jsxruntime.jsx.call(void 0, "circle",{cx:"9",cy:"6",r:"2",fill:"currentColor",stroke:"none"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"12",x2:"20",y2:"12"}),_jsxruntime.jsx.call(void 0, "circle",{cx:"15",cy:"12",r:"2",fill:"currentColor",stroke:"none"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"18",x2:"20",y2:"18"}),_jsxruntime.jsx.call(void 0, "circle",{cx:"11",cy:"18",r:"2",fill:"currentColor",stroke:"none"})]})}function ei(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "line",{x1:"12",y1:"5",x2:"12",y2:"19"}),_jsxruntime.jsx.call(void 0, "line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}var ti=_jsxruntime.jsx.call(void 0, "div",{className:"rle-empty",children:"Map unavailable"});function ii(){let t=_react.useRef.call(void 0, null),[e,i]=_react.useState.call(void 0, !0),[r,n]=_react.useState.call(void 0, !0);return _react.useEffect.call(void 0, ()=>{let s=t.current;if(!s)return;let o=()=>{let{clientWidth:g,scrollLeft:m,scrollWidth:D}=s;i(m<=0),n(m+g>=D-1)},l=0,p=()=>{l||(l=requestAnimationFrame(()=>{l=0,o()}))};o(),s.addEventListener("scroll",o,{passive:!0});let d,a;return typeof ResizeObserver<"u"&&(d=new ResizeObserver(o),d.observe(s)),typeof MutationObserver<"u"&&(a=new MutationObserver(p),a.observe(s,{characterData:!0,childList:!0,subtree:!0})),()=>{s.removeEventListener("scroll",o),_optionalChain([d, 'optionalAccess', _30 => _30.disconnect, 'call', _31 => _31()]),_optionalChain([a, 'optionalAccess', _32 => _32.disconnect, 'call', _33 => _33()]),l&&cancelAnimationFrame(l)}},[]),{atEnd:r,atStart:e,ref:t}}function ri(t,e){if(t===e)return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;let i=t,r=e,n=new Set([...Object.keys(i),...Object.keys(r)]);for(let s of n)if(i[s]!==r[s])return!1;return!0}function nt({search:t,toolbarEnd:e,mobileAction:i,autoFetch:r=!0,hasMap:n,mapCenter:s,mapZoom:o,mapControls:l,className:p}){let d=v(),{Search:a}=T(),g=U(),{filters:m,set:D}=re(),{pagination:I}=F(),c=_nullishCoalesce(n, () => (d.map!=null)),[P,O]=_react.useState.call(void 0, "list"),[x,N]=_react.useState.call(void 0, !1),{atEnd:$,atStart:G,ref:Z}=ii(),[h,y]=_react.useState.call(void 0, m),[f,L]=_react.useState.call(void 0, x);x!==f&&(L(x),x&&y(m));let w=pe=>y(pt=>({...pt,...pe})),[H,k]=_react.useState.call(void 0, !1),de=_react.useRef.call(void 0, !1);_react.useEffect.call(void 0, ()=>{if(H){if(I.loading){de.current=!0;return}de.current&&(de.current=!1,k(!1),N(!1))}},[H,I.loading]);let W=t?{value:String(_nullishCoalesce(m[t.filterKey], () => (""))),onChange:pe=>{D({[t.filterKey]:pe||void 0})},placeholder:t.placeholder}:void 0;_react.useEffect.call(void 0, ()=>{r!==!1&&d.applyFilters({})},[d,r]);let ot=()=>{w(d.filters.clearedParams())},at=()=>{if(ri(h,m)){N(!1);return}k(!0),d.applyFilters(h)},lt=d.filters.activeKeys(m).length,dt=_nullishCoalesce(g.total, () => (g.items.length));return _jsxruntime.jsxs.call(void 0, "div",{className:p?`rle-app ${p}`:"rle-app",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"rle-filter-bar",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"rle-filter-bar__scroll",ref:Z,children:[W&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__search",children:_jsxruntime.jsx.call(void 0, a,{value:W.value,onChange:W.onChange,placeholder:W.placeholder})}),_jsxruntime.jsx.call(void 0, ue,{className:"rle-filters-row",groupClassName:"rle-filter-group",hideLabels:!0})]}),!G&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__fade rle-filter-bar__fade--start","aria-hidden":"true"}),!$&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__fade rle-filter-bar__fade--end","aria-hidden":"true"})]}),_jsxruntime.jsx.call(void 0, it,{search:W,onFiltersClick:()=>N(!0),filterCount:lt,action:i}),_jsxruntime.jsxs.call(void 0, "div",{className:`rle-body ${c?"rle-split":"rle-body--list-only"}`,"data-mobile-view":P,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"rle-list",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"rle-list-header",children:[_jsxruntime.jsx.call(void 0, qe,{}),e&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-list-header__toolbar",children:e})]}),_jsxruntime.jsx.call(void 0, He,{className:"rle-list-grid"}),_jsxruntime.jsx.call(void 0, We,{})]}),c&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-map",children:_jsxruntime.jsx.call(void 0, $e,{center:s,zoom:o,fallback:ti,mapControls:l})})]}),c&&_jsxruntime.jsx.call(void 0, Ye,{view:P,onViewChange:O}),_jsxruntime.jsx.call(void 0, tt,{title:"Filters",open:x,onOpenChange:N,footer:_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-btn rle-btn--ghost",onClick:ot,children:"Clear all"}),_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-btn rle-btn--primary rle-sheet__apply",disabled:I.loading,onClick:at,children:I.loading?_jsxruntime.jsx.call(void 0, "span",{className:"rle-spinner","aria-label":"Updating results"}):`Show ${dt} results`})]}),children:_jsxruntime.jsx.call(void 0, ue,{className:"rle-filter-stack",groupClassName:"rle-filter-group",draft:h,onDraftChange:w})})]})}function st(t){return"provider"in t}function li(t){let e=t!=null&&!st(t),i=e?t.apiKey:void 0,r=e?t.mapId:void 0,n=e?t.mapOptions:void 0,s=e?t.styles:void 0,[o,l]=_react.useState.call(void 0, ()=>!t||st(t)?{ready:!0,provider:_optionalChain([t, 'optionalAccess', _34 => _34.provider])}:{ready:!1});return _react.useEffect.call(void 0, ()=>{if(!i)return;let p=!1;return Promise.resolve().then(() => _interopRequireWildcard(require("./maps/google/index.cjs"))).then(({googleProvider:d})=>{p||l({ready:!0,provider:d({apiKey:i,mapId:r,mapOptions:n,styles:s})})}),()=>{p=!0}},[i,r]),o}function di({onFiltersChange:t}){let e=_react.useRef.call(void 0, t);return e.current=t,je("FiltersChanged",i=>{i.type==="FiltersChanged"&&e.current(i.filters)}),null}function xn(t){let{datasets:e,filters:i,map:r,components:n,initialFilters:s,onFiltersChange:o,mobileAction:l,search:p,toolbarEnd:d,mapControls:a,config:g,autoFetch:m,className:D}=t,{ready:I,provider:c}=li(r);if(!I)return null;let P=[];for(let N of e)P.push(Re(N));i&&P.push(Me(i)),c&&P.push(Ne(c)),s&&P.push(De(s)),g&&P.push(xe(g));let O=Ee(...P),x={...Je,...n};return _jsxruntime.jsxs.call(void 0, Ge,{...O,children:[o&&_jsxruntime.jsx.call(void 0, di,{onFiltersChange:o}),_jsxruntime.jsx.call(void 0, _e,{...x,children:_jsxruntime.jsx.call(void 0, nt,{className:D,search:p,toolbarEnd:d,mobileAction:l,autoFetch:m,mapCenter:_optionalChain([r, 'optionalAccess', _35 => _35.center]),mapZoom:_optionalChain([r, 'optionalAccess', _36 => _36.zoom]),mapControls:a})})]})}exports.a = X; exports.b = z; exports.c = J; exports.d = Y; exports.e = Ie; exports.f = ee; exports.g = te; exports.h = Ee; exports.i = xe; exports.j = Ne; exports.k = Re; exports.l = Me; exports.m = wi; exports.n = De; exports.o = ki; exports.p = ce; exports.q = _e; exports.r = T; exports.s = ie; exports.t = v; exports.u = F; exports.v = re; exports.w = ue; exports.x = U; exports.y = He; exports.z = $e; exports.A = We; exports.B = qe; exports.C = je; exports.D = Ge; exports.E = fe; exports.F = ge; exports.G = ye; exports.H = ve; exports.I = he; exports.J = be; exports.K = Pe; exports.L = Te; exports.M = Fe; exports.N = Ce; exports.O = Je; exports.P = Ye; exports.Q = tt; exports.R = nt; exports.S = xn;
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2;"use client";
|
|
2
|
-
var
|
|
2
|
+
var _chunkSR7UMK4Ucjs = require('./chunk-SR7UMK4U.cjs');var P=(r=>(r.Paged="paged",r.Infinite="infinite",r))(P||{});var v=(i=>(i.FiltersChanged="FiltersChanged",i.ResultsLoaded="ResultsLoaded",i.PointClicked="PointClicked",i.BoundsChanged="BoundsChanged",i.LayerToggled="LayerToggled",i))(v||{});var d= (_class =class{__init() {this.listeners=new Set}constructor(t={}){;_class.prototype.__init.call(this);this.query={...t}}getQuery(){return{...this.query}}setQuery(t){this.query={...t},this.notify()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}notify(){for(let t of[...this.listeners])t()}}, _class);function b(e,t){let r=new Set([...Object.keys(e),...Object.keys(t)]);for(let s of r)if(e[s]!==t[s])return!1;return!0}var h= (_class2 =class{__init2() {this.isSyncing=!1}__init3() {this.unsubscribeEngine=null}__init4() {this.unsubscribeHistory=null}constructor(t){;_class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);this.history=t.history,this.toQueryFn=t.toQuery,this.toFiltersFn=t.toFilters,this.hydrateOnStart=_nullishCoalesce(t.hydrateOnStart, () => (!0))}start(t){this.stop(),this.unsubscribeEngine=t.subscribe(()=>{this.isSyncing||this.syncEngineToHistory(t)}),this.unsubscribeHistory=this.history.subscribe(()=>{this.isSyncing||this.withSyncGuard(()=>{this.applyFiltersSafely(t,this.toFiltersFn(this.history.getQuery()))})}),this.hydrateOnStart&&this.withSyncGuard(()=>{this.applyFiltersSafely(t,this.toFiltersFn(this.history.getQuery()))})}stop(){_optionalChain([this, 'access', _ => _.unsubscribeEngine, 'optionalCall', _2 => _2()]),this.unsubscribeEngine=null,_optionalChain([this, 'access', _3 => _3.unsubscribeHistory, 'optionalCall', _4 => _4()]),this.unsubscribeHistory=null}syncEngineToHistory(t){let r=this.toQueryFn(t.state.filters);b(r,this.history.getQuery())||this.withSyncGuard(()=>this.history.setQuery(r))}applyFiltersSafely(t,r){Promise.resolve(t.applyFilters(r)).catch(()=>{})}withSyncGuard(t){this.isSyncing=!0;try{t()}finally{this.isSyncing=!1}}}, _class2);var m=class{constructor(t={}){this.mode=_nullishCoalesce(t.mode, () => ("replace"))}getQuery(){if(typeof window>"u")return{};let t=new URLSearchParams(window.location.search),r={};for(let[s,o]of t)o!==""&&(r[s]=o);return r}setQuery(t){if(typeof window>"u")return;let r=new URLSearchParams;for(let[c,a]of Object.entries(t))a===void 0||a===""||r.set(c,a);let s=r.toString(),o=s?`?${s}`:"";if(o===window.location.search)return;let i=`${window.location.pathname}${o}${window.location.hash}`;this.mode==="push"?window.history.pushState(window.history.state,"",i):window.history.replaceState(window.history.state,"",i)}subscribe(t){return typeof window>"u"?()=>{}:(window.addEventListener("popstate",t),()=>{window.removeEventListener("popstate",t)})}};var _jsxruntime = require('react/jsx-runtime');function rt({children:e}){let{Toolbar:t}=_chunkSR7UMK4Ucjs.r.call(void 0, );return _jsxruntime.jsx.call(void 0, t,{children:e})}var _react = require('react');function lt(){let e=_chunkSR7UMK4Ucjs.t.call(void 0, ),t=_chunkSR7UMK4Ucjs.u.call(void 0, ),r=_react.useCallback.call(void 0, l=>e.loadPoints(l),[e]),s=_react.useCallback.call(void 0, (l,f)=>e.selectPoint(l,f),[e]),o=_react.useCallback.call(void 0, l=>e.setHovered(e.primaryDatasetId,l),[e]),i=_react.useCallback.call(void 0, ()=>_optionalChain([e, 'access', _5 => _5.map, 'optionalAccess', _6 => _6.zoomIn, 'call', _7 => _7()]),[e]),c=_react.useCallback.call(void 0, ()=>_optionalChain([e, 'access', _8 => _8.map, 'optionalAccess', _9 => _9.zoomOut, 'call', _10 => _10()]),[e]),a=_react.useCallback.call(void 0, ()=>_optionalChain([e, 'access', _11 => _11.map, 'optionalAccess', _12 => _12.toggleFullscreen, 'call', _13 => _13()]),[e]);return{bounds:t.bounds,points:t.points,hovered:t.hovered,loadPoints:r,selectPoint:s,setHovered:o,zoomIn:i,zoomOut:c,toggleFullscreen:a}}function dt(e){let t=_chunkSR7UMK4Ucjs.t.call(void 0, ),r=_chunkSR7UMK4Ucjs.u.call(void 0, ),s=_react.useCallback.call(void 0, ()=>t.toggleLayer(e),[t,e]);return{visible:_nullishCoalesce(r.layers[e], () => (!0)),points:_nullishCoalesce(r.points[e], () => ([])),toggle:s}}exports.BrowserHistoryPort = m; exports.DatasetRegistry = _chunkSR7UMK4Ucjs.c; exports.FallbackPopup = _chunkSR7UMK4Ucjs.p; exports.FilterRegistry = _chunkSR7UMK4Ucjs.b; exports.ListingApp = _chunkSR7UMK4Ucjs.S; exports.ListingComponentsProvider = _chunkSR7UMK4Ucjs.q; exports.ListingConfig = _chunkSR7UMK4Ucjs.f; exports.ListingEngine = _chunkSR7UMK4Ucjs.g; exports.ListingEngineContext = _chunkSR7UMK4Ucjs.s; exports.ListingEventType = v; exports.ListingFilters = _chunkSR7UMK4Ucjs.w; exports.ListingList = _chunkSR7UMK4Ucjs.y; exports.ListingMap = _chunkSR7UMK4Ucjs.z; exports.ListingPagination = _chunkSR7UMK4Ucjs.A; exports.ListingProvider = _chunkSR7UMK4Ucjs.D; exports.ListingResultHeader = _chunkSR7UMK4Ucjs.B; exports.ListingStore = _chunkSR7UMK4Ucjs.a; exports.ListingToolbar = rt; exports.MemoryHistoryPort = d; exports.PaginationMode = P; exports.TypedEmitter = _chunkSR7UMK4Ucjs.d; exports.UrlSyncController = h; exports.composeListingProviders = _chunkSR7UMK4Ucjs.h; exports.listingDefaultConfig = _chunkSR7UMK4Ucjs.e; exports.useListing = _chunkSR7UMK4Ucjs.t; exports.useListingComponents = _chunkSR7UMK4Ucjs.r; exports.useListingEvent = _chunkSR7UMK4Ucjs.C; exports.useListingFilters = _chunkSR7UMK4Ucjs.v; exports.useListingLayer = dt; exports.useListingMap = lt; exports.useListingResults = _chunkSR7UMK4Ucjs.x; exports.useListingState = _chunkSR7UMK4Ucjs.u; exports.withConfig = _chunkSR7UMK4Ucjs.i; exports.withDataset = _chunkSR7UMK4Ucjs.k; exports.withFilters = _chunkSR7UMK4Ucjs.l; exports.withInitialFilters = _chunkSR7UMK4Ucjs.n; exports.withMap = _chunkSR7UMK4Ucjs.j; exports.withPrimaryDataset = _chunkSR7UMK4Ucjs.o; exports.withUrlSync = _chunkSR7UMK4Ucjs.m;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { P as Page, B as Bounds, E as EntityId, M as MapPoint, U as Unsubscribe, a as MapProvider, Q as QueryParams, L as LatLng } from './map-provider.interface-B5Law7gE.cjs';
|
|
2
2
|
export { b as EntityAdapter, c as MapHandle, d as MapInitOptions, e as MapOverlayHandle, f as PageRequest, R as RenderedLayer } from './map-provider.interface-B5Law7gE.cjs';
|
|
3
|
-
import { P as PaginationMode, D as DatasetDefinition, I as IListingConfigOptions, F as FilterRegistry, a as IListingToolbarProps } from './listing-app-
|
|
4
|
-
export { C as ClusterOptions, b as FallbackPopup, c as FilterControlProps, d as FilterDefinition, e as IListingCardProps, f as IListingComponents, g as IListingEmptyProps, h as IListingFilterPanelProps, i as IListingLoadingProps, j as IListingMarkerProps, k as IListingPopupProps, l as IListingResultHeaderProps, m as IListingSearchProps, n as IListingSidebarProps, L as ListingApp, o as ListingAppProps, p as ListingComponentsProvider, M as MarkerRenderer, u as useListingComponents } from './listing-app-
|
|
3
|
+
import { P as PaginationMode, D as DatasetDefinition, I as IListingConfigOptions, F as FilterRegistry, a as IListingToolbarProps } from './listing-app-S7zz1ovr.cjs';
|
|
4
|
+
export { C as ClusterOptions, b as FallbackPopup, c as FilterControlProps, d as FilterDefinition, e as IListingCardProps, f as IListingComponents, g as IListingEmptyProps, h as IListingFilterPanelProps, i as IListingLoadingProps, j as IListingMarkerProps, k as IListingPopupProps, l as IListingResultHeaderProps, m as IListingSearchProps, n as IListingSidebarProps, L as ListingApp, o as ListingAppProps, p as ListingComponentsProvider, M as MarkerRenderer, u as useListingComponents } from './listing-app-S7zz1ovr.cjs';
|
|
5
5
|
import * as react from 'react';
|
|
6
6
|
import { ReactNode } from 'react';
|
|
7
7
|
|
|
@@ -376,7 +376,7 @@ declare class BrowserHistoryPort implements HistoryPort {
|
|
|
376
376
|
subscribe(cb: () => void): () => void;
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
-
interface IListingFiltersProps {
|
|
379
|
+
interface IListingFiltersProps<TFilters = unknown> {
|
|
380
380
|
/**
|
|
381
381
|
* ClassName for the container wrapping every filter group. Purely a
|
|
382
382
|
* styling hook -- this component stays structure-only, so it never bakes
|
|
@@ -394,6 +394,24 @@ interface IListingFiltersProps {
|
|
|
394
394
|
* leave off (labels shown) for a stacked form layout like the mobile sheet.
|
|
395
395
|
*/
|
|
396
396
|
hideLabels?: boolean;
|
|
397
|
+
/**
|
|
398
|
+
* Deferred/draft mode: supply alongside `onDraftChange` to have every
|
|
399
|
+
* control read its value from `def.fromParams(draft)` instead of the
|
|
400
|
+
* engine's live applied filters, and route `onChange` through
|
|
401
|
+
* `onDraftChange` instead of `engine.applyFilters`. Nothing reaches the
|
|
402
|
+
* engine until the caller applies its own accumulated draft (e.g. the
|
|
403
|
+
* mobile sheet's "Show N results" button committing it via
|
|
404
|
+
* `engine.applyFilters(draft)`).
|
|
405
|
+
*
|
|
406
|
+
* Both `draft` and `onDraftChange` must be supplied together to enable
|
|
407
|
+
* deferred mode -- either one alone falls back to the original LIVE
|
|
408
|
+
* behavior (default, used by the desktop filter bar): each control reads
|
|
409
|
+
* `engine.filters`/live applied state and applies straight to the engine
|
|
410
|
+
* on change.
|
|
411
|
+
*/
|
|
412
|
+
draft?: TFilters;
|
|
413
|
+
/** Paired with `draft` to enable deferred mode -- see `draft`'s doc. */
|
|
414
|
+
onDraftChange?: (params: Partial<TFilters>) => void;
|
|
397
415
|
}
|
|
398
416
|
/**
|
|
399
417
|
* Structure-only filter panel: one control per `engine.filters.list()` entry,
|
|
@@ -422,8 +440,14 @@ interface IListingFiltersProps {
|
|
|
422
440
|
* behavior). Passing a horizontal `className` does NOT change the
|
|
423
441
|
* label-above-control structure within each group -- only how the groups
|
|
424
442
|
* themselves are laid out relative to each other.
|
|
443
|
+
*
|
|
444
|
+
* `draft`/`onDraftChange` (both required together) switch every control from
|
|
445
|
+
* LIVE (read/write straight through `engine.filters`/`applyFilters`) to
|
|
446
|
+
* DEFERRED (read/write through the caller's own draft state) -- see
|
|
447
|
+
* `IListingFiltersProps.draft`'s doc. Omitted (the default), this component's
|
|
448
|
+
* behavior is unchanged from before either prop existed.
|
|
425
449
|
*/
|
|
426
|
-
declare function ListingFilters({ className, groupClassName, hideLabels }?: IListingFiltersProps): react.JSX.Element;
|
|
450
|
+
declare function ListingFilters<TFilters = unknown>({ className, groupClassName, hideLabels, draft, onDraftChange, }?: IListingFiltersProps<TFilters>): react.JSX.Element;
|
|
427
451
|
|
|
428
452
|
/**
|
|
429
453
|
* Structure-only results list. Renders the injected `Loading` while the
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { P as Page, B as Bounds, E as EntityId, M as MapPoint, U as Unsubscribe, a as MapProvider, Q as QueryParams, L as LatLng } from './map-provider.interface-B5Law7gE.js';
|
|
2
2
|
export { b as EntityAdapter, c as MapHandle, d as MapInitOptions, e as MapOverlayHandle, f as PageRequest, R as RenderedLayer } from './map-provider.interface-B5Law7gE.js';
|
|
3
|
-
import { P as PaginationMode, D as DatasetDefinition, I as IListingConfigOptions, F as FilterRegistry, a as IListingToolbarProps } from './listing-app-
|
|
4
|
-
export { C as ClusterOptions, b as FallbackPopup, c as FilterControlProps, d as FilterDefinition, e as IListingCardProps, f as IListingComponents, g as IListingEmptyProps, h as IListingFilterPanelProps, i as IListingLoadingProps, j as IListingMarkerProps, k as IListingPopupProps, l as IListingResultHeaderProps, m as IListingSearchProps, n as IListingSidebarProps, L as ListingApp, o as ListingAppProps, p as ListingComponentsProvider, M as MarkerRenderer, u as useListingComponents } from './listing-app-
|
|
3
|
+
import { P as PaginationMode, D as DatasetDefinition, I as IListingConfigOptions, F as FilterRegistry, a as IListingToolbarProps } from './listing-app-CKWKPJrW.js';
|
|
4
|
+
export { C as ClusterOptions, b as FallbackPopup, c as FilterControlProps, d as FilterDefinition, e as IListingCardProps, f as IListingComponents, g as IListingEmptyProps, h as IListingFilterPanelProps, i as IListingLoadingProps, j as IListingMarkerProps, k as IListingPopupProps, l as IListingResultHeaderProps, m as IListingSearchProps, n as IListingSidebarProps, L as ListingApp, o as ListingAppProps, p as ListingComponentsProvider, M as MarkerRenderer, u as useListingComponents } from './listing-app-CKWKPJrW.js';
|
|
5
5
|
import * as react from 'react';
|
|
6
6
|
import { ReactNode } from 'react';
|
|
7
7
|
|
|
@@ -376,7 +376,7 @@ declare class BrowserHistoryPort implements HistoryPort {
|
|
|
376
376
|
subscribe(cb: () => void): () => void;
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
-
interface IListingFiltersProps {
|
|
379
|
+
interface IListingFiltersProps<TFilters = unknown> {
|
|
380
380
|
/**
|
|
381
381
|
* ClassName for the container wrapping every filter group. Purely a
|
|
382
382
|
* styling hook -- this component stays structure-only, so it never bakes
|
|
@@ -394,6 +394,24 @@ interface IListingFiltersProps {
|
|
|
394
394
|
* leave off (labels shown) for a stacked form layout like the mobile sheet.
|
|
395
395
|
*/
|
|
396
396
|
hideLabels?: boolean;
|
|
397
|
+
/**
|
|
398
|
+
* Deferred/draft mode: supply alongside `onDraftChange` to have every
|
|
399
|
+
* control read its value from `def.fromParams(draft)` instead of the
|
|
400
|
+
* engine's live applied filters, and route `onChange` through
|
|
401
|
+
* `onDraftChange` instead of `engine.applyFilters`. Nothing reaches the
|
|
402
|
+
* engine until the caller applies its own accumulated draft (e.g. the
|
|
403
|
+
* mobile sheet's "Show N results" button committing it via
|
|
404
|
+
* `engine.applyFilters(draft)`).
|
|
405
|
+
*
|
|
406
|
+
* Both `draft` and `onDraftChange` must be supplied together to enable
|
|
407
|
+
* deferred mode -- either one alone falls back to the original LIVE
|
|
408
|
+
* behavior (default, used by the desktop filter bar): each control reads
|
|
409
|
+
* `engine.filters`/live applied state and applies straight to the engine
|
|
410
|
+
* on change.
|
|
411
|
+
*/
|
|
412
|
+
draft?: TFilters;
|
|
413
|
+
/** Paired with `draft` to enable deferred mode -- see `draft`'s doc. */
|
|
414
|
+
onDraftChange?: (params: Partial<TFilters>) => void;
|
|
397
415
|
}
|
|
398
416
|
/**
|
|
399
417
|
* Structure-only filter panel: one control per `engine.filters.list()` entry,
|
|
@@ -422,8 +440,14 @@ interface IListingFiltersProps {
|
|
|
422
440
|
* behavior). Passing a horizontal `className` does NOT change the
|
|
423
441
|
* label-above-control structure within each group -- only how the groups
|
|
424
442
|
* themselves are laid out relative to each other.
|
|
443
|
+
*
|
|
444
|
+
* `draft`/`onDraftChange` (both required together) switch every control from
|
|
445
|
+
* LIVE (read/write straight through `engine.filters`/`applyFilters`) to
|
|
446
|
+
* DEFERRED (read/write through the caller's own draft state) -- see
|
|
447
|
+
* `IListingFiltersProps.draft`'s doc. Omitted (the default), this component's
|
|
448
|
+
* behavior is unchanged from before either prop existed.
|
|
425
449
|
*/
|
|
426
|
-
declare function ListingFilters({ className, groupClassName, hideLabels }?: IListingFiltersProps): react.JSX.Element;
|
|
450
|
+
declare function ListingFilters<TFilters = unknown>({ className, groupClassName, hideLabels, draft, onDraftChange, }?: IListingFiltersProps<TFilters>): react.JSX.Element;
|
|
427
451
|
|
|
428
452
|
/**
|
|
429
453
|
* Structure-only results list. Renders the injected `Loading` while the
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{A as N,B as V,C as W,D as X,S as g,a as S,b as Q,c as x,d as T,e as L,f as H,g as O,h as E,i as k,j as q,k as I,l as C,m as U,n as B,o as z,p as G,q as R,r as p,s as $,t as u,u as y,v as j,w as A,x as D,y as J,z as K}from"./chunk-
|
|
2
|
+
import{A as N,B as V,C as W,D as X,S as g,a as S,b as Q,c as x,d as T,e as L,f as H,g as O,h as E,i as k,j as q,k as I,l as C,m as U,n as B,o as z,p as G,q as R,r as p,s as $,t as u,u as y,v as j,w as A,x as D,y as J,z as K}from"./chunk-PG33Q2EN.js";var P=(r=>(r.Paged="paged",r.Infinite="infinite",r))(P||{});var v=(i=>(i.FiltersChanged="FiltersChanged",i.ResultsLoaded="ResultsLoaded",i.PointClicked="PointClicked",i.BoundsChanged="BoundsChanged",i.LayerToggled="LayerToggled",i))(v||{});var d=class{query;listeners=new Set;constructor(t={}){this.query={...t}}getQuery(){return{...this.query}}setQuery(t){this.query={...t},this.notify()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}notify(){for(let t of[...this.listeners])t()}};function b(e,t){let r=new Set([...Object.keys(e),...Object.keys(t)]);for(let s of r)if(e[s]!==t[s])return!1;return!0}var h=class{history;toQueryFn;toFiltersFn;hydrateOnStart;isSyncing=!1;unsubscribeEngine=null;unsubscribeHistory=null;constructor(t){this.history=t.history,this.toQueryFn=t.toQuery,this.toFiltersFn=t.toFilters,this.hydrateOnStart=t.hydrateOnStart??!0}start(t){this.stop(),this.unsubscribeEngine=t.subscribe(()=>{this.isSyncing||this.syncEngineToHistory(t)}),this.unsubscribeHistory=this.history.subscribe(()=>{this.isSyncing||this.withSyncGuard(()=>{this.applyFiltersSafely(t,this.toFiltersFn(this.history.getQuery()))})}),this.hydrateOnStart&&this.withSyncGuard(()=>{this.applyFiltersSafely(t,this.toFiltersFn(this.history.getQuery()))})}stop(){this.unsubscribeEngine?.(),this.unsubscribeEngine=null,this.unsubscribeHistory?.(),this.unsubscribeHistory=null}syncEngineToHistory(t){let r=this.toQueryFn(t.state.filters);b(r,this.history.getQuery())||this.withSyncGuard(()=>this.history.setQuery(r))}applyFiltersSafely(t,r){Promise.resolve(t.applyFilters(r)).catch(()=>{})}withSyncGuard(t){this.isSyncing=!0;try{t()}finally{this.isSyncing=!1}}};var m=class{mode;constructor(t={}){this.mode=t.mode??"replace"}getQuery(){if(typeof window>"u")return{};let t=new URLSearchParams(window.location.search),r={};for(let[s,o]of t)o!==""&&(r[s]=o);return r}setQuery(t){if(typeof window>"u")return;let r=new URLSearchParams;for(let[c,a]of Object.entries(t))a===void 0||a===""||r.set(c,a);let s=r.toString(),o=s?`?${s}`:"";if(o===window.location.search)return;let i=`${window.location.pathname}${o}${window.location.hash}`;this.mode==="push"?window.history.pushState(window.history.state,"",i):window.history.replaceState(window.history.state,"",i)}subscribe(t){return typeof window>"u"?()=>{}:(window.addEventListener("popstate",t),()=>{window.removeEventListener("popstate",t)})}};import{jsx as F}from"react/jsx-runtime";function rt({children:e}){let{Toolbar:t}=p();return F(t,{children:e})}import{useCallback as n}from"react";function lt(){let e=u(),t=y(),r=n(l=>e.loadPoints(l),[e]),s=n((l,f)=>e.selectPoint(l,f),[e]),o=n(l=>e.setHovered(e.primaryDatasetId,l),[e]),i=n(()=>e.map?.zoomIn(),[e]),c=n(()=>e.map?.zoomOut(),[e]),a=n(()=>e.map?.toggleFullscreen(),[e]);return{bounds:t.bounds,points:t.points,hovered:t.hovered,loadPoints:r,selectPoint:s,setHovered:o,zoomIn:i,zoomOut:c,toggleFullscreen:a}}import{useCallback as w}from"react";function dt(e){let t=u(),r=y(),s=w(()=>t.toggleLayer(e),[t,e]);return{visible:r.layers[e]??!0,points:r.points[e]??[],toggle:s}}export{m as BrowserHistoryPort,x as DatasetRegistry,G as FallbackPopup,Q as FilterRegistry,g as ListingApp,R as ListingComponentsProvider,H as ListingConfig,O as ListingEngine,$ as ListingEngineContext,v as ListingEventType,A as ListingFilters,J as ListingList,K as ListingMap,N as ListingPagination,X as ListingProvider,V as ListingResultHeader,S as ListingStore,rt as ListingToolbar,d as MemoryHistoryPort,P as PaginationMode,T as TypedEmitter,h as UrlSyncController,E as composeListingProviders,L as listingDefaultConfig,u as useListing,p as useListingComponents,W as useListingEvent,j as useListingFilters,dt as useListingLayer,lt as useListingMap,D as useListingResults,y as useListingState,k as withConfig,I as withDataset,C as withFilters,B as withInitialFilters,q as withMap,z as withPrimaryDataset,U as withUrlSync};
|
|
@@ -228,12 +228,27 @@ interface IStyledListingLayoutProps {
|
|
|
228
228
|
* the same `mobileView` state as the CSS toggle. Omitted when there is no
|
|
229
229
|
* map (nothing to toggle to).
|
|
230
230
|
* - `<BottomSheet title="Filters">`: the SAME `<ListingFilters>` component,
|
|
231
|
-
* stacked vertically (`className="rle-filter-stack"`)
|
|
232
|
-
*
|
|
231
|
+
* stacked vertically (`className="rle-filter-stack"`), but in DEFERRED mode
|
|
232
|
+
* (`draft`/`onDraftChange` -- see that component's doc): every control edit
|
|
233
|
+
* inside the sheet buffers into local `draft` state instead of applying to
|
|
234
|
+
* the engine, so the list/map behind the sheet never move while it's open.
|
|
235
|
+
* `draft` is re-synced from the currently applied filters each time the
|
|
236
|
+
* sheet transitions closed -> open (a render-phase adjustment, not an
|
|
237
|
+
* effect). The footer has "Clear all" (resets the DRAFT via
|
|
233
238
|
* `engine.filters.clearedParams()` -- see that method's doc for why a reset
|
|
234
|
-
* round-trips each def's to/fromParams
|
|
235
|
-
*
|
|
236
|
-
*
|
|
239
|
+
* round-trips each def's to/fromParams -- NOT applied until committed) and
|
|
240
|
+
* "Show N results", which commits: `engine.applyFilters(draft)`, then
|
|
241
|
+
* closes the sheet once the resulting refetch settles (or immediately, with
|
|
242
|
+
* no refetch at all, if the draft is unchanged from what's already
|
|
243
|
+
* applied -- see `handleApplyDraft`). While a commit's refetch (or any
|
|
244
|
+
* OTHER live refetch, e.g. the desktop bar or search box, which still apply
|
|
245
|
+
* immediately) is in flight -- `pagination.loading` (`useListingState()`) is
|
|
246
|
+
* true -- the apply button is `disabled` and its label swaps for a
|
|
247
|
+
* `.rle-spinner`, so the sheet reads as "updating" instead of letting the
|
|
248
|
+
* user close onto a stale count. `.rle-sheet__apply` pins a `min-width` so
|
|
249
|
+
* that swap never changes the button's footprint. The result count itself
|
|
250
|
+
* (`Show N results`) always reflects the currently APPLIED results, not a
|
|
251
|
+
* live preview of the draft -- it only changes once a commit lands.
|
|
237
252
|
* - Fetches the first page itself on mount (`engine.applyFilters({})`) by
|
|
238
253
|
* default -- pass `autoFetch={false}`
|
|
239
254
|
* to opt out and drive the first fetch yourself.
|
|
@@ -228,12 +228,27 @@ interface IStyledListingLayoutProps {
|
|
|
228
228
|
* the same `mobileView` state as the CSS toggle. Omitted when there is no
|
|
229
229
|
* map (nothing to toggle to).
|
|
230
230
|
* - `<BottomSheet title="Filters">`: the SAME `<ListingFilters>` component,
|
|
231
|
-
* stacked vertically (`className="rle-filter-stack"`)
|
|
232
|
-
*
|
|
231
|
+
* stacked vertically (`className="rle-filter-stack"`), but in DEFERRED mode
|
|
232
|
+
* (`draft`/`onDraftChange` -- see that component's doc): every control edit
|
|
233
|
+
* inside the sheet buffers into local `draft` state instead of applying to
|
|
234
|
+
* the engine, so the list/map behind the sheet never move while it's open.
|
|
235
|
+
* `draft` is re-synced from the currently applied filters each time the
|
|
236
|
+
* sheet transitions closed -> open (a render-phase adjustment, not an
|
|
237
|
+
* effect). The footer has "Clear all" (resets the DRAFT via
|
|
233
238
|
* `engine.filters.clearedParams()` -- see that method's doc for why a reset
|
|
234
|
-
* round-trips each def's to/fromParams
|
|
235
|
-
*
|
|
236
|
-
*
|
|
239
|
+
* round-trips each def's to/fromParams -- NOT applied until committed) and
|
|
240
|
+
* "Show N results", which commits: `engine.applyFilters(draft)`, then
|
|
241
|
+
* closes the sheet once the resulting refetch settles (or immediately, with
|
|
242
|
+
* no refetch at all, if the draft is unchanged from what's already
|
|
243
|
+
* applied -- see `handleApplyDraft`). While a commit's refetch (or any
|
|
244
|
+
* OTHER live refetch, e.g. the desktop bar or search box, which still apply
|
|
245
|
+
* immediately) is in flight -- `pagination.loading` (`useListingState()`) is
|
|
246
|
+
* true -- the apply button is `disabled` and its label swaps for a
|
|
247
|
+
* `.rle-spinner`, so the sheet reads as "updating" instead of letting the
|
|
248
|
+
* user close onto a stale count. `.rle-sheet__apply` pins a `min-width` so
|
|
249
|
+
* that swap never changes the button's footprint. The result count itself
|
|
250
|
+
* (`Show N results`) always reflects the currently APPLIED results, not a
|
|
251
|
+
* live preview of the draft -- it only changes once a commit lands.
|
|
237
252
|
* - Fetches the first page itself on mount (`engine.applyFilters({})`) by
|
|
238
253
|
* default -- pass `autoFetch={false}`
|
|
239
254
|
* to opt out and drive the first fetch yourself.
|
package/dist/styled/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
|
-
var
|
|
2
|
+
var _chunkSR7UMK4Ucjs = require('../chunk-SR7UMK4U.cjs');var _jsxruntime = require('react/jsx-runtime');function L({children:o}){return _jsxruntime.jsx.call(void 0, _chunkSR7UMK4Ucjs.q,{..._chunkSR7UMK4Ucjs.O,children:o})}exports.BottomNav = _chunkSR7UMK4Ucjs.P; exports.BottomSheet = _chunkSR7UMK4Ucjs.Q; exports.ListingApp = _chunkSR7UMK4Ucjs.S; exports.StyledCard = _chunkSR7UMK4Ucjs.E; exports.StyledComponentsProviderWithDefaults = L; exports.StyledEmpty = _chunkSR7UMK4Ucjs.F; exports.StyledFilterPanel = _chunkSR7UMK4Ucjs.G; exports.StyledListingLayout = _chunkSR7UMK4Ucjs.R; exports.StyledLoading = _chunkSR7UMK4Ucjs.H; exports.StyledMarker = _chunkSR7UMK4Ucjs.I; exports.StyledPopup = _chunkSR7UMK4Ucjs.J; exports.StyledResultHeader = _chunkSR7UMK4Ucjs.K; exports.StyledSearch = _chunkSR7UMK4Ucjs.L; exports.StyledSidebar = _chunkSR7UMK4Ucjs.M; exports.StyledToolbar = _chunkSR7UMK4Ucjs.N; exports.styledDefaultComponents = _chunkSR7UMK4Ucjs.O;
|
package/dist/styled/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { e as IListingCardProps, g as IListingEmptyProps, h as IListingFilterPanelProps, i as IListingLoadingProps, j as IListingMarkerProps, k as IListingPopupProps, l as IListingResultHeaderProps, m as IListingSearchProps, n as IListingSidebarProps, a as IListingToolbarProps, f as IListingComponents } from '../listing-app-
|
|
4
|
-
export { B as BottomNav, q as BottomNavView, r as IBottomNavAction, s as IBottomNavProps, t as IStyledListingLayoutProps, L as ListingApp, v as ListingAppMapProp, o as ListingAppProps, S as StyledListingLayout } from '../listing-app-
|
|
3
|
+
import { e as IListingCardProps, g as IListingEmptyProps, h as IListingFilterPanelProps, i as IListingLoadingProps, j as IListingMarkerProps, k as IListingPopupProps, l as IListingResultHeaderProps, m as IListingSearchProps, n as IListingSidebarProps, a as IListingToolbarProps, f as IListingComponents } from '../listing-app-S7zz1ovr.cjs';
|
|
4
|
+
export { B as BottomNav, q as BottomNavView, r as IBottomNavAction, s as IBottomNavProps, t as IStyledListingLayoutProps, L as ListingApp, v as ListingAppMapProp, o as ListingAppProps, S as StyledListingLayout } from '../listing-app-S7zz1ovr.cjs';
|
|
5
5
|
import '../map-provider.interface-B5Law7gE.cjs';
|
|
6
6
|
|
|
7
7
|
/**
|
package/dist/styled/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { e as IListingCardProps, g as IListingEmptyProps, h as IListingFilterPanelProps, i as IListingLoadingProps, j as IListingMarkerProps, k as IListingPopupProps, l as IListingResultHeaderProps, m as IListingSearchProps, n as IListingSidebarProps, a as IListingToolbarProps, f as IListingComponents } from '../listing-app-
|
|
4
|
-
export { B as BottomNav, q as BottomNavView, r as IBottomNavAction, s as IBottomNavProps, t as IStyledListingLayoutProps, L as ListingApp, v as ListingAppMapProp, o as ListingAppProps, S as StyledListingLayout } from '../listing-app-
|
|
3
|
+
import { e as IListingCardProps, g as IListingEmptyProps, h as IListingFilterPanelProps, i as IListingLoadingProps, j as IListingMarkerProps, k as IListingPopupProps, l as IListingResultHeaderProps, m as IListingSearchProps, n as IListingSidebarProps, a as IListingToolbarProps, f as IListingComponents } from '../listing-app-CKWKPJrW.js';
|
|
4
|
+
export { B as BottomNav, q as BottomNavView, r as IBottomNavAction, s as IBottomNavProps, t as IStyledListingLayoutProps, L as ListingApp, v as ListingAppMapProp, o as ListingAppProps, S as StyledListingLayout } from '../listing-app-CKWKPJrW.js';
|
|
5
5
|
import '../map-provider.interface-B5Law7gE.js';
|
|
6
6
|
|
|
7
7
|
/**
|
package/dist/styled/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{E as r,F as p,G as i,H as d,I as y,J as l,K as n,L as m,M as s,N as a,O as t,P as S,Q as f,R as P,S as u,q as e}from"../chunk-
|
|
2
|
+
import{E as r,F as p,G as i,H as d,I as y,J as l,K as n,L as m,M as s,N as a,O as t,P as S,Q as f,R as P,S as u,q as e}from"../chunk-PG33Q2EN.js";import{jsx as g}from"react/jsx-runtime";function L({children:o}){return g(e,{...t,children:o})}export{S as BottomNav,f as BottomSheet,u as ListingApp,r as StyledCard,L as StyledComponentsProviderWithDefaults,p as StyledEmpty,i as StyledFilterPanel,P as StyledListingLayout,d as StyledLoading,y as StyledMarker,l as StyledPopup,n as StyledResultHeader,m as StyledSearch,s as StyledSidebar,a as StyledToolbar,t as styledDefaultComponents};
|
package/dist/styles.css
CHANGED
|
@@ -362,6 +362,31 @@
|
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
364
|
|
|
365
|
+
/* Small inline spinner for in-flight async state on a button (e.g. the mobile
|
|
366
|
+
filters sheet's apply button while a filter-triggered refetch is loading).
|
|
367
|
+
`currentColor` borders so it inherits whatever text color the host button
|
|
368
|
+
already sets (e.g. `--rle-primary-contrast` on `.rle-btn--primary`); the
|
|
369
|
+
transparent top edge is what reads as a moving notch once it spins. Covered
|
|
370
|
+
by the blanket `prefers-reduced-motion` rule at the end of this file (every
|
|
371
|
+
`rle-`-prefixed class has its `animation` dropped there), so it degrades to
|
|
372
|
+
a static ring rather than a separate opt-out here. */
|
|
373
|
+
.rle-spinner {
|
|
374
|
+
display: inline-block;
|
|
375
|
+
width: 16px;
|
|
376
|
+
height: 16px;
|
|
377
|
+
border: 2px solid currentColor;
|
|
378
|
+
border-top-color: transparent;
|
|
379
|
+
border-radius: 50%;
|
|
380
|
+
opacity: 0.85;
|
|
381
|
+
animation: rle-spin 0.75s linear infinite;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
@keyframes rle-spin {
|
|
385
|
+
to {
|
|
386
|
+
transform: rotate(360deg);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
365
390
|
.rle-result-header {
|
|
366
391
|
font-size: var(--rle-fs-md);
|
|
367
392
|
color: var(--rle-muted);
|
|
@@ -1015,6 +1040,12 @@
|
|
|
1015
1040
|
border-top: 1px solid var(--rle-border);
|
|
1016
1041
|
}
|
|
1017
1042
|
|
|
1043
|
+
/* Pinned so swapping "Show N results" for `.rle-spinner` while
|
|
1044
|
+
`pagination.loading` is true never collapses/reflows the button. */
|
|
1045
|
+
.rle-sheet__apply {
|
|
1046
|
+
min-width: 9.5rem;
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1018
1049
|
/* -----------------------------------------------------------------------
|
|
1019
1050
|
* Motion -- LAST on purpose: prefix-scoped like the base reset (every
|
|
1020
1051
|
* `rle-` element goes still, so a new component with a transition can't be
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-listing-engine",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Headless, composable listing engine for React: filterable list + Google-Maps multi-layer map, with pluggable data adapters, a filter/dataset registry, injectable components, and a Tailwind-free styled adapter.",
|
|
6
6
|
"funding": [
|
package/dist/chunk-TX6KIOD7.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
var Q=class{state;listeners=new Set;constructor(e){this.state=this.freezeState({filters:{...e.filters},results:{items:[],nextCursor:null},bounds:null,selection:null,hovered:null,pagination:{mode:e.mode??"paged",loading:!1},layers:{},points:{}})}getState(){return this.state}setFilters(e){this.setState({filters:{...this.state.filters,...e}})}setResults(e){this.setState({results:{items:[...e.items],nextCursor:e.nextCursor,total:e.total}})}appendResults(e){this.setState({results:{items:[...this.state.results.items,...e.items],nextCursor:e.nextCursor,total:e.total}})}setBounds(e){this.setState({bounds:e?{...e}:null})}setSelection(e){this.setState({selection:e})}setHovered(e){this.setState({hovered:e})}setLayerVisible(e,i){this.setState({layers:{...this.state.layers,[e]:i}})}setLoading(e){this.setState({pagination:{...this.state.pagination,loading:e}})}setPoints(e,i){this.setState({points:{...this.state.points,[e]:[...i]}})}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setState(e){this.state=this.freezeState({...this.state,...e}),this.notify()}notify(){for(let e of this.listeners)e()}freezeState(e){Object.freeze(e.filters),Object.freeze(e.results.items),Object.freeze(e.results),e.bounds&&Object.freeze(e.bounds),Object.freeze(e.pagination),Object.freeze(e.layers);for(let i of Object.values(e.points))Object.freeze(i);return Object.freeze(e.points),Object.freeze(e)}};var H=class{defs=new Map;add(e){if(this.defs.has(e.key))throw new Error(`FilterRegistry: filter "${e.key}" is already registered`);return this.defs.set(e.key,{...e}),this}remove(e){return this.defs.delete(e),this}replace(e,i){if(!this.defs.has(e))throw new Error(`FilterRegistry: cannot replace unregistered filter "${e}"`);return this.defs.set(e,{...i,key:e}),this}reorder(e){let i=this.list(),r=e.filter(o=>this.defs.has(o));r.forEach((o,n)=>{this.defs.get(o).order=n});let s=new Set(r);return i.filter(o=>!s.has(o.key)).forEach((o,n)=>{o.order=r.length+n}),this}list(){return[...this.defs.values()].sort((e,i)=>e.order-i.order)}has(e){return this.defs.has(e)}toFilters(e){return this.list().filter(r=>Object.hasOwn(e,r.key)).map(r=>r.toParams(e[r.key])).reduce((r,s)=>({...r,...s}),{})}activeKeys(e){return this.list().filter(i=>i.isActive?.(e)).map(i=>i.key)}clearedParams(){return this.list().reduce((e,i)=>Object.assign(e,i.toParams(i.fromParams({}))),{})}};var G=class{defs=new Map;add(e){if(this.defs.has(e.id))throw new Error(`DatasetRegistry: dataset "${e.id}" is already registered`);return this.defs.set(e.id,{...e}),this}get(e){return this.defs.get(e)}has(e){return this.defs.has(e)}list(){return[...this.defs.values()]}visibleIds(){return this.list().filter(e=>e.visible?.()!==!1).map(e=>e.id)}};var Z=class{map=new Map;dispose(){this.map.clear()}emit(e){let i=this.map.get(e.type);if(i)for(let s of[...i])s(e);let r=this.map.get("*");if(r)for(let s of[...r])s(e)}on(e,i){let r=this.map.get(e);return r||(r=new Set,this.map.set(e,r)),r.add(i),()=>{r.delete(i)}}};var Ce={pagination:"paged",pageSize:20,debounceMs:250};var X=class{options;constructor(e){this.options=Object.freeze({...Ce,...e})}};var J=class{filters;map;datasets;primaryDatasetId;store;emitter=new Z;config;debounceTimer=null;debounceResolve=null;queryToken=0;pointsToken=0;constructor(e){this.datasets=e.datasets,this.filters=e.filters??new H,this.map=e.map,this.config=new X(e.config);let i=e.primaryDatasetId??this.datasets.list()[0]?.id;if(i==null||!this.datasets.has(i))throw new Error(`ListingEngine: primary dataset "${i??""}" is not registered \u2014 pass a valid primaryDatasetId or register at least one dataset`);this.primaryDatasetId=i,this.store=new Q({filters:e.initialFilters??{},mode:this.config.options.pagination})}get state(){return this.store.getState()}get options(){return this.config.options}applyFilters(e){this.store.setFilters(e),this.emitter.emit({type:"FiltersChanged",filters:this.currentFilters()}),this.clearDebounce();let i=++this.queryToken,r=this.config.options.debounceMs;return r<=0?this.runQuery(i):new Promise(s=>{this.debounceResolve=s,this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.debounceResolve=null,s(this.runQuery(i))},r)})}async loadPage(){let e=this.state.results.nextCursor;if(e===null)return;let i=++this.queryToken,r=this.primaryDataset();this.store.setLoading(!0);try{let s=await r.adapter.list(this.currentFilters(),{cursor:e,limit:this.config.options.pageSize});if(i!==this.queryToken)return;this.config.options.pagination==="infinite"?this.store.appendResults(s):this.store.setResults(s),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:s.items.length})}finally{i===this.queryToken&&this.store.setLoading(!1)}}async loadPoints(e){this.store.setBounds(e),this.emitter.emit({type:"BoundsChanged",bounds:e});let i=this.currentFilters(),r=++this.pointsToken;await Promise.allSettled(this.datasets.visibleIds().map(async s=>{let o=this.datasets.get(s);if(!o)return;let n=await o.adapter.getPoints(i,e);r===this.pointsToken&&this.store.setPoints(s,n)}))}selectPoint(e,i){this.store.setSelection(i);let r=this.state.points[e]?.find(s=>s.id===i);r&&this.emitter.emit({type:"PointClicked",datasetId:e,id:r.id,entity:r.entity})}setHovered(e,i){this.store.setHovered(i)}toggleLayer(e){let r=!(this.state.layers[e]??!0);this.store.setLayerVisible(e,r),this.emitter.emit({type:"LayerToggled",datasetId:e,visible:r})}subscribe(e){return this.store.subscribe(e)}on(e,i){return this.emitter.on(e,i)}dispose(){this.clearDebounce(),this.emitter.dispose()}async runQuery(e){if(e!==this.queryToken)return;let i=this.primaryDataset();this.store.setLoading(!0);try{let r=await i.adapter.list(this.currentFilters(),{cursor:null,limit:this.config.options.pageSize});if(e!==this.queryToken)return;this.store.setResults(r),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:r.items.length})}finally{e===this.queryToken&&this.store.setLoading(!1)}}primaryDataset(){return this.datasets.get(this.primaryDatasetId)}currentFilters(){return this.store.getState().filters}clearDebounce(){this.debounceTimer!==null&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.debounceResolve!==null&&(this.debounceResolve(),this.debounceResolve=null)}};function Se(...t){let e={config:{},filters:new H,datasets:new G};for(let i of t)i(e);return e}var Ie=t=>e=>{e.config={...e.config,...t}},we=t=>e=>{e.map=t},ke=t=>e=>{e.datasets.add(t)},Ee=t=>e=>{t(e.filters)},yi=t=>e=>{e.urlSync=t},xe=t=>e=>{e.initialFilters=t},vi=t=>e=>{e.primaryDatasetId=t};import{createContext as it,useContext as rt}from"react";import{jsx as S,jsxs as gt}from"react/jsx-runtime";function nt(t){return String(t?.title??"")}var st=({item:t})=>S("div",{children:nt(t)}),ot=()=>S("div",{}),le=()=>S("div",{}),at=({children:t})=>S("div",{children:t}),lt=({children:t})=>S("div",{children:t}),dt=({value:t,onChange:e,placeholder:i})=>S("input",{type:"search",value:t,placeholder:i,onChange:r=>e(r.target.value),"aria-label":i??"Search"}),pt=()=>S("div",{role:"status",children:"No results"}),ct=()=>S("div",{role:"status","aria-busy":"true",children:"Loading\u2026"}),ut=({count:t})=>gt("div",{children:[t," results"]}),mt=({children:t})=>S("div",{children:t}),C={Card:st,Marker:ot,Popup:le,Sidebar:at,FilterPanel:lt,Search:dt,Empty:pt,Loading:ct,ResultHeader:ut,Toolbar:mt},Ne=it(C);function Re(t){let{Card:e,Marker:i,Popup:r,Sidebar:s,FilterPanel:o,Search:n,Empty:a,Loading:d,ResultHeader:l,Toolbar:c,children:h}=t,b={Card:e??C.Card,Marker:i??C.Marker,Popup:r??C.Popup,Sidebar:s??C.Sidebar,FilterPanel:o??C.FilterPanel,Search:n??C.Search,Empty:a??C.Empty,Loading:d??C.Loading,ResultHeader:l??C.ResultHeader,Toolbar:c??C.Toolbar};return S(Ne.Provider,{value:b,children:h})}function P(){return rt(Ne)}import{createContext as ft}from"react";var Y=ft(null);import{useContext as yt}from"react";function g(){let t=yt(Y);if(t===null)throw new Error("useListing must be used within a <ListingProvider>");return t}import{useCallback as Me,useSyncExternalStore as vt}from"react";function I(){let t=g(),e=Me(r=>t.subscribe(r),[t]),i=Me(()=>t.state,[t]);return vt(e,i,i)}import{useCallback as De}from"react";function ee(){let t=g(),e=I(),i=De(s=>t.applyFilters(s),[t]),r=De((s,o)=>t.applyFilters({[s]:o}),[t]);return{filters:e.filters,set:i,setField:r}}import{jsx as $,jsxs as ht}from"react/jsx-runtime";function de({className:t,groupClassName:e,hideLabels:i}={}){let r=g(),{FilterPanel:s}=P(),{filters:o}=ee();return $(s,{children:$("div",{className:t??"space-y-5",children:r.filters.list().map(n=>{if(typeof n.render=="string")return $("div",{"data-filter":n.key,className:e},n.key);let a=n.render;return ht("div",{className:e,children:[n.label&&!i&&$("div",{className:"mb-1.5 text-[13px] font-medium text-foreground",children:n.label}),$(a,{value:n.fromParams(o),onChange:d=>{r.applyFilters(n.toParams(d))}})]},n.key)})})})}function z(){return I().results}import{jsx as te}from"react/jsx-runtime";function Lt(t,e){if(t&&typeof t=="object"&&"id"in t){let i=t.id;if(typeof i=="string"||typeof i=="number")return i}return e}function Oe({className:t}={}){let e=g(),{items:i}=z(),{pagination:r,selection:s}=I(),{Card:o,Empty:n,Loading:a}=P();return r.loading&&i.length===0?te(a,{}):i.length===0?te(n,{}):te("div",{role:"list",className:t,children:i.map((d,l)=>{let c=Lt(d,l);return te(o,{item:d,selected:s===c,onSelect:()=>e.selectPoint(e.primaryDatasetId,c)},c)})})}import{useEffect as W,useRef as B,useState as _e}from"react";import{createPortal as bt}from"react-dom";import{jsx as pe,jsxs as He}from"react/jsx-runtime";var Pt={west:-179.9,south:-85,east:179.9,north:85},Be=.1,Ae=.02;function Tt(t){if(t.length===0)return null;let e=t[0].lng,i=t[0].lng,r=t[0].lat,s=t[0].lat;for(let{lat:a,lng:d}of t)d<e&&(e=d),d>i&&(i=d),a<r&&(r=a),a>s&&(s=a);let o=s>r?(s-r)*Be:Ae,n=i>e?(i-e)*Be:Ae;return{west:e-n,east:i+n,south:r-o,north:s+o}}function ze(t){let{center:e,zoom:i,fallback:r,mapControls:s}=t,o=g(),n=I(),a=B(null),d=B(null),l=B(null),[c,h]=_e(!1),b=B(!1),w=B(!1),k=B(!1),p=o.map;W(()=>{let L=l.current;if(!p||!L)return;let f=[];for(let u of Object.keys(n.points)){if(n.layers[u]===!1)continue;let y=o.datasets.get(u),R=n.points[u]??[],ae={id:u,markers:R.map(M=>({id:M.id,position:M.position,iconUrl:y?.marker.iconUrl?.(M.entity),element:y?.marker.element?.(M.entity)})),clustering:y?.clustering,onMarkerClick:M=>o.selectPoint(u,M)};f.push(p.renderLayer(L,ae))}return()=>{f.forEach(u=>u())}},[o,p,c,n.points,n.layers]),W(()=>{if(!a.current||!p)return;let L=a.current,f=!1,u=null;return(async()=>{let y=await p.mount(L,{center:e,zoom:i,fullscreenTarget:d.current??void 0});if(f){p.destroy(y);return}l.current=y,u=p.onBoundsChange(y,R=>{k.current?k.current=!1:w.current=!0,o.loadPoints(R)}),h(!0),o.loadPoints(Pt)})(),()=>{f=!0,u?.(),l.current&&(p.destroy(l.current),l.current=null),h(!1)}},[o,p]),W(()=>{let L=l.current;if(!p||!L||e||b.current||w.current)return;let f=[];for(let y of Object.keys(n.points))if(n.layers[y]!==!1)for(let R of n.points[y]??[])f.push(R.position);let u=Tt(f);u&&(b.current=!0,k.current=!0,p.fitBounds(L,u))},[p,e,c,n.points,n.layers]),W(()=>{p?.updateMarkerStates(n.selection,n.hovered)},[p,c,n.selection,n.hovered]);let{Popup:F}=P(),O=F!==le,_=n.points[o.primaryDatasetId]??[],A=n.selection!=null?_.find(L=>L.id===n.selection):void 0,[V,j]=_e(null),N=B(A);return N.current=A,W(()=>{let L=l.current;if(!p||!L||!O)return;let f=N.current;if(!f)return;let u=p.mountOverlay(f.position);j({entity:f.entity,position:f.position,container:u.container});let y=()=>o.selectPoint(o.primaryDatasetId,null),R=M=>{M.key==="Escape"&&y()};document.addEventListener("keydown",R);let ae=p.onMapClick(y);return()=>{document.removeEventListener("keydown",R),ae(),u.unmount(),j(null)}},[o,p,c,n.selection,O]),He("div",{ref:d,className:"relative h-full min-h-0 w-full",children:[He("div",{ref:a,className:!p&&r?"flex h-full min-h-0 w-full items-center justify-center":"h-full min-h-0 w-full",children:[!p&&r,O&&V?bt(pe(F,{entity:V.entity,onClose:()=>o.selectPoint(o.primaryDatasetId,null)}),V.container):null]}),s!=null&&pe("div",{className:"pointer-events-none absolute inset-0",children:pe("div",{className:"pointer-events-auto",children:s})})]})}import{jsx as Ft}from"react/jsx-runtime";function Ke(){let t=g(),{results:e,pagination:i}=I();return e.nextCursor==null?null:Ft("button",{type:"button",disabled:i.loading,onClick:()=>{t.loadPage()},children:"Load more"})}import{jsx as Ct}from"react/jsx-runtime";function Ue(){let{items:t,total:e}=z(),{ResultHeader:i}=P();return Ct(i,{count:t.length,total:e})}import{useEffect as St,useRef as It}from"react";function Ve(t,e){let i=g(),r=It(e);r.current=e,St(()=>i.on(t,s=>r.current(s)),[i,t])}import{useEffect as wt,useState as $e}from"react";import{jsx as kt}from"react/jsx-runtime";function We(t){let{children:e,...i}=t,[r]=$e(()=>i),[s,o]=$e(null);return wt(()=>{let n=new J({datasets:r.datasets,filters:r.filters,config:r.config,map:r.map,initialFilters:r.initialFilters,primaryDatasetId:r.primaryDatasetId});return r.urlSync&&r.urlSync.start(n),o(n),()=>{r.urlSync&&r.urlSync.stop(),n.dispose(),o(a=>a===n?null:a)}},[r]),s?kt(Y.Provider,{value:s,children:e}):null}function K(t){return typeof t!="number"?t:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t)}import{Fragment as xt,jsx as E,jsxs as qe}from"react/jsx-runtime";function Et(t){return t?"rle-card rle-card--selected":"rle-card"}function ce({item:t,selected:e,onSelect:i}){let r=t??{},s=Et(e),o=qe(xt,{children:[r.imageUrl?E("img",{src:r.imageUrl,alt:r.title??"",className:"rle-card-media"}):E("div",{className:"rle-card-media rle-card-media--placeholder","aria-hidden":"true"}),qe("div",{className:"rle-card-body",children:[r.title&&E("span",{className:"rle-card-title",children:r.title}),r.subtitle&&E("span",{className:"rle-card-address",children:r.subtitle}),r.badge&&E("div",{className:"rle-card-info",children:E("span",{className:"rle-card-info-item",children:r.badge})}),r.price!=null&&E("span",{className:"rle-card-price",children:K(r.price)})]})]});return i?E("button",{type:"button",onClick:i,"aria-pressed":e??!1,className:s,children:o}):E("article",{className:s,children:o})}import{jsx as ie,jsxs as je}from"react/jsx-runtime";function ue(t){return je("div",{role:"status",className:"rle-empty",children:[je("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",className:"rle-empty-icon","aria-hidden":"true",children:[ie("circle",{cx:"11",cy:"11",r:"7"}),ie("path",{d:"m21 21-4.3-4.3"})]}),ie("p",{className:"rle-empty-title",children:"No results"}),ie("p",{className:"rle-empty-hint",children:"Try adjusting your filters or search terms."})]})}import{jsx as Nt}from"react/jsx-runtime";function me({children:t}){return Nt("div",{className:"rle-filter-panel",children:t})}import{jsx as re,jsxs as Rt}from"react/jsx-runtime";function ge(t){return re("div",{className:"rle-loading",role:"status","aria-busy":"true","aria-label":"Loading results",children:Array.from({length:3}).map((e,i)=>Rt("div",{className:"rle-loading-item",children:[re("div",{className:"rle-skeleton",style:{aspectRatio:"4 / 3",width:"100%"}}),re("div",{className:"rle-skeleton",style:{height:16,width:"65%"}}),re("div",{className:"rle-skeleton",style:{height:12,width:"35%"}})]},i))})}import{jsx as Mt}from"react/jsx-runtime";function fe({point:t}){let e=t.entity??{};return Mt("span",{className:"rle-pin",children:e.price!=null?K(e.price):""})}import{jsx as U,jsxs as ye}from"react/jsx-runtime";function ve({entity:t,onClose:e}){let i=t??{};return ye("div",{className:"rle-popup",role:"group","aria-label":"Location details",children:[U("button",{type:"button",onClick:e,"aria-label":"Close",className:"rle-popup-close",children:ye("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[U("path",{d:"M18 6 6 18"}),U("path",{d:"m6 6 12 12"})]})}),ye("div",{children:[i.title&&U("div",{className:"rle-card-title",children:i.title}),i.subtitle&&U("div",{className:"rle-card-address",children:i.subtitle}),i.price!=null&&U("div",{className:"rle-card-price",children:K(i.price)})]})]})}import{jsx as Dt}from"react/jsx-runtime";function he({count:t,total:e}){let i=e!=null&&e!==t?`${t} of ${e} results`:`${t} results`;return Dt("div",{className:"rle-result-header",children:i})}import{jsx as Ot}from"react/jsx-runtime";function Le({value:t,onChange:e,placeholder:i}){return Ot("input",{type:"search",value:t,placeholder:i,onChange:r=>e(r.target.value),"aria-label":i??"Search",className:"rle-input"})}import{jsx as _t}from"react/jsx-runtime";function be({children:t}){return _t("aside",{className:"rle-sidebar",children:t})}import{jsx as Bt}from"react/jsx-runtime";function Pe({children:t}){return Bt("div",{className:"rle-toolbar",children:t})}var Qe={Card:ce,Marker:fe,Popup:ve,Sidebar:be,FilterPanel:me,Search:Le,Empty:ue,Loading:ge,ResultHeader:he,Toolbar:Pe};import{jsx as T,jsxs as q}from"react/jsx-runtime";function Ge({view:t,onViewChange:e}){return T("nav",{className:"rle-bottom-nav","aria-label":"Listing navigation",children:q("div",{className:"rle-viewtoggle",role:"group","aria-label":"View",children:[q("button",{type:"button",className:`rle-viewtoggle__btn${t==="list"?" rle-viewtoggle__btn--active":""}`,"aria-pressed":t==="list",onClick:()=>e("list"),children:[T(At,{}),"List"]}),q("button",{type:"button",className:`rle-viewtoggle__btn${t==="map"?" rle-viewtoggle__btn--active":""}`,"aria-pressed":t==="map",onClick:()=>e("map"),children:[T(Ht,{}),"Map"]})]})})}function At(){return q("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[T("line",{x1:"8",y1:"6",x2:"20",y2:"6"}),T("line",{x1:"8",y1:"12",x2:"20",y2:"12"}),T("line",{x1:"8",y1:"18",x2:"20",y2:"18"}),T("line",{x1:"4",y1:"6",x2:"4.01",y2:"6"}),T("line",{x1:"4",y1:"12",x2:"4.01",y2:"12"}),T("line",{x1:"4",y1:"18",x2:"4.01",y2:"18"})]})}function Ht(){return q("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[T("polygon",{points:"1 6 8 3 16 6 23 3 23 18 16 21 8 18 1 21 1 6"}),T("line",{x1:"8",y1:"3",x2:"8",y2:"18"}),T("line",{x1:"16",y1:"6",x2:"16",y2:"21"})]})}import{useEffect as Te,useRef as zt,useState as Ze}from"react";import{createPortal as Kt}from"react-dom";import{Fragment as Vt,jsx as x,jsxs as ne}from"react/jsx-runtime";function Xe({open:t,onOpenChange:e,title:i,children:r,footer:s}){let o=zt(null),[n,a]=Ze(!1),[d,l]=Ze(!1);return Te(()=>{if(!t){l(!1),a(!1);return}a(!0);let c=requestAnimationFrame(()=>l(!0));return()=>cancelAnimationFrame(c)},[t]),Te(()=>{if(!n)return;let c=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=c}},[n]),Te(()=>{if(!n)return;o.current?.focus();function c(h){h.key==="Escape"&&e(!1)}return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[n,e]),!n||typeof document>"u"?null:Kt(ne(Vt,{children:[x("div",{className:`rle-sheet-backdrop${d?" rle-sheet-backdrop--open":""}`,onClick:()=>e(!1),"aria-hidden":"true"}),ne("div",{ref:o,className:`rle-sheet${d?" rle-sheet--open":""}`,role:"dialog","aria-modal":"true","aria-label":i,tabIndex:-1,children:[x("div",{className:"rle-sheet__handle","aria-hidden":"true"}),ne("div",{className:"rle-sheet__header",children:[i&&x("div",{className:"rle-sheet__title",children:i}),x("button",{type:"button",className:"rle-sheet__close",onClick:()=>e(!1),"aria-label":"Close",children:x(Ut,{})})]}),x("div",{className:"rle-sheet__body",children:r}),s&&x("div",{className:"rle-sheet__footer",children:s})]})]}),document.body)}function Ut(){return ne("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[x("path",{d:"M18 6 6 18"}),x("path",{d:"m6 6 12 12"})]})}import{useEffect as Ye,useRef as qt,useState as oe}from"react";import{jsx as v,jsxs as se}from"react/jsx-runtime";function Je({search:t,onFiltersClick:e,filterCount:i=0,action:r}){let{Search:s}=P();return se("header",{className:"rle-mobile-header",children:[t&&v("div",{className:"rle-mobile-header__search",children:v(s,{value:t.value,onChange:t.onChange,placeholder:t.placeholder})}),se("button",{type:"button",className:"rle-btn rle-mobile-header__btn",onClick:e,children:[v($t,{}),v("span",{children:"Filters"}),i>0&&v("span",{className:"rle-mobile-header__count",children:i})]}),r&&v("button",{type:"button",className:"rle-btn rle-mobile-header__btn rle-mobile-header__btn--icon",onClick:r.onClick,"aria-label":r.label,children:r.icon??v(Wt,{})})]})}function $t(){return se("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[v("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),v("circle",{cx:"9",cy:"6",r:"2",fill:"currentColor",stroke:"none"}),v("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),v("circle",{cx:"15",cy:"12",r:"2",fill:"currentColor",stroke:"none"}),v("line",{x1:"4",y1:"18",x2:"20",y2:"18"}),v("circle",{cx:"11",cy:"18",r:"2",fill:"currentColor",stroke:"none"})]})}function Wt(){return se("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[v("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),v("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}import{Fragment as Gt,jsx as m,jsxs as D}from"react/jsx-runtime";var jt=m("div",{className:"rle-empty",children:"Map unavailable"});function Qt(){let t=qt(null),[e,i]=oe(!0),[r,s]=oe(!0);return Ye(()=>{let o=t.current;if(!o)return;let n=()=>{let{clientWidth:h,scrollLeft:b,scrollWidth:w}=o;i(b<=0),s(b+h>=w-1)},a=0,d=()=>{a||(a=requestAnimationFrame(()=>{a=0,n()}))};n(),o.addEventListener("scroll",n,{passive:!0});let l,c;return typeof ResizeObserver<"u"&&(l=new ResizeObserver(n),l.observe(o)),typeof MutationObserver<"u"&&(c=new MutationObserver(d),c.observe(o,{characterData:!0,childList:!0,subtree:!0})),()=>{o.removeEventListener("scroll",n),l?.disconnect(),c?.disconnect(),a&&cancelAnimationFrame(a)}},[]),{atEnd:r,atStart:e,ref:t}}function et({search:t,toolbarEnd:e,mobileAction:i,autoFetch:r=!0,hasMap:s,mapCenter:o,mapZoom:n,mapControls:a,className:d}){let l=g(),{Search:c}=P(),h=z(),{filters:b,set:w}=ee(),k=s??l.map!=null,[p,F]=oe("list"),[O,_]=oe(!1),{atEnd:A,atStart:V,ref:j}=Qt(),N=t?{value:String(b[t.filterKey]??""),onChange:y=>{w({[t.filterKey]:y||void 0})},placeholder:t.placeholder}:void 0;Ye(()=>{r!==!1&&l.applyFilters({})},[l,r]);let L=()=>{w(l.filters.clearedParams())},f=l.filters.activeKeys(b).length,u=h.total??h.items.length;return D("div",{className:d?`rle-app ${d}`:"rle-app",children:[D("div",{className:"rle-filter-bar",children:[D("div",{className:"rle-filter-bar__scroll",ref:j,children:[N&&m("div",{className:"rle-filter-bar__search",children:m(c,{value:N.value,onChange:N.onChange,placeholder:N.placeholder})}),m(de,{className:"rle-filters-row",groupClassName:"rle-filter-group",hideLabels:!0})]}),!V&&m("div",{className:"rle-filter-bar__fade rle-filter-bar__fade--start","aria-hidden":"true"}),!A&&m("div",{className:"rle-filter-bar__fade rle-filter-bar__fade--end","aria-hidden":"true"})]}),m(Je,{search:N,onFiltersClick:()=>_(!0),filterCount:f,action:i}),D("div",{className:`rle-body ${k?"rle-split":"rle-body--list-only"}`,"data-mobile-view":p,children:[D("div",{className:"rle-list",children:[D("div",{className:"rle-list-header",children:[m(Ue,{}),e&&m("div",{className:"rle-list-header__toolbar",children:e})]}),m(Oe,{className:"rle-list-grid"}),m(Ke,{})]}),k&&m("div",{className:"rle-map",children:m(ze,{center:o,zoom:n,fallback:jt,mapControls:a})})]}),k&&m(Ge,{view:p,onViewChange:F}),m(Xe,{title:"Filters",open:O,onOpenChange:_,footer:D(Gt,{children:[m("button",{type:"button",className:"rle-btn rle-btn--ghost",onClick:L,children:"Clear all"}),D("button",{type:"button",className:"rle-btn rle-btn--primary",onClick:()=>_(!1),children:["Show ",u," results"]})]}),children:m(de,{className:"rle-filter-stack",groupClassName:"rle-filter-group"})})]})}import{useEffect as Zt,useRef as Xt,useState as Jt}from"react";import{jsx as Fe,jsxs as ti}from"react/jsx-runtime";function tt(t){return"provider"in t}function Yt(t){let e=t!=null&&!tt(t),i=e?t.apiKey:void 0,r=e?t.mapId:void 0,s=e?t.mapOptions:void 0,o=e?t.styles:void 0,[n,a]=Jt(()=>!t||tt(t)?{ready:!0,provider:t?.provider}:{ready:!1});return Zt(()=>{if(!i)return;let d=!1;return import("./maps/google/index.js").then(({googleProvider:l})=>{d||a({ready:!0,provider:l({apiKey:i,mapId:r,mapOptions:s,styles:o})})}),()=>{d=!0}},[i,r]),n}function ei({onFiltersChange:t}){let e=Xt(t);return e.current=t,Ve("FiltersChanged",i=>{i.type==="FiltersChanged"&&e.current(i.filters)}),null}function Pn(t){let{datasets:e,filters:i,map:r,components:s,initialFilters:o,onFiltersChange:n,mobileAction:a,search:d,toolbarEnd:l,mapControls:c,config:h,autoFetch:b,className:w}=t,{ready:k,provider:p}=Yt(r);if(!k)return null;let F=[];for(let A of e)F.push(ke(A));i&&F.push(Ee(i)),p&&F.push(we(p)),o&&F.push(xe(o)),h&&F.push(Ie(h));let O=Se(...F),_={...Qe,...s};return ti(We,{...O,children:[n&&Fe(ei,{onFiltersChange:n}),Fe(Re,{..._,children:Fe(et,{className:w,search:d,toolbarEnd:l,mobileAction:a,autoFetch:b,mapCenter:r?.center,mapZoom:r?.zoom,mapControls:c})})]})}export{Q as a,H as b,G as c,Z as d,Ce as e,X as f,J as g,Se as h,Ie as i,we as j,ke as k,Ee as l,yi as m,xe as n,vi as o,le as p,Re as q,P as r,Y as s,g as t,I as u,ee as v,de as w,z as x,Oe as y,ze as z,Ke as A,Ue as B,Ve as C,We as D,ce as E,ue as F,me as G,ge as H,fe as I,ve as J,he as K,Le as L,be as M,Pe as N,Qe as O,Ge as P,Xe as Q,et as R,Pn as S};
|
package/dist/chunk-X4LBPNOS.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5;"use client";
|
|
2
|
-
var Q= (_class =class{__init() {this.listeners=new Set}constructor(e){;_class.prototype.__init.call(this);this.state=this.freezeState({filters:{...e.filters},results:{items:[],nextCursor:null},bounds:null,selection:null,hovered:null,pagination:{mode:_nullishCoalesce(e.mode, () => ("paged")),loading:!1},layers:{},points:{}})}getState(){return this.state}setFilters(e){this.setState({filters:{...this.state.filters,...e}})}setResults(e){this.setState({results:{items:[...e.items],nextCursor:e.nextCursor,total:e.total}})}appendResults(e){this.setState({results:{items:[...this.state.results.items,...e.items],nextCursor:e.nextCursor,total:e.total}})}setBounds(e){this.setState({bounds:e?{...e}:null})}setSelection(e){this.setState({selection:e})}setHovered(e){this.setState({hovered:e})}setLayerVisible(e,i){this.setState({layers:{...this.state.layers,[e]:i}})}setLoading(e){this.setState({pagination:{...this.state.pagination,loading:e}})}setPoints(e,i){this.setState({points:{...this.state.points,[e]:[...i]}})}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setState(e){this.state=this.freezeState({...this.state,...e}),this.notify()}notify(){for(let e of this.listeners)e()}freezeState(e){Object.freeze(e.filters),Object.freeze(e.results.items),Object.freeze(e.results),e.bounds&&Object.freeze(e.bounds),Object.freeze(e.pagination),Object.freeze(e.layers);for(let i of Object.values(e.points))Object.freeze(i);return Object.freeze(e.points),Object.freeze(e)}}, _class);var H= (_class2 =class{constructor() { _class2.prototype.__init2.call(this); }__init2() {this.defs=new Map}add(e){if(this.defs.has(e.key))throw new Error(`FilterRegistry: filter "${e.key}" is already registered`);return this.defs.set(e.key,{...e}),this}remove(e){return this.defs.delete(e),this}replace(e,i){if(!this.defs.has(e))throw new Error(`FilterRegistry: cannot replace unregistered filter "${e}"`);return this.defs.set(e,{...i,key:e}),this}reorder(e){let i=this.list(),r=e.filter(o=>this.defs.has(o));r.forEach((o,n)=>{this.defs.get(o).order=n});let s=new Set(r);return i.filter(o=>!s.has(o.key)).forEach((o,n)=>{o.order=r.length+n}),this}list(){return[...this.defs.values()].sort((e,i)=>e.order-i.order)}has(e){return this.defs.has(e)}toFilters(e){return this.list().filter(r=>Object.hasOwn(e,r.key)).map(r=>r.toParams(e[r.key])).reduce((r,s)=>({...r,...s}),{})}activeKeys(e){return this.list().filter(i=>_optionalChain([i, 'access', _2 => _2.isActive, 'optionalCall', _3 => _3(e)])).map(i=>i.key)}clearedParams(){return this.list().reduce((e,i)=>Object.assign(e,i.toParams(i.fromParams({}))),{})}}, _class2);var G= (_class3 =class{constructor() { _class3.prototype.__init3.call(this); }__init3() {this.defs=new Map}add(e){if(this.defs.has(e.id))throw new Error(`DatasetRegistry: dataset "${e.id}" is already registered`);return this.defs.set(e.id,{...e}),this}get(e){return this.defs.get(e)}has(e){return this.defs.has(e)}list(){return[...this.defs.values()]}visibleIds(){return this.list().filter(e=>_optionalChain([e, 'access', _4 => _4.visible, 'optionalCall', _5 => _5()])!==!1).map(e=>e.id)}}, _class3);var Z= (_class4 =class{constructor() { _class4.prototype.__init4.call(this); }__init4() {this.map=new Map}dispose(){this.map.clear()}emit(e){let i=this.map.get(e.type);if(i)for(let s of[...i])s(e);let r=this.map.get("*");if(r)for(let s of[...r])s(e)}on(e,i){let r=this.map.get(e);return r||(r=new Set,this.map.set(e,r)),r.add(i),()=>{r.delete(i)}}}, _class4);var Ce={pagination:"paged",pageSize:20,debounceMs:250};var X=class{constructor(e){this.options=Object.freeze({...Ce,...e})}};var J= (_class5 =class{__init5() {this.emitter=new Z}__init6() {this.debounceTimer=null}__init7() {this.debounceResolve=null}__init8() {this.queryToken=0}__init9() {this.pointsToken=0}constructor(e){;_class5.prototype.__init5.call(this);_class5.prototype.__init6.call(this);_class5.prototype.__init7.call(this);_class5.prototype.__init8.call(this);_class5.prototype.__init9.call(this);this.datasets=e.datasets,this.filters=_nullishCoalesce(e.filters, () => (new H)),this.map=e.map,this.config=new X(e.config);let i=_nullishCoalesce(e.primaryDatasetId, () => (_optionalChain([this, 'access', _6 => _6.datasets, 'access', _7 => _7.list, 'call', _8 => _8(), 'access', _9 => _9[0], 'optionalAccess', _10 => _10.id])));if(i==null||!this.datasets.has(i))throw new Error(`ListingEngine: primary dataset "${_nullishCoalesce(i, () => (""))}" is not registered \u2014 pass a valid primaryDatasetId or register at least one dataset`);this.primaryDatasetId=i,this.store=new Q({filters:_nullishCoalesce(e.initialFilters, () => ({})),mode:this.config.options.pagination})}get state(){return this.store.getState()}get options(){return this.config.options}applyFilters(e){this.store.setFilters(e),this.emitter.emit({type:"FiltersChanged",filters:this.currentFilters()}),this.clearDebounce();let i=++this.queryToken,r=this.config.options.debounceMs;return r<=0?this.runQuery(i):new Promise(s=>{this.debounceResolve=s,this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.debounceResolve=null,s(this.runQuery(i))},r)})}async loadPage(){let e=this.state.results.nextCursor;if(e===null)return;let i=++this.queryToken,r=this.primaryDataset();this.store.setLoading(!0);try{let s=await r.adapter.list(this.currentFilters(),{cursor:e,limit:this.config.options.pageSize});if(i!==this.queryToken)return;this.config.options.pagination==="infinite"?this.store.appendResults(s):this.store.setResults(s),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:s.items.length})}finally{i===this.queryToken&&this.store.setLoading(!1)}}async loadPoints(e){this.store.setBounds(e),this.emitter.emit({type:"BoundsChanged",bounds:e});let i=this.currentFilters(),r=++this.pointsToken;await Promise.allSettled(this.datasets.visibleIds().map(async s=>{let o=this.datasets.get(s);if(!o)return;let n=await o.adapter.getPoints(i,e);r===this.pointsToken&&this.store.setPoints(s,n)}))}selectPoint(e,i){this.store.setSelection(i);let r=_optionalChain([this, 'access', _11 => _11.state, 'access', _12 => _12.points, 'access', _13 => _13[e], 'optionalAccess', _14 => _14.find, 'call', _15 => _15(s=>s.id===i)]);r&&this.emitter.emit({type:"PointClicked",datasetId:e,id:r.id,entity:r.entity})}setHovered(e,i){this.store.setHovered(i)}toggleLayer(e){let r=!(_nullishCoalesce(this.state.layers[e], () => (!0)));this.store.setLayerVisible(e,r),this.emitter.emit({type:"LayerToggled",datasetId:e,visible:r})}subscribe(e){return this.store.subscribe(e)}on(e,i){return this.emitter.on(e,i)}dispose(){this.clearDebounce(),this.emitter.dispose()}async runQuery(e){if(e!==this.queryToken)return;let i=this.primaryDataset();this.store.setLoading(!0);try{let r=await i.adapter.list(this.currentFilters(),{cursor:null,limit:this.config.options.pageSize});if(e!==this.queryToken)return;this.store.setResults(r),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:r.items.length})}finally{e===this.queryToken&&this.store.setLoading(!1)}}primaryDataset(){return this.datasets.get(this.primaryDatasetId)}currentFilters(){return this.store.getState().filters}clearDebounce(){this.debounceTimer!==null&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.debounceResolve!==null&&(this.debounceResolve(),this.debounceResolve=null)}}, _class5);function Se(...t){let e={config:{},filters:new H,datasets:new G};for(let i of t)i(e);return e}var Ie=t=>e=>{e.config={...e.config,...t}},we= exports.j =t=>e=>{e.map=t},ke= exports.k =t=>e=>{e.datasets.add(t)},Ee= exports.l =t=>e=>{t(e.filters)},yi= exports.m =t=>e=>{e.urlSync=t},xe= exports.n =t=>e=>{e.initialFilters=t},vi= exports.o =t=>e=>{e.primaryDatasetId=t};var _react = require('react');var _jsxruntime = require('react/jsx-runtime');function nt(t){return String(_nullishCoalesce(_optionalChain([t, 'optionalAccess', _16 => _16.title]), () => ("")))}var st=({item:t})=>_jsxruntime.jsx.call(void 0, "div",{children:nt(t)}),ot=()=>_jsxruntime.jsx.call(void 0, "div",{}),le= exports.p =()=>_jsxruntime.jsx.call(void 0, "div",{}),at=({children:t})=>_jsxruntime.jsx.call(void 0, "div",{children:t}),lt=({children:t})=>_jsxruntime.jsx.call(void 0, "div",{children:t}),dt=({value:t,onChange:e,placeholder:i})=>_jsxruntime.jsx.call(void 0, "input",{type:"search",value:t,placeholder:i,onChange:r=>e(r.target.value),"aria-label":_nullishCoalesce(i, () => ("Search"))}),pt=()=>_jsxruntime.jsx.call(void 0, "div",{role:"status",children:"No results"}),ct=()=>_jsxruntime.jsx.call(void 0, "div",{role:"status","aria-busy":"true",children:"Loading\u2026"}),ut=({count:t})=>_jsxruntime.jsxs.call(void 0, "div",{children:[t," results"]}),mt=({children:t})=>_jsxruntime.jsx.call(void 0, "div",{children:t}),C={Card:st,Marker:ot,Popup:le,Sidebar:at,FilterPanel:lt,Search:dt,Empty:pt,Loading:ct,ResultHeader:ut,Toolbar:mt},Ne=_react.createContext.call(void 0, C);function Re(t){let{Card:e,Marker:i,Popup:r,Sidebar:s,FilterPanel:o,Search:n,Empty:a,Loading:d,ResultHeader:l,Toolbar:c,children:h}=t,b={Card:_nullishCoalesce(e, () => (C.Card)),Marker:_nullishCoalesce(i, () => (C.Marker)),Popup:_nullishCoalesce(r, () => (C.Popup)),Sidebar:_nullishCoalesce(s, () => (C.Sidebar)),FilterPanel:_nullishCoalesce(o, () => (C.FilterPanel)),Search:_nullishCoalesce(n, () => (C.Search)),Empty:_nullishCoalesce(a, () => (C.Empty)),Loading:_nullishCoalesce(d, () => (C.Loading)),ResultHeader:_nullishCoalesce(l, () => (C.ResultHeader)),Toolbar:_nullishCoalesce(c, () => (C.Toolbar))};return _jsxruntime.jsx.call(void 0, Ne.Provider,{value:b,children:h})}function P(){return _react.useContext.call(void 0, Ne)}var Y=_react.createContext.call(void 0, null);function g(){let t=_react.useContext.call(void 0, Y);if(t===null)throw new Error("useListing must be used within a <ListingProvider>");return t}function I(){let t=g(),e=_react.useCallback.call(void 0, r=>t.subscribe(r),[t]),i=_react.useCallback.call(void 0, ()=>t.state,[t]);return _react.useSyncExternalStore.call(void 0, e,i,i)}function ee(){let t=g(),e=I(),i=_react.useCallback.call(void 0, s=>t.applyFilters(s),[t]),r=_react.useCallback.call(void 0, (s,o)=>t.applyFilters({[s]:o}),[t]);return{filters:e.filters,set:i,setField:r}}function de({className:t,groupClassName:e,hideLabels:i}={}){let r=g(),{FilterPanel:s}=P(),{filters:o}=ee();return _jsxruntime.jsx.call(void 0, s,{children:_jsxruntime.jsx.call(void 0, "div",{className:_nullishCoalesce(t, () => ("space-y-5")),children:r.filters.list().map(n=>{if(typeof n.render=="string")return _jsxruntime.jsx.call(void 0, "div",{"data-filter":n.key,className:e},n.key);let a=n.render;return _jsxruntime.jsxs.call(void 0, "div",{className:e,children:[n.label&&!i&&_jsxruntime.jsx.call(void 0, "div",{className:"mb-1.5 text-[13px] font-medium text-foreground",children:n.label}),_jsxruntime.jsx.call(void 0, a,{value:n.fromParams(o),onChange:d=>{r.applyFilters(n.toParams(d))}})]},n.key)})})})}function z(){return I().results}function Lt(t,e){if(t&&typeof t=="object"&&"id"in t){let i=t.id;if(typeof i=="string"||typeof i=="number")return i}return e}function Oe({className:t}={}){let e=g(),{items:i}=z(),{pagination:r,selection:s}=I(),{Card:o,Empty:n,Loading:a}=P();return r.loading&&i.length===0?_jsxruntime.jsx.call(void 0, a,{}):i.length===0?_jsxruntime.jsx.call(void 0, n,{}):_jsxruntime.jsx.call(void 0, "div",{role:"list",className:t,children:i.map((d,l)=>{let c=Lt(d,l);return _jsxruntime.jsx.call(void 0, o,{item:d,selected:s===c,onSelect:()=>e.selectPoint(e.primaryDatasetId,c)},c)})})}var _reactdom = require('react-dom');var Pt={west:-179.9,south:-85,east:179.9,north:85},Be=.1,Ae=.02;function Tt(t){if(t.length===0)return null;let e=t[0].lng,i=t[0].lng,r=t[0].lat,s=t[0].lat;for(let{lat:a,lng:d}of t)d<e&&(e=d),d>i&&(i=d),a<r&&(r=a),a>s&&(s=a);let o=s>r?(s-r)*Be:Ae,n=i>e?(i-e)*Be:Ae;return{west:e-n,east:i+n,south:r-o,north:s+o}}function ze(t){let{center:e,zoom:i,fallback:r,mapControls:s}=t,o=g(),n=I(),a=_react.useRef.call(void 0, null),d=_react.useRef.call(void 0, null),l=_react.useRef.call(void 0, null),[c,h]=_react.useState.call(void 0, !1),b=_react.useRef.call(void 0, !1),w=_react.useRef.call(void 0, !1),k=_react.useRef.call(void 0, !1),p=o.map;_react.useEffect.call(void 0, ()=>{let L=l.current;if(!p||!L)return;let f=[];for(let u of Object.keys(n.points)){if(n.layers[u]===!1)continue;let y=o.datasets.get(u),R=_nullishCoalesce(n.points[u], () => ([])),ae={id:u,markers:R.map(M=>({id:M.id,position:M.position,iconUrl:_optionalChain([y, 'optionalAccess', _17 => _17.marker, 'access', _18 => _18.iconUrl, 'optionalCall', _19 => _19(M.entity)]),element:_optionalChain([y, 'optionalAccess', _20 => _20.marker, 'access', _21 => _21.element, 'optionalCall', _22 => _22(M.entity)])})),clustering:_optionalChain([y, 'optionalAccess', _23 => _23.clustering]),onMarkerClick:M=>o.selectPoint(u,M)};f.push(p.renderLayer(L,ae))}return()=>{f.forEach(u=>u())}},[o,p,c,n.points,n.layers]),_react.useEffect.call(void 0, ()=>{if(!a.current||!p)return;let L=a.current,f=!1,u=null;return(async()=>{let y=await p.mount(L,{center:e,zoom:i,fullscreenTarget:_nullishCoalesce(d.current, () => (void 0))});if(f){p.destroy(y);return}l.current=y,u=p.onBoundsChange(y,R=>{k.current?k.current=!1:w.current=!0,o.loadPoints(R)}),h(!0),o.loadPoints(Pt)})(),()=>{f=!0,_optionalChain([u, 'optionalCall', _24 => _24()]),l.current&&(p.destroy(l.current),l.current=null),h(!1)}},[o,p]),_react.useEffect.call(void 0, ()=>{let L=l.current;if(!p||!L||e||b.current||w.current)return;let f=[];for(let y of Object.keys(n.points))if(n.layers[y]!==!1)for(let R of _nullishCoalesce(n.points[y], () => ([])))f.push(R.position);let u=Tt(f);u&&(b.current=!0,k.current=!0,p.fitBounds(L,u))},[p,e,c,n.points,n.layers]),_react.useEffect.call(void 0, ()=>{_optionalChain([p, 'optionalAccess', _25 => _25.updateMarkerStates, 'call', _26 => _26(n.selection,n.hovered)])},[p,c,n.selection,n.hovered]);let{Popup:F}=P(),O=F!==le,_=_nullishCoalesce(n.points[o.primaryDatasetId], () => ([])),A=n.selection!=null?_.find(L=>L.id===n.selection):void 0,[V,j]=_react.useState.call(void 0, null),N=_react.useRef.call(void 0, A);return N.current=A,_react.useEffect.call(void 0, ()=>{let L=l.current;if(!p||!L||!O)return;let f=N.current;if(!f)return;let u=p.mountOverlay(f.position);j({entity:f.entity,position:f.position,container:u.container});let y=()=>o.selectPoint(o.primaryDatasetId,null),R=M=>{M.key==="Escape"&&y()};document.addEventListener("keydown",R);let ae=p.onMapClick(y);return()=>{document.removeEventListener("keydown",R),ae(),u.unmount(),j(null)}},[o,p,c,n.selection,O]),_jsxruntime.jsxs.call(void 0, "div",{ref:d,className:"relative h-full min-h-0 w-full",children:[_jsxruntime.jsxs.call(void 0, "div",{ref:a,className:!p&&r?"flex h-full min-h-0 w-full items-center justify-center":"h-full min-h-0 w-full",children:[!p&&r,O&&V?_reactdom.createPortal.call(void 0, _jsxruntime.jsx.call(void 0, F,{entity:V.entity,onClose:()=>o.selectPoint(o.primaryDatasetId,null)}),V.container):null]}),s!=null&&_jsxruntime.jsx.call(void 0, "div",{className:"pointer-events-none absolute inset-0",children:_jsxruntime.jsx.call(void 0, "div",{className:"pointer-events-auto",children:s})})]})}function Ke(){let t=g(),{results:e,pagination:i}=I();return e.nextCursor==null?null:_jsxruntime.jsx.call(void 0, "button",{type:"button",disabled:i.loading,onClick:()=>{t.loadPage()},children:"Load more"})}function Ue(){let{items:t,total:e}=z(),{ResultHeader:i}=P();return _jsxruntime.jsx.call(void 0, i,{count:t.length,total:e})}function Ve(t,e){let i=g(),r=_react.useRef.call(void 0, e);r.current=e,_react.useEffect.call(void 0, ()=>i.on(t,s=>r.current(s)),[i,t])}function We(t){let{children:e,...i}=t,[r]=_react.useState.call(void 0, ()=>i),[s,o]=_react.useState.call(void 0, null);return _react.useEffect.call(void 0, ()=>{let n=new J({datasets:r.datasets,filters:r.filters,config:r.config,map:r.map,initialFilters:r.initialFilters,primaryDatasetId:r.primaryDatasetId});return r.urlSync&&r.urlSync.start(n),o(n),()=>{r.urlSync&&r.urlSync.stop(),n.dispose(),o(a=>a===n?null:a)}},[r]),s?_jsxruntime.jsx.call(void 0, Y.Provider,{value:s,children:e}):null}function K(t){return typeof t!="number"?t:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t)}function Et(t){return t?"rle-card rle-card--selected":"rle-card"}function ce({item:t,selected:e,onSelect:i}){let r=_nullishCoalesce(t, () => ({})),s=Et(e),o=_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[r.imageUrl?_jsxruntime.jsx.call(void 0, "img",{src:r.imageUrl,alt:_nullishCoalesce(r.title, () => ("")),className:"rle-card-media"}):_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-media rle-card-media--placeholder","aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{className:"rle-card-body",children:[r.title&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-title",children:r.title}),r.subtitle&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-address",children:r.subtitle}),r.badge&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-info",children:_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-info-item",children:r.badge})}),r.price!=null&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-price",children:K(r.price)})]})]});return i?_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:i,"aria-pressed":_nullishCoalesce(e, () => (!1)),className:s,children:o}):_jsxruntime.jsx.call(void 0, "article",{className:s,children:o})}function ue(t){return _jsxruntime.jsxs.call(void 0, "div",{role:"status",className:"rle-empty",children:[_jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",className:"rle-empty-icon","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "circle",{cx:"11",cy:"11",r:"7"}),_jsxruntime.jsx.call(void 0, "path",{d:"m21 21-4.3-4.3"})]}),_jsxruntime.jsx.call(void 0, "p",{className:"rle-empty-title",children:"No results"}),_jsxruntime.jsx.call(void 0, "p",{className:"rle-empty-hint",children:"Try adjusting your filters or search terms."})]})}function me({children:t}){return _jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-panel",children:t})}function ge(t){return _jsxruntime.jsx.call(void 0, "div",{className:"rle-loading",role:"status","aria-busy":"true","aria-label":"Loading results",children:Array.from({length:3}).map((e,i)=>_jsxruntime.jsxs.call(void 0, "div",{className:"rle-loading-item",children:[_jsxruntime.jsx.call(void 0, "div",{className:"rle-skeleton",style:{aspectRatio:"4 / 3",width:"100%"}}),_jsxruntime.jsx.call(void 0, "div",{className:"rle-skeleton",style:{height:16,width:"65%"}}),_jsxruntime.jsx.call(void 0, "div",{className:"rle-skeleton",style:{height:12,width:"35%"}})]},i))})}function fe({point:t}){let e=_nullishCoalesce(t.entity, () => ({}));return _jsxruntime.jsx.call(void 0, "span",{className:"rle-pin",children:e.price!=null?K(e.price):""})}function ve({entity:t,onClose:e}){let i=_nullishCoalesce(t, () => ({}));return _jsxruntime.jsxs.call(void 0, "div",{className:"rle-popup",role:"group","aria-label":"Location details",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:e,"aria-label":"Close",className:"rle-popup-close",children:_jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M18 6 6 18"}),_jsxruntime.jsx.call(void 0, "path",{d:"m6 6 12 12"})]})}),_jsxruntime.jsxs.call(void 0, "div",{children:[i.title&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-title",children:i.title}),i.subtitle&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-address",children:i.subtitle}),i.price!=null&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-price",children:K(i.price)})]})]})}function he({count:t,total:e}){let i=e!=null&&e!==t?`${t} of ${e} results`:`${t} results`;return _jsxruntime.jsx.call(void 0, "div",{className:"rle-result-header",children:i})}function Le({value:t,onChange:e,placeholder:i}){return _jsxruntime.jsx.call(void 0, "input",{type:"search",value:t,placeholder:i,onChange:r=>e(r.target.value),"aria-label":_nullishCoalesce(i, () => ("Search")),className:"rle-input"})}function be({children:t}){return _jsxruntime.jsx.call(void 0, "aside",{className:"rle-sidebar",children:t})}function Pe({children:t}){return _jsxruntime.jsx.call(void 0, "div",{className:"rle-toolbar",children:t})}var Qe={Card:ce,Marker:fe,Popup:ve,Sidebar:be,FilterPanel:me,Search:Le,Empty:ue,Loading:ge,ResultHeader:he,Toolbar:Pe};function Ge({view:t,onViewChange:e}){return _jsxruntime.jsx.call(void 0, "nav",{className:"rle-bottom-nav","aria-label":"Listing navigation",children:_jsxruntime.jsxs.call(void 0, "div",{className:"rle-viewtoggle",role:"group","aria-label":"View",children:[_jsxruntime.jsxs.call(void 0, "button",{type:"button",className:`rle-viewtoggle__btn${t==="list"?" rle-viewtoggle__btn--active":""}`,"aria-pressed":t==="list",onClick:()=>e("list"),children:[_jsxruntime.jsx.call(void 0, At,{}),"List"]}),_jsxruntime.jsxs.call(void 0, "button",{type:"button",className:`rle-viewtoggle__btn${t==="map"?" rle-viewtoggle__btn--active":""}`,"aria-pressed":t==="map",onClick:()=>e("map"),children:[_jsxruntime.jsx.call(void 0, Ht,{}),"Map"]})]})})}function At(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "line",{x1:"8",y1:"6",x2:"20",y2:"6"}),_jsxruntime.jsx.call(void 0, "line",{x1:"8",y1:"12",x2:"20",y2:"12"}),_jsxruntime.jsx.call(void 0, "line",{x1:"8",y1:"18",x2:"20",y2:"18"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"6",x2:"4.01",y2:"6"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"12",x2:"4.01",y2:"12"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"18",x2:"4.01",y2:"18"})]})}function Ht(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "polygon",{points:"1 6 8 3 16 6 23 3 23 18 16 21 8 18 1 21 1 6"}),_jsxruntime.jsx.call(void 0, "line",{x1:"8",y1:"3",x2:"8",y2:"18"}),_jsxruntime.jsx.call(void 0, "line",{x1:"16",y1:"6",x2:"16",y2:"21"})]})}function Xe({open:t,onOpenChange:e,title:i,children:r,footer:s}){let o=_react.useRef.call(void 0, null),[n,a]=_react.useState.call(void 0, !1),[d,l]=_react.useState.call(void 0, !1);return _react.useEffect.call(void 0, ()=>{if(!t){l(!1),a(!1);return}a(!0);let c=requestAnimationFrame(()=>l(!0));return()=>cancelAnimationFrame(c)},[t]),_react.useEffect.call(void 0, ()=>{if(!n)return;let c=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=c}},[n]),_react.useEffect.call(void 0, ()=>{if(!n)return;_optionalChain([o, 'access', _27 => _27.current, 'optionalAccess', _28 => _28.focus, 'call', _29 => _29()]);function c(h){h.key==="Escape"&&e(!1)}return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[n,e]),!n||typeof document>"u"?null:_reactdom.createPortal.call(void 0, _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "div",{className:`rle-sheet-backdrop${d?" rle-sheet-backdrop--open":""}`,onClick:()=>e(!1),"aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{ref:o,className:`rle-sheet${d?" rle-sheet--open":""}`,role:"dialog","aria-modal":"true","aria-label":i,tabIndex:-1,children:[_jsxruntime.jsx.call(void 0, "div",{className:"rle-sheet__handle","aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{className:"rle-sheet__header",children:[i&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-sheet__title",children:i}),_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-sheet__close",onClick:()=>e(!1),"aria-label":"Close",children:_jsxruntime.jsx.call(void 0, Ut,{})})]}),_jsxruntime.jsx.call(void 0, "div",{className:"rle-sheet__body",children:r}),s&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-sheet__footer",children:s})]})]}),document.body)}function Ut(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M18 6 6 18"}),_jsxruntime.jsx.call(void 0, "path",{d:"m6 6 12 12"})]})}function Je({search:t,onFiltersClick:e,filterCount:i=0,action:r}){let{Search:s}=P();return _jsxruntime.jsxs.call(void 0, "header",{className:"rle-mobile-header",children:[t&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-mobile-header__search",children:_jsxruntime.jsx.call(void 0, s,{value:t.value,onChange:t.onChange,placeholder:t.placeholder})}),_jsxruntime.jsxs.call(void 0, "button",{type:"button",className:"rle-btn rle-mobile-header__btn",onClick:e,children:[_jsxruntime.jsx.call(void 0, $t,{}),_jsxruntime.jsx.call(void 0, "span",{children:"Filters"}),i>0&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-mobile-header__count",children:i})]}),r&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-btn rle-mobile-header__btn rle-mobile-header__btn--icon",onClick:r.onClick,"aria-label":r.label,children:_nullishCoalesce(r.icon, () => (_jsxruntime.jsx.call(void 0, Wt,{})))})]})}function $t(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"6",x2:"20",y2:"6"}),_jsxruntime.jsx.call(void 0, "circle",{cx:"9",cy:"6",r:"2",fill:"currentColor",stroke:"none"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"12",x2:"20",y2:"12"}),_jsxruntime.jsx.call(void 0, "circle",{cx:"15",cy:"12",r:"2",fill:"currentColor",stroke:"none"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"18",x2:"20",y2:"18"}),_jsxruntime.jsx.call(void 0, "circle",{cx:"11",cy:"18",r:"2",fill:"currentColor",stroke:"none"})]})}function Wt(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "line",{x1:"12",y1:"5",x2:"12",y2:"19"}),_jsxruntime.jsx.call(void 0, "line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}var jt=_jsxruntime.jsx.call(void 0, "div",{className:"rle-empty",children:"Map unavailable"});function Qt(){let t=_react.useRef.call(void 0, null),[e,i]=_react.useState.call(void 0, !0),[r,s]=_react.useState.call(void 0, !0);return _react.useEffect.call(void 0, ()=>{let o=t.current;if(!o)return;let n=()=>{let{clientWidth:h,scrollLeft:b,scrollWidth:w}=o;i(b<=0),s(b+h>=w-1)},a=0,d=()=>{a||(a=requestAnimationFrame(()=>{a=0,n()}))};n(),o.addEventListener("scroll",n,{passive:!0});let l,c;return typeof ResizeObserver<"u"&&(l=new ResizeObserver(n),l.observe(o)),typeof MutationObserver<"u"&&(c=new MutationObserver(d),c.observe(o,{characterData:!0,childList:!0,subtree:!0})),()=>{o.removeEventListener("scroll",n),_optionalChain([l, 'optionalAccess', _30 => _30.disconnect, 'call', _31 => _31()]),_optionalChain([c, 'optionalAccess', _32 => _32.disconnect, 'call', _33 => _33()]),a&&cancelAnimationFrame(a)}},[]),{atEnd:r,atStart:e,ref:t}}function et({search:t,toolbarEnd:e,mobileAction:i,autoFetch:r=!0,hasMap:s,mapCenter:o,mapZoom:n,mapControls:a,className:d}){let l=g(),{Search:c}=P(),h=z(),{filters:b,set:w}=ee(),k=_nullishCoalesce(s, () => (l.map!=null)),[p,F]=_react.useState.call(void 0, "list"),[O,_]=_react.useState.call(void 0, !1),{atEnd:A,atStart:V,ref:j}=Qt(),N=t?{value:String(_nullishCoalesce(b[t.filterKey], () => (""))),onChange:y=>{w({[t.filterKey]:y||void 0})},placeholder:t.placeholder}:void 0;_react.useEffect.call(void 0, ()=>{r!==!1&&l.applyFilters({})},[l,r]);let L=()=>{w(l.filters.clearedParams())},f=l.filters.activeKeys(b).length,u=_nullishCoalesce(h.total, () => (h.items.length));return _jsxruntime.jsxs.call(void 0, "div",{className:d?`rle-app ${d}`:"rle-app",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"rle-filter-bar",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"rle-filter-bar__scroll",ref:j,children:[N&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__search",children:_jsxruntime.jsx.call(void 0, c,{value:N.value,onChange:N.onChange,placeholder:N.placeholder})}),_jsxruntime.jsx.call(void 0, de,{className:"rle-filters-row",groupClassName:"rle-filter-group",hideLabels:!0})]}),!V&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__fade rle-filter-bar__fade--start","aria-hidden":"true"}),!A&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__fade rle-filter-bar__fade--end","aria-hidden":"true"})]}),_jsxruntime.jsx.call(void 0, Je,{search:N,onFiltersClick:()=>_(!0),filterCount:f,action:i}),_jsxruntime.jsxs.call(void 0, "div",{className:`rle-body ${k?"rle-split":"rle-body--list-only"}`,"data-mobile-view":p,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"rle-list",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"rle-list-header",children:[_jsxruntime.jsx.call(void 0, Ue,{}),e&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-list-header__toolbar",children:e})]}),_jsxruntime.jsx.call(void 0, Oe,{className:"rle-list-grid"}),_jsxruntime.jsx.call(void 0, Ke,{})]}),k&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-map",children:_jsxruntime.jsx.call(void 0, ze,{center:o,zoom:n,fallback:jt,mapControls:a})})]}),k&&_jsxruntime.jsx.call(void 0, Ge,{view:p,onViewChange:F}),_jsxruntime.jsx.call(void 0, Xe,{title:"Filters",open:O,onOpenChange:_,footer:_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-btn rle-btn--ghost",onClick:L,children:"Clear all"}),_jsxruntime.jsxs.call(void 0, "button",{type:"button",className:"rle-btn rle-btn--primary",onClick:()=>_(!1),children:["Show ",u," results"]})]}),children:_jsxruntime.jsx.call(void 0, de,{className:"rle-filter-stack",groupClassName:"rle-filter-group"})})]})}function tt(t){return"provider"in t}function Yt(t){let e=t!=null&&!tt(t),i=e?t.apiKey:void 0,r=e?t.mapId:void 0,s=e?t.mapOptions:void 0,o=e?t.styles:void 0,[n,a]=_react.useState.call(void 0, ()=>!t||tt(t)?{ready:!0,provider:_optionalChain([t, 'optionalAccess', _34 => _34.provider])}:{ready:!1});return _react.useEffect.call(void 0, ()=>{if(!i)return;let d=!1;return Promise.resolve().then(() => _interopRequireWildcard(require("./maps/google/index.cjs"))).then(({googleProvider:l})=>{d||a({ready:!0,provider:l({apiKey:i,mapId:r,mapOptions:s,styles:o})})}),()=>{d=!0}},[i,r]),n}function ei({onFiltersChange:t}){let e=_react.useRef.call(void 0, t);return e.current=t,Ve("FiltersChanged",i=>{i.type==="FiltersChanged"&&e.current(i.filters)}),null}function Pn(t){let{datasets:e,filters:i,map:r,components:s,initialFilters:o,onFiltersChange:n,mobileAction:a,search:d,toolbarEnd:l,mapControls:c,config:h,autoFetch:b,className:w}=t,{ready:k,provider:p}=Yt(r);if(!k)return null;let F=[];for(let A of e)F.push(ke(A));i&&F.push(Ee(i)),p&&F.push(we(p)),o&&F.push(xe(o)),h&&F.push(Ie(h));let O=Se(...F),_={...Qe,...s};return _jsxruntime.jsxs.call(void 0, We,{...O,children:[n&&_jsxruntime.jsx.call(void 0, ei,{onFiltersChange:n}),_jsxruntime.jsx.call(void 0, Re,{..._,children:_jsxruntime.jsx.call(void 0, et,{className:w,search:d,toolbarEnd:l,mobileAction:a,autoFetch:b,mapCenter:_optionalChain([r, 'optionalAccess', _35 => _35.center]),mapZoom:_optionalChain([r, 'optionalAccess', _36 => _36.zoom]),mapControls:c})})]})}exports.a = Q; exports.b = H; exports.c = G; exports.d = Z; exports.e = Ce; exports.f = X; exports.g = J; exports.h = Se; exports.i = Ie; exports.j = we; exports.k = ke; exports.l = Ee; exports.m = yi; exports.n = xe; exports.o = vi; exports.p = le; exports.q = Re; exports.r = P; exports.s = Y; exports.t = g; exports.u = I; exports.v = ee; exports.w = de; exports.x = z; exports.y = Oe; exports.z = ze; exports.A = Ke; exports.B = Ue; exports.C = Ve; exports.D = We; exports.E = ce; exports.F = ue; exports.G = me; exports.H = ge; exports.I = fe; exports.J = ve; exports.K = he; exports.L = Le; exports.M = be; exports.N = Pe; exports.O = Qe; exports.P = Ge; exports.Q = Xe; exports.R = et; exports.S = Pn;
|