Event Shared Utilities
manifest-ui/event-sharedFreeUtility
Shared utilities for event components (Leaflet map helpers, signal badges).
Install it
npx shadcn@latest add https://ui.manifest.build/r/event-shared.jsonSource
1'use client'23import { cn } from '@/lib/utils'4import { MapPin } from 'lucide-react'5import { lazy } from 'react'6import type { ComponentType } from 'react'7import type { EventSignal } from './types'89// Internal types for react-leaflet component attributes (not exported component props)10export type LeafletMarkerAttrs = {11 position: [number, number]12 // eslint-disable-next-line @typescript-eslint/no-explicit-any13 icon?: any14 zIndexOffset?: number15 eventHandlers?: {16 click?: () => void17 }18}1920// Props for the lazy-loaded leaflet map component21export interface LazyLeafletMapConfig {22 center: [number, number]23 zoom: number24 style?: React.CSSProperties25 scrollWheelZoom?: boolean26 tileUrl?: string27 tileAttribution?: string28 renderMarkers: (ctx: {29 Marker: ComponentType<LeafletMarkerAttrs>30 L: typeof import('leaflet')31 }) => React.ReactNode32}3334/**35 * Lazy-loaded Leaflet map component using React.lazy.36 * Avoids Invalid hook call errors from dynamic import module boundaries.37 */38export const LazyLeafletMap = lazy<ComponentType<LazyLeafletMapConfig>>(async () => {39 // Guard against SSR - react-leaflet/leaflet require window40 if (typeof window === 'undefined') {41 // eslint-disable-next-line @typescript-eslint/no-explicit-any42 return { default: (() => null) as any }43 }4445 const { MapContainer, TileLayer, Marker } = await import('react-leaflet')46 const L = (await import('leaflet')).default4748 // Inject Leaflet CSS with deduplication49 const LEAFLET_CSS_ID = 'leaflet-css-1.9.4'50 if (typeof document !== 'undefined' && !document.getElementById(LEAFLET_CSS_ID)) {51 const link = document.createElement('link')52 link.id = LEAFLET_CSS_ID53 link.rel = 'stylesheet'54 link.href = 'https://unpkg.com/leaflet@1.9.4/dist/leaflet.css'55 document.head.appendChild(link)56 }5758 function LazyLeafletMapComponent(props: LazyLeafletMapConfig) {59 const tileUrl = props.tileUrl ?? 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png'60 const tileAttribution = props.tileAttribution ?? '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> © <a href="https://carto.com/attributions">CARTO</a>'6162 return (63 <MapContainer64 center={props.center}65 zoom={props.zoom}66 style={props.style ?? { height: '100%', width: '100%' }}67 zoomControl={true}68 scrollWheelZoom={props.scrollWheelZoom ?? true}69 >70 <TileLayer attribution={tileAttribution} url={tileUrl} />71// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from Manifest UI
All 32 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Manifest Typesmanifest-types | Manifest UI | Utilities | Free | no deps |
