ublo-lib 1.12.15 → 1.12.17

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.
@@ -4,10 +4,11 @@ import { useUbloContext } from "ublo/with-ublo";
4
4
  import MapEvents from "./map-events";
5
5
  import Markers from "./markers";
6
6
  import Helper from "./helper";
7
- import css from "./editable-map.module.css";
8
- import "leaflet/dist/leaflet.css";
9
7
  import Cluster from "./cluster";
10
8
  import MarkerList from "./marker-list";
9
+ import FullScreenButton from "./full-screen-button";
10
+ import css from "./editable-map.module.css";
11
+ import "leaflet/dist/leaflet.css";
11
12
  import { jsx as _jsx } from "react/jsx-runtime";
12
13
  import { jsxs as _jsxs } from "react/jsx-runtime";
13
14
  const FRANCE_CENTER = [46.807934, 3.645097];
@@ -17,9 +18,11 @@ export default function EditableMap({
17
18
  iconSet
18
19
  }) {
19
20
  const ref = React.useRef();
21
+ const containerRef = React.useRef();
20
22
  const {
21
23
  cmsMode
22
24
  } = useUbloContext();
25
+ const [fullScreen, setFullScreen] = React.useState(false);
23
26
  const {
24
27
  element,
25
28
  presets,
@@ -30,7 +33,7 @@ export default function EditableMap({
30
33
  const [center, setCenter] = React.useState(presets?.center || FRANCE_CENTER);
31
34
  const [zoom, setZoom] = React.useState(presets?.zoom ?? DEFAULT_ZOOM);
32
35
  const [markers, setMarkers] = React.useState(presets?.markers || []);
33
- const scrollWheelZoom = isInDialog || Boolean(cmsMode);
36
+ const scrollWheelZoom = Boolean(cmsMode) || isInDialog || fullScreen;
34
37
  const refreshSize = () => {
35
38
  ref.current.invalidateSize();
36
39
  };
@@ -50,6 +53,7 @@ export default function EditableMap({
50
53
  }
51
54
  }, [center, element, isEditing, markers, zoom]);
52
55
  return _jsxs("div", {
56
+ ref: containerRef,
53
57
  className: css.container,
54
58
  "data-cms-remove": "",
55
59
  children: [_jsxs(MapContainer, {
@@ -78,10 +82,15 @@ export default function EditableMap({
78
82
  isEditing: isEditing
79
83
  })
80
84
  })]
85
+ }), !isEditing && _jsx(FullScreenButton, {
86
+ fullScreen: fullScreen,
87
+ setFullScreen: setFullScreen,
88
+ containerRef: containerRef
81
89
  }), !isEditing && markers.length > 2 && _jsx(MarkerList, {
82
90
  mapRef: ref,
83
91
  markers: markers,
84
- iconSet: iconSet
92
+ iconSet: iconSet,
93
+ isInDialog: !fullScreen && isInDialog
85
94
  }), isEditing && _jsx(Helper, {})]
86
95
  });
87
96
  }
@@ -2,10 +2,17 @@
2
2
  .map {
3
3
  width: 100%;
4
4
  height: 100%;
5
+ font-family: inherit !important;
6
+ border-radius: var(--ds-radius-100, 6px);
5
7
  }
6
8
 
7
9
  .container {
8
10
  position: relative;
11
+ display: flex;
12
+ }
13
+
14
+ .map {
15
+ flex: 1 1 100%;
9
16
  }
10
17
 
11
18
  .map :global(.leaflet-pane) {
@@ -35,18 +42,38 @@
35
42
  transform: translate(-50%, -50%);
36
43
  }
37
44
 
38
- @media (max-width: 992px) {
39
- .map :global(.leaflet-tooltip) {
40
- display: none !important;
41
- }
42
- }
43
-
44
45
  .map :global(.leaflet-popup-tip-container),
45
46
  .map :global(.leaflet-tooltip::before) {
46
47
  content: none;
47
48
  display: none;
48
49
  }
49
50
 
51
+ .map :global(.leaflet-popup-content-wrapper) {
52
+ position: relative;
53
+ background-color: transparent;
54
+ backdrop-filter: brightness(110%) contrast(90%) blur(var(--ds-blur, 5px));
55
+ box-shadow: var(--ds-shadow-100, 0px 3px 6px rgba(0, 0, 0, 0.12));
56
+ }
57
+
58
+ .map :global(.leaflet-popup-content-wrapper::before) {
59
+ content: "";
60
+ position: absolute;
61
+ top: 0;
62
+ left: 0;
63
+ width: 100%;
64
+ height: 100%;
65
+ background-color: var(--ds-grey-000, #fff);
66
+ border-radius: inherit;
67
+ opacity: 0.8;
68
+ }
69
+
70
+ .map:global(.leaflet-container) :global(a.leaflet-popup-close-button) {
71
+ top: 5px;
72
+ right: 5px;
73
+ color: var(--ds-grey-700, #232324);
74
+ font-size: 22px;
75
+ }
76
+
50
77
  .map :global(.leaflet-tile-pane) {
51
78
  filter: saturate(0.05) hue-rotate(100deg) contrast(1.2);
52
79
  }
@@ -54,27 +81,64 @@
54
81
  .map :global(.marker-cluster) {
55
82
  color: var(--ds-grey-000, #fff);
56
83
  background-color: transparent;
57
- opacity: 0.85;
58
84
  }
59
85
 
60
86
  .map :global(.marker-cluster::before) {
61
87
  content: "";
62
88
  position: absolute;
63
- top: 0;
64
- left: 0;
65
- width: 100%;
66
- height: 100%;
67
- background-color: var(--ds-secondary, var(--ds-blue-400, #4177f6));
68
- opacity: 0.45;
89
+ top: 1px;
90
+ left: 1px;
91
+ width: calc(100% - 2px);
92
+ height: calc(100% - 2px);
93
+ background-color: var(--ds-grey-700, #232324);
69
94
  border-radius: 50%;
95
+ opacity: 0.3;
70
96
  pointer-events: none;
97
+ filter: drop-shadow(var(--ds-shadow-100, 0px 3px 6px rgba(0, 0, 0, 0.12)));
98
+ transition: transform 160ms
99
+ var(--ds-transition-easing, cubic-bezier(0.4, 0.1, 0.2, 0.9));
71
100
  }
72
101
 
73
- .map :global(.marker-cluster:hover) {
74
- opacity: 1;
102
+ .map :global(.marker-cluster:hover::before) {
103
+ transform: scale(1.08);
75
104
  }
76
105
 
77
106
  .map :global(.marker-cluster > div) {
78
107
  position: relative;
108
+ font-weight: 700;
109
+ font-size: 16px;
79
110
  background-color: var(--ds-secondary, var(--ds-blue-400, #4177f6));
111
+ transition: transform 160ms
112
+ var(--ds-transition-easing, cubic-bezier(0.4, 0.1, 0.2, 0.9));
113
+ }
114
+
115
+ .map :global(.marker-cluster:hover > div) {
116
+ transform: scale(1.1);
117
+ }
118
+
119
+ .map :global(.leaflet-tooltip) {
120
+ padding: 10px 16px;
121
+ font-size: 15px;
122
+ font-weight: 700;
123
+ font-family: inherit;
124
+ text-shadow: -1px 0px 1px white, 0px -1px 1px white, 1px 0px 1px white,
125
+ 0px 1px 1px white;
126
+ /* text-shadow: 0px 0px 4px magenta; */
127
+ background-color: transparent;
128
+ box-shadow: none;
129
+ border: 0;
130
+ animation: leaflet-tooltip-appearance 320ms
131
+ var(--ds-transition-easing, cubic-bezier(0.4, 0.1, 0.2, 0.9));
132
+ }
133
+
134
+ @keyframes leaflet-tooltip-appearance {
135
+ 0% {
136
+ opacity: 0;
137
+ }
138
+ }
139
+
140
+ @media (max-width: 992px) {
141
+ .map :global(.leaflet-tooltip) {
142
+ display: none !important;
143
+ }
80
144
  }
@@ -0,0 +1,69 @@
1
+ import * as React from "react";
2
+ import Button from "dt-design-system/es/button";
3
+ import * as Icons from "dt-design-system/es/icons";
4
+ import css from "./full-screen-button.module.css";
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ export default function FullScreenButton({
7
+ fullScreen,
8
+ setFullScreen,
9
+ containerRef
10
+ }) {
11
+ const [fullScreenCompatible, setFullScreenCompatible] = React.useState(true);
12
+ const cleanupFullScreen = React.useCallback(e => {
13
+ if (!document.fullscreenElement) {
14
+ setFullScreen(false);
15
+ }
16
+ }, [setFullScreen]);
17
+ React.useEffect(() => {
18
+ setFullScreenCompatible(isFullScreenCompatible());
19
+ return () => {
20
+ document.removeEventListener("fullscreenchange", cleanupFullScreen);
21
+ };
22
+ }, [cleanupFullScreen]);
23
+ if (!fullScreenCompatible) return null;
24
+ const Icon = Icons[fullScreen ? "Minimize" : "Maximize"];
25
+ const toggleFullScreen = e => {
26
+ e.preventDefault();
27
+ e.stopPropagation();
28
+ if (!fullScreen) {
29
+ enterFullScreen(containerRef.current, setFullScreen);
30
+ document.addEventListener("fullscreenchange", cleanupFullScreen);
31
+ } else {
32
+ exitFullScreen(setFullScreen);
33
+ document.removeEventListener("fullscreenchange", cleanupFullScreen);
34
+ }
35
+ };
36
+ return _jsx(Button, {
37
+ type: "button",
38
+ className: css.button,
39
+ onClick: toggleFullScreen,
40
+ children: _jsx(Icon, {})
41
+ });
42
+ }
43
+ function isFullScreenCompatible() {
44
+ return document.fullscreenEnabled || document.webkitFullscreenEnabled || document.mozFullscreenEnabled || document.msFullscreenEnabled;
45
+ }
46
+ function enterFullScreen(el, setFullScreen) {
47
+ if (el.requestFullscreen) {
48
+ el.requestFullscreen();
49
+ } else if (el.mozRequestFullScreen) {
50
+ el.mozRequestFullScreen();
51
+ } else if (el.webkitRequestFullscreen) {
52
+ el.webkitRequestFullscreen();
53
+ } else if (el.msRequestFullscreen) {
54
+ el.msRequestFullscreen();
55
+ }
56
+ setFullScreen(true);
57
+ }
58
+ function exitFullScreen(setFullScreen) {
59
+ if (document.exitFullscreen) {
60
+ document.exitFullscreen();
61
+ } else if (document.webkitExitFullscreen) {
62
+ document.webkitExitFullscreen();
63
+ } else if (document.mozCancelFullScreen) {
64
+ document.mozCancelFullScreen();
65
+ } else if (document.msExitFullscreen) {
66
+ document.msExitFullscreen();
67
+ }
68
+ setFullScreen(false);
69
+ }
@@ -0,0 +1,5 @@
1
+ .button {
2
+ position: absolute;
3
+ top: 80px;
4
+ left: 10px;
5
+ }
@@ -12,7 +12,15 @@ export default function IconPicker({
12
12
  }) {
13
13
  const [opened, setOpened] = React.useState(false);
14
14
  const Icon = Icons[iconSet][selectedIcon] || Icons[iconSet].Location;
15
- const keys = Object.keys(Icons[iconSet]);
15
+ const keys = Object.keys(Icons[iconSet]).sort((a, b) => {
16
+ const {
17
+ key: aKey
18
+ } = Icons[iconSet][a]();
19
+ const {
20
+ key: bKey
21
+ } = Icons[iconSet][b]();
22
+ return Number(aKey) - Number(bKey);
23
+ });
16
24
  const togglePicker = () => {
17
25
  setOpened(!opened);
18
26
  };
@@ -1,7 +1,7 @@
1
1
  svg.selectedIcon {
2
- flex: 0 0 24px;
3
- width: 24px;
4
- height: 24px;
2
+ flex: 0 0 44px;
3
+ width: 44px;
4
+ height: 44px;
5
5
  fill: var(--ds-secondary, var(--ds-blue-400, #4177f6));
6
6
  z-index: initial !important;
7
7
  }
@@ -13,12 +13,14 @@ svg.selectedIcon {
13
13
  width: 100%;
14
14
  height: 100%;
15
15
  display: grid;
16
- grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
16
+ grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
17
17
  grid-template-rows: max-content;
18
18
  justify-items: start;
19
19
  gap: 10px;
20
20
  background-color: var(--ds-grey-000, #fff);
21
+ border-radius: var(--ds-radius-100, 6px);
21
22
  overflow: auto;
23
+ overscroll-behavior: contain;
22
24
  z-index: 1;
23
25
  }
24
26
 
@@ -27,25 +29,31 @@ svg.selectedIcon {
27
29
  }
28
30
 
29
31
  .helper {
32
+ position: sticky;
33
+ bottom: 0;
30
34
  grid-column: 1 / -1;
31
35
  width: 100%;
32
36
  margin-top: auto;
37
+ padding-top: 6px;
33
38
  text-align: center;
34
39
  font-weight: 700;
35
40
  font-family: var(--ds-sans-serif-font, "Open Sans", sans-serif);
36
41
  font-size: 12px;
42
+ background-color: white;
43
+ z-index: 1;
37
44
  }
38
45
 
39
46
  .iconButton {
40
- width: 40px;
41
- height: 40px;
47
+ width: 60px;
48
+ height: 60px;
42
49
  padding: 0;
43
50
  margin: 0 auto;
44
51
  }
45
52
 
46
53
  .icon {
47
- flex: 0 0 24px !important;
48
- width: 24px !important;
49
- height: 24px !important;
54
+ flex: 0 0 50px !important;
55
+ width: 50px !important;
56
+ height: 50px !important;
50
57
  fill: var(--ds-secondary, var(--ds-blue-400, #4177f6)) !important;
58
+ z-index: 0 !important;
51
59
  }