@biodiv-platform/naksha-maplibre-layers 5.0.4 → 5.0.5
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/esm/index.js +88 -22
- package/dist/index.d.ts +1 -0
- package/dist/index.js +78 -21
- package/package.json +9 -4
package/dist/esm/index.js
CHANGED
|
@@ -149,7 +149,10 @@ var locales_default = { en: en_default, fr: fr_default, hi: hi_default };
|
|
|
149
149
|
// src/components/map/index.tsx
|
|
150
150
|
import { defaultViewState as defaultViewState2 } from "@biodiv-platform/naksha-commons";
|
|
151
151
|
import { useMemo as useMemo7, useState as useState10 } from "react";
|
|
152
|
-
import MapGL, {
|
|
152
|
+
import MapGL, {
|
|
153
|
+
FullscreenControl,
|
|
154
|
+
NavigationControl
|
|
155
|
+
} from "react-map-gl/maplibre";
|
|
153
156
|
import { tw as tw20 } from "twind";
|
|
154
157
|
|
|
155
158
|
// src/hooks/use-layers.tsx
|
|
@@ -1397,7 +1400,6 @@ import { tw as tw13 } from "twind";
|
|
|
1397
1400
|
// src/components/sidebar/common/layer-item.tsx
|
|
1398
1401
|
import { useT as useT6 } from "@biodiv-platform/naksha-commons";
|
|
1399
1402
|
import { useMemo as useMemo3, useState as useState6 } from "react";
|
|
1400
|
-
import { SortableHandle } from "react-sortable-hoc";
|
|
1401
1403
|
import { RWebShare } from "react-web-share";
|
|
1402
1404
|
import { tw as tw12 } from "twind";
|
|
1403
1405
|
|
|
@@ -1706,13 +1708,29 @@ function LayerItemStyle({ item }) {
|
|
|
1706
1708
|
|
|
1707
1709
|
// src/components/sidebar/common/layer-item.tsx
|
|
1708
1710
|
import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1711
|
+
function DragHandle({
|
|
1712
|
+
dragHandleProps
|
|
1713
|
+
}) {
|
|
1714
|
+
return /* @__PURE__ */ jsx16("div", __spreadProps(__spreadValues({
|
|
1715
|
+
className: tw12`mt-1 w-6 text-center cursor-move`,
|
|
1716
|
+
style: { touchAction: "none" }
|
|
1717
|
+
}, dragHandleProps), {
|
|
1718
|
+
children: /* @__PURE__ */ jsx16(GrabberIcon, {})
|
|
1719
|
+
}));
|
|
1720
|
+
}
|
|
1721
|
+
function LayerItem({
|
|
1722
|
+
item,
|
|
1723
|
+
extended,
|
|
1724
|
+
dragHandleProps
|
|
1725
|
+
}) {
|
|
1714
1726
|
const { t } = useT6();
|
|
1715
|
-
const {
|
|
1727
|
+
const {
|
|
1728
|
+
layer,
|
|
1729
|
+
query,
|
|
1730
|
+
mp,
|
|
1731
|
+
query: { setClickedLngLat },
|
|
1732
|
+
setIsInfoBarOpen
|
|
1733
|
+
} = useLayers();
|
|
1716
1734
|
const [isAdded, setIsAdded] = useState6(layer.selectedIds.includes(item.id));
|
|
1717
1735
|
const [isLoading, setIsLoading] = useState6(false);
|
|
1718
1736
|
const shareData = useMemo3(
|
|
@@ -1757,7 +1775,9 @@ function LayerItem({ item, extended }) {
|
|
|
1757
1775
|
onChange: onToggleLayer,
|
|
1758
1776
|
isLoading
|
|
1759
1777
|
}),
|
|
1760
|
-
extended && /* @__PURE__ */ jsx16(DragHandle, {
|
|
1778
|
+
extended && /* @__PURE__ */ jsx16(DragHandle, {
|
|
1779
|
+
dragHandleProps
|
|
1780
|
+
})
|
|
1761
1781
|
]
|
|
1762
1782
|
}),
|
|
1763
1783
|
/* @__PURE__ */ jsx16("img", {
|
|
@@ -1921,19 +1941,63 @@ function arrayMoveImmutable(array, fromIndex, toIndex) {
|
|
|
1921
1941
|
}
|
|
1922
1942
|
|
|
1923
1943
|
// src/components/sidebar/selected/selected-item-list.tsx
|
|
1924
|
-
import {
|
|
1944
|
+
import {
|
|
1945
|
+
closestCenter,
|
|
1946
|
+
DndContext,
|
|
1947
|
+
PointerSensor,
|
|
1948
|
+
useSensor,
|
|
1949
|
+
useSensors
|
|
1950
|
+
} from "@dnd-kit/core";
|
|
1951
|
+
import { SortableContext, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
1952
|
+
import { CSS } from "@dnd-kit/utilities";
|
|
1925
1953
|
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
})
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1954
|
+
function SortableSelectedItem({ item, extended }) {
|
|
1955
|
+
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
|
|
1956
|
+
id: item.id
|
|
1957
|
+
});
|
|
1958
|
+
const style = {
|
|
1959
|
+
transform: CSS.Transform.toString(transform),
|
|
1960
|
+
transition,
|
|
1961
|
+
opacity: isDragging ? 0.5 : 1
|
|
1962
|
+
};
|
|
1963
|
+
return /* @__PURE__ */ jsx20("div", {
|
|
1964
|
+
ref: setNodeRef,
|
|
1965
|
+
style,
|
|
1966
|
+
children: /* @__PURE__ */ jsx20(LayerItem, {
|
|
1967
|
+
item,
|
|
1968
|
+
extended,
|
|
1969
|
+
dragHandleProps: __spreadValues(__spreadValues({}, attributes), listeners)
|
|
1970
|
+
})
|
|
1971
|
+
});
|
|
1972
|
+
}
|
|
1973
|
+
var SelectedItemList = ({ layerList, onSortEnd }) => {
|
|
1974
|
+
const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 4 } }));
|
|
1975
|
+
const handleDragEnd = (event) => {
|
|
1976
|
+
const { active, over } = event;
|
|
1977
|
+
if (over && active.id !== over.id) {
|
|
1978
|
+
const oldIndex = layerList.findIndex((item) => item.id === active.id);
|
|
1979
|
+
const newIndex = layerList.findIndex((item) => item.id === over.id);
|
|
1980
|
+
if (oldIndex !== -1 && newIndex !== -1) {
|
|
1981
|
+
onSortEnd({ oldIndex, newIndex });
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
};
|
|
1985
|
+
return /* @__PURE__ */ jsx20(DndContext, {
|
|
1986
|
+
sensors,
|
|
1987
|
+
collisionDetection: closestCenter,
|
|
1988
|
+
onDragEnd: handleDragEnd,
|
|
1989
|
+
children: /* @__PURE__ */ jsx20(SortableContext, {
|
|
1990
|
+
items: layerList.map((item) => item.id),
|
|
1991
|
+
strategy: verticalListSortingStrategy,
|
|
1992
|
+
children: /* @__PURE__ */ jsx20("div", {
|
|
1993
|
+
children: layerList.map((item) => /* @__PURE__ */ jsx20(SortableSelectedItem, {
|
|
1994
|
+
item,
|
|
1995
|
+
extended: true
|
|
1996
|
+
}, item.id))
|
|
1997
|
+
})
|
|
1998
|
+
})
|
|
1999
|
+
});
|
|
2000
|
+
};
|
|
1937
2001
|
|
|
1938
2002
|
// src/components/sidebar/selected/index.tsx
|
|
1939
2003
|
import { useT as useT8 } from "@biodiv-platform/naksha-commons";
|
|
@@ -2517,7 +2581,6 @@ function Map2() {
|
|
|
2517
2581
|
setCoordinates(event.lngLat);
|
|
2518
2582
|
hover.onHover(event);
|
|
2519
2583
|
};
|
|
2520
|
-
console.info("NakshaMaplibreLayers props");
|
|
2521
2584
|
return /* @__PURE__ */ jsxs18("div", {
|
|
2522
2585
|
className: tw20`h-full w-full relative bg-gray-100`,
|
|
2523
2586
|
children: [
|
|
@@ -2538,6 +2601,9 @@ function Map2() {
|
|
|
2538
2601
|
showZoom: true,
|
|
2539
2602
|
showCompass: true
|
|
2540
2603
|
}),
|
|
2604
|
+
mp.showFullscreenControl && /* @__PURE__ */ jsx31(FullscreenControl, {
|
|
2605
|
+
position: "bottom-right"
|
|
2606
|
+
}),
|
|
2541
2607
|
/* @__PURE__ */ jsx31(markers_list_default, {}),
|
|
2542
2608
|
layer.selectedLayers.map((_l, index) => {
|
|
2543
2609
|
const beforeId = index > 0 ? layer.selectedIds[index - 1] : void 0;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1418,7 +1418,6 @@ var import_twind13 = require("twind");
|
|
|
1418
1418
|
// src/components/sidebar/common/layer-item.tsx
|
|
1419
1419
|
var import_naksha_commons8 = require("@biodiv-platform/naksha-commons");
|
|
1420
1420
|
var import_react7 = require("react");
|
|
1421
|
-
var import_react_sortable_hoc = require("react-sortable-hoc");
|
|
1422
1421
|
var import_react_web_share = require("react-web-share");
|
|
1423
1422
|
var import_twind12 = require("twind");
|
|
1424
1423
|
|
|
@@ -1727,13 +1726,29 @@ function LayerItemStyle({ item }) {
|
|
|
1727
1726
|
|
|
1728
1727
|
// src/components/sidebar/common/layer-item.tsx
|
|
1729
1728
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1729
|
+
function DragHandle({
|
|
1730
|
+
dragHandleProps
|
|
1731
|
+
}) {
|
|
1732
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", __spreadProps(__spreadValues({
|
|
1733
|
+
className: import_twind12.tw`mt-1 w-6 text-center cursor-move`,
|
|
1734
|
+
style: { touchAction: "none" }
|
|
1735
|
+
}, dragHandleProps), {
|
|
1736
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(GrabberIcon, {})
|
|
1737
|
+
}));
|
|
1738
|
+
}
|
|
1739
|
+
function LayerItem({
|
|
1740
|
+
item,
|
|
1741
|
+
extended,
|
|
1742
|
+
dragHandleProps
|
|
1743
|
+
}) {
|
|
1735
1744
|
const { t } = (0, import_naksha_commons8.useT)();
|
|
1736
|
-
const {
|
|
1745
|
+
const {
|
|
1746
|
+
layer,
|
|
1747
|
+
query,
|
|
1748
|
+
mp,
|
|
1749
|
+
query: { setClickedLngLat },
|
|
1750
|
+
setIsInfoBarOpen
|
|
1751
|
+
} = useLayers();
|
|
1737
1752
|
const [isAdded, setIsAdded] = (0, import_react7.useState)(layer.selectedIds.includes(item.id));
|
|
1738
1753
|
const [isLoading, setIsLoading] = (0, import_react7.useState)(false);
|
|
1739
1754
|
const shareData = (0, import_react7.useMemo)(
|
|
@@ -1778,7 +1793,9 @@ function LayerItem({ item, extended }) {
|
|
|
1778
1793
|
onChange: onToggleLayer,
|
|
1779
1794
|
isLoading
|
|
1780
1795
|
}),
|
|
1781
|
-
extended && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(DragHandle, {
|
|
1796
|
+
extended && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(DragHandle, {
|
|
1797
|
+
dragHandleProps
|
|
1798
|
+
})
|
|
1782
1799
|
]
|
|
1783
1800
|
}),
|
|
1784
1801
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("img", {
|
|
@@ -1942,19 +1959,57 @@ function arrayMoveImmutable(array, fromIndex, toIndex) {
|
|
|
1942
1959
|
}
|
|
1943
1960
|
|
|
1944
1961
|
// src/components/sidebar/selected/selected-item-list.tsx
|
|
1945
|
-
var
|
|
1962
|
+
var import_core9 = require("@dnd-kit/core");
|
|
1963
|
+
var import_sortable = require("@dnd-kit/sortable");
|
|
1964
|
+
var import_utilities = require("@dnd-kit/utilities");
|
|
1946
1965
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
})
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1966
|
+
function SortableSelectedItem({ item, extended }) {
|
|
1967
|
+
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = (0, import_sortable.useSortable)({
|
|
1968
|
+
id: item.id
|
|
1969
|
+
});
|
|
1970
|
+
const style = {
|
|
1971
|
+
transform: import_utilities.CSS.Transform.toString(transform),
|
|
1972
|
+
transition,
|
|
1973
|
+
opacity: isDragging ? 0.5 : 1
|
|
1974
|
+
};
|
|
1975
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", {
|
|
1976
|
+
ref: setNodeRef,
|
|
1977
|
+
style,
|
|
1978
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(LayerItem, {
|
|
1979
|
+
item,
|
|
1980
|
+
extended,
|
|
1981
|
+
dragHandleProps: __spreadValues(__spreadValues({}, attributes), listeners)
|
|
1982
|
+
})
|
|
1983
|
+
});
|
|
1984
|
+
}
|
|
1985
|
+
var SelectedItemList = ({ layerList, onSortEnd }) => {
|
|
1986
|
+
const sensors = (0, import_core9.useSensors)((0, import_core9.useSensor)(import_core9.PointerSensor, { activationConstraint: { distance: 4 } }));
|
|
1987
|
+
const handleDragEnd = (event) => {
|
|
1988
|
+
const { active, over } = event;
|
|
1989
|
+
if (over && active.id !== over.id) {
|
|
1990
|
+
const oldIndex = layerList.findIndex((item) => item.id === active.id);
|
|
1991
|
+
const newIndex = layerList.findIndex((item) => item.id === over.id);
|
|
1992
|
+
if (oldIndex !== -1 && newIndex !== -1) {
|
|
1993
|
+
onSortEnd({ oldIndex, newIndex });
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
};
|
|
1997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_core9.DndContext, {
|
|
1998
|
+
sensors,
|
|
1999
|
+
collisionDetection: import_core9.closestCenter,
|
|
2000
|
+
onDragEnd: handleDragEnd,
|
|
2001
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_sortable.SortableContext, {
|
|
2002
|
+
items: layerList.map((item) => item.id),
|
|
2003
|
+
strategy: import_sortable.verticalListSortingStrategy,
|
|
2004
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", {
|
|
2005
|
+
children: layerList.map((item) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SortableSelectedItem, {
|
|
2006
|
+
item,
|
|
2007
|
+
extended: true
|
|
2008
|
+
}, item.id))
|
|
2009
|
+
})
|
|
2010
|
+
})
|
|
2011
|
+
});
|
|
2012
|
+
};
|
|
1958
2013
|
|
|
1959
2014
|
// src/components/sidebar/selected/index.tsx
|
|
1960
2015
|
var import_naksha_commons10 = require("@biodiv-platform/naksha-commons");
|
|
@@ -2538,7 +2593,6 @@ function Map2() {
|
|
|
2538
2593
|
setCoordinates(event.lngLat);
|
|
2539
2594
|
hover.onHover(event);
|
|
2540
2595
|
};
|
|
2541
|
-
console.info("NakshaMaplibreLayers props");
|
|
2542
2596
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
|
|
2543
2597
|
className: import_twind20.tw`h-full w-full relative bg-gray-100`,
|
|
2544
2598
|
children: [
|
|
@@ -2559,6 +2613,9 @@ function Map2() {
|
|
|
2559
2613
|
showZoom: true,
|
|
2560
2614
|
showCompass: true
|
|
2561
2615
|
}),
|
|
2616
|
+
mp.showFullscreenControl && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_maplibre9.FullscreenControl, {
|
|
2617
|
+
position: "bottom-right"
|
|
2618
|
+
}),
|
|
2562
2619
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(markers_list_default, {}),
|
|
2563
2620
|
layer.selectedLayers.map((_l, index) => {
|
|
2564
2621
|
const beforeId = index > 0 ? layer.selectedIds[index - 1] : void 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@biodiv-platform/naksha-maplibre-layers",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.5",
|
|
4
4
|
"author": "harshzalavadiya",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -20,7 +20,10 @@
|
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"react": ">=18",
|
|
22
22
|
"maplibre-gl": "^5.6.2",
|
|
23
|
-
"react-map-gl": "^8.0.4"
|
|
23
|
+
"react-map-gl": "^8.0.4",
|
|
24
|
+
"@dnd-kit/core": "^6.3.1",
|
|
25
|
+
"@dnd-kit/sortable": "^10.0.0",
|
|
26
|
+
"@dnd-kit/utilities": "^3.2.2"
|
|
24
27
|
},
|
|
25
28
|
"devDependencies": {
|
|
26
29
|
"@biodiv-platform/eslint-preset": "*",
|
|
@@ -31,7 +34,10 @@
|
|
|
31
34
|
"maplibre-gl": "^5.6.2",
|
|
32
35
|
"react-map-gl": "^8.0.4",
|
|
33
36
|
"tsup": "^6.1.2",
|
|
34
|
-
"typescript": "^4.7.3"
|
|
37
|
+
"typescript": "^4.7.3",
|
|
38
|
+
"@dnd-kit/core": "^6.3.1",
|
|
39
|
+
"@dnd-kit/sortable": "^10.0.0",
|
|
40
|
+
"@dnd-kit/utilities": "^3.2.2"
|
|
35
41
|
},
|
|
36
42
|
"dependencies": {
|
|
37
43
|
"@bumaga/tabs": "^0.2.0",
|
|
@@ -42,7 +48,6 @@
|
|
|
42
48
|
"geohash": "^0.0.1",
|
|
43
49
|
"highlight-search-result": "^1.0.4",
|
|
44
50
|
"immer": "^9.0.15",
|
|
45
|
-
"react-sortable-hoc": "^2.0.0",
|
|
46
51
|
"react-tiny-popover": "^7.0.1",
|
|
47
52
|
"react-virtual": "^2.10.4",
|
|
48
53
|
"react-virtualized-auto-sizer": "^1.0.6",
|