mirror of
https://github.com/symfony/ux-map.git
synced 2026-03-23 23:42:07 +01:00
Modernize and simplify our packages building tools, replace Rollup by tsup
This commit is contained in:
30
assets/dist/abstract_map_controller.d.ts
vendored
30
assets/dist/abstract_map_controller.d.ts
vendored
@@ -1,19 +1,20 @@
|
||||
import { Controller } from '@hotwired/stimulus';
|
||||
export type Point = {
|
||||
|
||||
type Point = {
|
||||
lat: number;
|
||||
lng: number;
|
||||
};
|
||||
export type Identifier = string;
|
||||
export type WithIdentifier<T extends Record<string, unknown>> = T & {
|
||||
type Identifier = string;
|
||||
type WithIdentifier<T extends Record<string, unknown>> = T & {
|
||||
'@id': Identifier;
|
||||
};
|
||||
type ExtraData = Record<string, unknown>;
|
||||
export declare const IconTypes: {
|
||||
declare const IconTypes: {
|
||||
readonly Url: "url";
|
||||
readonly Svg: "svg";
|
||||
readonly UxIcon: "ux-icon";
|
||||
};
|
||||
export type Icon = {
|
||||
type Icon = {
|
||||
width: number;
|
||||
height: number;
|
||||
} & ({
|
||||
@@ -27,7 +28,7 @@ export type Icon = {
|
||||
type: typeof IconTypes.Svg;
|
||||
html: string;
|
||||
});
|
||||
export type MapDefinition<MapOptions, BridgeMapOptions> = {
|
||||
type MapDefinition<MapOptions, BridgeMapOptions> = {
|
||||
center: Point | null;
|
||||
zoom: number | null;
|
||||
minZoom: number | null;
|
||||
@@ -36,7 +37,7 @@ export type MapDefinition<MapOptions, BridgeMapOptions> = {
|
||||
bridgeOptions?: BridgeMapOptions;
|
||||
extra: ExtraData;
|
||||
};
|
||||
export type MarkerDefinition<BridgeMarkerOptions, BridgeInfoWindowOptions> = WithIdentifier<{
|
||||
type MarkerDefinition<BridgeMarkerOptions, BridgeInfoWindowOptions> = WithIdentifier<{
|
||||
position: Point;
|
||||
title: string | null;
|
||||
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
|
||||
@@ -45,7 +46,7 @@ export type MarkerDefinition<BridgeMarkerOptions, BridgeInfoWindowOptions> = Wit
|
||||
bridgeOptions?: BridgeMarkerOptions;
|
||||
extra: ExtraData;
|
||||
}>;
|
||||
export type PolygonDefinition<BridgePolygonOptions, BridgeInfoWindowOptions> = WithIdentifier<{
|
||||
type PolygonDefinition<BridgePolygonOptions, BridgeInfoWindowOptions> = WithIdentifier<{
|
||||
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
|
||||
points: Array<Point> | Array<Array<Point>>;
|
||||
title: string | null;
|
||||
@@ -53,7 +54,7 @@ export type PolygonDefinition<BridgePolygonOptions, BridgeInfoWindowOptions> = W
|
||||
bridgeOptions?: BridgePolygonOptions;
|
||||
extra: ExtraData;
|
||||
}>;
|
||||
export type PolylineDefinition<BridgePolylineOptions, BridgeInfoWindowOptions> = WithIdentifier<{
|
||||
type PolylineDefinition<BridgePolylineOptions, BridgeInfoWindowOptions> = WithIdentifier<{
|
||||
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
|
||||
points: Array<Point>;
|
||||
title: string | null;
|
||||
@@ -61,7 +62,7 @@ export type PolylineDefinition<BridgePolylineOptions, BridgeInfoWindowOptions> =
|
||||
bridgeOptions?: BridgePolylineOptions;
|
||||
extra: ExtraData;
|
||||
}>;
|
||||
export type CircleDefinition<BridgeCircleOptions, BridgeInfoWindowOptions> = WithIdentifier<{
|
||||
type CircleDefinition<BridgeCircleOptions, BridgeInfoWindowOptions> = WithIdentifier<{
|
||||
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
|
||||
center: Point;
|
||||
radius: number;
|
||||
@@ -70,7 +71,7 @@ export type CircleDefinition<BridgeCircleOptions, BridgeInfoWindowOptions> = Wit
|
||||
bridgeOptions?: BridgeCircleOptions;
|
||||
extra: ExtraData;
|
||||
}>;
|
||||
export type RectangleDefinition<BridgeRectangleOptions, BridgeInfoWindowOptions> = WithIdentifier<{
|
||||
type RectangleDefinition<BridgeRectangleOptions, BridgeInfoWindowOptions> = WithIdentifier<{
|
||||
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
|
||||
southWest: Point;
|
||||
northEast: Point;
|
||||
@@ -79,7 +80,7 @@ export type RectangleDefinition<BridgeRectangleOptions, BridgeInfoWindowOptions>
|
||||
bridgeOptions?: BridgeRectangleOptions;
|
||||
extra: ExtraData;
|
||||
}>;
|
||||
export type InfoWindowDefinition<BridgeInfoWindowOptions> = {
|
||||
type InfoWindowDefinition<BridgeInfoWindowOptions> = {
|
||||
headerContent: string | null;
|
||||
content: string | null;
|
||||
position: Point;
|
||||
@@ -89,7 +90,7 @@ export type InfoWindowDefinition<BridgeInfoWindowOptions> = {
|
||||
bridgeOptions?: BridgeInfoWindowOptions;
|
||||
extra: ExtraData;
|
||||
};
|
||||
export default abstract class<MapOptions, BridgeMapOptions, BridgeMap, BridgeMarkerOptions, BridgeMarker, BridgeInfoWindowOptions, BridgeInfoWindow, BridgePolygonOptions, BridgePolygon, BridgePolylineOptions, BridgePolyline, BridgeCircleOptions, BridgeCircle, BridgeRectangleOptions, BridgeRectangle> extends Controller<HTMLElement> {
|
||||
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;
|
||||
@@ -192,4 +193,5 @@ export default abstract class<MapOptions, BridgeMapOptions, BridgeMap, BridgeMar
|
||||
private createDrawingFactory;
|
||||
private onDrawChanged;
|
||||
}
|
||||
export {};
|
||||
|
||||
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 };
|
||||
|
||||
278
assets/dist/abstract_map_controller.js
vendored
278
assets/dist/abstract_map_controller.js
vendored
@@ -1,143 +1,153 @@
|
||||
import { Controller } from '@hotwired/stimulus';
|
||||
|
||||
const IconTypes = {
|
||||
Url: 'url',
|
||||
Svg: 'svg',
|
||||
UxIcon: 'ux-icon',
|
||||
// src/abstract_map_controller.ts
|
||||
import { Controller } from "@hotwired/stimulus";
|
||||
var IconTypes = {
|
||||
Url: "url",
|
||||
Svg: "svg",
|
||||
UxIcon: "ux-icon"
|
||||
};
|
||||
class default_1 extends Controller {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.markers = new Map();
|
||||
this.polygons = new Map();
|
||||
this.polylines = new Map();
|
||||
this.circles = new Map();
|
||||
this.rectangles = new Map();
|
||||
this.infoWindows = [];
|
||||
this.isConnected = false;
|
||||
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();
|
||||
}
|
||||
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;
|
||||
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;
|
||||
}
|
||||
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;
|
||||
this.onDrawChanged(this.markers, this.markersValue, this.createMarker, this.doRemoveMarker);
|
||||
if (this.fitBoundsToMarkersValue) {
|
||||
this.doFitBoundsToMarkers();
|
||||
}
|
||||
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;
|
||||
}
|
||||
polygonsValueChanged() {
|
||||
if (!this.isConnected) {
|
||||
return;
|
||||
}
|
||||
this.onDrawChanged(this.polygons, this.polygonsValue, this.createPolygon, this.doRemovePolygon);
|
||||
this.onDrawChanged(this.polygons, this.polygonsValue, this.createPolygon, this.doRemovePolygon);
|
||||
}
|
||||
polylinesValueChanged() {
|
||||
if (!this.isConnected) {
|
||||
return;
|
||||
}
|
||||
polylinesValueChanged() {
|
||||
if (!this.isConnected) {
|
||||
return;
|
||||
}
|
||||
this.onDrawChanged(this.polylines, this.polylinesValue, this.createPolyline, this.doRemovePolyline);
|
||||
this.onDrawChanged(this.polylines, this.polylinesValue, this.createPolyline, this.doRemovePolyline);
|
||||
}
|
||||
circlesValueChanged() {
|
||||
if (!this.isConnected) {
|
||||
return;
|
||||
}
|
||||
circlesValueChanged() {
|
||||
if (!this.isConnected) {
|
||||
return;
|
||||
}
|
||||
this.onDrawChanged(this.circles, this.circlesValue, this.createCircle, this.doRemoveCircle);
|
||||
this.onDrawChanged(this.circles, this.circlesValue, this.createCircle, this.doRemoveCircle);
|
||||
}
|
||||
rectanglesValueChanged() {
|
||||
if (!this.isConnected) {
|
||||
return;
|
||||
}
|
||||
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 });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
default_1.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,
|
||||
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
|
||||
};
|
||||
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
|
||||
};
|
||||
|
||||
export { IconTypes, default_1 as default };
|
||||
|
||||
Reference in New Issue
Block a user