ublo-lib 1.41.0 → 1.41.1
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/es/common/components/editable-map/color-picker.d.ts +6 -0
- package/es/common/components/editable-map/color-picker.d.ts.map +1 -0
- package/es/common/components/editable-map/color-picker.js +27 -0
- package/es/common/components/editable-map/color-picker.module.css +66 -0
- package/es/common/components/editable-map/edit-form.d.ts.map +1 -1
- package/es/common/components/editable-map/edit-form.js +16 -11
- package/es/common/components/editable-map/edit-form.module.css +38 -2
- package/es/common/components/editable-map/editable-map.d.ts.map +1 -1
- package/es/common/components/editable-map/editable-map.js +133 -14
- package/es/common/components/editable-map/editable-map.module.css +65 -20
- package/es/common/components/editable-map/full-screen-button.d.ts +2 -1
- package/es/common/components/editable-map/full-screen-button.d.ts.map +1 -1
- package/es/common/components/editable-map/full-screen-button.js +6 -2
- package/es/common/components/editable-map/full-screen-button.module.css +6 -2
- package/es/common/components/editable-map/geoman.d.ts +8 -0
- package/es/common/components/editable-map/geoman.d.ts.map +1 -0
- package/es/common/components/editable-map/geoman.js +181 -0
- package/es/common/components/editable-map/icon-picker.d.ts.map +1 -1
- package/es/common/components/editable-map/icon-picker.js +2 -2
- package/es/common/components/editable-map/icon-picker.module.css +6 -1
- package/es/common/components/editable-map/icons/ui.d.ts +2 -0
- package/es/common/components/editable-map/icons/ui.d.ts.map +1 -0
- package/es/common/components/editable-map/icons/ui.js +7 -0
- package/es/common/components/editable-map/initial-marker-form.d.ts +4 -0
- package/es/common/components/editable-map/initial-marker-form.d.ts.map +1 -0
- package/es/common/components/editable-map/initial-marker-form.js +17 -0
- package/es/common/components/editable-map/initial-marker-form.module.css +25 -0
- package/es/common/components/editable-map/map-events.d.ts +1 -14
- package/es/common/components/editable-map/map-events.d.ts.map +1 -1
- package/es/common/components/editable-map/map-events.js +1 -24
- package/es/common/components/editable-map/marker-list.d.ts +7 -1
- package/es/common/components/editable-map/marker-list.d.ts.map +1 -1
- package/es/common/components/editable-map/marker-list.js +33 -11
- package/es/common/components/editable-map/marker-list.module.css +29 -21
- package/es/common/components/editable-map/markers.js +2 -19
- package/es/common/components/editable-map/popup-data.d.ts.map +1 -1
- package/es/common/components/editable-map/popup-data.js +2 -2
- package/es/common/components/editable-map/popup-data.module.css +15 -0
- package/es/common/components/editable-map/slopes-toggle.module.css +1 -0
- package/es/common/components/editable-map/utils/file-manager.d.ts +2 -0
- package/es/common/components/editable-map/utils/file-manager.d.ts.map +1 -0
- package/es/common/components/editable-map/utils/file-manager.js +29 -0
- package/es/common/utils/file-manager.d.ts +1 -0
- package/es/common/utils/file-manager.d.ts.map +1 -1
- package/package.json +1 -1
- package/es/common/components/editable-map/helper.d.ts +0 -2
- package/es/common/components/editable-map/helper.d.ts.map +0 -1
- package/es/common/components/editable-map/helper.js +0 -7
- package/es/common/components/editable-map/helper.module.css +0 -62
- package/es/common/components/editable-map/input-marker.d.ts +0 -4
- package/es/common/components/editable-map/input-marker.d.ts.map +0 -1
- package/es/common/components/editable-map/input-marker.js +0 -16
- package/es/common/components/editable-map/input-marker.module.css +0 -17
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-picker.d.ts","sourceRoot":"","sources":["../../../../src/common/components/editable-map/color-picker.js"],"names":[],"mappings":"AAkBA;;;;4CAiCC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import classNames from "classnames";
|
|
4
|
+
import Popover from "dt-design-system/es/popover";
|
|
5
|
+
import Button from "dt-design-system/es/button";
|
|
6
|
+
import * as Icons from "./icons/ui";
|
|
7
|
+
import styles from "./color-picker.module.css";
|
|
8
|
+
const COLORS_SET = [
|
|
9
|
+
{
|
|
10
|
+
label: "Marron",
|
|
11
|
+
value: "#4c3228",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
label: "Prune",
|
|
15
|
+
value: "#ca7aca",
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
export default function ColorPicker({ showMarkerList, color, setColor }) {
|
|
19
|
+
const classes = classNames(styles.button, {
|
|
20
|
+
[styles.alignedToRight]: !showMarkerList,
|
|
21
|
+
});
|
|
22
|
+
return (_jsxs(Popover, { className: styles.popover, contentProps: {
|
|
23
|
+
side: "bottom",
|
|
24
|
+
align: "end",
|
|
25
|
+
alignOffset: -10,
|
|
26
|
+
}, trigger: _jsx(Button, { className: classes, children: _jsx(Icons.ColorPalette, {}) }), children: [_jsx("div", { className: styles.title, children: "Couleur des trac\u00E9s" }), COLORS_SET.map(({ value, label }) => (_jsxs("div", { className: styles.choice, onClick: () => setColor(value), "data-checked": color === value, children: [_jsx("span", { className: styles.tag, "data-color": value }), _jsx("div", { children: label })] }, value)))] }));
|
|
27
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
.button {
|
|
2
|
+
--ds-button-background: var(--ds-grey-000, #fff);
|
|
3
|
+
--ds-button-hover-background: var(--ds-grey-000, #f8f8f8);
|
|
4
|
+
--ds-button-shadow: var(--ds-shadow-100, 0px 3px 6px rgba(0, 0, 0, 0.12));
|
|
5
|
+
|
|
6
|
+
position: absolute;
|
|
7
|
+
top: 10px;
|
|
8
|
+
right: 270px;
|
|
9
|
+
color: var(--ds-grey-800, #000);
|
|
10
|
+
z-index: 1000;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.alignedToRight {
|
|
14
|
+
right: 10px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.popover {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
gap: 10px;
|
|
21
|
+
min-width: 140px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.title {
|
|
25
|
+
font-weight: 700;
|
|
26
|
+
font-size: 15px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.choice {
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
gap: 10px;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
span.tag {
|
|
37
|
+
position: relative;
|
|
38
|
+
width: 15px;
|
|
39
|
+
height: 15px;
|
|
40
|
+
border-radius: 50%;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
span.tag[data-color="#4c3228"] {
|
|
44
|
+
background: #4c3228;
|
|
45
|
+
}
|
|
46
|
+
span.tag[data-color="#ca7aca"] {
|
|
47
|
+
background-color: #ca7aca;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.choice[data-checked="true"] span.tag::after {
|
|
51
|
+
content: "";
|
|
52
|
+
position: absolute;
|
|
53
|
+
top: 0;
|
|
54
|
+
left: 0;
|
|
55
|
+
width: 100%;
|
|
56
|
+
height: 100%;
|
|
57
|
+
transform: scale(1.5);
|
|
58
|
+
border-radius: 50%;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.choice[data-checked="true"] span.tag[data-color="#4c3228"]::after {
|
|
62
|
+
border: 1px solid #4c3228;
|
|
63
|
+
}
|
|
64
|
+
.choice[data-checked="true"] span.tag[data-color="#ca7aca"]::after {
|
|
65
|
+
border: 1px solid #ca7aca;
|
|
66
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit-form.d.ts","sourceRoot":"","sources":["../../../../src/common/components/editable-map/edit-form.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"edit-form.d.ts","sourceRoot":"","sources":["../../../../src/common/components/editable-map/edit-form.js"],"names":[],"mappings":"AAUA;;;;;4CAkHC"}
|
|
@@ -5,26 +5,31 @@ import Textarea from "dt-design-system/es/textarea";
|
|
|
5
5
|
import Button from "dt-design-system/es/button";
|
|
6
6
|
import Checkbox from "dt-design-system/es/checkbox";
|
|
7
7
|
import * as Icons from "dt-design-system/es/icons";
|
|
8
|
+
import * as FileManager from "./utils/file-manager";
|
|
8
9
|
import IconPicker from "./icon-picker";
|
|
9
10
|
import css from "./edit-form.module.css";
|
|
10
11
|
export default function EditForm({ popupRef, marker, setMarkers, iconSet }) {
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
setMarkers((currents) => currents.filter((marker) => marker.id !== id));
|
|
15
|
-
};
|
|
16
|
-
const closeMarker = () => {
|
|
17
|
-
popupRef.current.close();
|
|
18
|
-
};
|
|
19
|
-
const updateMarker = (field) => (value) => {
|
|
12
|
+
const [editingMarker, setEditingMarker] = React.useState(marker || {});
|
|
13
|
+
const { id, icon, image, title, description, url, label, tooltipOpened, important, } = editingMarker;
|
|
14
|
+
const updateMarker = () => {
|
|
20
15
|
setMarkers((currents) => {
|
|
21
16
|
return currents.map((marker) => {
|
|
22
17
|
if (marker.id === id) {
|
|
23
|
-
return
|
|
18
|
+
return editingMarker;
|
|
24
19
|
}
|
|
25
20
|
return marker;
|
|
26
21
|
});
|
|
27
22
|
});
|
|
23
|
+
popupRef.current.close();
|
|
24
|
+
};
|
|
25
|
+
const updateEditingMarker = (field) => (value) => {
|
|
26
|
+
setEditingMarker({ ...editingMarker, [field]: value });
|
|
27
|
+
};
|
|
28
|
+
const updateImage = (path) => {
|
|
29
|
+
updateEditingMarker("image")(path);
|
|
28
30
|
};
|
|
29
|
-
return (_jsxs("div", { className: css.form, children: [_jsxs("div", { className: css.row, children: [_jsx(IconPicker, { callback:
|
|
31
|
+
return (_jsxs("div", { className: css.form, children: [_jsxs("div", { className: css.row, children: [_jsx(IconPicker, { callback: updateEditingMarker("icon"), selectedIcon: icon, iconSet: iconSet }), _jsxs("div", { className: css.imageContainer, children: [_jsx(Button, { className: css.image, variant: "transparent", onClick: () => FileManager.load(updateImage, 320, 200), children: image ? _jsx("img", { src: image, alt: "" }) : _jsx(Icons.Image, {}) }), image && (_jsx(Button, { onClick: (e) => {
|
|
32
|
+
e.stopPropagation();
|
|
33
|
+
updateImage(undefined);
|
|
34
|
+
}, variant: "danger", className: css.removeImage, compact: true, children: _jsx(Icons.Bin, {}) }))] }), _jsx(Input, { label: "Titre", value: title, className: css.title, onValueChange: updateEditingMarker("title"), compact: true })] }), _jsx(Textarea, { label: "Description", value: description, className: css.description, onValueChange: updateEditingMarker("description"), placeholder: "Description du point d'int\u00E9r\u00EAt", compact: true }), _jsxs("div", { className: css.row, children: [_jsx(Input, { label: "Lien bouton", value: url, onValueChange: updateEditingMarker("url"), compact: true }), _jsx(Input, { label: "Libell\u00E9 bouton", value: label, onValueChange: updateEditingMarker("label"), compact: true })] }), _jsx(Checkbox, { label: "Important", checked: important, onCheckedChange: updateEditingMarker("important") }), _jsx(Checkbox, { label: "Tooltip affich\u00E9 par d\u00E9faut", checked: tooltipOpened, onCheckedChange: updateEditingMarker("tooltipOpened") }), _jsx("div", { className: css.buttons, children: _jsxs(Button, { variant: "success", onClick: updateMarker, compact: true, children: ["Valider", _jsx(Icons.Check, {})] }) })] }));
|
|
30
35
|
}
|
|
@@ -1,11 +1,47 @@
|
|
|
1
1
|
.form {
|
|
2
2
|
position: relative;
|
|
3
|
-
width:
|
|
3
|
+
width: 340px;
|
|
4
4
|
display: flex;
|
|
5
5
|
flex-direction: column;
|
|
6
6
|
gap: 8px;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
.imageContainer {
|
|
10
|
+
position: relative;
|
|
11
|
+
z-index: 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.image {
|
|
15
|
+
flex: 0 0 80px;
|
|
16
|
+
width: 80px;
|
|
17
|
+
height: 60px;
|
|
18
|
+
border: 1px solid var(--ds-grey-200, #ededed);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.image:has(img) {
|
|
22
|
+
padding: 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.image > img {
|
|
26
|
+
width: 100%;
|
|
27
|
+
height: 100%;
|
|
28
|
+
object-fit: cover;
|
|
29
|
+
border-radius: inherit;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.removeImage {
|
|
33
|
+
position: absolute;
|
|
34
|
+
top: 4px;
|
|
35
|
+
right: 4px;
|
|
36
|
+
opacity: 0;
|
|
37
|
+
transition: opacity 160ms
|
|
38
|
+
var(--ds-transition-easing, cubic-bezier(0.4, 0.1, 0.2, 0.9));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.imageContainer:hover .removeImage {
|
|
42
|
+
opacity: 1;
|
|
43
|
+
}
|
|
44
|
+
|
|
9
45
|
.row {
|
|
10
46
|
display: flex;
|
|
11
47
|
align-items: flex-end;
|
|
@@ -23,6 +59,6 @@
|
|
|
23
59
|
|
|
24
60
|
.buttons {
|
|
25
61
|
display: flex;
|
|
26
|
-
justify-content:
|
|
62
|
+
justify-content: flex-end;
|
|
27
63
|
margin-top: 6px;
|
|
28
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editable-map.d.ts","sourceRoot":"","sources":["../../../../src/common/components/editable-map/editable-map.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"editable-map.d.ts","sourceRoot":"","sources":["../../../../src/common/components/editable-map/editable-map.js"],"names":[],"mappings":"AA8BA;;;;4CAuRC"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
|
+
import * as L from "leaflet";
|
|
3
4
|
import { AttributionControl, MapContainer, TileLayer } from "react-leaflet";
|
|
4
5
|
import { useUbloContext } from "ublo/with-ublo";
|
|
5
6
|
import Button from "dt-design-system/es/button";
|
|
6
7
|
import * as Icons from "dt-design-system/es/icons";
|
|
7
|
-
import
|
|
8
|
+
import classNames from "classnames";
|
|
9
|
+
import Geoman from "./geoman";
|
|
10
|
+
import ColorPicker from "./color-picker";
|
|
11
|
+
import MapEvents from "./map-events";
|
|
8
12
|
import Markers from "./markers";
|
|
9
|
-
import Helper from "./helper";
|
|
10
13
|
import Cluster from "./cluster";
|
|
11
|
-
import
|
|
14
|
+
import InitialMarkerForm from "./initial-marker-form";
|
|
12
15
|
import MarkerList from "./marker-list";
|
|
13
16
|
import FullScreenButton from "./full-screen-button";
|
|
14
17
|
import SlopesToggle from "./slopes-toggle";
|
|
@@ -16,11 +19,20 @@ import css from "./editable-map.module.css";
|
|
|
16
19
|
import "leaflet/dist/leaflet.css";
|
|
17
20
|
const FRANCE_CENTER = [46.807934, 3.645097];
|
|
18
21
|
const DEFAULT_ZOOM = 6;
|
|
22
|
+
const DEFAULT_MARKER_DATA = {
|
|
23
|
+
icon: "Location",
|
|
24
|
+
title: "Nouveau point d'intérêt",
|
|
25
|
+
description: "",
|
|
26
|
+
url: "",
|
|
27
|
+
label: "",
|
|
28
|
+
tooltipOpened: false,
|
|
29
|
+
};
|
|
19
30
|
export default function EditableMap({ format, iconSet, hideSlopes }) {
|
|
20
31
|
const ref = React.useRef();
|
|
21
32
|
const containerRef = React.useRef();
|
|
22
33
|
const { cmsMode } = useUbloContext();
|
|
23
34
|
const [fullScreen, setFullScreen] = React.useState(false);
|
|
35
|
+
const [markerListOpened, setMarkerListOpened] = React.useState(true);
|
|
24
36
|
const { element, presets, isInDialog } = format;
|
|
25
37
|
const isInZone = element.closest(".cms");
|
|
26
38
|
const isEditing = isInZone && cmsMode === "editing";
|
|
@@ -30,6 +42,10 @@ export default function EditableMap({ format, iconSet, hideSlopes }) {
|
|
|
30
42
|
const [zoom, setZoom] = React.useState(defaultZoom);
|
|
31
43
|
const [markers, setMarkers] = React.useState(presets?.markers || []);
|
|
32
44
|
const [showSlopes, setShowSlopes] = React.useState(presets?.showSlopes || false);
|
|
45
|
+
const [shapes, setShapes] = React.useState(presets?.shapes || []);
|
|
46
|
+
const [mapIsReady, setMapIsReady] = React.useState(false);
|
|
47
|
+
const [color, setColor] = React.useState("#4c3228");
|
|
48
|
+
const [isMarkerListSorted, setIsMarkerListSorted] = React.useState(presets?.isMarkerListSorted || false);
|
|
33
49
|
const scrollWheelZoom = Boolean(cmsMode) || isInDialog || fullScreen;
|
|
34
50
|
const refreshSize = () => {
|
|
35
51
|
ref.current.invalidateSize();
|
|
@@ -39,6 +55,96 @@ export default function EditableMap({ format, iconSet, hideSlopes }) {
|
|
|
39
55
|
setZoom(defaultZoom);
|
|
40
56
|
ref.current.setView(defaultCenter, defaultZoom, { animate: true });
|
|
41
57
|
};
|
|
58
|
+
const addInitialMarker = (position) => {
|
|
59
|
+
const isFocused = Boolean(element.querySelector("cms-section-ui"));
|
|
60
|
+
if (!isEditing || !isFocused)
|
|
61
|
+
return;
|
|
62
|
+
setMarkers([{ id: 1, ...DEFAULT_MARKER_DATA, position }]);
|
|
63
|
+
ref.current.setView(position, 13);
|
|
64
|
+
};
|
|
65
|
+
const handleEdit = (e) => {
|
|
66
|
+
if (e.layer.options?.id || e.layer.options?.shape === "Text")
|
|
67
|
+
return;
|
|
68
|
+
const customId = e.layer._customId;
|
|
69
|
+
const shapeType = e.shape;
|
|
70
|
+
const position = e.layer.getLatLngs
|
|
71
|
+
? e.layer.getLatLngs()
|
|
72
|
+
: e.layer.getLatLng();
|
|
73
|
+
let updatedShape = {
|
|
74
|
+
latlngs: position,
|
|
75
|
+
};
|
|
76
|
+
if (shapeType === "Circle") {
|
|
77
|
+
updatedShape = {
|
|
78
|
+
...updatedShape,
|
|
79
|
+
radius: e.layer.getRadius(),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
setShapes((prevShapes) => prevShapes.map((shape) => shape.id === customId ? { ...shape, ...updatedShape } : shape));
|
|
83
|
+
};
|
|
84
|
+
const handleDrag = (e) => {
|
|
85
|
+
const customId = e.layer.options?.id || e.layer._customId;
|
|
86
|
+
const position = e.layer.getLatLngs
|
|
87
|
+
? e.layer.getLatLngs()
|
|
88
|
+
: e.layer.getLatLng();
|
|
89
|
+
if (e.layer instanceof L.Marker && e.layer.options?.shape !== "Text") {
|
|
90
|
+
setMarkers((prevMarkers) => prevMarkers.map((marker) => marker.id === customId ? { ...marker, position } : marker));
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
setShapes((prevShapes) => prevShapes.map((shape) => {
|
|
94
|
+
return shape.id === customId
|
|
95
|
+
? { ...shape, latlngs: position }
|
|
96
|
+
: shape;
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const drawShapeOnMap = React.useCallback((shape) => {
|
|
101
|
+
let layer;
|
|
102
|
+
const { id, shape: shapeType, latlngs, radius, content, color } = shape;
|
|
103
|
+
const options = {
|
|
104
|
+
color,
|
|
105
|
+
fillOpacity: 0.1,
|
|
106
|
+
};
|
|
107
|
+
switch (shapeType) {
|
|
108
|
+
case "Line":
|
|
109
|
+
layer = L.polyline(latlngs, options).addTo(ref.current);
|
|
110
|
+
break;
|
|
111
|
+
case "Rectangle":
|
|
112
|
+
layer = L.rectangle(latlngs, options).addTo(ref.current);
|
|
113
|
+
break;
|
|
114
|
+
case "Polygon":
|
|
115
|
+
layer = L.polygon(latlngs, options).addTo(ref.current);
|
|
116
|
+
break;
|
|
117
|
+
case "Circle":
|
|
118
|
+
layer = L.circle(latlngs, {
|
|
119
|
+
...options,
|
|
120
|
+
radius,
|
|
121
|
+
}).addTo(ref.current);
|
|
122
|
+
break;
|
|
123
|
+
case "Text":
|
|
124
|
+
layer = L.marker(latlngs, {
|
|
125
|
+
icon: L.divIcon({
|
|
126
|
+
className: "custom-text-icon",
|
|
127
|
+
html: `<div class="em-custom-text">${content}</div>`,
|
|
128
|
+
}),
|
|
129
|
+
type: "Text",
|
|
130
|
+
shape: "Text",
|
|
131
|
+
}).addTo(ref.current);
|
|
132
|
+
break;
|
|
133
|
+
default:
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
layer._customId = id;
|
|
137
|
+
layer.on("pm:edit", handleEdit);
|
|
138
|
+
layer.on("pm:dragend", handleDrag);
|
|
139
|
+
return layer;
|
|
140
|
+
}, []);
|
|
141
|
+
React.useEffect(() => {
|
|
142
|
+
if (presets?.shapes?.length && mapIsReady) {
|
|
143
|
+
presets?.shapes.forEach((shape) => {
|
|
144
|
+
drawShapeOnMap(shape);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}, [drawShapeOnMap, mapIsReady, presets?.shapes]);
|
|
42
148
|
React.useEffect(() => {
|
|
43
149
|
if (isInDialog) {
|
|
44
150
|
window.refreshDialogMapSize = refreshSize;
|
|
@@ -46,20 +152,33 @@ export default function EditableMap({ format, iconSet, hideSlopes }) {
|
|
|
46
152
|
}, [isInDialog]);
|
|
47
153
|
React.useEffect(() => {
|
|
48
154
|
if (isEditing) {
|
|
49
|
-
const newPresets = {
|
|
155
|
+
const newPresets = {
|
|
156
|
+
markers,
|
|
157
|
+
isMarkerListSorted,
|
|
158
|
+
shapes,
|
|
159
|
+
zoom,
|
|
160
|
+
center,
|
|
161
|
+
showSlopes,
|
|
162
|
+
};
|
|
50
163
|
element.setAttribute("data-presets", JSON.stringify(newPresets));
|
|
51
164
|
}
|
|
52
|
-
}, [
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
165
|
+
}, [
|
|
166
|
+
center,
|
|
167
|
+
element,
|
|
168
|
+
isEditing,
|
|
169
|
+
markers,
|
|
170
|
+
isMarkerListSorted,
|
|
171
|
+
shapes,
|
|
172
|
+
showSlopes,
|
|
173
|
+
zoom,
|
|
174
|
+
]);
|
|
60
175
|
const attribution = showSlopes
|
|
61
176
|
? '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> & <a href="https://www.opensnowmap.org/">OpenSnowMap</a> contributors'
|
|
62
177
|
: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';
|
|
63
178
|
const showInputMarker = isEditing && !markers.length;
|
|
64
|
-
|
|
179
|
+
const showMarkerList = markers.length > 2;
|
|
180
|
+
const resetCenterClasses = classNames(css.resetCenter, {
|
|
181
|
+
[css.alignedToRight]: !showMarkerList || !markerListOpened,
|
|
182
|
+
});
|
|
183
|
+
return (_jsxs("div", { ref: containerRef, className: css.container, "data-cms-remove": "", children: [_jsxs(MapContainer, { ref: ref, center: center, zoom: zoom, scrollWheelZoom: scrollWheelZoom, className: css.map, attributionControl: false, whenReady: () => setMapIsReady(true), children: [_jsx(TileLayer, { attribution: attribution, url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" }), isEditing && (_jsxs(_Fragment, { children: [_jsx(Geoman, { handleDrag: handleDrag, setMarkers: setMarkers, iconSet: iconSet, setShapes: setShapes, color: color }), _jsx(ColorPicker, { showMarkerList: showMarkerList, color: color, setColor: setColor })] })), showSlopes && (_jsx(TileLayer, { url: "https://tiles.opensnowmap.org/pistes/{z}/{x}/{y}.png" })), _jsx(MapEvents, { setZoom: setZoom, setCenter: setCenter }), _jsx(Cluster, { isEditing: isEditing, children: _jsx(Markers, { markers: markers, setMarkers: setMarkers, iconSet: iconSet, isEditing: isEditing }) }), _jsx(AttributionControl, { position: "bottomright", prefix: "" })] }), showInputMarker && _jsx(InitialMarkerForm, { callback: addInitialMarker }), !isEditing && (_jsx(FullScreenButton, { fullScreen: fullScreen, setFullScreen: setFullScreen, containerRef: containerRef, isListOpened: showMarkerList && markerListOpened })), !isEditing && (_jsx(Button, { type: "button", variant: "secondary", className: resetCenterClasses, onClick: resetCenter, children: _jsx(Icons.MyLocation, {}) })), !hideSlopes && (_jsx(SlopesToggle, { showSlopes: showSlopes, setShowSlopes: setShowSlopes })), showMarkerList && (_jsx(MarkerList, { cmsMode: cmsMode, mapRef: ref, markers: markers, setMarkers: setMarkers, iconSet: iconSet, isInDialog: !fullScreen && isInDialog, opened: markerListOpened, setOpened: setMarkerListOpened, isSorted: isMarkerListSorted, setIsSorted: setIsMarkerListSorted }))] }));
|
|
65
184
|
}
|
|
@@ -13,17 +13,26 @@
|
|
|
13
13
|
|
|
14
14
|
button.resetCenter {
|
|
15
15
|
position: absolute;
|
|
16
|
-
top:
|
|
17
|
-
|
|
16
|
+
top: 46px;
|
|
17
|
+
right: 270px;
|
|
18
18
|
background-color: var(--ds-grey-000, #fff);
|
|
19
19
|
box-shadow: var(--ds-shadow-100, 0px 3px 6px rgba(0, 0, 0, 0.12));
|
|
20
20
|
user-select: none;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
button.alignedToRight {
|
|
24
|
+
right: 10px;
|
|
25
|
+
}
|
|
26
|
+
|
|
23
27
|
button.resetCenter:hover {
|
|
24
28
|
background-color: var(--ds-grey-100, #f8f8f8);
|
|
25
29
|
}
|
|
26
30
|
|
|
31
|
+
button.marker {
|
|
32
|
+
position: relative;
|
|
33
|
+
z-index: 1000;
|
|
34
|
+
}
|
|
35
|
+
|
|
27
36
|
.map {
|
|
28
37
|
flex: 1 1 100%;
|
|
29
38
|
z-index: 0;
|
|
@@ -43,6 +52,11 @@ button.resetCenter:hover {
|
|
|
43
52
|
transform: translateX(-50%);
|
|
44
53
|
}
|
|
45
54
|
|
|
55
|
+
.map :global(.leaflet-pm-toolbar) {
|
|
56
|
+
display: flex;
|
|
57
|
+
flex-direction: column;
|
|
58
|
+
}
|
|
59
|
+
|
|
46
60
|
:global(:is(.cms--connected, .cms--info)) .container:empty::after {
|
|
47
61
|
content: "Activez le mode édition pour modifier la carte, déconnectez-vous pour la consulter.";
|
|
48
62
|
position: absolute;
|
|
@@ -69,21 +83,13 @@ button.resetCenter:hover {
|
|
|
69
83
|
|
|
70
84
|
.map :global(.leaflet-popup-content-wrapper) {
|
|
71
85
|
position: relative;
|
|
72
|
-
background-color:
|
|
73
|
-
|
|
86
|
+
background-color: var(--ds-grey-000, #fff);
|
|
87
|
+
border: 1px solid var(--ds-grey-200, #ededed);
|
|
74
88
|
box-shadow: var(--ds-shadow-100, 0px 3px 6px rgba(0, 0, 0, 0.12));
|
|
75
89
|
}
|
|
76
90
|
|
|
77
|
-
.map :global(.leaflet-popup-content
|
|
78
|
-
|
|
79
|
-
position: absolute;
|
|
80
|
-
top: 0;
|
|
81
|
-
left: 0;
|
|
82
|
-
width: 100%;
|
|
83
|
-
height: 100%;
|
|
84
|
-
background-color: var(--ds-grey-000, #fff);
|
|
85
|
-
border-radius: inherit;
|
|
86
|
-
opacity: 0.8;
|
|
91
|
+
:global(.cms--editing) .map :global(.leaflet-popup-content) {
|
|
92
|
+
width: auto !important;
|
|
87
93
|
}
|
|
88
94
|
|
|
89
95
|
.map:global(.leaflet-container) :global(a.leaflet-popup-close-button) {
|
|
@@ -140,6 +146,7 @@ button.resetCenter:hover {
|
|
|
140
146
|
|
|
141
147
|
.map :global(.leaflet-tooltip) {
|
|
142
148
|
padding: 10px 16px;
|
|
149
|
+
color: var(--ds-grey-700, #262626);
|
|
143
150
|
font-size: 15px;
|
|
144
151
|
font-weight: 700;
|
|
145
152
|
font-family: inherit;
|
|
@@ -170,7 +177,7 @@ button.resetCenter:hover {
|
|
|
170
177
|
}
|
|
171
178
|
|
|
172
179
|
.map:global(.leaflet-touch .leaflet-control-layers a),
|
|
173
|
-
.map:global(.leaflet-touch .leaflet-bar a) {
|
|
180
|
+
.map:global(.leaflet-touch .leaflet-bar a:not(.leaflet-pm-action)) {
|
|
174
181
|
width: 33px;
|
|
175
182
|
height: 33px;
|
|
176
183
|
box-shadow: var(--ds-shadow-100, 0px 3px 6px rgba(0, 0, 0, 0.12));
|
|
@@ -183,19 +190,22 @@ button.resetCenter:hover {
|
|
|
183
190
|
cursor: not-allowed;
|
|
184
191
|
}
|
|
185
192
|
|
|
186
|
-
.map:global(
|
|
187
|
-
.
|
|
193
|
+
.map:global(
|
|
194
|
+
.leaflet-touch .leaflet-control-layers a:not(.leaflet-pm-action):hover
|
|
195
|
+
),
|
|
196
|
+
.map:global(.leaflet-touch .leaflet-bar a:not(.leaflet-pm-action):hover) {
|
|
188
197
|
background-color: var(--ds-grey-100, #f8f8f8);
|
|
189
198
|
}
|
|
190
199
|
|
|
191
|
-
.map:global(.leaflet-touch .leaflet-control-
|
|
192
|
-
.map:global(.
|
|
200
|
+
.map:global(.leaflet-touch .leaflet-control-zoom a:first-child),
|
|
201
|
+
.map :global(.button-container:first-child a:first-child) {
|
|
193
202
|
border-top-left-radius: var(--ds-radius-200, 10px);
|
|
194
203
|
border-top-right-radius: var(--ds-radius-200, 10px);
|
|
195
204
|
}
|
|
196
205
|
|
|
197
206
|
.map:global(.leaflet-touch .leaflet-control-layers a:last-child),
|
|
198
|
-
.map:global(.leaflet-touch .leaflet-bar a:last-child)
|
|
207
|
+
.map:global(.leaflet-touch .leaflet-bar a:last-child),
|
|
208
|
+
.map :global(.button-container:last-child a:first-child) {
|
|
199
209
|
border-bottom-left-radius: var(--ds-radius-200, 10px);
|
|
200
210
|
border-bottom-right-radius: var(--ds-radius-200, 10px);
|
|
201
211
|
}
|
|
@@ -204,3 +214,38 @@ button.resetCenter:hover {
|
|
|
204
214
|
.map:global(.leaflet-touch .leaflet-bar a span) {
|
|
205
215
|
font-size: 18px;
|
|
206
216
|
}
|
|
217
|
+
|
|
218
|
+
.map :global(.leaflet-popup-close-button) {
|
|
219
|
+
display: none;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.map :global(.leaflet-popup-content) {
|
|
223
|
+
margin: 0;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
:global(body.cms--editing) .map :global(.leaflet-popup-content) {
|
|
227
|
+
margin: 13px 24px 13px 20px;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.map :global(.leaflet-popup-content-wrapper) {
|
|
231
|
+
padding: 0;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
:global(.cms--editing) .map :global(.leaflet-popup-content-wrapper) {
|
|
235
|
+
padding: 1px;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.map :global(.em-custom-text),
|
|
239
|
+
.map :global(.pm-textarea) {
|
|
240
|
+
width: max-content;
|
|
241
|
+
max-width: 200px;
|
|
242
|
+
padding: 6px;
|
|
243
|
+
color: var(--ds-grey-700, #262626);
|
|
244
|
+
font-size: 16px;
|
|
245
|
+
font-weight: 700;
|
|
246
|
+
font-family: inherit;
|
|
247
|
+
text-align: center;
|
|
248
|
+
text-shadow: -1px 0px 1px white, 0px -1px 1px white, 1px 0px 1px white,
|
|
249
|
+
0px 1px 1px white;
|
|
250
|
+
transform: translate(-50%, -50%);
|
|
251
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export default function FullScreenButton({ fullScreen, setFullScreen, containerRef, }: {
|
|
1
|
+
export default function FullScreenButton({ fullScreen, setFullScreen, containerRef, isListOpened, }: {
|
|
2
2
|
fullScreen: any;
|
|
3
3
|
setFullScreen: any;
|
|
4
4
|
containerRef: any;
|
|
5
|
+
isListOpened: any;
|
|
5
6
|
}): import("react/jsx-runtime").JSX.Element;
|
|
6
7
|
//# sourceMappingURL=full-screen-button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"full-screen-button.d.ts","sourceRoot":"","sources":["../../../../src/common/components/editable-map/full-screen-button.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"full-screen-button.d.ts","sourceRoot":"","sources":["../../../../src/common/components/editable-map/full-screen-button.js"],"names":[],"mappings":"AAMA;;;;;4CAkDC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
|
+
import classNames from "classnames";
|
|
3
4
|
import Button from "dt-design-system/es/button";
|
|
4
5
|
import * as Icons from "dt-design-system/es/icons";
|
|
5
6
|
import css from "./full-screen-button.module.css";
|
|
6
|
-
export default function FullScreenButton({ fullScreen, setFullScreen, containerRef, }) {
|
|
7
|
+
export default function FullScreenButton({ fullScreen, setFullScreen, containerRef, isListOpened, }) {
|
|
7
8
|
const [fullScreenCompatible, setFullScreenCompatible] = React.useState(true);
|
|
8
9
|
const cleanupFullScreen = React.useCallback(() => {
|
|
9
10
|
if (!document.fullscreenElement) {
|
|
@@ -19,6 +20,9 @@ export default function FullScreenButton({ fullScreen, setFullScreen, containerR
|
|
|
19
20
|
if (!fullScreenCompatible)
|
|
20
21
|
return null;
|
|
21
22
|
const Icon = Icons[fullScreen ? "Minimize" : "Maximize"];
|
|
23
|
+
const classes = classNames(css.button, {
|
|
24
|
+
[css.opened]: isListOpened,
|
|
25
|
+
});
|
|
22
26
|
const toggleFullScreen = (e) => {
|
|
23
27
|
e.preventDefault();
|
|
24
28
|
e.stopPropagation();
|
|
@@ -31,7 +35,7 @@ export default function FullScreenButton({ fullScreen, setFullScreen, containerR
|
|
|
31
35
|
document.removeEventListener("fullscreenchange", cleanupFullScreen);
|
|
32
36
|
}
|
|
33
37
|
};
|
|
34
|
-
return (_jsx(Button, { variant: "secondary", type: "button", className:
|
|
38
|
+
return (_jsx(Button, { variant: "secondary", type: "button", className: classes, onClick: toggleFullScreen, children: _jsx(Icon, {}) }));
|
|
35
39
|
}
|
|
36
40
|
function isFullScreenCompatible() {
|
|
37
41
|
return (document.fullscreenEnabled ||
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
button.button {
|
|
2
2
|
position: absolute;
|
|
3
|
-
top:
|
|
4
|
-
|
|
3
|
+
top: 10px;
|
|
4
|
+
right: 10px;
|
|
5
5
|
background-color: var(--ds-grey-000, #fff);
|
|
6
6
|
box-shadow: var(--ds-shadow-100, 0px 3px 6px rgba(0, 0, 0, 0.12));
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
button.opened {
|
|
10
|
+
right: 270px;
|
|
11
|
+
}
|
|
12
|
+
|
|
9
13
|
button.button:hover {
|
|
10
14
|
background-color: var(--ds-grey-100, #f8f8f8);
|
|
11
15
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geoman.d.ts","sourceRoot":"","sources":["../../../../src/common/components/editable-map/geoman.js"],"names":[],"mappings":";AAiBA;;;;;QAmOC"}
|