@mapfirst.ai/react 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -86,6 +86,8 @@ declare function usePrimaryType(mapFirst: MapFirstCore | null): [PropertyType, (
86
86
  /**
87
87
  * Hook to access and control the selected marker.
88
88
  * Returns the current selected marker ID and a setter function.
89
+ * Note: This hook requires the MapFirstCore instance. For simpler usage with reactive updates,
90
+ * use state.selectedPropertyId from useMapFirstCore instead.
89
91
  *
90
92
  * @example
91
93
  * ```tsx
package/dist/index.d.ts CHANGED
@@ -86,6 +86,8 @@ declare function usePrimaryType(mapFirst: MapFirstCore | null): [PropertyType, (
86
86
  /**
87
87
  * Hook to access and control the selected marker.
88
88
  * Returns the current selected marker ID and a setter function.
89
+ * Note: This hook requires the MapFirstCore instance. For simpler usage with reactive updates,
90
+ * use state.selectedPropertyId from useMapFirstCore instead.
89
91
  *
90
92
  * @example
91
93
  * ```tsx
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var S=Object.create;var d=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var m=(e,n)=>{for(var r in n)d(e,r,{get:n[r],enumerable:!0})},C=(e,n,r,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of b(n))!k.call(e,a)&&a!==r&&d(e,a,{get:()=>n[a],enumerable:!(o=h(n,a))||o.enumerable});return e};var x=(e,n,r)=>(r=e!=null?S(P(e)):{},C(n||!e||!e.__esModule?d(r,"default",{value:e,enumerable:!0}):r,e)),R=e=>C(d({},"__esModule",{value:!0}),e);var w={};m(w,{MarkerDebugList:()=>G,useGoogleMapsAttachment:()=>O,useMapFirst:()=>B,useMapFirstCore:()=>T,useMapFirstProperties:()=>E,useMapFirstSelectedProperty:()=>L,useMapLibreAttachment:()=>N,useMapboxAttachment:()=>I,usePrimaryType:()=>F,useSelectedMarker:()=>A});module.exports=R(w);var s=x(require("react")),M=require("@mapfirst.ai/core"),p=require("react/jsx-runtime");function T(e){let n=s.default.useRef(null),[r,o]=s.default.useState(null),a=s.default.useRef(e);return s.default.useEffect(()=>{a.current=e}),s.default.useEffect(()=>{let f=a.current,y={adapter:null,...f,callbacks:{...f.callbacks,onPropertiesChange:u=>{var t,l;o(c=>c?{...c,properties:u}:null),(l=(t=a.current.callbacks)==null?void 0:t.onPropertiesChange)==null||l.call(t,u)},onSelectedPropertyChange:u=>{var t,l;o(c=>c?{...c,selectedPropertyId:u}:null),(l=(t=a.current.callbacks)==null?void 0:t.onSelectedPropertyChange)==null||l.call(t,u)},onPrimaryTypeChange:u=>{var t,l;o(c=>c?{...c,primary:u}:null),(l=(t=a.current.callbacks)==null?void 0:t.onPrimaryTypeChange)==null||l.call(t,u)},onFiltersChange:u=>{var t,l;o(c=>c?{...c,filters:u}:null),(l=(t=a.current.callbacks)==null?void 0:t.onFiltersChange)==null||l.call(t,u)},onBoundsChange:u=>{var t,l;o(c=>c?{...c,bounds:u}:null),(l=(t=a.current.callbacks)==null?void 0:t.onBoundsChange)==null||l.call(t,u)},onCenterChange:(u,t)=>{var l,c;o(g=>g?{...g,center:u,zoom:t}:null),(c=(l=a.current.callbacks)==null?void 0:l.onCenterChange)==null||c.call(l,u,t)},onZoomChange:u=>{var t,l;o(c=>c?{...c,zoom:u}:null),(l=(t=a.current.callbacks)==null?void 0:t.onZoomChange)==null||l.call(t,u)},onActiveLocationChange:u=>{var t,l;o(c=>c?{...c,activeLocation:u}:null),(l=(t=a.current.callbacks)==null?void 0:t.onActiveLocationChange)==null||l.call(t,u)},onLoadingStateChange:u=>{var t,l;o(c=>c?{...c,initialLoading:u}:null),(l=(t=a.current.callbacks)==null?void 0:t.onLoadingStateChange)==null||l.call(t,u)},onSearchingStateChange:u=>{var t,l;o(c=>c?{...c,isSearching:u}:null),(l=(t=a.current.callbacks)==null?void 0:t.onSearchingStateChange)==null||l.call(t,u)}}},i=new M.MapFirstCore(y);return n.current=i,o(i.getState()),()=>{i.destroy(),n.current=null,o(null)}},[]),{mapFirst:n.current,state:r}}function E(e){let[n,r]=s.default.useState([]);return s.default.useEffect(()=>{if(!e){r([]);return}r(e.getState().properties)},[e]),n}function L(e){let[n,r]=s.default.useState(null);return s.default.useEffect(()=>{if(!e){r(null);return}r(e.getState().selectedPropertyId)},[e]),n}function F(e){let[n,r]=s.default.useState("Accommodation");s.default.useEffect(()=>{if(!e){r("Accommodation");return}r(e.getState().primary)},[e]);let o=s.default.useCallback(a=>{e&&(e.setPrimaryType(a),r(a))},[e]);return[n,o]}function A(e){let[n,r]=s.default.useState(null);s.default.useEffect(()=>{if(!e){r(null);return}r(e.getState().selectedPropertyId)},[e]);let o=s.default.useCallback(a=>{e&&(e.setSelectedMarker(a),r(a))},[e]);return[n,o]}function N({mapFirst:e,map:n,maplibregl:r,onMarkerClick:o}){let a=s.default.useRef(!1);s.default.useEffect(()=>{!e||!n||a.current||(e.attachMap(n,{platform:"maplibre",maplibregl:r,onMarkerClick:o}),a.current=!0)},[e,n,r,o])}function O({mapFirst:e,map:n,google:r,onMarkerClick:o}){let a=s.default.useRef(!1);s.default.useEffect(()=>{!e||!n||a.current||(e.attachMap(n,{platform:"google",google:r,onMarkerClick:o}),a.current=!0)},[e,n,r,o])}function I({mapFirst:e,map:n,mapboxgl:r,onMarkerClick:o}){let a=s.default.useRef(!1);s.default.useEffect(()=>{!e||!n||a.current||(e.attachMap(n,{platform:"mapbox",mapboxgl:r,onMarkerClick:o}),a.current=!0)},[e,n,r,o])}function B(e){let n=s.default.useRef(null);return s.default.useEffect(()=>{if(!e)return;let r=new M.MapFirstCore(e);return n.current=r,()=>{r.destroy(),n.current=null}},[e]),n}function G({markers:e}){return(0,p.jsxs)("div",{style:{fontFamily:"sans-serif",fontSize:14},children:[(0,p.jsx)("strong",{children:"Markers"}),(0,p.jsx)("ul",{children:e.map(n=>{var r,o,a,f,y,i;return(0,p.jsxs)("li",{children:[n.name," \u2014 ",(a=(o=(r=n.location)==null?void 0:r.lat)==null?void 0:o.toFixed(3))!=null?a:"n/a",","," ",(i=(y=(f=n.location)==null?void 0:f.lon)==null?void 0:y.toFixed(3))!=null?i:"n/a"]},String(n.tripadvisor_id))})})]})}0&&(module.exports={MarkerDebugList,useGoogleMapsAttachment,useMapFirst,useMapFirstCore,useMapFirstProperties,useMapFirstSelectedProperty,useMapLibreAttachment,useMapboxAttachment,usePrimaryType,useSelectedMarker});
1
+ "use strict";var S=Object.create;var d=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var m=(e,n)=>{for(var r in n)d(e,r,{get:n[r],enumerable:!0})},C=(e,n,r,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of b(n))!k.call(e,a)&&a!==r&&d(e,a,{get:()=>n[a],enumerable:!(o=h(n,a))||o.enumerable});return e};var x=(e,n,r)=>(r=e!=null?S(P(e)):{},C(n||!e||!e.__esModule?d(r,"default",{value:e,enumerable:!0}):r,e)),R=e=>C(d({},"__esModule",{value:!0}),e);var w={};m(w,{MarkerDebugList:()=>G,useGoogleMapsAttachment:()=>O,useMapFirst:()=>B,useMapFirstCore:()=>T,useMapFirstProperties:()=>E,useMapFirstSelectedProperty:()=>L,useMapLibreAttachment:()=>N,useMapboxAttachment:()=>I,usePrimaryType:()=>F,useSelectedMarker:()=>A});module.exports=R(w);var s=x(require("react")),M=require("@mapfirst.ai/core"),p=require("react/jsx-runtime");function T(e){let n=s.default.useRef(null),[r,o]=s.default.useState(null),a=s.default.useRef(e);return s.default.useEffect(()=>{a.current=e}),s.default.useEffect(()=>{let f=a.current,y={adapter:null,...f,callbacks:{...f.callbacks,onPropertiesChange:u=>{var t,l;o(c=>c?{...c,properties:u}:null),(l=(t=a.current.callbacks)==null?void 0:t.onPropertiesChange)==null||l.call(t,u)},onSelectedPropertyChange:u=>{var t,l;o(c=>c?{...c,selectedPropertyId:u}:null),(l=(t=a.current.callbacks)==null?void 0:t.onSelectedPropertyChange)==null||l.call(t,u)},onPrimaryTypeChange:u=>{var t,l;o(c=>c?{...c,primary:u}:null),(l=(t=a.current.callbacks)==null?void 0:t.onPrimaryTypeChange)==null||l.call(t,u)},onFiltersChange:u=>{var t,l;o(c=>c?{...c,filters:u}:null),(l=(t=a.current.callbacks)==null?void 0:t.onFiltersChange)==null||l.call(t,u)},onBoundsChange:u=>{var t,l;o(c=>c?{...c,bounds:u}:null),(l=(t=a.current.callbacks)==null?void 0:t.onBoundsChange)==null||l.call(t,u)},onCenterChange:(u,t)=>{var l,c;o(g=>g?{...g,center:u,zoom:t}:null),(c=(l=a.current.callbacks)==null?void 0:l.onCenterChange)==null||c.call(l,u,t)},onZoomChange:u=>{var t,l;o(c=>c?{...c,zoom:u}:null),(l=(t=a.current.callbacks)==null?void 0:t.onZoomChange)==null||l.call(t,u)},onActiveLocationChange:u=>{var t,l;o(c=>c?{...c,activeLocation:u}:null),(l=(t=a.current.callbacks)==null?void 0:t.onActiveLocationChange)==null||l.call(t,u)},onLoadingStateChange:u=>{var t,l;o(c=>c?{...c,initialLoading:u}:null),(l=(t=a.current.callbacks)==null?void 0:t.onLoadingStateChange)==null||l.call(t,u)},onSearchingStateChange:u=>{var t,l;o(c=>c?{...c,isSearching:u}:null),(l=(t=a.current.callbacks)==null?void 0:t.onSearchingStateChange)==null||l.call(t,u)}}},i=new M.MapFirstCore(y);return n.current=i,o(i.getState()),()=>{i.destroy(),n.current=null,o(null)}},[]),{mapFirst:n.current,state:r}}function E(e){let[n,r]=s.default.useState([]);return s.default.useEffect(()=>{if(!e){r([]);return}r(e.getState().properties)},[e]),n}function L(e){let[n,r]=s.default.useState(null);return s.default.useEffect(()=>{if(!e){r(null);return}r(e.getState().selectedPropertyId)},[e]),n}function F(e){let[n,r]=s.default.useState("Accommodation");s.default.useEffect(()=>{if(!e){r("Accommodation");return}r(e.getState().primary)},[e]);let o=s.default.useCallback(a=>{e&&(e.setPrimaryType(a),r(a))},[e]);return[n,o]}function A(e){let[n,r]=s.default.useState(null);s.default.useEffect(()=>{if(!e){r(null);return}r(e.getState().selectedPropertyId)},[e]);let o=s.default.useCallback(a=>{e&&e.setSelectedMarker(a)},[e]);return[n,o]}function N({mapFirst:e,map:n,maplibregl:r,onMarkerClick:o}){let a=s.default.useRef(!1);s.default.useEffect(()=>{!e||!n||a.current||(e.attachMap(n,{platform:"maplibre",maplibregl:r,onMarkerClick:o}),a.current=!0)},[e,n,r,o])}function O({mapFirst:e,map:n,google:r,onMarkerClick:o}){let a=s.default.useRef(!1);s.default.useEffect(()=>{!e||!n||a.current||(e.attachMap(n,{platform:"google",google:r,onMarkerClick:o}),a.current=!0)},[e,n,r,o])}function I({mapFirst:e,map:n,mapboxgl:r,onMarkerClick:o}){let a=s.default.useRef(!1);s.default.useEffect(()=>{!e||!n||a.current||(e.attachMap(n,{platform:"mapbox",mapboxgl:r,onMarkerClick:o}),a.current=!0)},[e,n,r,o])}function B(e){let n=s.default.useRef(null);return s.default.useEffect(()=>{if(!e)return;let r=new M.MapFirstCore(e);return n.current=r,()=>{r.destroy(),n.current=null}},[e]),n}function G({markers:e}){return(0,p.jsxs)("div",{style:{fontFamily:"sans-serif",fontSize:14},children:[(0,p.jsx)("strong",{children:"Markers"}),(0,p.jsx)("ul",{children:e.map(n=>{var r,o,a,f,y,i;return(0,p.jsxs)("li",{children:[n.name," \u2014 ",(a=(o=(r=n.location)==null?void 0:r.lat)==null?void 0:o.toFixed(3))!=null?a:"n/a",","," ",(i=(y=(f=n.location)==null?void 0:f.lon)==null?void 0:y.toFixed(3))!=null?i:"n/a"]},String(n.tripadvisor_id))})})]})}0&&(module.exports={MarkerDebugList,useGoogleMapsAttachment,useMapFirst,useMapFirstCore,useMapFirstProperties,useMapFirstSelectedProperty,useMapLibreAttachment,useMapboxAttachment,usePrimaryType,useSelectedMarker});
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n MapFirstCore,\n type MapFirstOptions,\n type BaseMapFirstOptions,\n type Property,\n type MapLibreNamespace,\n type GoogleMapsNamespace,\n type MapboxNamespace,\n type MapState,\n type PropertyType,\n} from \"@mapfirst.ai/core\";\n\n/**\n * Hook that creates a MapFirstCore instance that can be initialized before maps are ready.\n * Supports two-phase initialization: create SDK first, attach map later.\n * Returns the instance and reactive state that updates when SDK state changes.\n *\n * @example\n * ```tsx\n * // Phase 1: Create SDK instance with location data\n * const { mapFirst, state } = useMapFirstCore({\n * initialLocationData: {\n * city: \"New York\",\n * country: \"United States\",\n * currency: \"USD\"\n * }\n * });\n *\n * // Access reactive state\n * console.log(state.properties); // Updates when properties change\n * console.log(state.isSearching); // Updates when search state changes\n *\n * // Phase 2: Attach map when ready\n * useEffect(() => {\n * if (mapLibreInstance && mapFirst) {\n * mapFirst.attachMap(mapLibreInstance, {\n * platform: \"maplibre\",\n * maplibregl: maplibregl,\n * onMarkerClick: (marker) => console.log(marker)\n * });\n * }\n * }, [mapLibreInstance, mapFirst]);\n * ```\n */\nexport function useMapFirstCore(options: BaseMapFirstOptions) {\n const instanceRef = React.useRef<MapFirstCore | null>(null);\n const [state, setState] = React.useState<MapState | null>(null);\n\n // Memoize the options to prevent recreation on every render\n const optionsRef = React.useRef(options);\n React.useEffect(() => {\n optionsRef.current = options;\n });\n\n React.useEffect(() => {\n const opts = optionsRef.current;\n\n // Create MapFirstCore instance without map using adapter-driven options\n const coreOptions: MapFirstOptions = {\n adapter: null as any, // Will be set when attachMap is called\n ...opts,\n callbacks: {\n ...opts.callbacks,\n // Add internal callbacks to trigger React re-renders\n onPropertiesChange: (properties) => {\n setState((prev) => (prev ? { ...prev, properties } : null));\n optionsRef.current.callbacks?.onPropertiesChange?.(properties);\n },\n onSelectedPropertyChange: (id) => {\n setState((prev) =>\n prev ? { ...prev, selectedPropertyId: id } : null\n );\n optionsRef.current.callbacks?.onSelectedPropertyChange?.(id);\n },\n onPrimaryTypeChange: (type) => {\n setState((prev) => (prev ? { ...prev, primary: type } : null));\n optionsRef.current.callbacks?.onPrimaryTypeChange?.(type);\n },\n onFiltersChange: (filters) => {\n setState((prev) => (prev ? { ...prev, filters } : null));\n optionsRef.current.callbacks?.onFiltersChange?.(filters);\n },\n onBoundsChange: (bounds) => {\n setState((prev) => (prev ? { ...prev, bounds } : null));\n optionsRef.current.callbacks?.onBoundsChange?.(bounds);\n },\n onCenterChange: (center, zoom) => {\n setState((prev) => (prev ? { ...prev, center, zoom } : null));\n optionsRef.current.callbacks?.onCenterChange?.(center, zoom);\n },\n onZoomChange: (zoom) => {\n setState((prev) => (prev ? { ...prev, zoom } : null));\n optionsRef.current.callbacks?.onZoomChange?.(zoom);\n },\n onActiveLocationChange: (location) => {\n setState((prev) =>\n prev ? { ...prev, activeLocation: location } : null\n );\n optionsRef.current.callbacks?.onActiveLocationChange?.(location);\n },\n onLoadingStateChange: (loading) => {\n setState((prev) =>\n prev ? { ...prev, initialLoading: loading } : null\n );\n optionsRef.current.callbacks?.onLoadingStateChange?.(loading);\n },\n onSearchingStateChange: (searching) => {\n setState((prev) =>\n prev ? { ...prev, isSearching: searching } : null\n );\n optionsRef.current.callbacks?.onSearchingStateChange?.(searching);\n },\n },\n };\n\n const instance = new MapFirstCore(coreOptions);\n instanceRef.current = instance;\n\n // Initialize state from SDK\n setState(instance.getState());\n\n return () => {\n instance.destroy();\n instanceRef.current = null;\n setState(null);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return { mapFirst: instanceRef.current, state };\n}\n\n/**\n * Hook to access reactive properties from MapFirst SDK.\n * Returns the current properties array that updates when properties change.\n *\n * @example\n * ```tsx\n * const { mapFirst } = useMapFirstCore({ ... });\n * const properties = useMapFirstProperties(mapFirst);\n *\n * return <div>Found {properties.length} properties</div>;\n * ```\n */\nexport function useMapFirstProperties(\n mapFirst: MapFirstCore | null\n): Property[] {\n const [properties, setProperties] = React.useState<Property[]>([]);\n\n React.useEffect(() => {\n if (!mapFirst) {\n setProperties([]);\n return;\n }\n\n // Initialize with current state\n setProperties(mapFirst.getState().properties);\n }, [mapFirst]);\n\n return properties;\n}\n\n/**\n * Hook to access the selected property ID from MapFirst SDK.\n * Returns the currently selected property ID that updates when selection changes.\n *\n * @example\n * ```tsx\n * const { mapFirst } = useMapFirstCore({ ... });\n * const selectedId = useMapFirstSelectedProperty(mapFirst);\n *\n * return <div>Selected: {selectedId || 'None'}</div>;\n * ```\n */\nexport function useMapFirstSelectedProperty(\n mapFirst: MapFirstCore | null\n): number | null {\n const [selectedId, setSelectedId] = React.useState<number | null>(null);\n\n React.useEffect(() => {\n if (!mapFirst) {\n setSelectedId(null);\n return;\n }\n\n // Initialize with current state\n setSelectedId(mapFirst.getState().selectedPropertyId);\n }, [mapFirst]);\n\n return selectedId;\n}\n\n/**\n * Hook to access and control the primary property type.\n * Returns the current primary type and a setter function.\n *\n * @example\n * ```tsx\n * const { mapFirst } = useMapFirstCore({ ... });\n * const [primaryType, setPrimaryType] = usePrimaryType(mapFirst);\n *\n * return (\n * <select value={primaryType} onChange={(e) => setPrimaryType(e.target.value as PropertyType)}>\n * <option value=\"Accommodation\">Hotels</option>\n * <option value=\"Restaurant\">Restaurants</option>\n * <option value=\"Attraction\">Attractions</option>\n * </select>\n * );\n * ```\n */\nexport function usePrimaryType(\n mapFirst: MapFirstCore | null\n): [PropertyType, (type: PropertyType) => void] {\n const [primaryType, setPrimaryTypeState] =\n React.useState<PropertyType>(\"Accommodation\");\n\n React.useEffect(() => {\n if (!mapFirst) {\n setPrimaryTypeState(\"Accommodation\");\n return;\n }\n\n // Initialize with current state\n setPrimaryTypeState(mapFirst.getState().primary);\n }, [mapFirst]);\n\n const setPrimaryType = React.useCallback(\n (type: PropertyType) => {\n if (mapFirst) {\n mapFirst.setPrimaryType(type);\n setPrimaryTypeState(type);\n }\n },\n [mapFirst]\n );\n\n return [primaryType, setPrimaryType];\n}\n\n/**\n * Hook to access and control the selected marker.\n * Returns the current selected marker ID and a setter function.\n *\n * @example\n * ```tsx\n * const { mapFirst } = useMapFirstCore({ ... });\n * const [selectedMarker, setSelectedMarker] = useSelectedMarker(mapFirst);\n *\n * return (\n * <div>\n * <p>Selected: {selectedMarker || 'None'}</p>\n * <button onClick={() => setSelectedMarker(null)}>Clear Selection</button>\n * </div>\n * );\n * ```\n */\nexport function useSelectedMarker(\n mapFirst: MapFirstCore | null\n): [number | null, (id: number | null) => void] {\n const [selectedMarker, setSelectedMarkerState] = React.useState<\n number | null\n >(null);\n\n React.useEffect(() => {\n if (!mapFirst) {\n setSelectedMarkerState(null);\n return;\n }\n\n // Initialize with current state\n setSelectedMarkerState(mapFirst.getState().selectedPropertyId);\n }, [mapFirst]);\n\n const setSelectedMarker = React.useCallback(\n (id: number | null) => {\n if (mapFirst) {\n mapFirst.setSelectedMarker(id);\n setSelectedMarkerState(id);\n }\n },\n [mapFirst]\n );\n\n return [selectedMarker, setSelectedMarker];\n}\n\n/**\n * Hook for MapLibre GL JS integration.\n * Automatically attaches the map when both the SDK instance and map are available.\n *\n * @example\n * ```tsx\n * const { mapFirst, state } = useMapFirstCore({ initialLocationData: { city: \"Paris\", country: \"France\" } });\n * const mapRef = useRef<maplibregl.Map | null>(null);\n *\n * useMapLibreAttachment({\n * mapFirst,\n * map: mapRef.current,\n * maplibregl: maplibregl,\n * onMarkerClick: (marker) => console.log(marker)\n * });\n *\n * // Access reactive state\n * console.log(state?.properties);\n * ```\n */\nexport function useMapLibreAttachment({\n mapFirst,\n map,\n maplibregl,\n onMarkerClick,\n}: {\n mapFirst: MapFirstCore | null;\n map: any | null;\n maplibregl: MapLibreNamespace;\n onMarkerClick?: (marker: Property) => void;\n}) {\n const attachedRef = React.useRef(false);\n\n React.useEffect(() => {\n if (!mapFirst || !map || attachedRef.current) {\n return;\n }\n\n mapFirst.attachMap(map, {\n platform: \"maplibre\",\n maplibregl,\n onMarkerClick,\n });\n\n attachedRef.current = true;\n }, [mapFirst, map, maplibregl, onMarkerClick]);\n}\n\n/**\n * Hook for Google Maps integration.\n * Automatically attaches the map when both the SDK instance and map are available.\n *\n * @example\n * ```tsx\n * const { mapFirst, state } = useMapFirstCore({ initialLocationData: { city: \"Tokyo\", country: \"Japan\" } });\n * const mapRef = useRef<google.maps.Map | null>(null);\n *\n * useGoogleMapsAttachment({\n * mapFirst,\n * map: mapRef.current,\n * google: window.google,\n * onMarkerClick: (marker) => console.log(marker)\n * });\n *\n * // Access reactive state\n * console.log(state?.isSearching);\n * ```\n */\nexport function useGoogleMapsAttachment({\n mapFirst,\n map,\n google,\n onMarkerClick,\n}: {\n mapFirst: MapFirstCore | null;\n map: any | null;\n google: GoogleMapsNamespace;\n onMarkerClick?: (marker: Property) => void;\n}) {\n const attachedRef = React.useRef(false);\n\n React.useEffect(() => {\n if (!mapFirst || !map || attachedRef.current) {\n return;\n }\n\n mapFirst.attachMap(map, {\n platform: \"google\",\n google,\n onMarkerClick,\n });\n\n attachedRef.current = true;\n }, [mapFirst, map, google, onMarkerClick]);\n}\n\n/**\n * Hook for Mapbox GL JS integration.\n * Automatically attaches the map when both the SDK instance and map are available.\n *\n * @example\n * ```tsx\n * const { mapFirst, state } = useMapFirstCore({ initialLocationData: { city: \"London\", country: \"United Kingdom\" } });\n * const mapRef = useRef<mapboxgl.Map | null>(null);\n *\n * useMapboxAttachment({\n * mapFirst,\n * map: mapRef.current,\n * mapboxgl: mapboxgl,\n * onMarkerClick: (marker) => console.log(marker)\n * });\n *\n * // Access reactive state\n * console.log(state?.filters);\n * ```\n */\nexport function useMapboxAttachment({\n mapFirst,\n map,\n mapboxgl,\n onMarkerClick,\n}: {\n mapFirst: MapFirstCore | null;\n map: any | null;\n mapboxgl: MapboxNamespace;\n onMarkerClick?: (marker: Property) => void;\n}) {\n const attachedRef = React.useRef(false);\n\n React.useEffect(() => {\n if (!mapFirst || !map || attachedRef.current) {\n return;\n }\n\n mapFirst.attachMap(map, {\n platform: \"mapbox\",\n mapboxgl,\n onMarkerClick,\n });\n\n attachedRef.current = true;\n }, [mapFirst, map, mapboxgl, onMarkerClick]);\n}\n\n/**\n * Legacy hook that creates the MapFirstCore instance with a map immediately.\n * Use useMapFirstCore + useMap*Attachment hooks for better control.\n *\n * @deprecated Use useMapFirstCore and platform-specific attachment hooks instead\n */\nexport function useMapFirst(options: MapFirstOptions | null) {\n const instanceRef = React.useRef<MapFirstCore | null>(null);\n\n React.useEffect(() => {\n if (!options) {\n return undefined;\n }\n const instance = new MapFirstCore(options);\n instanceRef.current = instance;\n\n return () => {\n instance.destroy();\n instanceRef.current = null;\n };\n }, [options]);\n\n return instanceRef;\n}\n\n/**\n * Helper component that simply renders the markers it receives so non-React environments\n * can verify data flows before wiring the SDK into a map.\n */\nexport function MarkerDebugList({ markers }: { markers: Property[] }) {\n return (\n <div style={{ fontFamily: \"sans-serif\", fontSize: 14 }}>\n <strong>Markers</strong>\n <ul>\n {markers.map((marker) => (\n <li key={String(marker.tripadvisor_id)}>\n {marker.name} — {marker.location?.lat?.toFixed(3) ?? \"n/a\"},{\" \"}\n {marker.location?.lon?.toFixed(3) ?? \"n/a\"}\n </li>\n ))}\n </ul>\n </div>\n );\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,4BAAAC,EAAA,gBAAAC,EAAA,oBAAAC,EAAA,0BAAAC,EAAA,gCAAAC,EAAA,0BAAAC,EAAA,wBAAAC,EAAA,mBAAAC,EAAA,sBAAAC,IAAA,eAAAC,EAAAZ,GAAA,IAAAa,EAAkB,oBAClBC,EAUO,6BAocDC,EAAA,6BAlaC,SAASV,EAAgBW,EAA8B,CAC5D,IAAMC,EAAc,EAAAC,QAAM,OAA4B,IAAI,EACpD,CAACC,EAAOC,CAAQ,EAAI,EAAAF,QAAM,SAA0B,IAAI,EAGxDG,EAAa,EAAAH,QAAM,OAAOF,CAAO,EACvC,SAAAE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AACU,GAAOG,EAAY,UAIrCb,EAAS,UAAUU,EAAK,CACtB,SAAU,SACV,SAAAK,EACA,cAAAH,CACF,CAAC,EAEDC,EAAY,QAAU,GACxB,EAAG,CAACb,EAAUU,EAAKK,EAAUH,CAAa,CAAC,CAC7C,CAQO,SAAS9C,EAAYY,EAAiC,CAC3D,IAAMC,EAAc,EAAAC,QAAM,OAA4B,IAAI,EAE1D,SAAAA,QAAM,UAAU,IAAM,CACpB,GAAI,CAACF,EACH,OAEF,IAAMqB,EAAW,IAAI,eAAarB,CAAO,EACzC,OAAAC,EAAY,QAAUoB,EAEf,IAAM,CACXA,EAAS,QAAQ,EACjBpB,EAAY,QAAU,IACxB,CACF,EAAG,CAACD,CAAO,CAAC,EAELC,CACT,CAMO,SAASf,EAAgB,CAAE,QAAAoD,CAAQ,EAA4B,CACpE,SACE,QAAC,OAAI,MAAO,CAAE,WAAY,aAAc,SAAU,EAAG,EACnD,oBAAC,UAAO,mBAAO,KACf,OAAC,MACE,SAAAA,EAAQ,IAAKC,GAAQ,CAjd9B,IAAA9B,EAAAC,EAAA8B,EAAAC,EAAAC,EAAAC,EAkdU,iBAAC,MACE,UAAAJ,EAAO,KAAK,YAAIC,GAAA9B,GAAAD,EAAA8B,EAAO,WAAP,YAAA9B,EAAiB,MAAjB,YAAAC,EAAsB,QAAQ,KAA9B,KAAA8B,EAAoC,MAAM,IAAE,KAC5DG,GAAAD,GAAAD,EAAAF,EAAO,WAAP,YAAAE,EAAiB,MAAjB,YAAAC,EAAsB,QAAQ,KAA9B,KAAAC,EAAoC,QAF9B,OAAOJ,EAAO,cAAc,CAGrC,EACD,EACH,GACF,CAEJ","names":["index_exports","__export","MarkerDebugList","useGoogleMapsAttachment","useMapFirst","useMapFirstCore","useMapFirstProperties","useMapFirstSelectedProperty","useMapLibreAttachment","useMapboxAttachment","usePrimaryType","useSelectedMarker","__toCommonJS","import_react","import_core","import_jsx_runtime","options","instanceRef","React","state","setState","optionsRef","opts","coreOptions","properties","_a","_b","prev","id","type","filters","bounds","center","zoom","location","loading","searching","instance","mapFirst","setProperties","selectedId","setSelectedId","primaryType","setPrimaryTypeState","setPrimaryType","selectedMarker","setSelectedMarkerState","setSelectedMarker","map","maplibregl","onMarkerClick","attachedRef","google","mapboxgl","markers","marker","_c","_d","_e","_f"]}
1
+ {"version":3,"sources":["../src/index.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n MapFirstCore,\n type MapFirstOptions,\n type BaseMapFirstOptions,\n type Property,\n type MapLibreNamespace,\n type GoogleMapsNamespace,\n type MapboxNamespace,\n type MapState,\n type PropertyType,\n} from \"@mapfirst.ai/core\";\n\n/**\n * Hook that creates a MapFirstCore instance that can be initialized before maps are ready.\n * Supports two-phase initialization: create SDK first, attach map later.\n * Returns the instance and reactive state that updates when SDK state changes.\n *\n * @example\n * ```tsx\n * // Phase 1: Create SDK instance with location data\n * const { mapFirst, state } = useMapFirstCore({\n * initialLocationData: {\n * city: \"New York\",\n * country: \"United States\",\n * currency: \"USD\"\n * }\n * });\n *\n * // Access reactive state\n * console.log(state.properties); // Updates when properties change\n * console.log(state.isSearching); // Updates when search state changes\n *\n * // Phase 2: Attach map when ready\n * useEffect(() => {\n * if (mapLibreInstance && mapFirst) {\n * mapFirst.attachMap(mapLibreInstance, {\n * platform: \"maplibre\",\n * maplibregl: maplibregl,\n * onMarkerClick: (marker) => console.log(marker)\n * });\n * }\n * }, [mapLibreInstance, mapFirst]);\n * ```\n */\nexport function useMapFirstCore(options: BaseMapFirstOptions) {\n const instanceRef = React.useRef<MapFirstCore | null>(null);\n const [state, setState] = React.useState<MapState | null>(null);\n\n // Memoize the options to prevent recreation on every render\n const optionsRef = React.useRef(options);\n React.useEffect(() => {\n optionsRef.current = options;\n });\n\n React.useEffect(() => {\n const opts = optionsRef.current;\n\n // Create MapFirstCore instance without map using adapter-driven options\n const coreOptions: MapFirstOptions = {\n adapter: null as any, // Will be set when attachMap is called\n ...opts,\n callbacks: {\n ...opts.callbacks,\n // Add internal callbacks to trigger React re-renders\n onPropertiesChange: (properties) => {\n setState((prev) => (prev ? { ...prev, properties } : null));\n optionsRef.current.callbacks?.onPropertiesChange?.(properties);\n },\n onSelectedPropertyChange: (id) => {\n setState((prev) =>\n prev ? { ...prev, selectedPropertyId: id } : null\n );\n optionsRef.current.callbacks?.onSelectedPropertyChange?.(id);\n },\n onPrimaryTypeChange: (type) => {\n setState((prev) => (prev ? { ...prev, primary: type } : null));\n optionsRef.current.callbacks?.onPrimaryTypeChange?.(type);\n },\n onFiltersChange: (filters) => {\n setState((prev) => (prev ? { ...prev, filters } : null));\n optionsRef.current.callbacks?.onFiltersChange?.(filters);\n },\n onBoundsChange: (bounds) => {\n setState((prev) => (prev ? { ...prev, bounds } : null));\n optionsRef.current.callbacks?.onBoundsChange?.(bounds);\n },\n onCenterChange: (center, zoom) => {\n setState((prev) => (prev ? { ...prev, center, zoom } : null));\n optionsRef.current.callbacks?.onCenterChange?.(center, zoom);\n },\n onZoomChange: (zoom) => {\n setState((prev) => (prev ? { ...prev, zoom } : null));\n optionsRef.current.callbacks?.onZoomChange?.(zoom);\n },\n onActiveLocationChange: (location) => {\n setState((prev) =>\n prev ? { ...prev, activeLocation: location } : null\n );\n optionsRef.current.callbacks?.onActiveLocationChange?.(location);\n },\n onLoadingStateChange: (loading) => {\n setState((prev) =>\n prev ? { ...prev, initialLoading: loading } : null\n );\n optionsRef.current.callbacks?.onLoadingStateChange?.(loading);\n },\n onSearchingStateChange: (searching) => {\n setState((prev) =>\n prev ? { ...prev, isSearching: searching } : null\n );\n optionsRef.current.callbacks?.onSearchingStateChange?.(searching);\n },\n },\n };\n\n const instance = new MapFirstCore(coreOptions);\n instanceRef.current = instance;\n\n // Initialize state from SDK\n setState(instance.getState());\n\n return () => {\n instance.destroy();\n instanceRef.current = null;\n setState(null);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return { mapFirst: instanceRef.current, state };\n}\n\n/**\n * Hook to access reactive properties from MapFirst SDK.\n * Returns the current properties array that updates when properties change.\n *\n * @example\n * ```tsx\n * const { mapFirst } = useMapFirstCore({ ... });\n * const properties = useMapFirstProperties(mapFirst);\n *\n * return <div>Found {properties.length} properties</div>;\n * ```\n */\nexport function useMapFirstProperties(\n mapFirst: MapFirstCore | null\n): Property[] {\n const [properties, setProperties] = React.useState<Property[]>([]);\n\n React.useEffect(() => {\n if (!mapFirst) {\n setProperties([]);\n return;\n }\n\n // Initialize with current state\n setProperties(mapFirst.getState().properties);\n }, [mapFirst]);\n\n return properties;\n}\n\n/**\n * Hook to access the selected property ID from MapFirst SDK.\n * Returns the currently selected property ID that updates when selection changes.\n *\n * @example\n * ```tsx\n * const { mapFirst } = useMapFirstCore({ ... });\n * const selectedId = useMapFirstSelectedProperty(mapFirst);\n *\n * return <div>Selected: {selectedId || 'None'}</div>;\n * ```\n */\nexport function useMapFirstSelectedProperty(\n mapFirst: MapFirstCore | null\n): number | null {\n const [selectedId, setSelectedId] = React.useState<number | null>(null);\n\n React.useEffect(() => {\n if (!mapFirst) {\n setSelectedId(null);\n return;\n }\n\n // Initialize with current state\n setSelectedId(mapFirst.getState().selectedPropertyId);\n }, [mapFirst]);\n\n return selectedId;\n}\n\n/**\n * Hook to access and control the primary property type.\n * Returns the current primary type and a setter function.\n *\n * @example\n * ```tsx\n * const { mapFirst } = useMapFirstCore({ ... });\n * const [primaryType, setPrimaryType] = usePrimaryType(mapFirst);\n *\n * return (\n * <select value={primaryType} onChange={(e) => setPrimaryType(e.target.value as PropertyType)}>\n * <option value=\"Accommodation\">Hotels</option>\n * <option value=\"Restaurant\">Restaurants</option>\n * <option value=\"Attraction\">Attractions</option>\n * </select>\n * );\n * ```\n */\nexport function usePrimaryType(\n mapFirst: MapFirstCore | null\n): [PropertyType, (type: PropertyType) => void] {\n const [primaryType, setPrimaryTypeState] =\n React.useState<PropertyType>(\"Accommodation\");\n\n React.useEffect(() => {\n if (!mapFirst) {\n setPrimaryTypeState(\"Accommodation\");\n return;\n }\n\n // Initialize with current state\n setPrimaryTypeState(mapFirst.getState().primary);\n }, [mapFirst]);\n\n const setPrimaryType = React.useCallback(\n (type: PropertyType) => {\n if (mapFirst) {\n mapFirst.setPrimaryType(type);\n setPrimaryTypeState(type);\n }\n },\n [mapFirst]\n );\n\n return [primaryType, setPrimaryType];\n}\n\n/**\n * Hook to access and control the selected marker.\n * Returns the current selected marker ID and a setter function.\n * Note: This hook requires the MapFirstCore instance. For simpler usage with reactive updates,\n * use state.selectedPropertyId from useMapFirstCore instead.\n *\n * @example\n * ```tsx\n * const { mapFirst } = useMapFirstCore({ ... });\n * const [selectedMarker, setSelectedMarker] = useSelectedMarker(mapFirst);\n *\n * return (\n * <div>\n * <p>Selected: {selectedMarker || 'None'}</p>\n * <button onClick={() => setSelectedMarker(null)}>Clear Selection</button>\n * </div>\n * );\n * ```\n */\nexport function useSelectedMarker(\n mapFirst: MapFirstCore | null\n): [number | null, (id: number | null) => void] {\n const [selectedMarker, setSelectedMarkerState] = React.useState<\n number | null\n >(null);\n\n React.useEffect(() => {\n if (!mapFirst) {\n setSelectedMarkerState(null);\n return;\n }\n\n // Initialize with current state\n setSelectedMarkerState(mapFirst.getState().selectedPropertyId);\n }, [mapFirst]);\n\n const setSelectedMarker = React.useCallback(\n (id: number | null) => {\n if (mapFirst) {\n mapFirst.setSelectedMarker(id);\n }\n },\n [mapFirst]\n );\n\n return [selectedMarker, setSelectedMarker];\n}\n\n/**\n * Hook for MapLibre GL JS integration.\n * Automatically attaches the map when both the SDK instance and map are available.\n *\n * @example\n * ```tsx\n * const { mapFirst, state } = useMapFirstCore({ initialLocationData: { city: \"Paris\", country: \"France\" } });\n * const mapRef = useRef<maplibregl.Map | null>(null);\n *\n * useMapLibreAttachment({\n * mapFirst,\n * map: mapRef.current,\n * maplibregl: maplibregl,\n * onMarkerClick: (marker) => console.log(marker)\n * });\n *\n * // Access reactive state\n * console.log(state?.properties);\n * ```\n */\nexport function useMapLibreAttachment({\n mapFirst,\n map,\n maplibregl,\n onMarkerClick,\n}: {\n mapFirst: MapFirstCore | null;\n map: any | null;\n maplibregl: MapLibreNamespace;\n onMarkerClick?: (marker: Property) => void;\n}) {\n const attachedRef = React.useRef(false);\n\n React.useEffect(() => {\n if (!mapFirst || !map || attachedRef.current) {\n return;\n }\n\n mapFirst.attachMap(map, {\n platform: \"maplibre\",\n maplibregl,\n onMarkerClick,\n });\n\n attachedRef.current = true;\n }, [mapFirst, map, maplibregl, onMarkerClick]);\n}\n\n/**\n * Hook for Google Maps integration.\n * Automatically attaches the map when both the SDK instance and map are available.\n *\n * @example\n * ```tsx\n * const { mapFirst, state } = useMapFirstCore({ initialLocationData: { city: \"Tokyo\", country: \"Japan\" } });\n * const mapRef = useRef<google.maps.Map | null>(null);\n *\n * useGoogleMapsAttachment({\n * mapFirst,\n * map: mapRef.current,\n * google: window.google,\n * onMarkerClick: (marker) => console.log(marker)\n * });\n *\n * // Access reactive state\n * console.log(state?.isSearching);\n * ```\n */\nexport function useGoogleMapsAttachment({\n mapFirst,\n map,\n google,\n onMarkerClick,\n}: {\n mapFirst: MapFirstCore | null;\n map: any | null;\n google: GoogleMapsNamespace;\n onMarkerClick?: (marker: Property) => void;\n}) {\n const attachedRef = React.useRef(false);\n\n React.useEffect(() => {\n if (!mapFirst || !map || attachedRef.current) {\n return;\n }\n\n mapFirst.attachMap(map, {\n platform: \"google\",\n google,\n onMarkerClick,\n });\n\n attachedRef.current = true;\n }, [mapFirst, map, google, onMarkerClick]);\n}\n\n/**\n * Hook for Mapbox GL JS integration.\n * Automatically attaches the map when both the SDK instance and map are available.\n *\n * @example\n * ```tsx\n * const { mapFirst, state } = useMapFirstCore({ initialLocationData: { city: \"London\", country: \"United Kingdom\" } });\n * const mapRef = useRef<mapboxgl.Map | null>(null);\n *\n * useMapboxAttachment({\n * mapFirst,\n * map: mapRef.current,\n * mapboxgl: mapboxgl,\n * onMarkerClick: (marker) => console.log(marker)\n * });\n *\n * // Access reactive state\n * console.log(state?.filters);\n * ```\n */\nexport function useMapboxAttachment({\n mapFirst,\n map,\n mapboxgl,\n onMarkerClick,\n}: {\n mapFirst: MapFirstCore | null;\n map: any | null;\n mapboxgl: MapboxNamespace;\n onMarkerClick?: (marker: Property) => void;\n}) {\n const attachedRef = React.useRef(false);\n\n React.useEffect(() => {\n if (!mapFirst || !map || attachedRef.current) {\n return;\n }\n\n mapFirst.attachMap(map, {\n platform: \"mapbox\",\n mapboxgl,\n onMarkerClick,\n });\n\n attachedRef.current = true;\n }, [mapFirst, map, mapboxgl, onMarkerClick]);\n}\n\n/**\n * Legacy hook that creates the MapFirstCore instance with a map immediately.\n * Use useMapFirstCore + useMap*Attachment hooks for better control.\n *\n * @deprecated Use useMapFirstCore and platform-specific attachment hooks instead\n */\nexport function useMapFirst(options: MapFirstOptions | null) {\n const instanceRef = React.useRef<MapFirstCore | null>(null);\n\n React.useEffect(() => {\n if (!options) {\n return undefined;\n }\n const instance = new MapFirstCore(options);\n instanceRef.current = instance;\n\n return () => {\n instance.destroy();\n instanceRef.current = null;\n };\n }, [options]);\n\n return instanceRef;\n}\n\n/**\n * Helper component that simply renders the markers it receives so non-React environments\n * can verify data flows before wiring the SDK into a map.\n */\nexport function MarkerDebugList({ markers }: { markers: Property[] }) {\n return (\n <div style={{ fontFamily: \"sans-serif\", fontSize: 14 }}>\n <strong>Markers</strong>\n <ul>\n {markers.map((marker) => (\n <li key={String(marker.tripadvisor_id)}>\n {marker.name} — {marker.location?.lat?.toFixed(3) ?? \"n/a\"},{\" \"}\n {marker.location?.lon?.toFixed(3) ?? \"n/a\"}\n </li>\n ))}\n </ul>\n </div>\n );\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,4BAAAC,EAAA,gBAAAC,EAAA,oBAAAC,EAAA,0BAAAC,EAAA,gCAAAC,EAAA,0BAAAC,EAAA,wBAAAC,EAAA,mBAAAC,EAAA,sBAAAC,IAAA,eAAAC,EAAAZ,GAAA,IAAAa,EAAkB,oB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erDebugList","useGoogleMapsAttachment","useMapFirst","useMapFirstCore","useMapFirstProperties","useMapFirstSelectedProperty","useMapLibreAttachment","useMapboxAttachment","usePrimaryType","useSelectedMarker","__toCommonJS","import_react","import_core","import_jsx_runtime","options","instanceRef","React","state","setState","optionsRef","opts","coreOptions","properties","_a","_b","prev","id","type","filters","bounds","center","zoom","location","loading","searching","instance","mapFirst","setProperties","selectedId","setSelectedId","primaryType","setPrimaryTypeState","setPrimaryType","selectedMarker","setSelectedMarkerState","setSelectedMarker","map","maplibregl","onMarkerClick","attachedRef","google","mapboxgl","markers","marker","_c","_d","_e","_f"]}
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import s from"react";import{MapFirstCore as g}from"@mapfirst.ai/core";import{jsx as d,jsxs as M}from"react/jsx-runtime";function h(t){let n=s.useRef(null),[a,c]=s.useState(null),o=s.useRef(t);return s.useEffect(()=>{o.current=t}),s.useEffect(()=>{let p=o.current,f={adapter:null,...p,callbacks:{...p.callbacks,onPropertiesChange:l=>{var e,r;c(u=>u?{...u,properties:l}:null),(r=(e=o.current.callbacks)==null?void 0:e.onPropertiesChange)==null||r.call(e,l)},onSelectedPropertyChange:l=>{var e,r;c(u=>u?{...u,selectedPropertyId:l}:null),(r=(e=o.current.callbacks)==null?void 0:e.onSelectedPropertyChange)==null||r.call(e,l)},onPrimaryTypeChange:l=>{var e,r;c(u=>u?{...u,primary:l}:null),(r=(e=o.current.callbacks)==null?void 0:e.onPrimaryTypeChange)==null||r.call(e,l)},onFiltersChange:l=>{var e,r;c(u=>u?{...u,filters:l}:null),(r=(e=o.current.callbacks)==null?void 0:e.onFiltersChange)==null||r.call(e,l)},onBoundsChange:l=>{var e,r;c(u=>u?{...u,bounds:l}:null),(r=(e=o.current.callbacks)==null?void 0:e.onBoundsChange)==null||r.call(e,l)},onCenterChange:(l,e)=>{var r,u;c(y=>y?{...y,center:l,zoom:e}:null),(u=(r=o.current.callbacks)==null?void 0:r.onCenterChange)==null||u.call(r,l,e)},onZoomChange:l=>{var e,r;c(u=>u?{...u,zoom:l}:null),(r=(e=o.current.callbacks)==null?void 0:e.onZoomChange)==null||r.call(e,l)},onActiveLocationChange:l=>{var e,r;c(u=>u?{...u,activeLocation:l}:null),(r=(e=o.current.callbacks)==null?void 0:e.onActiveLocationChange)==null||r.call(e,l)},onLoadingStateChange:l=>{var e,r;c(u=>u?{...u,initialLoading:l}:null),(r=(e=o.current.callbacks)==null?void 0:e.onLoadingStateChange)==null||r.call(e,l)},onSearchingStateChange:l=>{var e,r;c(u=>u?{...u,isSearching:l}:null),(r=(e=o.current.callbacks)==null?void 0:e.onSearchingStateChange)==null||r.call(e,l)}}},i=new g(f);return n.current=i,c(i.getState()),()=>{i.destroy(),n.current=null,c(null)}},[]),{mapFirst:n.current,state:a}}function b(t){let[n,a]=s.useState([]);return s.useEffect(()=>{if(!t){a([]);return}a(t.getState().properties)},[t]),n}function P(t){let[n,a]=s.useState(null);return s.useEffect(()=>{if(!t){a(null);return}a(t.getState().selectedPropertyId)},[t]),n}function k(t){let[n,a]=s.useState("Accommodation");s.useEffect(()=>{if(!t){a("Accommodation");return}a(t.getState().primary)},[t]);let c=s.useCallback(o=>{t&&(t.setPrimaryType(o),a(o))},[t]);return[n,c]}function m(t){let[n,a]=s.useState(null);s.useEffect(()=>{if(!t){a(null);return}a(t.getState().selectedPropertyId)},[t]);let c=s.useCallback(o=>{t&&(t.setSelectedMarker(o),a(o))},[t]);return[n,c]}function x({mapFirst:t,map:n,maplibregl:a,onMarkerClick:c}){let o=s.useRef(!1);s.useEffect(()=>{!t||!n||o.current||(t.attachMap(n,{platform:"maplibre",maplibregl:a,onMarkerClick:c}),o.current=!0)},[t,n,a,c])}function R({mapFirst:t,map:n,google:a,onMarkerClick:c}){let o=s.useRef(!1);s.useEffect(()=>{!t||!n||o.current||(t.attachMap(n,{platform:"google",google:a,onMarkerClick:c}),o.current=!0)},[t,n,a,c])}function T({mapFirst:t,map:n,mapboxgl:a,onMarkerClick:c}){let o=s.useRef(!1);s.useEffect(()=>{!t||!n||o.current||(t.attachMap(n,{platform:"mapbox",mapboxgl:a,onMarkerClick:c}),o.current=!0)},[t,n,a,c])}function E(t){let n=s.useRef(null);return s.useEffect(()=>{if(!t)return;let a=new g(t);return n.current=a,()=>{a.destroy(),n.current=null}},[t]),n}function L({markers:t}){return M("div",{style:{fontFamily:"sans-serif",fontSize:14},children:[d("strong",{children:"Markers"}),d("ul",{children:t.map(n=>{var a,c,o,p,f,i;return M("li",{children:[n.name," \u2014 ",(o=(c=(a=n.location)==null?void 0:a.lat)==null?void 0:c.toFixed(3))!=null?o:"n/a",","," ",(i=(f=(p=n.location)==null?void 0:p.lon)==null?void 0:f.toFixed(3))!=null?i:"n/a"]},String(n.tripadvisor_id))})})]})}export{L as MarkerDebugList,R as useGoogleMapsAttachment,E as useMapFirst,h as useMapFirstCore,b as useMapFirstProperties,P as useMapFirstSelectedProperty,x as useMapLibreAttachment,T as useMapboxAttachment,k as usePrimaryType,m as useSelectedMarker};
1
+ import s from"react";import{MapFirstCore as g}from"@mapfirst.ai/core";import{jsx as d,jsxs as M}from"react/jsx-runtime";function h(t){let n=s.useRef(null),[a,c]=s.useState(null),o=s.useRef(t);return s.useEffect(()=>{o.current=t}),s.useEffect(()=>{let p=o.current,f={adapter:null,...p,callbacks:{...p.callbacks,onPropertiesChange:l=>{var e,r;c(u=>u?{...u,properties:l}:null),(r=(e=o.current.callbacks)==null?void 0:e.onPropertiesChange)==null||r.call(e,l)},onSelectedPropertyChange:l=>{var e,r;c(u=>u?{...u,selectedPropertyId:l}:null),(r=(e=o.current.callbacks)==null?void 0:e.onSelectedPropertyChange)==null||r.call(e,l)},onPrimaryTypeChange:l=>{var e,r;c(u=>u?{...u,primary:l}:null),(r=(e=o.current.callbacks)==null?void 0:e.onPrimaryTypeChange)==null||r.call(e,l)},onFiltersChange:l=>{var e,r;c(u=>u?{...u,filters:l}:null),(r=(e=o.current.callbacks)==null?void 0:e.onFiltersChange)==null||r.call(e,l)},onBoundsChange:l=>{var e,r;c(u=>u?{...u,bounds:l}:null),(r=(e=o.current.callbacks)==null?void 0:e.onBoundsChange)==null||r.call(e,l)},onCenterChange:(l,e)=>{var r,u;c(y=>y?{...y,center:l,zoom:e}:null),(u=(r=o.current.callbacks)==null?void 0:r.onCenterChange)==null||u.call(r,l,e)},onZoomChange:l=>{var e,r;c(u=>u?{...u,zoom:l}:null),(r=(e=o.current.callbacks)==null?void 0:e.onZoomChange)==null||r.call(e,l)},onActiveLocationChange:l=>{var e,r;c(u=>u?{...u,activeLocation:l}:null),(r=(e=o.current.callbacks)==null?void 0:e.onActiveLocationChange)==null||r.call(e,l)},onLoadingStateChange:l=>{var e,r;c(u=>u?{...u,initialLoading:l}:null),(r=(e=o.current.callbacks)==null?void 0:e.onLoadingStateChange)==null||r.call(e,l)},onSearchingStateChange:l=>{var e,r;c(u=>u?{...u,isSearching:l}:null),(r=(e=o.current.callbacks)==null?void 0:e.onSearchingStateChange)==null||r.call(e,l)}}},i=new g(f);return n.current=i,c(i.getState()),()=>{i.destroy(),n.current=null,c(null)}},[]),{mapFirst:n.current,state:a}}function b(t){let[n,a]=s.useState([]);return s.useEffect(()=>{if(!t){a([]);return}a(t.getState().properties)},[t]),n}function P(t){let[n,a]=s.useState(null);return s.useEffect(()=>{if(!t){a(null);return}a(t.getState().selectedPropertyId)},[t]),n}function k(t){let[n,a]=s.useState("Accommodation");s.useEffect(()=>{if(!t){a("Accommodation");return}a(t.getState().primary)},[t]);let c=s.useCallback(o=>{t&&(t.setPrimaryType(o),a(o))},[t]);return[n,c]}function m(t){let[n,a]=s.useState(null);s.useEffect(()=>{if(!t){a(null);return}a(t.getState().selectedPropertyId)},[t]);let c=s.useCallback(o=>{t&&t.setSelectedMarker(o)},[t]);return[n,c]}function x({mapFirst:t,map:n,maplibregl:a,onMarkerClick:c}){let o=s.useRef(!1);s.useEffect(()=>{!t||!n||o.current||(t.attachMap(n,{platform:"maplibre",maplibregl:a,onMarkerClick:c}),o.current=!0)},[t,n,a,c])}function R({mapFirst:t,map:n,google:a,onMarkerClick:c}){let o=s.useRef(!1);s.useEffect(()=>{!t||!n||o.current||(t.attachMap(n,{platform:"google",google:a,onMarkerClick:c}),o.current=!0)},[t,n,a,c])}function T({mapFirst:t,map:n,mapboxgl:a,onMarkerClick:c}){let o=s.useRef(!1);s.useEffect(()=>{!t||!n||o.current||(t.attachMap(n,{platform:"mapbox",mapboxgl:a,onMarkerClick:c}),o.current=!0)},[t,n,a,c])}function E(t){let n=s.useRef(null);return s.useEffect(()=>{if(!t)return;let a=new g(t);return n.current=a,()=>{a.destroy(),n.current=null}},[t]),n}function L({markers:t}){return M("div",{style:{fontFamily:"sans-serif",fontSize:14},children:[d("strong",{children:"Markers"}),d("ul",{children:t.map(n=>{var a,c,o,p,f,i;return M("li",{children:[n.name," \u2014 ",(o=(c=(a=n.location)==null?void 0:a.lat)==null?void 0:c.toFixed(3))!=null?o:"n/a",","," ",(i=(f=(p=n.location)==null?void 0:p.lon)==null?void 0:f.toFixed(3))!=null?i:"n/a"]},String(n.tripadvisor_id))})})]})}export{L as MarkerDebugList,R as useGoogleMapsAttachment,E as useMapFirst,h as useMapFirstCore,b as useMapFirstProperties,P as useMapFirstSelectedProperty,x as useMapLibreAttachment,T as useMapboxAttachment,k as usePrimaryType,m as useSelectedMarker};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n MapFirstCore,\n type MapFirstOptions,\n type BaseMapFirstOptions,\n type Property,\n type MapLibreNamespace,\n type GoogleMapsNamespace,\n type MapboxNamespace,\n type MapState,\n type PropertyType,\n} from \"@mapfirst.ai/core\";\n\n/**\n * Hook that creates a MapFirstCore instance that can be initialized before maps are ready.\n * Supports two-phase initialization: create SDK first, attach map later.\n * Returns the instance and reactive state that updates when SDK state changes.\n *\n * @example\n * ```tsx\n * // Phase 1: Create SDK instance with location data\n * const { mapFirst, state } = useMapFirstCore({\n * initialLocationData: {\n * city: \"New York\",\n * country: \"United States\",\n * currency: \"USD\"\n * }\n * });\n *\n * // Access reactive state\n * console.log(state.properties); // Updates when properties change\n * console.log(state.isSearching); // Updates when search state changes\n *\n * // Phase 2: Attach map when ready\n * useEffect(() => {\n * if (mapLibreInstance && mapFirst) {\n * mapFirst.attachMap(mapLibreInstance, {\n * platform: \"maplibre\",\n * maplibregl: maplibregl,\n * onMarkerClick: (marker) => console.log(marker)\n * });\n * }\n * }, [mapLibreInstance, mapFirst]);\n * ```\n */\nexport function useMapFirstCore(options: BaseMapFirstOptions) {\n const instanceRef = React.useRef<MapFirstCore | null>(null);\n const [state, setState] = React.useState<MapState | null>(null);\n\n // Memoize the options to prevent recreation on every render\n const optionsRef = React.useRef(options);\n React.useEffect(() => {\n optionsRef.current = options;\n });\n\n React.useEffect(() => {\n const opts = optionsRef.current;\n\n // Create MapFirstCore instance without map using adapter-driven options\n const coreOptions: MapFirstOptions = {\n adapter: null as any, // Will be set when attachMap is called\n ...opts,\n callbacks: {\n ...opts.callbacks,\n // Add internal callbacks to trigger React re-renders\n onPropertiesChange: (properties) => {\n setState((prev) => (prev ? { ...prev, properties } : null));\n optionsRef.current.callbacks?.onPropertiesChange?.(properties);\n },\n onSelectedPropertyChange: (id) => {\n setState((prev) =>\n prev ? { ...prev, selectedPropertyId: id } : null\n );\n optionsRef.current.callbacks?.onSelectedPropertyChange?.(id);\n },\n onPrimaryTypeChange: (type) => {\n setState((prev) => (prev ? { ...prev, primary: type } : null));\n optionsRef.current.callbacks?.onPrimaryTypeChange?.(type);\n },\n onFiltersChange: (filters) => {\n setState((prev) => (prev ? { ...prev, filters } : null));\n optionsRef.current.callbacks?.onFiltersChange?.(filters);\n },\n onBoundsChange: (bounds) => {\n setState((prev) => (prev ? { ...prev, bounds } : null));\n optionsRef.current.callbacks?.onBoundsChange?.(bounds);\n },\n onCenterChange: (center, zoom) => {\n setState((prev) => (prev ? { ...prev, center, zoom } : null));\n optionsRef.current.callbacks?.onCenterChange?.(center, zoom);\n },\n onZoomChange: (zoom) => {\n setState((prev) => (prev ? { ...prev, zoom } : null));\n optionsRef.current.callbacks?.onZoomChange?.(zoom);\n },\n onActiveLocationChange: (location) => {\n setState((prev) =>\n prev ? { ...prev, activeLocation: location } : null\n );\n optionsRef.current.callbacks?.onActiveLocationChange?.(location);\n },\n onLoadingStateChange: (loading) => {\n setState((prev) =>\n prev ? { ...prev, initialLoading: loading } : null\n );\n optionsRef.current.callbacks?.onLoadingStateChange?.(loading);\n },\n onSearchingStateChange: (searching) => {\n setState((prev) =>\n prev ? { ...prev, isSearching: searching } : null\n );\n optionsRef.current.callbacks?.onSearchingStateChange?.(searching);\n },\n },\n };\n\n const instance = new MapFirstCore(coreOptions);\n instanceRef.current = instance;\n\n // Initialize state from SDK\n setState(instance.getState());\n\n return () => {\n instance.destroy();\n instanceRef.current = null;\n setState(null);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return { mapFirst: instanceRef.current, state };\n}\n\n/**\n * Hook to access reactive properties from MapFirst SDK.\n * Returns the current properties array that updates when properties change.\n *\n * @example\n * ```tsx\n * const { mapFirst } = useMapFirstCore({ ... });\n * const properties = useMapFirstProperties(mapFirst);\n *\n * return <div>Found {properties.length} properties</div>;\n * ```\n */\nexport function useMapFirstProperties(\n mapFirst: MapFirstCore | null\n): Property[] {\n const [properties, setProperties] = React.useState<Property[]>([]);\n\n React.useEffect(() => {\n if (!mapFirst) {\n setProperties([]);\n return;\n }\n\n // Initialize with current state\n setProperties(mapFirst.getState().properties);\n }, [mapFirst]);\n\n return properties;\n}\n\n/**\n * Hook to access the selected property ID from MapFirst SDK.\n * Returns the currently selected property ID that updates when selection changes.\n *\n * @example\n * ```tsx\n * const { mapFirst } = useMapFirstCore({ ... });\n * const selectedId = useMapFirstSelectedProperty(mapFirst);\n *\n * return <div>Selected: {selectedId || 'None'}</div>;\n * ```\n */\nexport function useMapFirstSelectedProperty(\n mapFirst: MapFirstCore | null\n): number | null {\n const [selectedId, setSelectedId] = React.useState<number | null>(null);\n\n React.useEffect(() => {\n if (!mapFirst) {\n setSelectedId(null);\n return;\n }\n\n // Initialize with current state\n setSelectedId(mapFirst.getState().selectedPropertyId);\n }, [mapFirst]);\n\n return selectedId;\n}\n\n/**\n * Hook to access and control the primary property type.\n * Returns the current primary type and a setter function.\n *\n * @example\n * ```tsx\n * const { mapFirst } = useMapFirstCore({ ... });\n * const [primaryType, setPrimaryType] = usePrimaryType(mapFirst);\n *\n * return (\n * <select value={primaryType} onChange={(e) => setPrimaryType(e.target.value as PropertyType)}>\n * <option value=\"Accommodation\">Hotels</option>\n * <option value=\"Restaurant\">Restaurants</option>\n * <option value=\"Attraction\">Attractions</option>\n * </select>\n * );\n * ```\n */\nexport function usePrimaryType(\n mapFirst: MapFirstCore | null\n): [PropertyType, (type: PropertyType) => void] {\n const [primaryType, setPrimaryTypeState] =\n React.useState<PropertyType>(\"Accommodation\");\n\n React.useEffect(() => {\n if (!mapFirst) {\n setPrimaryTypeState(\"Accommodation\");\n return;\n }\n\n // Initialize with current state\n setPrimaryTypeState(mapFirst.getState().primary);\n }, [mapFirst]);\n\n const setPrimaryType = React.useCallback(\n (type: PropertyType) => {\n if (mapFirst) {\n mapFirst.setPrimaryType(type);\n setPrimaryTypeState(type);\n }\n },\n [mapFirst]\n );\n\n return [primaryType, setPrimaryType];\n}\n\n/**\n * Hook to access and control the selected marker.\n * Returns the current selected marker ID and a setter function.\n *\n * @example\n * ```tsx\n * const { mapFirst } = useMapFirstCore({ ... });\n * const [selectedMarker, setSelectedMarker] = useSelectedMarker(mapFirst);\n *\n * return (\n * <div>\n * <p>Selected: {selectedMarker || 'None'}</p>\n * <button onClick={() => setSelectedMarker(null)}>Clear Selection</button>\n * </div>\n * );\n * ```\n */\nexport function useSelectedMarker(\n mapFirst: MapFirstCore | null\n): [number | null, (id: number | null) => void] {\n const [selectedMarker, setSelectedMarkerState] = React.useState<\n number | null\n >(null);\n\n React.useEffect(() => {\n if (!mapFirst) {\n setSelectedMarkerState(null);\n return;\n }\n\n // Initialize with current state\n setSelectedMarkerState(mapFirst.getState().selectedPropertyId);\n }, [mapFirst]);\n\n const setSelectedMarker = React.useCallback(\n (id: number | null) => {\n if (mapFirst) {\n mapFirst.setSelectedMarker(id);\n setSelectedMarkerState(id);\n }\n },\n [mapFirst]\n );\n\n return [selectedMarker, setSelectedMarker];\n}\n\n/**\n * Hook for MapLibre GL JS integration.\n * Automatically attaches the map when both the SDK instance and map are available.\n *\n * @example\n * ```tsx\n * const { mapFirst, state } = useMapFirstCore({ initialLocationData: { city: \"Paris\", country: \"France\" } });\n * const mapRef = useRef<maplibregl.Map | null>(null);\n *\n * useMapLibreAttachment({\n * mapFirst,\n * map: mapRef.current,\n * maplibregl: maplibregl,\n * onMarkerClick: (marker) => console.log(marker)\n * });\n *\n * // Access reactive state\n * console.log(state?.properties);\n * ```\n */\nexport function useMapLibreAttachment({\n mapFirst,\n map,\n maplibregl,\n onMarkerClick,\n}: {\n mapFirst: MapFirstCore | null;\n map: any | null;\n maplibregl: MapLibreNamespace;\n onMarkerClick?: (marker: Property) => void;\n}) {\n const attachedRef = React.useRef(false);\n\n React.useEffect(() => {\n if (!mapFirst || !map || attachedRef.current) {\n return;\n }\n\n mapFirst.attachMap(map, {\n platform: \"maplibre\",\n maplibregl,\n onMarkerClick,\n });\n\n attachedRef.current = true;\n }, [mapFirst, map, maplibregl, onMarkerClick]);\n}\n\n/**\n * Hook for Google Maps integration.\n * Automatically attaches the map when both the SDK instance and map are available.\n *\n * @example\n * ```tsx\n * const { mapFirst, state } = useMapFirstCore({ initialLocationData: { city: \"Tokyo\", country: \"Japan\" } });\n * const mapRef = useRef<google.maps.Map | null>(null);\n *\n * useGoogleMapsAttachment({\n * mapFirst,\n * map: mapRef.current,\n * google: window.google,\n * onMarkerClick: (marker) => console.log(marker)\n * });\n *\n * // Access reactive state\n * console.log(state?.isSearching);\n * ```\n */\nexport function useGoogleMapsAttachment({\n mapFirst,\n map,\n google,\n onMarkerClick,\n}: {\n mapFirst: MapFirstCore | null;\n map: any | null;\n google: GoogleMapsNamespace;\n onMarkerClick?: (marker: Property) => void;\n}) {\n const attachedRef = React.useRef(false);\n\n React.useEffect(() => {\n if (!mapFirst || !map || attachedRef.current) {\n return;\n }\n\n mapFirst.attachMap(map, {\n platform: \"google\",\n google,\n onMarkerClick,\n });\n\n attachedRef.current = true;\n }, [mapFirst, map, google, onMarkerClick]);\n}\n\n/**\n * Hook for Mapbox GL JS integration.\n * Automatically attaches the map when both the SDK instance and map are available.\n *\n * @example\n * ```tsx\n * const { mapFirst, state } = useMapFirstCore({ initialLocationData: { city: \"London\", country: \"United Kingdom\" } });\n * const mapRef = useRef<mapboxgl.Map | null>(null);\n *\n * useMapboxAttachment({\n * mapFirst,\n * map: mapRef.current,\n * mapboxgl: mapboxgl,\n * onMarkerClick: (marker) => console.log(marker)\n * });\n *\n * // Access reactive state\n * console.log(state?.filters);\n * ```\n */\nexport function useMapboxAttachment({\n mapFirst,\n map,\n mapboxgl,\n onMarkerClick,\n}: {\n mapFirst: MapFirstCore | null;\n map: any | null;\n mapboxgl: MapboxNamespace;\n onMarkerClick?: (marker: Property) => void;\n}) {\n const attachedRef = React.useRef(false);\n\n React.useEffect(() => {\n if (!mapFirst || !map || attachedRef.current) {\n return;\n }\n\n mapFirst.attachMap(map, {\n platform: \"mapbox\",\n mapboxgl,\n onMarkerClick,\n });\n\n attachedRef.current = true;\n }, [mapFirst, map, mapboxgl, onMarkerClick]);\n}\n\n/**\n * Legacy hook that creates the MapFirstCore instance with a map immediately.\n * Use useMapFirstCore + useMap*Attachment hooks for better control.\n *\n * @deprecated Use useMapFirstCore and platform-specific attachment hooks instead\n */\nexport function useMapFirst(options: MapFirstOptions | null) {\n const instanceRef = React.useRef<MapFirstCore | null>(null);\n\n React.useEffect(() => {\n if (!options) {\n return undefined;\n }\n const instance = new MapFirstCore(options);\n instanceRef.current = instance;\n\n return () => {\n instance.destroy();\n instanceRef.current = null;\n };\n }, [options]);\n\n return instanceRef;\n}\n\n/**\n * Helper component that simply renders the markers it receives so non-React environments\n * can verify data flows before wiring the SDK into a map.\n */\nexport function MarkerDebugList({ markers }: { markers: Property[] }) {\n return (\n <div style={{ fontFamily: \"sans-serif\", fontSize: 14 }}>\n <strong>Markers</strong>\n <ul>\n {markers.map((marker) => (\n <li key={String(marker.tripadvisor_id)}>\n {marker.name} — {marker.location?.lat?.toFixed(3) ?? \"n/a\"},{\" \"}\n {marker.location?.lon?.toFixed(3) ?? \"n/a\"}\n </li>\n ))}\n </ul>\n </div>\n );\n}\n"],"mappings":"AAAA,OAAOA,MAAW,QAClB,OACE,gBAAAC,MASK,oBAocD,cAAAC,EAGI,QAAAC,MAHJ,oBAlaC,SAASC,EAAgBC,EAA8B,CAC5D,IAAMC,EAAcN,EAAM,OAA4B,IAAI,EACpD,CAACO,EAAOC,CAAQ,EAAIR,EAAM,SAA0B,IAAI,EAGxDS,EAAaT,EAAM,OAAOK,CAAO,EACvC,OAAAL,EAAM,UAAU,IAAM,CACpBS,EAAW,QAAUJ,CACvB,CAAC,EAEDL,EAAM,UAAU,IAAM,CACpB,IAAMU,EAAOD,EAAW,QAGlBE,EAA+B,CACnC,QAAS,KACT,GAAGD,EACH,UAAW,CACT,GAAGA,EAAK,UAER,mBAAqBE,GAAe,CAjE5C,IAAAC,EAAAC,EAkEUN,EAAUO,GAAUA,EAAO,CAAE,GAAGA,EAAM,WAAAH,CAAW,EAAI,IAAK,GAC1DE,GAAAD,EAAAJ,EAAW,QAAQ,YAAnB,YAAAI,EAA8B,qBAA9B,MAAAC,EAAA,KAAAD,EAAmDD,EACrD,EACA,yBAA2BI,GAAO,CArE1C,IAAAH,EAAAC,EAsEUN,EAAUO,GACRA,EAAO,CAAE,GAAGA,EAAM,mBAAoBC,CAAG,EAAI,IAC/C,GACAF,GAAAD,EAAAJ,EAAW,QAAQ,YAAnB,YAAAI,EAA8B,2BAA9B,MAAAC,EAAA,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,EAAAC,EAAAuC,EAAAC,EAAAC,EAAAC,EAkdU,OAAArD,EAAC,MACE,UAAAiD,EAAO,KAAK,YAAIC,GAAAvC,GAAAD,EAAAuC,EAAO,WAAP,YAAAvC,EAAiB,MAAjB,YAAAC,EAAsB,QAAQ,KAA9B,KAAAuC,EAAoC,MAAM,IAAE,KAC5DG,GAAAD,GAAAD,EAAAF,EAAO,WAAP,YAAAE,EAAiB,MAAjB,YAAAC,EAAsB,QAAQ,KAA9B,KAAAC,EAAoC,QAF9B,OAAOJ,EAAO,cAAc,CAGrC,EACD,EACH,GACF,CAEJ","names":["React","MapFirstCore","jsx","jsxs","useMapFirstCore","options","instanceRef","state","setState","optionsRef","opts","coreOptions","properties","_a","_b","prev","id","type","filters","bounds","center","zoom","location","loading","searching","instance","useMapFirstProperties","mapFirst","setProperties","useMapFirstSelectedProperty","selectedId","setSelectedId","usePrimaryType","primaryType","setPrimaryTypeState","setPrimaryType","useSelectedMarker","selectedMarker","setSelectedMarkerState","setSelectedMarker","useMapLibreAttachment","map","maplibregl","onMarkerClick","attachedRef","useGoogleMapsAttachment","google","useMapboxAttachment","mapboxgl","useMapFirst","MarkerDebugList","markers","marker","_c","_d","_e","_f"]}
1
+ {"version":3,"sources":["../src/index.tsx"],"sourcesContent":["import React from \"react\";\nimport {\n MapFirstCore,\n type MapFirstOptions,\n type BaseMapFirstOptions,\n type Property,\n type MapLibreNamespace,\n type GoogleMapsNamespace,\n type MapboxNamespace,\n type MapState,\n type PropertyType,\n} from \"@mapfirst.ai/core\";\n\n/**\n * Hook that creates a MapFirstCore instance that can be initialized before maps are ready.\n * Supports two-phase initialization: create SDK first, attach map later.\n * Returns the instance and reactive state that updates when SDK state changes.\n *\n * @example\n * ```tsx\n * // Phase 1: Create SDK instance with location data\n * const { mapFirst, state } = useMapFirstCore({\n * initialLocationData: {\n * city: \"New York\",\n * country: \"United States\",\n * currency: \"USD\"\n * }\n * });\n *\n * // Access reactive state\n * console.log(state.properties); // Updates when properties change\n * console.log(state.isSearching); // Updates when search state changes\n *\n * // Phase 2: Attach map when ready\n * useEffect(() => {\n * if (mapLibreInstance && mapFirst) {\n * mapFirst.attachMap(mapLibreInstance, {\n * platform: \"maplibre\",\n * maplibregl: maplibregl,\n * onMarkerClick: (marker) => console.log(marker)\n * });\n * }\n * }, [mapLibreInstance, mapFirst]);\n * ```\n */\nexport function useMapFirstCore(options: BaseMapFirstOptions) {\n const instanceRef = React.useRef<MapFirstCore | null>(null);\n const [state, setState] = React.useState<MapState | null>(null);\n\n // Memoize the options to prevent recreation on every render\n const optionsRef = React.useRef(options);\n React.useEffect(() => {\n optionsRef.current = options;\n });\n\n React.useEffect(() => {\n const opts = optionsRef.current;\n\n // Create MapFirstCore instance without map using adapter-driven options\n const coreOptions: MapFirstOptions = {\n adapter: null as any, // Will be set when attachMap is called\n ...opts,\n callbacks: {\n ...opts.callbacks,\n // Add internal callbacks to trigger React re-renders\n onPropertiesChange: (properties) => {\n setState((prev) => (prev ? { ...prev, properties } : null));\n optionsRef.current.callbacks?.onPropertiesChange?.(properties);\n },\n onSelectedPropertyChange: (id) => {\n setState((prev) =>\n prev ? { ...prev, selectedPropertyId: id } : null\n );\n optionsRef.current.callbacks?.onSelectedPropertyChange?.(id);\n },\n onPrimaryTypeChange: (type) => {\n setState((prev) => (prev ? { ...prev, primary: type } : null));\n optionsRef.current.callbacks?.onPrimaryTypeChange?.(type);\n },\n onFiltersChange: (filters) => {\n setState((prev) => (prev ? { ...prev, filters } : null));\n optionsRef.current.callbacks?.onFiltersChange?.(filters);\n },\n onBoundsChange: (bounds) => {\n setState((prev) => (prev ? { ...prev, bounds } : null));\n optionsRef.current.callbacks?.onBoundsChange?.(bounds);\n },\n onCenterChange: (center, zoom) => {\n setState((prev) => (prev ? { ...prev, center, zoom } : null));\n optionsRef.current.callbacks?.onCenterChange?.(center, zoom);\n },\n onZoomChange: (zoom) => {\n setState((prev) => (prev ? { ...prev, zoom } : null));\n optionsRef.current.callbacks?.onZoomChange?.(zoom);\n },\n onActiveLocationChange: (location) => {\n setState((prev) =>\n prev ? { ...prev, activeLocation: location } : null\n );\n optionsRef.current.callbacks?.onActiveLocationChange?.(location);\n },\n onLoadingStateChange: (loading) => {\n setState((prev) =>\n prev ? { ...prev, initialLoading: loading } : null\n );\n optionsRef.current.callbacks?.onLoadingStateChange?.(loading);\n },\n onSearchingStateChange: (searching) => {\n setState((prev) =>\n prev ? { ...prev, isSearching: searching } : null\n );\n optionsRef.current.callbacks?.onSearchingStateChange?.(searching);\n },\n },\n };\n\n const instance = new MapFirstCore(coreOptions);\n instanceRef.current = instance;\n\n // Initialize state from SDK\n setState(instance.getState());\n\n return () => {\n instance.destroy();\n instanceRef.current = null;\n setState(null);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return { mapFirst: instanceRef.current, state };\n}\n\n/**\n * Hook to access reactive properties from MapFirst SDK.\n * Returns the current properties array that updates when properties change.\n *\n * @example\n * ```tsx\n * const { mapFirst } = useMapFirstCore({ ... });\n * const properties = useMapFirstProperties(mapFirst);\n *\n * return <div>Found {properties.length} properties</div>;\n * ```\n */\nexport function useMapFirstProperties(\n mapFirst: MapFirstCore | null\n): Property[] {\n const [properties, setProperties] = React.useState<Property[]>([]);\n\n React.useEffect(() => {\n if (!mapFirst) {\n setProperties([]);\n return;\n }\n\n // Initialize with current state\n setProperties(mapFirst.getState().properties);\n }, [mapFirst]);\n\n return properties;\n}\n\n/**\n * Hook to access the selected property ID from MapFirst SDK.\n * Returns the currently selected property ID that updates when selection changes.\n *\n * @example\n * ```tsx\n * const { mapFirst } = useMapFirstCore({ ... });\n * const selectedId = useMapFirstSelectedProperty(mapFirst);\n *\n * return <div>Selected: {selectedId || 'None'}</div>;\n * ```\n */\nexport function useMapFirstSelectedProperty(\n mapFirst: MapFirstCore | null\n): number | null {\n const [selectedId, setSelectedId] = React.useState<number | null>(null);\n\n React.useEffect(() => {\n if (!mapFirst) {\n setSelectedId(null);\n return;\n }\n\n // Initialize with current state\n setSelectedId(mapFirst.getState().selectedPropertyId);\n }, [mapFirst]);\n\n return selectedId;\n}\n\n/**\n * Hook to access and control the primary property type.\n * Returns the current primary type and a setter function.\n *\n * @example\n * ```tsx\n * const { mapFirst } = useMapFirstCore({ ... });\n * const [primaryType, setPrimaryType] = usePrimaryType(mapFirst);\n *\n * return (\n * <select value={primaryType} onChange={(e) => setPrimaryType(e.target.value as PropertyType)}>\n * <option value=\"Accommodation\">Hotels</option>\n * <option value=\"Restaurant\">Restaurants</option>\n * <option value=\"Attraction\">Attractions</option>\n * </select>\n * );\n * ```\n */\nexport function usePrimaryType(\n mapFirst: MapFirstCore | null\n): [PropertyType, (type: PropertyType) => void] {\n const [primaryType, setPrimaryTypeState] =\n React.useState<PropertyType>(\"Accommodation\");\n\n React.useEffect(() => {\n if (!mapFirst) {\n setPrimaryTypeState(\"Accommodation\");\n return;\n }\n\n // Initialize with current state\n setPrimaryTypeState(mapFirst.getState().primary);\n }, [mapFirst]);\n\n const setPrimaryType = React.useCallback(\n (type: PropertyType) => {\n if (mapFirst) {\n mapFirst.setPrimaryType(type);\n setPrimaryTypeState(type);\n }\n },\n [mapFirst]\n );\n\n return [primaryType, setPrimaryType];\n}\n\n/**\n * Hook to access and control the selected marker.\n * Returns the current selected marker ID and a setter function.\n * Note: This hook requires the MapFirstCore instance. For simpler usage with reactive updates,\n * use state.selectedPropertyId from useMapFirstCore instead.\n *\n * @example\n * ```tsx\n * const { mapFirst } = useMapFirstCore({ ... });\n * const [selectedMarker, setSelectedMarker] = useSelectedMarker(mapFirst);\n *\n * return (\n * <div>\n * <p>Selected: {selectedMarker || 'None'}</p>\n * <button onClick={() => setSelectedMarker(null)}>Clear Selection</button>\n * </div>\n * );\n * ```\n */\nexport function useSelectedMarker(\n mapFirst: MapFirstCore | null\n): [number | null, (id: number | null) => void] {\n const [selectedMarker, setSelectedMarkerState] = React.useState<\n number | null\n >(null);\n\n React.useEffect(() => {\n if (!mapFirst) {\n setSelectedMarkerState(null);\n return;\n }\n\n // Initialize with current state\n setSelectedMarkerState(mapFirst.getState().selectedPropertyId);\n }, [mapFirst]);\n\n const setSelectedMarker = React.useCallback(\n (id: number | null) => {\n if (mapFirst) {\n mapFirst.setSelectedMarker(id);\n }\n },\n [mapFirst]\n );\n\n return [selectedMarker, setSelectedMarker];\n}\n\n/**\n * Hook for MapLibre GL JS integration.\n * Automatically attaches the map when both the SDK instance and map are available.\n *\n * @example\n * ```tsx\n * const { mapFirst, state } = useMapFirstCore({ initialLocationData: { city: \"Paris\", country: \"France\" } });\n * const mapRef = useRef<maplibregl.Map | null>(null);\n *\n * useMapLibreAttachment({\n * mapFirst,\n * map: mapRef.current,\n * maplibregl: maplibregl,\n * onMarkerClick: (marker) => console.log(marker)\n * });\n *\n * // Access reactive state\n * console.log(state?.properties);\n * ```\n */\nexport function useMapLibreAttachment({\n mapFirst,\n map,\n maplibregl,\n onMarkerClick,\n}: {\n mapFirst: MapFirstCore | null;\n map: any | null;\n maplibregl: MapLibreNamespace;\n onMarkerClick?: (marker: Property) => void;\n}) {\n const attachedRef = React.useRef(false);\n\n React.useEffect(() => {\n if (!mapFirst || !map || attachedRef.current) {\n return;\n }\n\n mapFirst.attachMap(map, {\n platform: \"maplibre\",\n maplibregl,\n onMarkerClick,\n });\n\n attachedRef.current = true;\n }, [mapFirst, map, maplibregl, onMarkerClick]);\n}\n\n/**\n * Hook for Google Maps integration.\n * Automatically attaches the map when both the SDK instance and map are available.\n *\n * @example\n * ```tsx\n * const { mapFirst, state } = useMapFirstCore({ initialLocationData: { city: \"Tokyo\", country: \"Japan\" } });\n * const mapRef = useRef<google.maps.Map | null>(null);\n *\n * useGoogleMapsAttachment({\n * mapFirst,\n * map: mapRef.current,\n * google: window.google,\n * onMarkerClick: (marker) => console.log(marker)\n * });\n *\n * // Access reactive state\n * console.log(state?.isSearching);\n * ```\n */\nexport function useGoogleMapsAttachment({\n mapFirst,\n map,\n google,\n onMarkerClick,\n}: {\n mapFirst: MapFirstCore | null;\n map: any | null;\n google: GoogleMapsNamespace;\n onMarkerClick?: (marker: Property) => void;\n}) {\n const attachedRef = React.useRef(false);\n\n React.useEffect(() => {\n if (!mapFirst || !map || attachedRef.current) {\n return;\n }\n\n mapFirst.attachMap(map, {\n platform: \"google\",\n google,\n onMarkerClick,\n });\n\n attachedRef.current = true;\n }, [mapFirst, map, google, onMarkerClick]);\n}\n\n/**\n * Hook for Mapbox GL JS integration.\n * Automatically attaches the map when both the SDK instance and map are available.\n *\n * @example\n * ```tsx\n * const { mapFirst, state } = useMapFirstCore({ initialLocationData: { city: \"London\", country: \"United Kingdom\" } });\n * const mapRef = useRef<mapboxgl.Map | null>(null);\n *\n * useMapboxAttachment({\n * mapFirst,\n * map: mapRef.current,\n * mapboxgl: mapboxgl,\n * onMarkerClick: (marker) => console.log(marker)\n * });\n *\n * // Access reactive state\n * console.log(state?.filters);\n * ```\n */\nexport function useMapboxAttachment({\n mapFirst,\n map,\n mapboxgl,\n onMarkerClick,\n}: {\n mapFirst: MapFirstCore | null;\n map: any | null;\n mapboxgl: MapboxNamespace;\n onMarkerClick?: (marker: Property) => void;\n}) {\n const attachedRef = React.useRef(false);\n\n React.useEffect(() => {\n if (!mapFirst || !map || attachedRef.current) {\n return;\n }\n\n mapFirst.attachMap(map, {\n platform: \"mapbox\",\n mapboxgl,\n onMarkerClick,\n });\n\n attachedRef.current = true;\n }, [mapFirst, map, mapboxgl, onMarkerClick]);\n}\n\n/**\n * Legacy hook that creates the MapFirstCore instance with a map immediately.\n * Use useMapFirstCore + useMap*Attachment hooks for better control.\n *\n * @deprecated Use useMapFirstCore and platform-specific attachment hooks instead\n */\nexport function useMapFirst(options: MapFirstOptions | null) {\n const instanceRef = React.useRef<MapFirstCore | null>(null);\n\n React.useEffect(() => {\n if (!options) {\n return undefined;\n }\n const instance = new MapFirstCore(options);\n instanceRef.current = instance;\n\n return () => {\n instance.destroy();\n instanceRef.current = null;\n };\n }, [options]);\n\n return instanceRef;\n}\n\n/**\n * Helper component that simply renders the markers it receives so non-React environments\n * can verify data flows before wiring the SDK into a map.\n */\nexport function MarkerDebugList({ markers }: { markers: Property[] }) {\n return (\n <div style={{ fontFamily: \"sans-serif\", fontSize: 14 }}>\n <strong>Markers</strong>\n <ul>\n {markers.map((marker) => (\n <li key={String(marker.tripadvisor_id)}>\n {marker.name} — {marker.location?.lat?.toFixed(3) ?? \"n/a\"},{\" \"}\n {marker.location?.lon?.toFixed(3) ?? \"n/a\"}\n </li>\n ))}\n </ul>\n </div>\n );\n}\n"],"mappings":"AAAA,OAAOA,MAAW,QAClB,OACE,gBAAAC,MASK,oBAqcD,cAAAC,EAGI,QAAAC,MAHJ,oBAnaC,SAASC,EAAgBC,EAA8B,CAC5D,IAAMC,EAAcN,EAAM,OAA4B,IAAI,EACpD,CAACO,EAAOC,CAAQ,EAAIR,EAAM,SAA0B,IAAI,EAGxDS,EAAaT,EAAM,OAAOK,CAAO,EACvC,OAAAL,EAAM,UAAU,IAAM,CACpBS,EAAW,QAAUJ,CACvB,CAAC,EAEDL,EAAM,UAAU,IAAM,CACpB,IAAMU,EAAOD,EAAW,QAGlBE,EAA+B,CACnC,QAAS,KACT,GAAGD,EACH,UAAW,CACT,GAAGA,EAAK,UAER,mBAAqBE,GAAe,CAjE5C,IAAAC,EAAAC,EAkEUN,EAAUO,GAAUA,EAAO,CAAE,GAAGA,EAAM,WAAAH,CAAW,EAAI,IAAK,GAC1DE,GAAAD,EAAAJ,EAAW,QAAQ,YAAnB,YAAAI,EAA8B,qBAA9B,MAAAC,EAAA,KAAAD,EAAmDD,EACrD,EACA,yBAA2BI,GAAO,CArE1C,IAAAH,EAAAC,EAsEUN,EAAUO,GACRA,EAAO,CAAE,GAAGA,EAAM,mBAAoBC,CAAG,EAAI,IAC/C,GACAF,GAAAD,EAAAJ,EAAW,QAAQ,YAAnB,YAAAI,EAA8B,2BAA9B,MAAAC,EAAA,KAAAD,EAAyDG,EAC3D,EACA,oBAAsBC,GAAS,CA3EvC,IAAAJ,E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IC,GAAAvC,GAAAD,EAAAuC,EAAO,WAAP,YAAAvC,EAAiB,MAAjB,YAAAC,EAAsB,QAAQ,KAA9B,KAAAuC,EAAoC,MAAM,IAAE,KAC5DG,GAAAD,GAAAD,EAAAF,EAAO,WAAP,YAAAE,EAAiB,MAAjB,YAAAC,EAAsB,QAAQ,KAA9B,KAAAC,EAAoC,QAF9B,OAAOJ,EAAO,cAAc,CAGrC,EACD,EACH,GACF,CAEJ","names":["React","MapFirstCore","jsx","jsxs","useMapFirstCore","options","instanceRef","state","setState","optionsRef","opts","coreOptions","properties","_a","_b","prev","id","type","filters","bounds","center","zoom","location","loading","searching","instance","useMapFirstProperties","mapFirst","setProperties","useMapFirstSelectedProperty","selectedId","setSelectedId","usePrimaryType","primaryType","setPrimaryTypeState","setPrimaryType","useSelectedMarker","selectedMarker","setSelectedMarkerState","setSelectedMarker","useMapLibreAttachment","map","maplibregl","onMarkerClick","attachedRef","useGoogleMapsAttachment","google","useMapboxAttachment","mapboxgl","useMapFirst","MarkerDebugList","markers","marker","_c","_d","_e","_f"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapfirst.ai/react",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "React hooks for MapFirst SDK - Reactive state management for map properties",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -17,10 +17,6 @@
17
17
  "README.md",
18
18
  "EXAMPLES.md"
19
19
  ],
20
- "scripts": {
21
- "build": "tsup src/index.tsx --format esm,cjs --dts --sourcemap --clean",
22
- "prepublishOnly": "pnpm build"
23
- },
24
20
  "keywords": [
25
21
  "react",
26
22
  "hooks",
@@ -44,6 +40,9 @@
44
40
  "react": ">=17 || >=18"
45
41
  },
46
42
  "dependencies": {
47
- "@mapfirst.ai/core": "0.0.3"
43
+ "@mapfirst.ai/core": "0.0.4"
44
+ },
45
+ "scripts": {
46
+ "build": "tsup src/index.tsx --format esm,cjs --dts --sourcemap --clean"
48
47
  }
49
48
  }