forked from symfony/ux
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Map] Third iteration, introduce Bridges, simplify Map creation and c…
…ustomization, abstract rendering and Stimulus controller
- Loading branch information
Showing
135 changed files
with
2,685 additions
and
2,587 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# CHANGELOG | ||
|
||
## 2.19.0 | ||
## Unreleased | ||
|
||
- Component added |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { Controller } from '@hotwired/stimulus'; | ||
export type LatLng = { | ||
lat: number; | ||
lng: number; | ||
}; | ||
export type MapView<Options, MarkerOptions, InfoWindowOptions> = { | ||
center: LatLng; | ||
zoom: number; | ||
fitBoundsToMarkers: boolean; | ||
markers: Array<MarkerDefinition<MarkerOptions, InfoWindowOptions>>; | ||
options: Options; | ||
}; | ||
export type MarkerDefinition<MarkerOptions, InfoWindowOptions> = { | ||
position: LatLng; | ||
title: string | null; | ||
infoWindow?: Omit<InfoWindowDefinition<InfoWindowOptions>, 'position'>; | ||
rawOptions?: MarkerOptions; | ||
}; | ||
export type InfoWindowDefinition<InfoWindowOptions> = { | ||
headerContent: string | null; | ||
content: string | null; | ||
position: LatLng; | ||
opened: boolean; | ||
autoClose: boolean; | ||
rawOptions?: InfoWindowOptions; | ||
}; | ||
export default abstract class<MapOptions, Map, MarkerOptions, Marker, InfoWindowOptions, InfoWindow> extends Controller<HTMLElement> { | ||
static values: { | ||
providerOptions: ObjectConstructor; | ||
view: ObjectConstructor; | ||
}; | ||
viewValue: MapView<MapOptions, MarkerOptions, InfoWindowOptions>; | ||
protected map: Map; | ||
protected markers: Array<Marker>; | ||
protected infoWindows: Array<InfoWindow>; | ||
initialize(): void; | ||
connect(): void; | ||
protected abstract doCreateMap({ center, zoom, options, }: { | ||
center: LatLng; | ||
zoom: number; | ||
options: MapOptions; | ||
}): Map; | ||
createMarker(definition: MarkerDefinition<MarkerOptions, InfoWindowOptions>): Marker; | ||
protected abstract doCreateMarker(definition: MarkerDefinition<MarkerOptions, InfoWindowOptions>): Marker; | ||
protected createInfoWindow({ definition, marker, }: { | ||
definition: MarkerDefinition<MarkerOptions, InfoWindowOptions>['infoWindow']; | ||
marker: Marker; | ||
}): InfoWindow; | ||
protected abstract doCreateInfoWindow({ definition, marker, }: { | ||
definition: MarkerDefinition<MarkerOptions, InfoWindowOptions>['infoWindow']; | ||
marker: Marker; | ||
}): InfoWindow; | ||
protected abstract doFitBoundsToMarkers(): void; | ||
private dispatchEvent; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Controller } from '@hotwired/stimulus'; | ||
|
||
class default_1 extends Controller { | ||
constructor() { | ||
super(...arguments); | ||
this.markers = []; | ||
this.infoWindows = []; | ||
} | ||
initialize() { } | ||
connect() { | ||
const { center, zoom, options, markers, fitBoundsToMarkers } = this.viewValue; | ||
this.dispatchEvent('pre-connect', { options }); | ||
this.map = this.doCreateMap({ center, zoom, options }); | ||
markers.forEach((marker) => this.createMarker(marker)); | ||
if (fitBoundsToMarkers) { | ||
this.doFitBoundsToMarkers(); | ||
} | ||
this.dispatchEvent('connect', { | ||
map: this.map, | ||
markers: this.markers, | ||
infoWindows: this.infoWindows, | ||
}); | ||
} | ||
createMarker(definition) { | ||
this.dispatchEvent('marker:before-create', { definition }); | ||
const marker = this.doCreateMarker(definition); | ||
this.dispatchEvent('marker:after-create', { marker }); | ||
this.markers.push(marker); | ||
return marker; | ||
} | ||
createInfoWindow({ definition, marker, }) { | ||
this.dispatchEvent('info-window:before-create', { definition, marker }); | ||
const infoWindow = this.doCreateInfoWindow({ definition, marker }); | ||
this.dispatchEvent('info-window:after-create', { infoWindow, marker }); | ||
this.infoWindows.push(infoWindow); | ||
return infoWindow; | ||
} | ||
dispatchEvent(name, payload = {}) { | ||
this.dispatch(name, { prefix: 'ux:map', detail: payload }); | ||
} | ||
} | ||
default_1.values = { | ||
providerOptions: Object, | ||
view: Object, | ||
}; | ||
|
||
export { default_1 as default }; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.