utopia-ui 3.0.91 → 3.0.93
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/dist/index.cjs +66 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.esm.js +66 -27
- package/dist/index.esm.js.map +1 -1
- package/dist/types/src/Components/Map/Subcomponents/Controls/LayerControl.d.ts +3 -1
- package/dist/types/src/Components/Map/UtopiaMap.d.ts +3 -1
- package/dist/types/src/Components/Map/UtopiaMapInner.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
@@ -255,6 +255,23 @@ function useFilterManager(initialTags) {
|
|
255
255
|
throw new Error();
|
256
256
|
}
|
257
257
|
}, initialLayers);
|
258
|
+
const allLayers = useLayers();
|
259
|
+
React.useEffect(() => {
|
260
|
+
if (allLayers.length === 0)
|
261
|
+
return;
|
262
|
+
const visibleNames = visibleLayers.map((l) => l.name);
|
263
|
+
const allNames = allLayers.map((l) => l.name);
|
264
|
+
const params = new URLSearchParams(location.search);
|
265
|
+
const allVisible = visibleNames.length === allNames.length &&
|
266
|
+
visibleNames.every((name) => allNames.includes(name));
|
267
|
+
if (allVisible) {
|
268
|
+
params.delete('layers');
|
269
|
+
}
|
270
|
+
else {
|
271
|
+
params.set('layers', visibleNames.join(','));
|
272
|
+
}
|
273
|
+
navigate(`${location.pathname}?${params.toString()}`, { replace: true });
|
274
|
+
}, [visibleLayers, allLayers, navigate]);
|
258
275
|
const [visibleGroupTypes, dispatchGroupTypes] = React.useReducer((state, action) => {
|
259
276
|
switch (action.type) {
|
260
277
|
case 'ADD_GROUP_TYPE':
|
@@ -1295,8 +1312,8 @@ const GratitudeControl = () => {
|
|
1295
1312
|
|
1296
1313
|
var LayerSVG = 'data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPScxLjEnIHZpZXdCb3g9JzAgMCAyMCAyMCcgc3Ryb2tlLXdpZHRoPSIyIiB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnPgogICAgPHBhdGgKICAgICAgICBpZD0nc3ZnXzEnCiAgICAgICAgZmlsbD0nY3VycmVudENvbG9yJwogICAgICAgIGQ9J20yLjc1NTY1LDExLjkwNzI3bC0xLjAzODUyLDAuMjgzNzJjLTAuNzc3MTgsMC4zODg1OSAtMC43NzcxOCwxLjAxMzggMCwxLjQwMjNsNy4wMTU2LDMuNTA3OGMwLjc3NzE4LDAuMzg4NTkgMi4wMjc1LDAuMzg4NTkgMi44MDQ3LDBsNy4wMTU2LC0zLjUwNzhjMC43NzcxOCwtMC4zODg1OSAwLjc3NzE4LC0xLjAxMzggMCwtMS40MDIzbC0wLjYzMzExLC0wLjQ4NjQzbC00LjY3NzE4LDIuMjM2MjRjLTEuNTQ1MiwwLjc3MjYyIC0zLjMxODc3LDEuNTgzNDMgLTQuODY0MDcsMC44MTA4MWwtNS42MjMwMiwtMi44NDQzNHonCiAgICAvPgogICAgPHBhdGgKICAgICAgICBpZD0nc3ZnXzInCiAgICAgICAgc3Ryb2tlPSdjdXJyZW50Q29sb3InCiAgICAgICAgZmlsbD0nbm9uZScKICAgICAgICBkPSdtMTEuMjQ3LDQuMzA4NTFsNi4yMzQ5LDMuMDg3N2MwLjY5MDgzLDAuMzQyMTEgMC42OTA4MywwLjg5Mjk1IDAsMS4yMzUxbC02LjIzNDksMy4wODc3Yy0wLjY5MDgzLDAuMzQyMTEgLTEuODAzMSwwLjM0MjEyIC0yLjQ5NCwwbC02LjIzNDksLTMuMDg3N2MtMC42OTA4MywtMC4zNDIxMSAtMC42OTA4MywtMC44OTI5NSAwLC0xLjIzNTFsNi4yMzQ5LC0zLjA4NzdjMC42OTA4MywtMC4zNDIxMSAxLjgwMzEsLTAuMzQyMTEgMi40OTQsMHonCiAgICAvPgo8L3N2Zz4=';
|
1297
1314
|
|
1298
|
-
function LayerControl() {
|
1299
|
-
const [open, setOpen] = React.useState(
|
1315
|
+
function LayerControl({ expandLayerControl = false }) {
|
1316
|
+
const [open, setOpen] = React.useState(expandLayerControl);
|
1300
1317
|
const layers = useLayers();
|
1301
1318
|
const isLayerVisible = useIsLayerVisible();
|
1302
1319
|
const toggleVisibleLayer = useToggleVisibleLayer();
|
@@ -2759,7 +2776,7 @@ const SelectPosition = ({ setSelectNewItemPosition }) => {
|
|
2759
2776
|
}, children: jsxRuntime.jsx("p", { className: 'tw:text-center ', children: "\u2715" }) }), jsxRuntime.jsx("div", { className: 'tw:alert tw:bg-base-100 tw:text-base-content', children: jsxRuntime.jsx("div", { children: jsxRuntime.jsx("span", { className: 'tw:text-lg', children: "Select position on the map!" }) }) })] }));
|
2760
2777
|
};
|
2761
2778
|
|
2762
|
-
function UtopiaMapInner({ children, geo, showFilterControl = false, showGratitudeControl = false, showLayerControl = true, showThemeControl = false, defaultTheme = '', donationWidget, }) {
|
2779
|
+
function UtopiaMapInner({ children, geo, showFilterControl = false, showGratitudeControl = false, showLayerControl = true, showThemeControl = false, defaultTheme = '', donationWidget, expandLayerControl, }) {
|
2763
2780
|
const selectNewItemPosition = useSelectPosition();
|
2764
2781
|
const setSelectNewItemPosition = useSetSelectPosition();
|
2765
2782
|
const setClusterRef = useSetClusterRef();
|
@@ -2869,7 +2886,50 @@ function UtopiaMapInner({ children, geo, showFilterControl = false, showGratitud
|
|
2869
2886
|
layer.bindPopup(feature.properties.name);
|
2870
2887
|
}
|
2871
2888
|
};
|
2872
|
-
|
2889
|
+
const addFilterTag = useAddFilterTag();
|
2890
|
+
const resetFilterTags = useResetFilterTags();
|
2891
|
+
const tags = useTags();
|
2892
|
+
const filterTags = useFilterTags();
|
2893
|
+
React.useEffect(() => {
|
2894
|
+
const params = new URLSearchParams(location.search);
|
2895
|
+
const urlTags = params.get('tags');
|
2896
|
+
const decodedTags = urlTags ? decodeURIComponent(urlTags) : '';
|
2897
|
+
const decodedTagsArray = decodedTags.split(';').filter(Boolean);
|
2898
|
+
const urlDiffersFromState = decodedTagsArray.some((ut) => !filterTags.find((ft) => ut.toLowerCase() === ft.name.toLowerCase())) ||
|
2899
|
+
filterTags.some((ft) => !decodedTagsArray.find((ut) => ut.toLowerCase() === ft.name.toLowerCase()));
|
2900
|
+
if (urlDiffersFromState) {
|
2901
|
+
resetFilterTags();
|
2902
|
+
decodedTagsArray.forEach((urlTag) => {
|
2903
|
+
const match = tags.find((t) => t.name.toLowerCase() === urlTag.toLowerCase());
|
2904
|
+
if (match)
|
2905
|
+
addFilterTag(match);
|
2906
|
+
});
|
2907
|
+
}
|
2908
|
+
}, [location, tags, filterTags, addFilterTag, resetFilterTags]);
|
2909
|
+
const toggleVisibleLayer = useToggleVisibleLayer();
|
2910
|
+
const allLayers = useLayers();
|
2911
|
+
const initializedRef = React.useRef(false);
|
2912
|
+
React.useEffect(() => {
|
2913
|
+
if (initializedRef.current || allLayers.length === 0)
|
2914
|
+
return;
|
2915
|
+
const params = new URLSearchParams(location.search);
|
2916
|
+
const urlLayersParam = params.get('layers');
|
2917
|
+
if (!urlLayersParam) {
|
2918
|
+
initializedRef.current = true;
|
2919
|
+
return;
|
2920
|
+
}
|
2921
|
+
const urlLayerNames = urlLayersParam.split(',').filter(Boolean);
|
2922
|
+
const layerNamesToHide = allLayers
|
2923
|
+
.map((l) => l.name)
|
2924
|
+
.filter((name) => !urlLayerNames.includes(name));
|
2925
|
+
layerNamesToHide.forEach((name) => {
|
2926
|
+
const match = allLayers.find((l) => l.name === name);
|
2927
|
+
if (match)
|
2928
|
+
toggleVisibleLayer(match);
|
2929
|
+
});
|
2930
|
+
initializedRef.current = true;
|
2931
|
+
}, [location, allLayers, toggleVisibleLayer]);
|
2932
|
+
return (jsxRuntime.jsxs("div", { className: `tw:h-full ${selectNewItemPosition != null ? 'crosshair-cursor-enabled' : ''}`, children: [jsxRuntime.jsx(reactRouterDom.Outlet, {}), jsxRuntime.jsxs(Control, { position: 'topLeft', zIndex: '1000', absolute: true, children: [jsxRuntime.jsx(SearchControl, {}), jsxRuntime.jsx(TagsControl, {})] }), jsxRuntime.jsxs(Control, { position: 'bottomLeft', zIndex: '999', absolute: true, children: [showFilterControl && jsxRuntime.jsx(FilterControl, {}), showLayerControl && jsxRuntime.jsx(LayerControl, { expandLayerControl: expandLayerControl ?? false }), showGratitudeControl && jsxRuntime.jsx(GratitudeControl, {})] }), jsxRuntime.jsx(reactLeaflet.TileLayer, { maxZoom: 19, attribution: '\u00A9 <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors', url: 'https://tile.osmand.net/hd/{z}/{x}/{y}.png' }), jsxRuntime.jsx(MarkerClusterGroup, { ref: (r) => setClusterRef(r), showCoverageOnHover: true, chunkedLoading: true, maxClusterRadius: 50, removeOutsideVisibleBounds: false, children: children }), geo && (jsxRuntime.jsx(reactLeaflet.GeoJSON, { data: geo, onEachFeature: onEachFeature, eventHandlers: {
|
2873
2933
|
click: (e) => {
|
2874
2934
|
if (selectNewItemPosition) {
|
2875
2935
|
e.layer.closePopup();
|
@@ -2913,8 +2973,8 @@ function UtopiaMapInner({ children, geo, showFilterControl = false, showGratitud
|
|
2913
2973
|
* ```
|
2914
2974
|
* @category Map
|
2915
2975
|
*/
|
2916
|
-
function UtopiaMap({ height = '500px', width = '100%', center = [50.6, 9.5], zoom = 10, children, geo, showFilterControl = false, showGratitudeControl = false, showLayerControl = true, showZoomControl = false, showThemeControl = false, defaultTheme, donationWidget, }) {
|
2917
|
-
return (jsxRuntime.jsx(ContextWrapper, { children: jsxRuntime.jsx(reactLeaflet.MapContainer, { style: { height, width }, center: new leaflet.LatLng(center[0], center[1]), zoom: zoom, zoomControl: showZoomControl, maxZoom: 19, children: jsxRuntime.jsx(UtopiaMapInner, { geo: geo, showFilterControl: showFilterControl, showGratitudeControl: showGratitudeControl, showLayerControl: showLayerControl, donationWidget: donationWidget, showThemeControl: showThemeControl, defaultTheme: defaultTheme, children: children }) }) }));
|
2976
|
+
function UtopiaMap({ height = '500px', width = '100%', center = [50.6, 9.5], zoom = 10, children, geo, showFilterControl = false, showGratitudeControl = false, showLayerControl = true, showZoomControl = false, showThemeControl = false, defaultTheme, donationWidget, expandLayerControl, }) {
|
2977
|
+
return (jsxRuntime.jsx(ContextWrapper, { children: jsxRuntime.jsx(reactLeaflet.MapContainer, { style: { height, width }, center: new leaflet.LatLng(center[0], center[1]), zoom: zoom, zoomControl: showZoomControl, maxZoom: 19, children: jsxRuntime.jsx(UtopiaMapInner, { geo: geo, showFilterControl: showFilterControl, showGratitudeControl: showGratitudeControl, showLayerControl: showLayerControl, donationWidget: donationWidget, showThemeControl: showThemeControl, defaultTheme: defaultTheme, expandLayerControl: expandLayerControl, children: children }) }) }));
|
2918
2978
|
}
|
2919
2979
|
|
2920
2980
|
const LayerContext = React.createContext({
|
@@ -3038,27 +3098,6 @@ function Tags({ data, api }) {
|
|
3038
3098
|
api && setTagApi(api);
|
3039
3099
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
3040
3100
|
}, [api, data]);
|
3041
|
-
const location = reactRouterDom.useLocation();
|
3042
|
-
const addFilterTag = useAddFilterTag();
|
3043
|
-
const resetFilterTags = useResetFilterTags();
|
3044
|
-
const tags = useTags();
|
3045
|
-
const filterTags = useFilterTags();
|
3046
|
-
React.useEffect(() => {
|
3047
|
-
const params = new URLSearchParams(location.search);
|
3048
|
-
const urlTags = params.get('tags');
|
3049
|
-
const decodedTags = urlTags ? decodeURIComponent(urlTags) : '';
|
3050
|
-
const decodedTagsArray = decodedTags.split(';');
|
3051
|
-
if (decodedTagsArray.some((ut) => !filterTags.find((ft) => ut.toLocaleLowerCase() === ft.name.toLocaleLowerCase())) ||
|
3052
|
-
filterTags.some((ft) => !decodedTagsArray.find((ut) => ut.toLocaleLowerCase() === ft.name.toLocaleLowerCase()))) {
|
3053
|
-
resetFilterTags();
|
3054
|
-
decodedTagsArray.map((urlTag) => {
|
3055
|
-
const tag = tags.find((t) => t.name.toLocaleLowerCase() === urlTag.toLocaleLowerCase());
|
3056
|
-
tag && addFilterTag(tag);
|
3057
|
-
return null;
|
3058
|
-
});
|
3059
|
-
}
|
3060
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
3061
|
-
}, [location, tags]);
|
3062
3101
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
3063
3102
|
}
|
3064
3103
|
|