@open-mercato/core 0.6.6-develop.6407.1.9a4c26cf6a → 0.6.6-develop.6408.1.0cbfbd7476
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/modules/customers/backend/customers/deals/map/components/DealsMapCanvasImpl.js +9 -1
- package/dist/modules/customers/backend/customers/deals/map/components/DealsMapCanvasImpl.js.map +2 -2
- package/package.json +12 -12
- package/src/modules/customers/backend/customers/deals/map/components/DealsMapCanvasImpl.tsx +12 -2
|
@@ -16,7 +16,15 @@ import { formatCurrency } from "../../../../../components/detail/utils.js";
|
|
|
16
16
|
const leafletRuntime = L.default ?? L;
|
|
17
17
|
const TILE_URL = process.env.NEXT_PUBLIC_OM_DEALS_MAP_TILE_URL ?? "https://tile.openstreetmap.org/{z}/{x}/{y}.png";
|
|
18
18
|
const TILE_ATTRIBUTION = process.env.NEXT_PUBLIC_OM_DEALS_MAP_TILE_ATTRIBUTION ?? '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';
|
|
19
|
-
|
|
19
|
+
function targetsPublicOsmTileHost(tileUrl) {
|
|
20
|
+
try {
|
|
21
|
+
const { hostname } = new URL(tileUrl);
|
|
22
|
+
return hostname === "openstreetmap.org" || hostname.endsWith(".openstreetmap.org");
|
|
23
|
+
} catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const USING_PUBLIC_OSM_TILES = targetsPublicOsmTileHost(TILE_URL);
|
|
20
28
|
let publicOsmTileWarningEmitted = false;
|
|
21
29
|
function warnOnPublicOsmTilesOnce() {
|
|
22
30
|
if (publicOsmTileWarningEmitted || !USING_PUBLIC_OSM_TILES) return;
|
package/dist/modules/customers/backend/customers/deals/map/components/DealsMapCanvasImpl.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../src/modules/customers/backend/customers/deals/map/components/DealsMapCanvasImpl.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport * as L from 'leaflet'\nimport 'leaflet.markercluster'\nimport 'leaflet/dist/leaflet.css'\nimport 'leaflet.markercluster/dist/MarkerCluster.css'\nimport 'leaflet.markercluster/dist/MarkerCluster.Default.css'\nimport { X } from 'lucide-react'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { IconButton } from '@open-mercato/ui/primitives/icon-button'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { translateWithFallback } from '@open-mercato/shared/lib/i18n/translate'\nimport type { FilterOptionTone } from '@open-mercato/shared/lib/query/advanced-filter'\nimport { formatCurrency } from '../../../../../components/detail/utils'\nimport type {\n DealsMapCanvasDeal,\n DealsMapCanvasProps,\n DealsMapPreview,\n} from './DealsMapCanvas'\n\nconst leafletRuntime = ((L as { default?: typeof L }).default ?? L) as typeof L\n\nconst TILE_URL =\n process.env.NEXT_PUBLIC_OM_DEALS_MAP_TILE_URL ?? 'https://tile.openstreetmap.org/{z}/{x}/{y}.png'\nconst TILE_ATTRIBUTION =\n process.env.NEXT_PUBLIC_OM_DEALS_MAP_TILE_ATTRIBUTION ??\n '© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors'\n// True whenever the EFFECTIVE tile URL targets OSM's public CDN \u2014 whether from the bundled default\n// (env unset) OR an env value pointed back at the same public host. OSM's tile usage policy\n// prohibits production/commercial traffic against it.\nconst USING_PUBLIC_OSM_TILES = TILE_URL.includes('tile.openstreetmap.org')\n\nlet publicOsmTileWarningEmitted = false\n// Warn once (per session) so deployments point NEXT_PUBLIC_OM_DEALS_MAP_TILE_URL at a self-hosted or\n// commercial tile service instead of silently shipping against the shared public CDN.\nfunction warnOnPublicOsmTilesOnce(): void {\n if (publicOsmTileWarningEmitted || !USING_PUBLIC_OSM_TILES) return\n publicOsmTileWarningEmitted = true\n // eslint-disable-next-line no-console\n console.warn(\n '[open-mercato] Deals map is using the public OpenStreetMap tile server. ' +\n \"OSM's tile usage policy prohibits production/commercial traffic \u2014 point \" +\n 'NEXT_PUBLIC_OM_DEALS_MAP_TILE_URL at a self-hosted or commercial tile service before deploying.',\n )\n}\n\nconst WORLD_CENTER: L.LatLngTuple = [20, 0]\nconst WORLD_ZOOM = 2\nconst SINGLE_PIN_ZOOM = 12\nconst FIT_PADDING: L.PointTuple = [32, 32]\n\n// Saturated pin fill per stage tone \u2014 mirrors `Lane.tsx` ACCENT_TONE_CLASS so the same\n// stage reads as the same color on the kanban color bar and on the map pin.\nconst PIN_TONE_CLASS: Record<FilterOptionTone, string> = {\n success: 'bg-status-success-icon',\n error: 'bg-status-error-icon',\n warning: 'bg-status-warning-icon',\n info: 'bg-status-info-icon',\n neutral: 'bg-status-neutral-icon',\n brand: 'bg-brand-violet',\n pink: 'bg-status-pink-icon',\n}\n\n// Stage badge surface for the preview card \u2014 mirrors `Lane.tsx` COUNT_BADGE_TONE_CLASS.\nconst STAGE_BADGE_TONE_CLASS: Record<FilterOptionTone, string> = {\n success: 'bg-status-success-bg text-status-success-text',\n error: 'bg-status-error-bg text-status-error-text',\n warning: 'bg-status-warning-bg text-status-warning-text',\n info: 'bg-status-info-bg text-status-info-text',\n neutral: 'bg-status-neutral-bg text-status-neutral-text',\n brand: 'bg-brand-violet/14 text-brand-violet',\n pink: 'bg-status-pink-bg text-status-pink-text',\n}\n\nfunction getPinToneClass(tone: FilterOptionTone | null): string {\n if (tone && tone in PIN_TONE_CLASS) return PIN_TONE_CLASS[tone]\n return 'bg-status-neutral-icon'\n}\n\nfunction getStageBadgeClass(tone: FilterOptionTone | null): string {\n if (tone && tone in STAGE_BADGE_TONE_CLASS) return STAGE_BADGE_TONE_CLASS[tone]\n return 'bg-muted text-muted-foreground'\n}\n\n// divIcon html is a raw string (no React) \u2014 only the server-issued deal id is interpolated,\n// never user-entered text, and styling comes exclusively from DS token classes.\nfunction buildMarkerIcon(dealId: string, tone: FilterOptionTone | null, selected: boolean): L.DivIcon {\n const sizePx = selected ? 20 : 14\n const dotClass = selected\n ? `block size-5 rounded-full border-2 border-card shadow-md ring-2 ring-ring ${getPinToneClass(tone)}`\n : `block size-3.5 rounded-full border-2 border-card shadow-md ${getPinToneClass(tone)}`\n return L.divIcon({\n className: `om-deal-map-marker${selected ? ' om-deal-map-marker--selected' : ''}`,\n html: `<span class=\"${dotClass}\" data-deal-id=\"${dealId}\"></span>`,\n iconSize: [sizePx, sizePx],\n iconAnchor: [sizePx / 2, sizePx / 2],\n })\n}\n\nfunction buildClusterIcon(count: number): L.DivIcon {\n return L.divIcon({\n className: 'om-deal-map-cluster',\n html: `<span class=\"flex size-9 items-center justify-center rounded-full border-2 border-card bg-brand-violet text-xs font-bold text-brand-violet-foreground shadow-md\">${count}</span>`,\n iconSize: [36, 36],\n iconAnchor: [18, 18],\n })\n}\n\nconst shortDateFormatter = new Intl.DateTimeFormat(undefined, {\n month: 'short',\n day: '2-digit',\n})\n\nfunction formatShortDate(value: string | null): string | null {\n if (!value) return null\n const date = new Date(value)\n if (Number.isNaN(date.getTime())) return null\n return shortDateFormatter.format(date)\n}\n\ntype PreviewCardProps = {\n preview: DealsMapPreview\n onClose: () => void\n}\n\nfunction DealMapPreviewCard({ preview, onClose }: PreviewCardProps): React.ReactElement {\n const t = useT()\n const closeDate = formatShortDate(preview.expectedCloseAt)\n const metaParts: string[] = []\n if (typeof preview.valueAmount === 'number') {\n metaParts.push(formatCurrency(preview.valueAmount, preview.valueCurrency))\n }\n if (typeof preview.probability === 'number') {\n metaParts.push(\n translateWithFallback(t, 'customers.deals.map.preview.probabilityShort', '{value}%', {\n value: Math.min(Math.max(Math.round(preview.probability), 0), 100),\n }),\n )\n }\n if (closeDate) {\n metaParts.push(\n translateWithFallback(t, 'customers.deals.map.preview.closeShort', 'Close {date}', {\n date: closeDate,\n }),\n )\n }\n return (\n <div\n data-map-preview-card={preview.id}\n className=\"absolute right-3 top-3 z-10 flex w-80 max-w-full flex-col gap-2 rounded-xl border border-border bg-popover p-4 shadow-lg\"\n >\n <div className=\"flex items-start justify-between gap-2\">\n <div className=\"flex min-w-0 flex-col\">\n {preview.companyLabel ? (\n <span className=\"truncate text-sm font-medium leading-normal text-foreground\">\n {preview.companyLabel}\n </span>\n ) : null}\n {preview.locationLine ? (\n <span className=\"truncate text-xs leading-normal text-muted-foreground\">\n {preview.locationLine}\n </span>\n ) : null}\n </div>\n <IconButton\n variant=\"ghost\"\n size=\"sm\"\n type=\"button\"\n onClick={onClose}\n aria-label={translateWithFallback(t, 'customers.deals.map.preview.close', 'Close preview')}\n >\n <X className=\"size-4\" aria-hidden=\"true\" />\n </IconButton>\n </div>\n <h3 className=\"text-base font-semibold leading-normal text-foreground\">{preview.title}</h3>\n {metaParts.length > 0 ? (\n <p className=\"text-sm leading-normal text-muted-foreground\">{metaParts.join(' \u00B7 ')}</p>\n ) : null}\n {preview.stageLabel || preview.ownerName ? (\n <div className=\"flex flex-wrap items-center gap-1.5\">\n {preview.stageLabel ? (\n <span\n className={`inline-flex items-center rounded-md px-2 py-0.5 text-xs font-semibold leading-normal ${getStageBadgeClass(preview.stageTone)}`}\n >\n {preview.stageLabel}\n </span>\n ) : null}\n {preview.ownerName ? (\n <span className=\"inline-flex items-center rounded-md bg-muted px-2 py-0.5 text-xs font-medium leading-normal text-foreground\">\n {preview.ownerName}\n </span>\n ) : null}\n </div>\n ) : null}\n <Button asChild className=\"mt-1 w-full\">\n <Link href={`/backend/customers/deals/${preview.id}`}>\n {translateWithFallback(t, 'customers.deals.map.preview.openDeal', 'Open deal')}\n </Link>\n </Button>\n </div>\n )\n}\n\nexport default function DealsMapCanvasImpl({\n deals,\n legendStages,\n preview,\n selectedDealId,\n onSelect,\n onCenterChange,\n className,\n}: DealsMapCanvasProps): React.ReactElement {\n const t = useT()\n const containerRef = React.useRef<HTMLDivElement | null>(null)\n const mapRef = React.useRef<L.Map | null>(null)\n const clusterRef = React.useRef<L.MarkerClusterGroup | null>(null)\n const markersByIdRef = React.useRef(new Map<string, L.Marker>())\n const dealsByIdRef = React.useRef(new Map<string, DealsMapCanvasDeal>())\n const previousSelectedIdRef = React.useRef<string | null>(null)\n const lastFitSignatureRef = React.useRef<string | null>(null)\n const centerChangeTimerRef = React.useRef<ReturnType<typeof setTimeout> | null>(null)\n\n const onSelectRef = React.useRef(onSelect)\n onSelectRef.current = onSelect\n const onCenterChangeRef = React.useRef(onCenterChange)\n onCenterChangeRef.current = onCenterChange\n\n React.useEffect(() => {\n const node = containerRef.current\n if (!node || mapRef.current) return undefined\n warnOnPublicOsmTilesOnce()\n const map = L.map(node, { zoomControl: false, worldCopyJump: true })\n // Zoom sits top-LEFT so it never overlaps the selection preview card (top-right overlay).\n L.control.zoom({ position: 'topleft' }).addTo(map)\n L.tileLayer(TILE_URL, { attribution: TILE_ATTRIBUTION, maxZoom: 19 }).addTo(map)\n map.setView(WORLD_CENTER, WORLD_ZOOM)\n const cluster = leafletRuntime.markerClusterGroup({\n showCoverageOnHover: false,\n iconCreateFunction: (markerCluster) => buildClusterIcon(markerCluster.getChildCount()),\n })\n map.addLayer(cluster)\n // `moveend` fires on every pan/zoom-end and each one re-renders the view + re-runs the panel's\n // proximity (haversine) sort, so debounce the state update. Read the center synchronously here\n // while the map pane is guaranteed positioned \u2014 deferring getCenter() into the timeout can hit\n // Leaflet's `_leaflet_pos` on a pane that has since been reset (fitBounds) or torn down.\n map.on('moveend', () => {\n const center = map.getCenter()\n if (centerChangeTimerRef.current) clearTimeout(centerChangeTimerRef.current)\n centerChangeTimerRef.current = setTimeout(() => {\n onCenterChangeRef.current({ latitude: center.lat, longitude: center.lng })\n }, 250)\n })\n mapRef.current = map\n clusterRef.current = cluster\n const resizeObserver = new ResizeObserver(() => {\n map.invalidateSize()\n })\n resizeObserver.observe(node)\n return () => {\n resizeObserver.disconnect()\n if (centerChangeTimerRef.current) {\n clearTimeout(centerChangeTimerRef.current)\n centerChangeTimerRef.current = null\n }\n // Cancel any in-flight pan/zoom/fly animation before teardown \u2014 otherwise its\n // CSS transitionend fires after the panes are gone and Leaflet reads `_leaflet_pos`\n // off an undefined map pane.\n map.stop()\n map.remove()\n mapRef.current = null\n clusterRef.current = null\n markersByIdRef.current.clear()\n dealsByIdRef.current.clear()\n previousSelectedIdRef.current = null\n lastFitSignatureRef.current = null\n }\n }, [])\n\n const dealsSignature = React.useMemo(() => deals.map((deal) => deal.id).join('|'), [deals])\n\n React.useEffect(() => {\n const map = mapRef.current\n const cluster = clusterRef.current\n if (!map || !cluster) return\n cluster.clearLayers()\n markersByIdRef.current.clear()\n dealsByIdRef.current.clear()\n const markers: L.Marker[] = []\n for (const deal of deals) {\n const marker = L.marker([deal.latitude, deal.longitude], {\n icon: buildMarkerIcon(deal.id, deal.tone, false),\n keyboard: false,\n })\n marker.on('click', () => onSelectRef.current(deal.id))\n markersByIdRef.current.set(deal.id, marker)\n dealsByIdRef.current.set(deal.id, deal)\n markers.push(marker)\n }\n cluster.addLayers(markers)\n if (lastFitSignatureRef.current !== dealsSignature) {\n lastFitSignatureRef.current = dealsSignature\n // Fit instantly (animate: false). The list pages in over several updates, so animated\n // re-fits would stack overlapping zoom transitions and race Leaflet's pane bookkeeping.\n map.stop()\n if (deals.length === 0) {\n map.setView(WORLD_CENTER, WORLD_ZOOM, { animate: false })\n } else if (deals.length === 1) {\n map.setView([deals[0].latitude, deals[0].longitude], SINGLE_PIN_ZOOM, { animate: false })\n } else {\n const bounds = L.latLngBounds(\n deals.map((deal) => [deal.latitude, deal.longitude] as L.LatLngTuple),\n )\n map.fitBounds(bounds, { padding: FIT_PADDING, animate: false })\n }\n }\n }, [deals, dealsSignature])\n\n React.useEffect(() => {\n const map = mapRef.current\n const cluster = clusterRef.current\n if (!map || !cluster) return\n const previousId = previousSelectedIdRef.current\n const selectionChanged = previousId !== selectedDealId\n if (previousId && previousId !== selectedDealId) {\n const previousMarker = markersByIdRef.current.get(previousId)\n const previousDeal = dealsByIdRef.current.get(previousId)\n if (previousMarker && previousDeal) {\n previousMarker.setIcon(buildMarkerIcon(previousDeal.id, previousDeal.tone, false))\n }\n }\n previousSelectedIdRef.current = selectedDealId\n if (!selectedDealId) return\n const marker = markersByIdRef.current.get(selectedDealId)\n const deal = dealsByIdRef.current.get(selectedDealId)\n if (!marker || !deal) return\n marker.setIcon(buildMarkerIcon(deal.id, deal.tone, true))\n // Only move the camera when the selection itself changed. This effect also depends on\n // `deals` so the selected marker's icon is re-applied after a marker rebuild \u2014 but a deal-set\n // change alone (e.g. a sibling query resolving) must not yank the viewport back to the pin.\n if (!selectionChanged) return\n map.stop()\n const visibleParent = cluster.getVisibleParent(marker)\n if (visibleParent && visibleParent !== marker) {\n cluster.zoomToShowLayer(marker, () => {})\n } else {\n map.flyTo(marker.getLatLng(), Math.max(map.getZoom(), SINGLE_PIN_ZOOM))\n }\n }, [selectedDealId, deals])\n\n // Escape clears the selected-deal preview. Bound at the document level (not the canvas region's\n // onKeyDown) so it fires regardless of whether focus is on the map, a panel card, or the preview\n // card. Registered only while a deal is selected, so it never swallows Escape elsewhere.\n React.useEffect(() => {\n if (!selectedDealId) return undefined\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key !== 'Escape') return\n onSelectRef.current(null)\n }\n document.addEventListener('keydown', onKeyDown)\n return () => document.removeEventListener('keydown', onKeyDown)\n }, [selectedDealId])\n\n return (\n <div\n role=\"region\"\n aria-label={translateWithFallback(t, 'customers.deals.map.canvas.label', 'Deals map')}\n className={`relative ${className ?? ''}`.trim()}\n >\n <div ref={containerRef} data-map-canvas className=\"absolute inset-0 z-0\" />\n {deals.length === 0 ? (\n <div className=\"pointer-events-none absolute inset-0 z-10 flex items-center justify-center p-6\">\n <div className=\"max-w-sm rounded-xl border border-border bg-card/95 p-4 text-center shadow-sm\">\n <p className=\"text-sm font-medium leading-normal text-foreground\">\n {translateWithFallback(t, 'customers.deals.map.panel.empty.title', 'No deals on the map yet')}\n </p>\n <p className=\"mt-1 text-xs leading-normal text-muted-foreground\">\n {translateWithFallback(\n t,\n 'customers.deals.map.panel.empty.description',\n 'Add latitude and longitude to company or person addresses to plot their deals here.',\n )}\n </p>\n </div>\n </div>\n ) : null}\n {legendStages.length > 0 ? (\n <div className=\"absolute bottom-3 left-3 z-10 flex flex-col gap-1.5 rounded-lg border border-border bg-card/95 p-3\">\n <span className=\"text-overline font-bold uppercase leading-normal text-muted-foreground\">\n {translateWithFallback(t, 'customers.deals.map.legend.title', 'Stages')}\n </span>\n {legendStages.map((stage) => (\n <span key={stage.id} className=\"flex items-center gap-2 text-xs leading-normal text-foreground\">\n <span\n className={`size-2.5 shrink-0 rounded-full ${getPinToneClass(stage.tone)}`}\n aria-hidden=\"true\"\n />\n {stage.label}\n </span>\n ))}\n </div>\n ) : null}\n {preview ? <DealMapPreviewCard preview={preview} onClose={() => onSelectRef.current(null)} /> : null}\n </div>\n )\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport Link from 'next/link'\nimport * as L from 'leaflet'\nimport 'leaflet.markercluster'\nimport 'leaflet/dist/leaflet.css'\nimport 'leaflet.markercluster/dist/MarkerCluster.css'\nimport 'leaflet.markercluster/dist/MarkerCluster.Default.css'\nimport { X } from 'lucide-react'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { IconButton } from '@open-mercato/ui/primitives/icon-button'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { translateWithFallback } from '@open-mercato/shared/lib/i18n/translate'\nimport type { FilterOptionTone } from '@open-mercato/shared/lib/query/advanced-filter'\nimport { formatCurrency } from '../../../../../components/detail/utils'\nimport type {\n DealsMapCanvasDeal,\n DealsMapCanvasProps,\n DealsMapPreview,\n} from './DealsMapCanvas'\n\nconst leafletRuntime = ((L as { default?: typeof L }).default ?? L) as typeof L\n\nconst TILE_URL =\n process.env.NEXT_PUBLIC_OM_DEALS_MAP_TILE_URL ?? 'https://tile.openstreetmap.org/{z}/{x}/{y}.png'\nconst TILE_ATTRIBUTION =\n process.env.NEXT_PUBLIC_OM_DEALS_MAP_TILE_ATTRIBUTION ??\n '© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors'\n// True whenever the EFFECTIVE tile URL targets OSM's public CDN \u2014 whether from the bundled default\n// (env unset) OR an env value pointed back at the same public host. OSM's tile usage policy\n// prohibits production/commercial traffic against it. Match on the parsed hostname rather than a raw\n// substring so a lookalike host (e.g. `tile.openstreetmap.org.example.com`) is not mistaken for OSM.\nfunction targetsPublicOsmTileHost(tileUrl: string): boolean {\n try {\n const { hostname } = new URL(tileUrl)\n return hostname === 'openstreetmap.org' || hostname.endsWith('.openstreetmap.org')\n } catch {\n return false\n }\n}\n\nconst USING_PUBLIC_OSM_TILES = targetsPublicOsmTileHost(TILE_URL)\n\nlet publicOsmTileWarningEmitted = false\n// Warn once (per session) so deployments point NEXT_PUBLIC_OM_DEALS_MAP_TILE_URL at a self-hosted or\n// commercial tile service instead of silently shipping against the shared public CDN.\nfunction warnOnPublicOsmTilesOnce(): void {\n if (publicOsmTileWarningEmitted || !USING_PUBLIC_OSM_TILES) return\n publicOsmTileWarningEmitted = true\n // eslint-disable-next-line no-console\n console.warn(\n '[open-mercato] Deals map is using the public OpenStreetMap tile server. ' +\n \"OSM's tile usage policy prohibits production/commercial traffic \u2014 point \" +\n 'NEXT_PUBLIC_OM_DEALS_MAP_TILE_URL at a self-hosted or commercial tile service before deploying.',\n )\n}\n\nconst WORLD_CENTER: L.LatLngTuple = [20, 0]\nconst WORLD_ZOOM = 2\nconst SINGLE_PIN_ZOOM = 12\nconst FIT_PADDING: L.PointTuple = [32, 32]\n\n// Saturated pin fill per stage tone \u2014 mirrors `Lane.tsx` ACCENT_TONE_CLASS so the same\n// stage reads as the same color on the kanban color bar and on the map pin.\nconst PIN_TONE_CLASS: Record<FilterOptionTone, string> = {\n success: 'bg-status-success-icon',\n error: 'bg-status-error-icon',\n warning: 'bg-status-warning-icon',\n info: 'bg-status-info-icon',\n neutral: 'bg-status-neutral-icon',\n brand: 'bg-brand-violet',\n pink: 'bg-status-pink-icon',\n}\n\n// Stage badge surface for the preview card \u2014 mirrors `Lane.tsx` COUNT_BADGE_TONE_CLASS.\nconst STAGE_BADGE_TONE_CLASS: Record<FilterOptionTone, string> = {\n success: 'bg-status-success-bg text-status-success-text',\n error: 'bg-status-error-bg text-status-error-text',\n warning: 'bg-status-warning-bg text-status-warning-text',\n info: 'bg-status-info-bg text-status-info-text',\n neutral: 'bg-status-neutral-bg text-status-neutral-text',\n brand: 'bg-brand-violet/14 text-brand-violet',\n pink: 'bg-status-pink-bg text-status-pink-text',\n}\n\nfunction getPinToneClass(tone: FilterOptionTone | null): string {\n if (tone && tone in PIN_TONE_CLASS) return PIN_TONE_CLASS[tone]\n return 'bg-status-neutral-icon'\n}\n\nfunction getStageBadgeClass(tone: FilterOptionTone | null): string {\n if (tone && tone in STAGE_BADGE_TONE_CLASS) return STAGE_BADGE_TONE_CLASS[tone]\n return 'bg-muted text-muted-foreground'\n}\n\n// divIcon html is a raw string (no React) \u2014 only the server-issued deal id is interpolated,\n// never user-entered text, and styling comes exclusively from DS token classes.\nfunction buildMarkerIcon(dealId: string, tone: FilterOptionTone | null, selected: boolean): L.DivIcon {\n const sizePx = selected ? 20 : 14\n const dotClass = selected\n ? `block size-5 rounded-full border-2 border-card shadow-md ring-2 ring-ring ${getPinToneClass(tone)}`\n : `block size-3.5 rounded-full border-2 border-card shadow-md ${getPinToneClass(tone)}`\n return L.divIcon({\n className: `om-deal-map-marker${selected ? ' om-deal-map-marker--selected' : ''}`,\n html: `<span class=\"${dotClass}\" data-deal-id=\"${dealId}\"></span>`,\n iconSize: [sizePx, sizePx],\n iconAnchor: [sizePx / 2, sizePx / 2],\n })\n}\n\nfunction buildClusterIcon(count: number): L.DivIcon {\n return L.divIcon({\n className: 'om-deal-map-cluster',\n html: `<span class=\"flex size-9 items-center justify-center rounded-full border-2 border-card bg-brand-violet text-xs font-bold text-brand-violet-foreground shadow-md\">${count}</span>`,\n iconSize: [36, 36],\n iconAnchor: [18, 18],\n })\n}\n\nconst shortDateFormatter = new Intl.DateTimeFormat(undefined, {\n month: 'short',\n day: '2-digit',\n})\n\nfunction formatShortDate(value: string | null): string | null {\n if (!value) return null\n const date = new Date(value)\n if (Number.isNaN(date.getTime())) return null\n return shortDateFormatter.format(date)\n}\n\ntype PreviewCardProps = {\n preview: DealsMapPreview\n onClose: () => void\n}\n\nfunction DealMapPreviewCard({ preview, onClose }: PreviewCardProps): React.ReactElement {\n const t = useT()\n const closeDate = formatShortDate(preview.expectedCloseAt)\n const metaParts: string[] = []\n if (typeof preview.valueAmount === 'number') {\n metaParts.push(formatCurrency(preview.valueAmount, preview.valueCurrency))\n }\n if (typeof preview.probability === 'number') {\n metaParts.push(\n translateWithFallback(t, 'customers.deals.map.preview.probabilityShort', '{value}%', {\n value: Math.min(Math.max(Math.round(preview.probability), 0), 100),\n }),\n )\n }\n if (closeDate) {\n metaParts.push(\n translateWithFallback(t, 'customers.deals.map.preview.closeShort', 'Close {date}', {\n date: closeDate,\n }),\n )\n }\n return (\n <div\n data-map-preview-card={preview.id}\n className=\"absolute right-3 top-3 z-10 flex w-80 max-w-full flex-col gap-2 rounded-xl border border-border bg-popover p-4 shadow-lg\"\n >\n <div className=\"flex items-start justify-between gap-2\">\n <div className=\"flex min-w-0 flex-col\">\n {preview.companyLabel ? (\n <span className=\"truncate text-sm font-medium leading-normal text-foreground\">\n {preview.companyLabel}\n </span>\n ) : null}\n {preview.locationLine ? (\n <span className=\"truncate text-xs leading-normal text-muted-foreground\">\n {preview.locationLine}\n </span>\n ) : null}\n </div>\n <IconButton\n variant=\"ghost\"\n size=\"sm\"\n type=\"button\"\n onClick={onClose}\n aria-label={translateWithFallback(t, 'customers.deals.map.preview.close', 'Close preview')}\n >\n <X className=\"size-4\" aria-hidden=\"true\" />\n </IconButton>\n </div>\n <h3 className=\"text-base font-semibold leading-normal text-foreground\">{preview.title}</h3>\n {metaParts.length > 0 ? (\n <p className=\"text-sm leading-normal text-muted-foreground\">{metaParts.join(' \u00B7 ')}</p>\n ) : null}\n {preview.stageLabel || preview.ownerName ? (\n <div className=\"flex flex-wrap items-center gap-1.5\">\n {preview.stageLabel ? (\n <span\n className={`inline-flex items-center rounded-md px-2 py-0.5 text-xs font-semibold leading-normal ${getStageBadgeClass(preview.stageTone)}`}\n >\n {preview.stageLabel}\n </span>\n ) : null}\n {preview.ownerName ? (\n <span className=\"inline-flex items-center rounded-md bg-muted px-2 py-0.5 text-xs font-medium leading-normal text-foreground\">\n {preview.ownerName}\n </span>\n ) : null}\n </div>\n ) : null}\n <Button asChild className=\"mt-1 w-full\">\n <Link href={`/backend/customers/deals/${preview.id}`}>\n {translateWithFallback(t, 'customers.deals.map.preview.openDeal', 'Open deal')}\n </Link>\n </Button>\n </div>\n )\n}\n\nexport default function DealsMapCanvasImpl({\n deals,\n legendStages,\n preview,\n selectedDealId,\n onSelect,\n onCenterChange,\n className,\n}: DealsMapCanvasProps): React.ReactElement {\n const t = useT()\n const containerRef = React.useRef<HTMLDivElement | null>(null)\n const mapRef = React.useRef<L.Map | null>(null)\n const clusterRef = React.useRef<L.MarkerClusterGroup | null>(null)\n const markersByIdRef = React.useRef(new Map<string, L.Marker>())\n const dealsByIdRef = React.useRef(new Map<string, DealsMapCanvasDeal>())\n const previousSelectedIdRef = React.useRef<string | null>(null)\n const lastFitSignatureRef = React.useRef<string | null>(null)\n const centerChangeTimerRef = React.useRef<ReturnType<typeof setTimeout> | null>(null)\n\n const onSelectRef = React.useRef(onSelect)\n onSelectRef.current = onSelect\n const onCenterChangeRef = React.useRef(onCenterChange)\n onCenterChangeRef.current = onCenterChange\n\n React.useEffect(() => {\n const node = containerRef.current\n if (!node || mapRef.current) return undefined\n warnOnPublicOsmTilesOnce()\n const map = L.map(node, { zoomControl: false, worldCopyJump: true })\n // Zoom sits top-LEFT so it never overlaps the selection preview card (top-right overlay).\n L.control.zoom({ position: 'topleft' }).addTo(map)\n L.tileLayer(TILE_URL, { attribution: TILE_ATTRIBUTION, maxZoom: 19 }).addTo(map)\n map.setView(WORLD_CENTER, WORLD_ZOOM)\n const cluster = leafletRuntime.markerClusterGroup({\n showCoverageOnHover: false,\n iconCreateFunction: (markerCluster) => buildClusterIcon(markerCluster.getChildCount()),\n })\n map.addLayer(cluster)\n // `moveend` fires on every pan/zoom-end and each one re-renders the view + re-runs the panel's\n // proximity (haversine) sort, so debounce the state update. Read the center synchronously here\n // while the map pane is guaranteed positioned \u2014 deferring getCenter() into the timeout can hit\n // Leaflet's `_leaflet_pos` on a pane that has since been reset (fitBounds) or torn down.\n map.on('moveend', () => {\n const center = map.getCenter()\n if (centerChangeTimerRef.current) clearTimeout(centerChangeTimerRef.current)\n centerChangeTimerRef.current = setTimeout(() => {\n onCenterChangeRef.current({ latitude: center.lat, longitude: center.lng })\n }, 250)\n })\n mapRef.current = map\n clusterRef.current = cluster\n const resizeObserver = new ResizeObserver(() => {\n map.invalidateSize()\n })\n resizeObserver.observe(node)\n return () => {\n resizeObserver.disconnect()\n if (centerChangeTimerRef.current) {\n clearTimeout(centerChangeTimerRef.current)\n centerChangeTimerRef.current = null\n }\n // Cancel any in-flight pan/zoom/fly animation before teardown \u2014 otherwise its\n // CSS transitionend fires after the panes are gone and Leaflet reads `_leaflet_pos`\n // off an undefined map pane.\n map.stop()\n map.remove()\n mapRef.current = null\n clusterRef.current = null\n markersByIdRef.current.clear()\n dealsByIdRef.current.clear()\n previousSelectedIdRef.current = null\n lastFitSignatureRef.current = null\n }\n }, [])\n\n const dealsSignature = React.useMemo(() => deals.map((deal) => deal.id).join('|'), [deals])\n\n React.useEffect(() => {\n const map = mapRef.current\n const cluster = clusterRef.current\n if (!map || !cluster) return\n cluster.clearLayers()\n markersByIdRef.current.clear()\n dealsByIdRef.current.clear()\n const markers: L.Marker[] = []\n for (const deal of deals) {\n const marker = L.marker([deal.latitude, deal.longitude], {\n icon: buildMarkerIcon(deal.id, deal.tone, false),\n keyboard: false,\n })\n marker.on('click', () => onSelectRef.current(deal.id))\n markersByIdRef.current.set(deal.id, marker)\n dealsByIdRef.current.set(deal.id, deal)\n markers.push(marker)\n }\n cluster.addLayers(markers)\n if (lastFitSignatureRef.current !== dealsSignature) {\n lastFitSignatureRef.current = dealsSignature\n // Fit instantly (animate: false). The list pages in over several updates, so animated\n // re-fits would stack overlapping zoom transitions and race Leaflet's pane bookkeeping.\n map.stop()\n if (deals.length === 0) {\n map.setView(WORLD_CENTER, WORLD_ZOOM, { animate: false })\n } else if (deals.length === 1) {\n map.setView([deals[0].latitude, deals[0].longitude], SINGLE_PIN_ZOOM, { animate: false })\n } else {\n const bounds = L.latLngBounds(\n deals.map((deal) => [deal.latitude, deal.longitude] as L.LatLngTuple),\n )\n map.fitBounds(bounds, { padding: FIT_PADDING, animate: false })\n }\n }\n }, [deals, dealsSignature])\n\n React.useEffect(() => {\n const map = mapRef.current\n const cluster = clusterRef.current\n if (!map || !cluster) return\n const previousId = previousSelectedIdRef.current\n const selectionChanged = previousId !== selectedDealId\n if (previousId && previousId !== selectedDealId) {\n const previousMarker = markersByIdRef.current.get(previousId)\n const previousDeal = dealsByIdRef.current.get(previousId)\n if (previousMarker && previousDeal) {\n previousMarker.setIcon(buildMarkerIcon(previousDeal.id, previousDeal.tone, false))\n }\n }\n previousSelectedIdRef.current = selectedDealId\n if (!selectedDealId) return\n const marker = markersByIdRef.current.get(selectedDealId)\n const deal = dealsByIdRef.current.get(selectedDealId)\n if (!marker || !deal) return\n marker.setIcon(buildMarkerIcon(deal.id, deal.tone, true))\n // Only move the camera when the selection itself changed. This effect also depends on\n // `deals` so the selected marker's icon is re-applied after a marker rebuild \u2014 but a deal-set\n // change alone (e.g. a sibling query resolving) must not yank the viewport back to the pin.\n if (!selectionChanged) return\n map.stop()\n const visibleParent = cluster.getVisibleParent(marker)\n if (visibleParent && visibleParent !== marker) {\n cluster.zoomToShowLayer(marker, () => {})\n } else {\n map.flyTo(marker.getLatLng(), Math.max(map.getZoom(), SINGLE_PIN_ZOOM))\n }\n }, [selectedDealId, deals])\n\n // Escape clears the selected-deal preview. Bound at the document level (not the canvas region's\n // onKeyDown) so it fires regardless of whether focus is on the map, a panel card, or the preview\n // card. Registered only while a deal is selected, so it never swallows Escape elsewhere.\n React.useEffect(() => {\n if (!selectedDealId) return undefined\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key !== 'Escape') return\n onSelectRef.current(null)\n }\n document.addEventListener('keydown', onKeyDown)\n return () => document.removeEventListener('keydown', onKeyDown)\n }, [selectedDealId])\n\n return (\n <div\n role=\"region\"\n aria-label={translateWithFallback(t, 'customers.deals.map.canvas.label', 'Deals map')}\n className={`relative ${className ?? ''}`.trim()}\n >\n <div ref={containerRef} data-map-canvas className=\"absolute inset-0 z-0\" />\n {deals.length === 0 ? (\n <div className=\"pointer-events-none absolute inset-0 z-10 flex items-center justify-center p-6\">\n <div className=\"max-w-sm rounded-xl border border-border bg-card/95 p-4 text-center shadow-sm\">\n <p className=\"text-sm font-medium leading-normal text-foreground\">\n {translateWithFallback(t, 'customers.deals.map.panel.empty.title', 'No deals on the map yet')}\n </p>\n <p className=\"mt-1 text-xs leading-normal text-muted-foreground\">\n {translateWithFallback(\n t,\n 'customers.deals.map.panel.empty.description',\n 'Add latitude and longitude to company or person addresses to plot their deals here.',\n )}\n </p>\n </div>\n </div>\n ) : null}\n {legendStages.length > 0 ? (\n <div className=\"absolute bottom-3 left-3 z-10 flex flex-col gap-1.5 rounded-lg border border-border bg-card/95 p-3\">\n <span className=\"text-overline font-bold uppercase leading-normal text-muted-foreground\">\n {translateWithFallback(t, 'customers.deals.map.legend.title', 'Stages')}\n </span>\n {legendStages.map((stage) => (\n <span key={stage.id} className=\"flex items-center gap-2 text-xs leading-normal text-foreground\">\n <span\n className={`size-2.5 shrink-0 rounded-full ${getPinToneClass(stage.tone)}`}\n aria-hidden=\"true\"\n />\n {stage.label}\n </span>\n ))}\n </div>\n ) : null}\n {preview ? <DealMapPreviewCard preview={preview} onClose={() => onSelect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AG,yCAAyC,yBAAyB,GAC9F;AAAA,UACA,oBAAC,OAAE,WAAU,qDACV;AAAA,YACC;AAAA,YACA;AAAA,YACA;AAAA,UACF,GACF;AAAA,WACF,GACF,IACE;AAAA,QACH,aAAa,SAAS,IACrB,qBAAC,SAAI,WAAU,sGACb;AAAA,8BAAC,UAAK,WAAU,0EACb,gCAAsB,GAAG,oCAAoC,QAAQ,GACxE;AAAA,UACC,aAAa,IAAI,CAAC,UACjB,qBAAC,UAAoB,WAAU,kEAC7B;AAAA;AAAA,cAAC;AAAA;AAAA,gBACC,WAAW,kCAAkC,gBAAgB,MAAM,IAAI,CAAC;AAAA,gBACxE,eAAY;AAAA;AAAA,YACd;AAAA,YACC,MAAM;AAAA,eALE,MAAM,EAMjB,CACD;AAAA,WACH,IACE;AAAA,QACH,UAAU,oBAAC,sBAAmB,SAAkB,SAAS,MAAM,YAAY,QAAQ,IAAI,GAAG,IAAK;AAAA;AAAA;AAAA,EAClG;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/core",
|
|
3
|
-
"version": "0.6.6-develop.
|
|
3
|
+
"version": "0.6.6-develop.6408.1.0cbfbd7476",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -231,6 +231,11 @@
|
|
|
231
231
|
"@mikro-orm/core": "^7.1.4",
|
|
232
232
|
"@mikro-orm/decorators": "^7.1.4",
|
|
233
233
|
"@mikro-orm/postgresql": "^7.1.4",
|
|
234
|
+
"@types/html-to-text": "^9.0.4",
|
|
235
|
+
"@types/leaflet": "^1.9.12",
|
|
236
|
+
"@types/leaflet.markercluster": "^1.5.5",
|
|
237
|
+
"@types/sanitize-html": "^2.13.0",
|
|
238
|
+
"@types/semver": "^7.5.8",
|
|
234
239
|
"@xyflow/react": "^12.11.0",
|
|
235
240
|
"ai": "^6.0.208",
|
|
236
241
|
"date-fns": "4.4.0",
|
|
@@ -248,28 +253,23 @@
|
|
|
248
253
|
"zod": "^4.4.3"
|
|
249
254
|
},
|
|
250
255
|
"peerDependencies": {
|
|
251
|
-
"@open-mercato/ai-assistant": "0.6.6-develop.
|
|
252
|
-
"@open-mercato/shared": "0.6.6-develop.
|
|
253
|
-
"@open-mercato/ui": "0.6.6-develop.
|
|
256
|
+
"@open-mercato/ai-assistant": "0.6.6-develop.6408.1.0cbfbd7476",
|
|
257
|
+
"@open-mercato/shared": "0.6.6-develop.6408.1.0cbfbd7476",
|
|
258
|
+
"@open-mercato/ui": "0.6.6-develop.6408.1.0cbfbd7476",
|
|
254
259
|
"react": "^19.0.0",
|
|
255
260
|
"react-dom": "^19.0.0"
|
|
256
261
|
},
|
|
257
262
|
"devDependencies": {
|
|
258
|
-
"@open-mercato/ai-assistant": "0.6.6-develop.
|
|
259
|
-
"@open-mercato/shared": "0.6.6-develop.
|
|
260
|
-
"@open-mercato/ui": "0.6.6-develop.
|
|
263
|
+
"@open-mercato/ai-assistant": "0.6.6-develop.6408.1.0cbfbd7476",
|
|
264
|
+
"@open-mercato/shared": "0.6.6-develop.6408.1.0cbfbd7476",
|
|
265
|
+
"@open-mercato/ui": "0.6.6-develop.6408.1.0cbfbd7476",
|
|
261
266
|
"@testing-library/dom": "^10.4.1",
|
|
262
267
|
"@testing-library/jest-dom": "^6.9.1",
|
|
263
268
|
"@testing-library/react": "^16.3.1",
|
|
264
269
|
"@types/chance": "^1.1.8",
|
|
265
|
-
"@types/html-to-text": "^9.0.4",
|
|
266
270
|
"@types/jest": "^30.0.0",
|
|
267
|
-
"@types/leaflet": "^1.9.12",
|
|
268
|
-
"@types/leaflet.markercluster": "^1.5.5",
|
|
269
271
|
"@types/react": "^19.2.17",
|
|
270
272
|
"@types/react-dom": "^19.2.3",
|
|
271
|
-
"@types/sanitize-html": "^2.13.0",
|
|
272
|
-
"@types/semver": "^7.5.8",
|
|
273
273
|
"chance": "^1.1.13",
|
|
274
274
|
"jest": "^30.4.2",
|
|
275
275
|
"jest-environment-jsdom": "^30.4.1",
|
|
@@ -29,8 +29,18 @@ const TILE_ATTRIBUTION =
|
|
|
29
29
|
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
|
30
30
|
// True whenever the EFFECTIVE tile URL targets OSM's public CDN — whether from the bundled default
|
|
31
31
|
// (env unset) OR an env value pointed back at the same public host. OSM's tile usage policy
|
|
32
|
-
// prohibits production/commercial traffic against it.
|
|
33
|
-
|
|
32
|
+
// prohibits production/commercial traffic against it. Match on the parsed hostname rather than a raw
|
|
33
|
+
// substring so a lookalike host (e.g. `tile.openstreetmap.org.example.com`) is not mistaken for OSM.
|
|
34
|
+
function targetsPublicOsmTileHost(tileUrl: string): boolean {
|
|
35
|
+
try {
|
|
36
|
+
const { hostname } = new URL(tileUrl)
|
|
37
|
+
return hostname === 'openstreetmap.org' || hostname.endsWith('.openstreetmap.org')
|
|
38
|
+
} catch {
|
|
39
|
+
return false
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const USING_PUBLIC_OSM_TILES = targetsPublicOsmTileHost(TILE_URL)
|
|
34
44
|
|
|
35
45
|
let publicOsmTileWarningEmitted = false
|
|
36
46
|
// Warn once (per session) so deployments point NEXT_PUBLIC_OM_DEALS_MAP_TILE_URL at a self-hosted or
|