mirror of
https://github.com/symfony/ux-map.git
synced 2026-03-23 23:42:07 +01:00
Migrate from tsup (deprecated) to tsdown
tsup is deprecated in favor of tsdown. Follow https://github.com/symfony/ux/pull/2935, https://github.com/symfony/ux/pull/2944, and many (local) tries were I was not really happy with the files generated by tsdown/rolldown, we are finally having something extra good! We have the benefits from https://github.com/symfony/ux/pull/2935, https://github.com/symfony/ux/pull/2944, but without their drawbacks. The code correctly follow the `es2022` target and does not do anything weird anymore with static properties (needed by controllers). I (Claude) added a plugin to remove the region and JSDoc comments (except if they contain `@deprecated``), since I think we want to keep the code non-minified.
This commit is contained in:
355
assets/dist/abstract_map_controller.d.ts
vendored
355
assets/dist/abstract_map_controller.d.ts
vendored
@@ -1,197 +1,216 @@
|
||||
import { Controller } from '@hotwired/stimulus';
|
||||
|
||||
import { Controller } from "@hotwired/stimulus";
|
||||
type Point = {
|
||||
lat: number;
|
||||
lng: number;
|
||||
lat: number;
|
||||
lng: number;
|
||||
};
|
||||
type Identifier = string;
|
||||
type WithIdentifier<T extends Record<string, unknown>> = T & {
|
||||
'@id': Identifier;
|
||||
'@id': Identifier;
|
||||
};
|
||||
type ExtraData = Record<string, unknown>;
|
||||
declare const IconTypes: {
|
||||
readonly Url: "url";
|
||||
readonly Svg: "svg";
|
||||
readonly UxIcon: "ux-icon";
|
||||
readonly Url: "url";
|
||||
readonly Svg: "svg";
|
||||
readonly UxIcon: "ux-icon";
|
||||
};
|
||||
type Icon = {
|
||||
width: number;
|
||||
height: number;
|
||||
width: number;
|
||||
height: number;
|
||||
} & ({
|
||||
type: typeof IconTypes.UxIcon;
|
||||
name: string;
|
||||
_generated_html: string;
|
||||
type: typeof IconTypes.UxIcon;
|
||||
name: string;
|
||||
_generated_html: string;
|
||||
} | {
|
||||
type: typeof IconTypes.Url;
|
||||
url: string;
|
||||
type: typeof IconTypes.Url;
|
||||
url: string;
|
||||
} | {
|
||||
type: typeof IconTypes.Svg;
|
||||
html: string;
|
||||
type: typeof IconTypes.Svg;
|
||||
html: string;
|
||||
});
|
||||
type MapDefinition<MapOptions, BridgeMapOptions> = {
|
||||
center: Point | null;
|
||||
zoom: number | null;
|
||||
minZoom: number | null;
|
||||
maxZoom: number | null;
|
||||
options: MapOptions;
|
||||
bridgeOptions?: BridgeMapOptions;
|
||||
extra: ExtraData;
|
||||
center: Point | null;
|
||||
zoom: number | null;
|
||||
minZoom: number | null;
|
||||
maxZoom: number | null;
|
||||
options: MapOptions;
|
||||
bridgeOptions?: BridgeMapOptions;
|
||||
extra: ExtraData;
|
||||
};
|
||||
type MarkerDefinition<BridgeMarkerOptions, BridgeInfoWindowOptions> = WithIdentifier<{
|
||||
position: Point;
|
||||
title: string | null;
|
||||
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
|
||||
icon?: Icon;
|
||||
rawOptions?: BridgeMarkerOptions;
|
||||
bridgeOptions?: BridgeMarkerOptions;
|
||||
extra: ExtraData;
|
||||
position: Point;
|
||||
title: string | null;
|
||||
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
|
||||
icon?: Icon;
|
||||
rawOptions?: BridgeMarkerOptions;
|
||||
bridgeOptions?: BridgeMarkerOptions;
|
||||
extra: ExtraData;
|
||||
}>;
|
||||
type PolygonDefinition<BridgePolygonOptions, BridgeInfoWindowOptions> = WithIdentifier<{
|
||||
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
|
||||
points: Array<Point> | Array<Array<Point>>;
|
||||
title: string | null;
|
||||
rawOptions?: BridgePolygonOptions;
|
||||
bridgeOptions?: BridgePolygonOptions;
|
||||
extra: ExtraData;
|
||||
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
|
||||
points: Array<Point> | Array<Array<Point>>;
|
||||
title: string | null;
|
||||
rawOptions?: BridgePolygonOptions;
|
||||
bridgeOptions?: BridgePolygonOptions;
|
||||
extra: ExtraData;
|
||||
}>;
|
||||
type PolylineDefinition<BridgePolylineOptions, BridgeInfoWindowOptions> = WithIdentifier<{
|
||||
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
|
||||
points: Array<Point>;
|
||||
title: string | null;
|
||||
rawOptions?: BridgePolylineOptions;
|
||||
bridgeOptions?: BridgePolylineOptions;
|
||||
extra: ExtraData;
|
||||
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
|
||||
points: Array<Point>;
|
||||
title: string | null;
|
||||
rawOptions?: BridgePolylineOptions;
|
||||
bridgeOptions?: BridgePolylineOptions;
|
||||
extra: ExtraData;
|
||||
}>;
|
||||
type CircleDefinition<BridgeCircleOptions, BridgeInfoWindowOptions> = WithIdentifier<{
|
||||
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
|
||||
center: Point;
|
||||
radius: number;
|
||||
title: string | null;
|
||||
rawOptions?: BridgeCircleOptions;
|
||||
bridgeOptions?: BridgeCircleOptions;
|
||||
extra: ExtraData;
|
||||
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
|
||||
center: Point;
|
||||
radius: number;
|
||||
title: string | null;
|
||||
rawOptions?: BridgeCircleOptions;
|
||||
bridgeOptions?: BridgeCircleOptions;
|
||||
extra: ExtraData;
|
||||
}>;
|
||||
type RectangleDefinition<BridgeRectangleOptions, BridgeInfoWindowOptions> = WithIdentifier<{
|
||||
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
|
||||
southWest: Point;
|
||||
northEast: Point;
|
||||
title: string | null;
|
||||
rawOptions?: BridgeRectangleOptions;
|
||||
bridgeOptions?: BridgeRectangleOptions;
|
||||
extra: ExtraData;
|
||||
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
|
||||
southWest: Point;
|
||||
northEast: Point;
|
||||
title: string | null;
|
||||
rawOptions?: BridgeRectangleOptions;
|
||||
bridgeOptions?: BridgeRectangleOptions;
|
||||
extra: ExtraData;
|
||||
}>;
|
||||
type InfoWindowDefinition<BridgeInfoWindowOptions> = {
|
||||
headerContent: string | null;
|
||||
content: string | null;
|
||||
position: Point;
|
||||
opened: boolean;
|
||||
autoClose: boolean;
|
||||
rawOptions?: BridgeInfoWindowOptions;
|
||||
bridgeOptions?: BridgeInfoWindowOptions;
|
||||
extra: ExtraData;
|
||||
headerContent: string | null;
|
||||
content: string | null;
|
||||
position: Point;
|
||||
opened: boolean;
|
||||
autoClose: boolean;
|
||||
rawOptions?: BridgeInfoWindowOptions;
|
||||
bridgeOptions?: BridgeInfoWindowOptions;
|
||||
extra: ExtraData;
|
||||
};
|
||||
declare abstract class export_default<MapOptions, BridgeMapOptions, BridgeMap, BridgeMarkerOptions, BridgeMarker, BridgeInfoWindowOptions, BridgeInfoWindow, BridgePolygonOptions, BridgePolygon, BridgePolylineOptions, BridgePolyline, BridgeCircleOptions, BridgeCircle, BridgeRectangleOptions, BridgeRectangle> extends Controller<HTMLElement> {
|
||||
static values: {
|
||||
providerOptions: ObjectConstructor;
|
||||
center: ObjectConstructor;
|
||||
zoom: NumberConstructor;
|
||||
minZoom: NumberConstructor;
|
||||
maxZoom: NumberConstructor;
|
||||
fitBoundsToMarkers: BooleanConstructor;
|
||||
markers: ArrayConstructor;
|
||||
polygons: ArrayConstructor;
|
||||
polylines: ArrayConstructor;
|
||||
circles: ArrayConstructor;
|
||||
rectangles: ArrayConstructor;
|
||||
options: ObjectConstructor;
|
||||
extra: ObjectConstructor;
|
||||
};
|
||||
centerValue: Point | null;
|
||||
zoomValue: number | null;
|
||||
minZoomValue: number | null;
|
||||
maxZoomValue: number | null;
|
||||
fitBoundsToMarkersValue: boolean;
|
||||
markersValue: Array<MarkerDefinition<BridgeMarkerOptions, BridgeInfoWindowOptions>>;
|
||||
polygonsValue: Array<PolygonDefinition<BridgePolygonOptions, BridgeInfoWindowOptions>>;
|
||||
polylinesValue: Array<PolylineDefinition<BridgePolylineOptions, BridgeInfoWindowOptions>>;
|
||||
circlesValue: Array<CircleDefinition<BridgeCircleOptions, BridgeInfoWindowOptions>>;
|
||||
rectanglesValue: Array<RectangleDefinition<BridgeRectangleOptions, BridgeInfoWindowOptions>>;
|
||||
optionsValue: MapOptions;
|
||||
extraValue: Record<string, unknown>;
|
||||
hasCenterValue: boolean;
|
||||
hasZoomValue: boolean;
|
||||
hasMinZoomValue: boolean;
|
||||
hasMaxZoomValue: boolean;
|
||||
hasFitBoundsToMarkersValue: boolean;
|
||||
hasMarkersValue: boolean;
|
||||
hasPolygonsValue: boolean;
|
||||
hasPolylinesValue: boolean;
|
||||
hasCirclesValue: boolean;
|
||||
hasRectanglesValue: boolean;
|
||||
hasOptionsValue: boolean;
|
||||
hasExtraValue: boolean;
|
||||
protected map: BridgeMap;
|
||||
protected markers: Map<string, BridgeMarker>;
|
||||
protected polygons: Map<string, BridgePolygon>;
|
||||
protected polylines: Map<string, BridgePolyline>;
|
||||
protected circles: Map<string, BridgeCircle>;
|
||||
protected rectangles: Map<string, BridgeRectangle>;
|
||||
protected infoWindows: Array<BridgeInfoWindow>;
|
||||
private isConnected;
|
||||
private createMarker;
|
||||
private createPolygon;
|
||||
private createPolyline;
|
||||
private createCircle;
|
||||
private createRectangle;
|
||||
protected abstract dispatchEvent(name: string, payload: Record<string, unknown>): void;
|
||||
connect(): void;
|
||||
createInfoWindow({ definition, element, }: {
|
||||
definition: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
|
||||
element: BridgeMarker | BridgePolygon | BridgePolyline | BridgeCircle | BridgeRectangle;
|
||||
}): BridgeInfoWindow;
|
||||
abstract centerValueChanged(): void;
|
||||
abstract zoomValueChanged(): void;
|
||||
abstract minZoomValueChanged(): void;
|
||||
abstract maxZoomValueChanged(): void;
|
||||
markersValueChanged(): void;
|
||||
polygonsValueChanged(): void;
|
||||
polylinesValueChanged(): void;
|
||||
circlesValueChanged(): void;
|
||||
rectanglesValueChanged(): void;
|
||||
protected abstract doCreateMap({ definition, }: {
|
||||
definition: MapDefinition<MapOptions, BridgeMapOptions>;
|
||||
}): BridgeMap;
|
||||
protected abstract doFitBoundsToMarkers(): void;
|
||||
protected abstract doCreateMarker({ definition, }: {
|
||||
definition: MarkerDefinition<BridgeMarkerOptions, BridgeInfoWindowOptions>;
|
||||
}): BridgeMarker;
|
||||
protected abstract doRemoveMarker(marker: BridgeMarker): void;
|
||||
protected abstract doCreatePolygon({ definition, }: {
|
||||
definition: PolygonDefinition<BridgePolygonOptions, BridgeInfoWindowOptions>;
|
||||
}): BridgePolygon;
|
||||
protected abstract doRemovePolygon(polygon: BridgePolygon): void;
|
||||
protected abstract doCreatePolyline({ definition, }: {
|
||||
definition: PolylineDefinition<BridgePolylineOptions, BridgeInfoWindowOptions>;
|
||||
}): BridgePolyline;
|
||||
protected abstract doRemovePolyline(polyline: BridgePolyline): void;
|
||||
protected abstract doCreateCircle({ definition, }: {
|
||||
definition: CircleDefinition<BridgeCircleOptions, BridgeInfoWindowOptions>;
|
||||
}): BridgeCircle;
|
||||
protected abstract doRemoveCircle(circle: BridgeCircle): void;
|
||||
protected abstract doCreateRectangle({ definition, }: {
|
||||
definition: RectangleDefinition<BridgeRectangleOptions, BridgeInfoWindowOptions>;
|
||||
}): BridgeRectangle;
|
||||
protected abstract doRemoveRectangle(rectangle: BridgeRectangle): void;
|
||||
protected abstract doCreateInfoWindow({ definition, element, }: {
|
||||
definition: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
|
||||
element: BridgeMarker | BridgePolygon | BridgePolyline | BridgeCircle | BridgeRectangle;
|
||||
}): BridgeInfoWindow;
|
||||
protected abstract doCreateIcon({ definition, element }: {
|
||||
definition: Icon;
|
||||
element: BridgeMarker;
|
||||
}): void;
|
||||
private createDrawingFactory;
|
||||
private onDrawChanged;
|
||||
static values: {
|
||||
providerOptions: ObjectConstructor;
|
||||
center: ObjectConstructor;
|
||||
zoom: NumberConstructor;
|
||||
minZoom: NumberConstructor;
|
||||
maxZoom: NumberConstructor;
|
||||
fitBoundsToMarkers: BooleanConstructor;
|
||||
markers: ArrayConstructor;
|
||||
polygons: ArrayConstructor;
|
||||
polylines: ArrayConstructor;
|
||||
circles: ArrayConstructor;
|
||||
rectangles: ArrayConstructor;
|
||||
options: ObjectConstructor;
|
||||
extra: ObjectConstructor;
|
||||
};
|
||||
centerValue: Point | null;
|
||||
zoomValue: number | null;
|
||||
minZoomValue: number | null;
|
||||
maxZoomValue: number | null;
|
||||
fitBoundsToMarkersValue: boolean;
|
||||
markersValue: Array<MarkerDefinition<BridgeMarkerOptions, BridgeInfoWindowOptions>>;
|
||||
polygonsValue: Array<PolygonDefinition<BridgePolygonOptions, BridgeInfoWindowOptions>>;
|
||||
polylinesValue: Array<PolylineDefinition<BridgePolylineOptions, BridgeInfoWindowOptions>>;
|
||||
circlesValue: Array<CircleDefinition<BridgeCircleOptions, BridgeInfoWindowOptions>>;
|
||||
rectanglesValue: Array<RectangleDefinition<BridgeRectangleOptions, BridgeInfoWindowOptions>>;
|
||||
optionsValue: MapOptions;
|
||||
extraValue: Record<string, unknown>;
|
||||
hasCenterValue: boolean;
|
||||
hasZoomValue: boolean;
|
||||
hasMinZoomValue: boolean;
|
||||
hasMaxZoomValue: boolean;
|
||||
hasFitBoundsToMarkersValue: boolean;
|
||||
hasMarkersValue: boolean;
|
||||
hasPolygonsValue: boolean;
|
||||
hasPolylinesValue: boolean;
|
||||
hasCirclesValue: boolean;
|
||||
hasRectanglesValue: boolean;
|
||||
hasOptionsValue: boolean;
|
||||
hasExtraValue: boolean;
|
||||
protected map: BridgeMap;
|
||||
protected markers: Map<string, BridgeMarker>;
|
||||
protected polygons: Map<string, BridgePolygon>;
|
||||
protected polylines: Map<string, BridgePolyline>;
|
||||
protected circles: Map<string, BridgeCircle>;
|
||||
protected rectangles: Map<string, BridgeRectangle>;
|
||||
protected infoWindows: Array<BridgeInfoWindow>;
|
||||
private isConnected;
|
||||
private createMarker;
|
||||
private createPolygon;
|
||||
private createPolyline;
|
||||
private createCircle;
|
||||
private createRectangle;
|
||||
protected abstract dispatchEvent(name: string, payload: Record<string, unknown>): void;
|
||||
connect(): void;
|
||||
createInfoWindow({
|
||||
definition,
|
||||
element
|
||||
}: {
|
||||
definition: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
|
||||
element: BridgeMarker | BridgePolygon | BridgePolyline | BridgeCircle | BridgeRectangle;
|
||||
}): BridgeInfoWindow;
|
||||
abstract centerValueChanged(): void;
|
||||
abstract zoomValueChanged(): void;
|
||||
abstract minZoomValueChanged(): void;
|
||||
abstract maxZoomValueChanged(): void;
|
||||
markersValueChanged(): void;
|
||||
polygonsValueChanged(): void;
|
||||
polylinesValueChanged(): void;
|
||||
circlesValueChanged(): void;
|
||||
rectanglesValueChanged(): void;
|
||||
protected abstract doCreateMap({
|
||||
definition
|
||||
}: {
|
||||
definition: MapDefinition<MapOptions, BridgeMapOptions>;
|
||||
}): BridgeMap;
|
||||
protected abstract doFitBoundsToMarkers(): void;
|
||||
protected abstract doCreateMarker({
|
||||
definition
|
||||
}: {
|
||||
definition: MarkerDefinition<BridgeMarkerOptions, BridgeInfoWindowOptions>;
|
||||
}): BridgeMarker;
|
||||
protected abstract doRemoveMarker(marker: BridgeMarker): void;
|
||||
protected abstract doCreatePolygon({
|
||||
definition
|
||||
}: {
|
||||
definition: PolygonDefinition<BridgePolygonOptions, BridgeInfoWindowOptions>;
|
||||
}): BridgePolygon;
|
||||
protected abstract doRemovePolygon(polygon: BridgePolygon): void;
|
||||
protected abstract doCreatePolyline({
|
||||
definition
|
||||
}: {
|
||||
definition: PolylineDefinition<BridgePolylineOptions, BridgeInfoWindowOptions>;
|
||||
}): BridgePolyline;
|
||||
protected abstract doRemovePolyline(polyline: BridgePolyline): void;
|
||||
protected abstract doCreateCircle({
|
||||
definition
|
||||
}: {
|
||||
definition: CircleDefinition<BridgeCircleOptions, BridgeInfoWindowOptions>;
|
||||
}): BridgeCircle;
|
||||
protected abstract doRemoveCircle(circle: BridgeCircle): void;
|
||||
protected abstract doCreateRectangle({
|
||||
definition
|
||||
}: {
|
||||
definition: RectangleDefinition<BridgeRectangleOptions, BridgeInfoWindowOptions>;
|
||||
}): BridgeRectangle;
|
||||
protected abstract doRemoveRectangle(rectangle: BridgeRectangle): void;
|
||||
protected abstract doCreateInfoWindow({
|
||||
definition,
|
||||
element
|
||||
}: {
|
||||
definition: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
|
||||
element: BridgeMarker | BridgePolygon | BridgePolyline | BridgeCircle | BridgeRectangle;
|
||||
}): BridgeInfoWindow;
|
||||
protected abstract doCreateIcon({
|
||||
definition,
|
||||
element
|
||||
}: {
|
||||
definition: Icon;
|
||||
element: BridgeMarker;
|
||||
}): void;
|
||||
private createDrawingFactory;
|
||||
private onDrawChanged;
|
||||
}
|
||||
|
||||
export { type CircleDefinition, type Icon, IconTypes, type Identifier, type InfoWindowDefinition, type MapDefinition, type MarkerDefinition, type Point, type PolygonDefinition, type PolylineDefinition, type RectangleDefinition, type WithIdentifier, export_default as default };
|
||||
export { CircleDefinition, Icon, IconTypes, Identifier, InfoWindowDefinition, MapDefinition, MarkerDefinition, Point, PolygonDefinition, PolylineDefinition, RectangleDefinition, WithIdentifier, export_default as default };
|
||||
304
assets/dist/abstract_map_controller.js
vendored
304
assets/dist/abstract_map_controller.js
vendored
@@ -1,167 +1,145 @@
|
||||
// src/abstract_map_controller.ts
|
||||
import { Controller } from "@hotwired/stimulus";
|
||||
var IconTypes = {
|
||||
Url: "url",
|
||||
Svg: "svg",
|
||||
UxIcon: "ux-icon"
|
||||
const IconTypes = {
|
||||
Url: "url",
|
||||
Svg: "svg",
|
||||
UxIcon: "ux-icon"
|
||||
};
|
||||
var abstract_map_controller_default = class extends Controller {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.markers = /* @__PURE__ */ new Map();
|
||||
this.polygons = /* @__PURE__ */ new Map();
|
||||
this.polylines = /* @__PURE__ */ new Map();
|
||||
this.circles = /* @__PURE__ */ new Map();
|
||||
this.rectangles = /* @__PURE__ */ new Map();
|
||||
this.infoWindows = [];
|
||||
this.isConnected = false;
|
||||
}
|
||||
connect() {
|
||||
const extra = this.hasExtraValue ? this.extraValue : {};
|
||||
const mapDefinition = {
|
||||
center: this.hasCenterValue ? this.centerValue : null,
|
||||
zoom: this.hasZoomValue ? this.zoomValue : null,
|
||||
minZoom: this.hasMinZoomValue ? this.minZoomValue : null,
|
||||
maxZoom: this.hasMaxZoomValue ? this.maxZoomValue : null,
|
||||
options: this.optionsValue,
|
||||
extra
|
||||
};
|
||||
this.dispatchEvent("pre-connect", mapDefinition);
|
||||
this.createMarker = this.createDrawingFactory("marker", this.markers, this.doCreateMarker.bind(this));
|
||||
this.createPolygon = this.createDrawingFactory("polygon", this.polygons, this.doCreatePolygon.bind(this));
|
||||
this.createPolyline = this.createDrawingFactory("polyline", this.polylines, this.doCreatePolyline.bind(this));
|
||||
this.createCircle = this.createDrawingFactory("circle", this.circles, this.doCreateCircle.bind(this));
|
||||
this.createRectangle = this.createDrawingFactory(
|
||||
"rectangle",
|
||||
this.rectangles,
|
||||
this.doCreateRectangle.bind(this)
|
||||
);
|
||||
this.map = this.doCreateMap({ definition: mapDefinition });
|
||||
this.markersValue.forEach((definition) => {
|
||||
this.createMarker({ definition });
|
||||
});
|
||||
this.polygonsValue.forEach((definition) => {
|
||||
this.createPolygon({ definition });
|
||||
});
|
||||
this.polylinesValue.forEach((definition) => {
|
||||
this.createPolyline({ definition });
|
||||
});
|
||||
this.circlesValue.forEach((definition) => {
|
||||
this.createCircle({ definition });
|
||||
});
|
||||
this.rectanglesValue.forEach((definition) => {
|
||||
this.createRectangle({ definition });
|
||||
});
|
||||
if (this.fitBoundsToMarkersValue) {
|
||||
this.doFitBoundsToMarkers();
|
||||
}
|
||||
this.dispatchEvent("connect", {
|
||||
map: this.map,
|
||||
markers: [...this.markers.values()],
|
||||
polygons: [...this.polygons.values()],
|
||||
polylines: [...this.polylines.values()],
|
||||
circles: [...this.circles.values()],
|
||||
rectangles: [...this.rectangles.values()],
|
||||
infoWindows: this.infoWindows,
|
||||
extra
|
||||
});
|
||||
this.isConnected = true;
|
||||
}
|
||||
//region Public API
|
||||
createInfoWindow({
|
||||
definition,
|
||||
element
|
||||
}) {
|
||||
this.dispatchEvent("info-window:before-create", { definition, element });
|
||||
const infoWindow = this.doCreateInfoWindow({ definition, element });
|
||||
this.dispatchEvent("info-window:after-create", { infoWindow, definition, element });
|
||||
this.infoWindows.push(infoWindow);
|
||||
return infoWindow;
|
||||
}
|
||||
markersValueChanged() {
|
||||
if (!this.isConnected) {
|
||||
return;
|
||||
}
|
||||
this.onDrawChanged(this.markers, this.markersValue, this.createMarker, this.doRemoveMarker);
|
||||
if (this.fitBoundsToMarkersValue) {
|
||||
this.doFitBoundsToMarkers();
|
||||
}
|
||||
}
|
||||
polygonsValueChanged() {
|
||||
if (!this.isConnected) {
|
||||
return;
|
||||
}
|
||||
this.onDrawChanged(this.polygons, this.polygonsValue, this.createPolygon, this.doRemovePolygon);
|
||||
}
|
||||
polylinesValueChanged() {
|
||||
if (!this.isConnected) {
|
||||
return;
|
||||
}
|
||||
this.onDrawChanged(this.polylines, this.polylinesValue, this.createPolyline, this.doRemovePolyline);
|
||||
}
|
||||
circlesValueChanged() {
|
||||
if (!this.isConnected) {
|
||||
return;
|
||||
}
|
||||
this.onDrawChanged(this.circles, this.circlesValue, this.createCircle, this.doRemoveCircle);
|
||||
}
|
||||
rectanglesValueChanged() {
|
||||
if (!this.isConnected) {
|
||||
return;
|
||||
}
|
||||
this.onDrawChanged(this.rectangles, this.rectanglesValue, this.createRectangle, this.doRemoveRectangle);
|
||||
}
|
||||
createDrawingFactory(type, draws, factory) {
|
||||
const eventBefore = `${type}:before-create`;
|
||||
const eventAfter = `${type}:after-create`;
|
||||
return ({ definition }) => {
|
||||
this.dispatchEvent(eventBefore, { definition });
|
||||
if (typeof definition.rawOptions !== "undefined") {
|
||||
console.warn(
|
||||
`[Symfony UX Map] The event "${eventBefore}" added a deprecated "rawOptions" property to the definition, it will be removed in a next major version, replace it with "bridgeOptions" instead.`,
|
||||
definition
|
||||
);
|
||||
}
|
||||
const drawing = factory({ definition });
|
||||
this.dispatchEvent(eventAfter, { [type]: drawing, definition });
|
||||
draws.set(definition["@id"], drawing);
|
||||
return drawing;
|
||||
};
|
||||
}
|
||||
onDrawChanged(draws, newDrawDefinitions, factory, remover) {
|
||||
const idsToRemove = new Set(draws.keys());
|
||||
newDrawDefinitions.forEach((definition) => {
|
||||
idsToRemove.delete(definition["@id"]);
|
||||
});
|
||||
idsToRemove.forEach((id) => {
|
||||
const draw = draws.get(id);
|
||||
remover(draw);
|
||||
draws.delete(id);
|
||||
});
|
||||
newDrawDefinitions.forEach((definition) => {
|
||||
if (!draws.has(definition["@id"])) {
|
||||
factory({ definition });
|
||||
}
|
||||
});
|
||||
}
|
||||
//endregion
|
||||
var _Class = class extends Controller {
|
||||
constructor(..._args) {
|
||||
super(..._args);
|
||||
this.markers = /* @__PURE__ */ new Map();
|
||||
this.polygons = /* @__PURE__ */ new Map();
|
||||
this.polylines = /* @__PURE__ */ new Map();
|
||||
this.circles = /* @__PURE__ */ new Map();
|
||||
this.rectangles = /* @__PURE__ */ new Map();
|
||||
this.infoWindows = [];
|
||||
this.isConnected = false;
|
||||
}
|
||||
connect() {
|
||||
const extra = this.hasExtraValue ? this.extraValue : {};
|
||||
const mapDefinition = {
|
||||
center: this.hasCenterValue ? this.centerValue : null,
|
||||
zoom: this.hasZoomValue ? this.zoomValue : null,
|
||||
minZoom: this.hasMinZoomValue ? this.minZoomValue : null,
|
||||
maxZoom: this.hasMaxZoomValue ? this.maxZoomValue : null,
|
||||
options: this.optionsValue,
|
||||
extra
|
||||
};
|
||||
this.dispatchEvent("pre-connect", mapDefinition);
|
||||
this.createMarker = this.createDrawingFactory("marker", this.markers, this.doCreateMarker.bind(this));
|
||||
this.createPolygon = this.createDrawingFactory("polygon", this.polygons, this.doCreatePolygon.bind(this));
|
||||
this.createPolyline = this.createDrawingFactory("polyline", this.polylines, this.doCreatePolyline.bind(this));
|
||||
this.createCircle = this.createDrawingFactory("circle", this.circles, this.doCreateCircle.bind(this));
|
||||
this.createRectangle = this.createDrawingFactory("rectangle", this.rectangles, this.doCreateRectangle.bind(this));
|
||||
this.map = this.doCreateMap({ definition: mapDefinition });
|
||||
this.markersValue.forEach((definition) => {
|
||||
this.createMarker({ definition });
|
||||
});
|
||||
this.polygonsValue.forEach((definition) => {
|
||||
this.createPolygon({ definition });
|
||||
});
|
||||
this.polylinesValue.forEach((definition) => {
|
||||
this.createPolyline({ definition });
|
||||
});
|
||||
this.circlesValue.forEach((definition) => {
|
||||
this.createCircle({ definition });
|
||||
});
|
||||
this.rectanglesValue.forEach((definition) => {
|
||||
this.createRectangle({ definition });
|
||||
});
|
||||
if (this.fitBoundsToMarkersValue) this.doFitBoundsToMarkers();
|
||||
this.dispatchEvent("connect", {
|
||||
map: this.map,
|
||||
markers: [...this.markers.values()],
|
||||
polygons: [...this.polygons.values()],
|
||||
polylines: [...this.polylines.values()],
|
||||
circles: [...this.circles.values()],
|
||||
rectangles: [...this.rectangles.values()],
|
||||
infoWindows: this.infoWindows,
|
||||
extra
|
||||
});
|
||||
this.isConnected = true;
|
||||
}
|
||||
createInfoWindow({ definition, element }) {
|
||||
this.dispatchEvent("info-window:before-create", {
|
||||
definition,
|
||||
element
|
||||
});
|
||||
const infoWindow = this.doCreateInfoWindow({
|
||||
definition,
|
||||
element
|
||||
});
|
||||
this.dispatchEvent("info-window:after-create", {
|
||||
infoWindow,
|
||||
definition,
|
||||
element
|
||||
});
|
||||
this.infoWindows.push(infoWindow);
|
||||
return infoWindow;
|
||||
}
|
||||
markersValueChanged() {
|
||||
if (!this.isConnected) return;
|
||||
this.onDrawChanged(this.markers, this.markersValue, this.createMarker, this.doRemoveMarker);
|
||||
if (this.fitBoundsToMarkersValue) this.doFitBoundsToMarkers();
|
||||
}
|
||||
polygonsValueChanged() {
|
||||
if (!this.isConnected) return;
|
||||
this.onDrawChanged(this.polygons, this.polygonsValue, this.createPolygon, this.doRemovePolygon);
|
||||
}
|
||||
polylinesValueChanged() {
|
||||
if (!this.isConnected) return;
|
||||
this.onDrawChanged(this.polylines, this.polylinesValue, this.createPolyline, this.doRemovePolyline);
|
||||
}
|
||||
circlesValueChanged() {
|
||||
if (!this.isConnected) return;
|
||||
this.onDrawChanged(this.circles, this.circlesValue, this.createCircle, this.doRemoveCircle);
|
||||
}
|
||||
rectanglesValueChanged() {
|
||||
if (!this.isConnected) return;
|
||||
this.onDrawChanged(this.rectangles, this.rectanglesValue, this.createRectangle, this.doRemoveRectangle);
|
||||
}
|
||||
createDrawingFactory(type, draws, factory) {
|
||||
const eventBefore = `${type}:before-create`;
|
||||
const eventAfter = `${type}:after-create`;
|
||||
return ({ definition }) => {
|
||||
this.dispatchEvent(eventBefore, { definition });
|
||||
if (typeof definition.rawOptions !== "undefined") console.warn(`[Symfony UX Map] The event "${eventBefore}" added a deprecated "rawOptions" property to the definition, it will be removed in a next major version, replace it with "bridgeOptions" instead.`, definition);
|
||||
const drawing = factory({ definition });
|
||||
this.dispatchEvent(eventAfter, {
|
||||
[type]: drawing,
|
||||
definition
|
||||
});
|
||||
draws.set(definition["@id"], drawing);
|
||||
return drawing;
|
||||
};
|
||||
}
|
||||
onDrawChanged(draws, newDrawDefinitions, factory, remover) {
|
||||
const idsToRemove = new Set(draws.keys());
|
||||
newDrawDefinitions.forEach((definition) => {
|
||||
idsToRemove.delete(definition["@id"]);
|
||||
});
|
||||
idsToRemove.forEach((id) => {
|
||||
remover(draws.get(id));
|
||||
draws.delete(id);
|
||||
});
|
||||
newDrawDefinitions.forEach((definition) => {
|
||||
if (!draws.has(definition["@id"])) factory({ definition });
|
||||
});
|
||||
}
|
||||
};
|
||||
abstract_map_controller_default.values = {
|
||||
providerOptions: Object,
|
||||
center: Object,
|
||||
zoom: Number,
|
||||
minZoom: Number,
|
||||
maxZoom: Number,
|
||||
fitBoundsToMarkers: Boolean,
|
||||
markers: Array,
|
||||
polygons: Array,
|
||||
polylines: Array,
|
||||
circles: Array,
|
||||
rectangles: Array,
|
||||
options: Object,
|
||||
extra: Object
|
||||
};
|
||||
export {
|
||||
IconTypes,
|
||||
abstract_map_controller_default as default
|
||||
_Class.values = {
|
||||
providerOptions: Object,
|
||||
center: Object,
|
||||
zoom: Number,
|
||||
minZoom: Number,
|
||||
maxZoom: Number,
|
||||
fitBoundsToMarkers: Boolean,
|
||||
markers: Array,
|
||||
polygons: Array,
|
||||
polylines: Array,
|
||||
circles: Array,
|
||||
rectangles: Array,
|
||||
options: Object,
|
||||
extra: Object
|
||||
};
|
||||
export { IconTypes, _Class as default };
|
||||
Reference in New Issue
Block a user