naksha-components-react 4.6.1-beta.14 → 4.6.1-beta.15
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 +133 -1
- package/dist/index.js +173 -1
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -1 +1,133 @@
|
|
|
1
|
-
|
|
1
|
+
// ../naksha-commons/dist/esm/index.js
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
var GMAPS_AUTOCOMPLETE_FIELDS = [
|
|
6
|
+
"formatted_address",
|
|
7
|
+
"geometry",
|
|
8
|
+
"name"
|
|
9
|
+
];
|
|
10
|
+
var GMAPS_LIBRARIES = {
|
|
11
|
+
DEFAULT: ["drawing", "places"],
|
|
12
|
+
AUTOCOMPLETE: ["drawing", "places"]
|
|
13
|
+
};
|
|
14
|
+
var LICENSES = {
|
|
15
|
+
"CC-BY": "//creativecommons.org/licenses/by/4.0",
|
|
16
|
+
"BY-SA": "//creativecommons.org/licenses/by-sa/4.0",
|
|
17
|
+
"BY-ND": "//creativecommons.org/licenses/by-nd/4.0",
|
|
18
|
+
"BY-NC": "//creativecommons.org/licenses/by-nc/4.0",
|
|
19
|
+
"BY-NC-SA": "//creativecommons.org/licenses/by-nc-sa/4.0",
|
|
20
|
+
"BY-NC-ND": "//creativecommons.org/licenses/by-nc-nd/4.0"
|
|
21
|
+
};
|
|
22
|
+
var MapStyles = /* @__PURE__ */ ((MapStyles2) => {
|
|
23
|
+
MapStyles2["MAP_STREETS"] = "0";
|
|
24
|
+
MapStyles2["MAP_SATELLITE"] = "1";
|
|
25
|
+
MapStyles2["MAP_DARK"] = "2";
|
|
26
|
+
MapStyles2["MAP_OSM"] = "3";
|
|
27
|
+
return MapStyles2;
|
|
28
|
+
})(MapStyles || {});
|
|
29
|
+
var defaultViewState = {
|
|
30
|
+
latitude: 22.5,
|
|
31
|
+
longitude: 79,
|
|
32
|
+
zoom: 3,
|
|
33
|
+
bearing: 0,
|
|
34
|
+
pitch: 0
|
|
35
|
+
};
|
|
36
|
+
var defaultMapStyles = [
|
|
37
|
+
{
|
|
38
|
+
text: "OSM",
|
|
39
|
+
key: "3",
|
|
40
|
+
style: "https://unpkg.com/maplibre-gl-styles@0.0.1/styles/osm-mapnik/v8/india.json"
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
var adminBoundries = [
|
|
44
|
+
"admin-0-boundary",
|
|
45
|
+
"admin-1-boundary",
|
|
46
|
+
"admin-0-boundary-disputed",
|
|
47
|
+
"admin-1-boundary-bg",
|
|
48
|
+
"admin-0-boundary-bg"
|
|
49
|
+
];
|
|
50
|
+
var getByPath = (obj, path) => {
|
|
51
|
+
path.split(".").forEach(function(level) {
|
|
52
|
+
if (!obj) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
obj = obj[level];
|
|
56
|
+
});
|
|
57
|
+
return obj;
|
|
58
|
+
};
|
|
59
|
+
var CounterContext = createContext(
|
|
60
|
+
{}
|
|
61
|
+
);
|
|
62
|
+
var TranslationProvider = ({
|
|
63
|
+
localeStrings,
|
|
64
|
+
lang = "en",
|
|
65
|
+
children
|
|
66
|
+
}) => {
|
|
67
|
+
const t = (key) => {
|
|
68
|
+
const translatedString = getByPath(localeStrings[lang], key);
|
|
69
|
+
if (!translatedString) {
|
|
70
|
+
console.warn(`Translation '${key}' for locale '${lang}' not found.`);
|
|
71
|
+
}
|
|
72
|
+
return translatedString;
|
|
73
|
+
};
|
|
74
|
+
return /* @__PURE__ */ jsx(CounterContext.Provider, {
|
|
75
|
+
value: { t },
|
|
76
|
+
children
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
function useT() {
|
|
80
|
+
return useContext(CounterContext);
|
|
81
|
+
}
|
|
82
|
+
function useDebounce(value, delay) {
|
|
83
|
+
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
84
|
+
useEffect(
|
|
85
|
+
() => {
|
|
86
|
+
const handler = setTimeout(() => {
|
|
87
|
+
setDebouncedValue(value);
|
|
88
|
+
}, delay);
|
|
89
|
+
return () => {
|
|
90
|
+
clearTimeout(handler);
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
[value, delay]
|
|
94
|
+
);
|
|
95
|
+
return debouncedValue;
|
|
96
|
+
}
|
|
97
|
+
var mapboxToGmapsViewState = (vp = defaultViewState, zoomOffset = 1) => {
|
|
98
|
+
return {
|
|
99
|
+
center: {
|
|
100
|
+
lat: vp.latitude,
|
|
101
|
+
lng: vp.longitude
|
|
102
|
+
},
|
|
103
|
+
zoom: vp.zoom + zoomOffset
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
var formatDate = (date) => {
|
|
107
|
+
const year = date.getFullYear().toString();
|
|
108
|
+
const month = (date.getMonth() + 101).toString().substring(1);
|
|
109
|
+
const day = (date.getDate() + 100).toString().substring(1);
|
|
110
|
+
return `${year}-${month}-${day}`;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// src/index.tsx
|
|
114
|
+
export * from "@biodiv-platform/naksha-gmaps-draw";
|
|
115
|
+
export * from "@biodiv-platform/naksha-gmaps-view";
|
|
116
|
+
export * from "@biodiv-platform/naksha-maplibre-draw";
|
|
117
|
+
export * from "@biodiv-platform/naksha-maplibre-layers";
|
|
118
|
+
export * from "@biodiv-platform/naksha-maplibre-view";
|
|
119
|
+
export {
|
|
120
|
+
GMAPS_AUTOCOMPLETE_FIELDS,
|
|
121
|
+
GMAPS_LIBRARIES,
|
|
122
|
+
LICENSES,
|
|
123
|
+
MapStyles,
|
|
124
|
+
TranslationProvider,
|
|
125
|
+
adminBoundries,
|
|
126
|
+
defaultMapStyles,
|
|
127
|
+
defaultViewState,
|
|
128
|
+
formatDate,
|
|
129
|
+
getByPath,
|
|
130
|
+
mapboxToGmapsViewState,
|
|
131
|
+
useDebounce,
|
|
132
|
+
useT
|
|
133
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1 +1,173 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/index.tsx
|
|
22
|
+
var src_exports = {};
|
|
23
|
+
__export(src_exports, {
|
|
24
|
+
GMAPS_AUTOCOMPLETE_FIELDS: () => GMAPS_AUTOCOMPLETE_FIELDS,
|
|
25
|
+
GMAPS_LIBRARIES: () => GMAPS_LIBRARIES,
|
|
26
|
+
LICENSES: () => LICENSES,
|
|
27
|
+
MapStyles: () => MapStyles,
|
|
28
|
+
TranslationProvider: () => TranslationProvider,
|
|
29
|
+
adminBoundries: () => adminBoundries,
|
|
30
|
+
defaultMapStyles: () => defaultMapStyles,
|
|
31
|
+
defaultViewState: () => defaultViewState,
|
|
32
|
+
formatDate: () => formatDate,
|
|
33
|
+
getByPath: () => getByPath,
|
|
34
|
+
mapboxToGmapsViewState: () => mapboxToGmapsViewState,
|
|
35
|
+
useDebounce: () => useDebounce,
|
|
36
|
+
useT: () => useT
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(src_exports);
|
|
39
|
+
|
|
40
|
+
// ../naksha-commons/dist/esm/index.js
|
|
41
|
+
var import_react = require("react");
|
|
42
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
43
|
+
var import_react2 = require("react");
|
|
44
|
+
var GMAPS_AUTOCOMPLETE_FIELDS = [
|
|
45
|
+
"formatted_address",
|
|
46
|
+
"geometry",
|
|
47
|
+
"name"
|
|
48
|
+
];
|
|
49
|
+
var GMAPS_LIBRARIES = {
|
|
50
|
+
DEFAULT: ["drawing", "places"],
|
|
51
|
+
AUTOCOMPLETE: ["drawing", "places"]
|
|
52
|
+
};
|
|
53
|
+
var LICENSES = {
|
|
54
|
+
"CC-BY": "//creativecommons.org/licenses/by/4.0",
|
|
55
|
+
"BY-SA": "//creativecommons.org/licenses/by-sa/4.0",
|
|
56
|
+
"BY-ND": "//creativecommons.org/licenses/by-nd/4.0",
|
|
57
|
+
"BY-NC": "//creativecommons.org/licenses/by-nc/4.0",
|
|
58
|
+
"BY-NC-SA": "//creativecommons.org/licenses/by-nc-sa/4.0",
|
|
59
|
+
"BY-NC-ND": "//creativecommons.org/licenses/by-nc-nd/4.0"
|
|
60
|
+
};
|
|
61
|
+
var MapStyles = /* @__PURE__ */ ((MapStyles2) => {
|
|
62
|
+
MapStyles2["MAP_STREETS"] = "0";
|
|
63
|
+
MapStyles2["MAP_SATELLITE"] = "1";
|
|
64
|
+
MapStyles2["MAP_DARK"] = "2";
|
|
65
|
+
MapStyles2["MAP_OSM"] = "3";
|
|
66
|
+
return MapStyles2;
|
|
67
|
+
})(MapStyles || {});
|
|
68
|
+
var defaultViewState = {
|
|
69
|
+
latitude: 22.5,
|
|
70
|
+
longitude: 79,
|
|
71
|
+
zoom: 3,
|
|
72
|
+
bearing: 0,
|
|
73
|
+
pitch: 0
|
|
74
|
+
};
|
|
75
|
+
var defaultMapStyles = [
|
|
76
|
+
{
|
|
77
|
+
text: "OSM",
|
|
78
|
+
key: "3",
|
|
79
|
+
style: "https://unpkg.com/maplibre-gl-styles@0.0.1/styles/osm-mapnik/v8/india.json"
|
|
80
|
+
}
|
|
81
|
+
];
|
|
82
|
+
var adminBoundries = [
|
|
83
|
+
"admin-0-boundary",
|
|
84
|
+
"admin-1-boundary",
|
|
85
|
+
"admin-0-boundary-disputed",
|
|
86
|
+
"admin-1-boundary-bg",
|
|
87
|
+
"admin-0-boundary-bg"
|
|
88
|
+
];
|
|
89
|
+
var getByPath = (obj, path) => {
|
|
90
|
+
path.split(".").forEach(function(level) {
|
|
91
|
+
if (!obj) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
obj = obj[level];
|
|
95
|
+
});
|
|
96
|
+
return obj;
|
|
97
|
+
};
|
|
98
|
+
var CounterContext = (0, import_react.createContext)(
|
|
99
|
+
{}
|
|
100
|
+
);
|
|
101
|
+
var TranslationProvider = ({
|
|
102
|
+
localeStrings,
|
|
103
|
+
lang = "en",
|
|
104
|
+
children
|
|
105
|
+
}) => {
|
|
106
|
+
const t = (key) => {
|
|
107
|
+
const translatedString = getByPath(localeStrings[lang], key);
|
|
108
|
+
if (!translatedString) {
|
|
109
|
+
console.warn(`Translation '${key}' for locale '${lang}' not found.`);
|
|
110
|
+
}
|
|
111
|
+
return translatedString;
|
|
112
|
+
};
|
|
113
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CounterContext.Provider, {
|
|
114
|
+
value: { t },
|
|
115
|
+
children
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
function useT() {
|
|
119
|
+
return (0, import_react.useContext)(CounterContext);
|
|
120
|
+
}
|
|
121
|
+
function useDebounce(value, delay) {
|
|
122
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react2.useState)(value);
|
|
123
|
+
(0, import_react2.useEffect)(
|
|
124
|
+
() => {
|
|
125
|
+
const handler = setTimeout(() => {
|
|
126
|
+
setDebouncedValue(value);
|
|
127
|
+
}, delay);
|
|
128
|
+
return () => {
|
|
129
|
+
clearTimeout(handler);
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
[value, delay]
|
|
133
|
+
);
|
|
134
|
+
return debouncedValue;
|
|
135
|
+
}
|
|
136
|
+
var mapboxToGmapsViewState = (vp = defaultViewState, zoomOffset = 1) => {
|
|
137
|
+
return {
|
|
138
|
+
center: {
|
|
139
|
+
lat: vp.latitude,
|
|
140
|
+
lng: vp.longitude
|
|
141
|
+
},
|
|
142
|
+
zoom: vp.zoom + zoomOffset
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
var formatDate = (date) => {
|
|
146
|
+
const year = date.getFullYear().toString();
|
|
147
|
+
const month = (date.getMonth() + 101).toString().substring(1);
|
|
148
|
+
const day = (date.getDate() + 100).toString().substring(1);
|
|
149
|
+
return `${year}-${month}-${day}`;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// src/index.tsx
|
|
153
|
+
__reExport(src_exports, require("@biodiv-platform/naksha-gmaps-draw"), module.exports);
|
|
154
|
+
__reExport(src_exports, require("@biodiv-platform/naksha-gmaps-view"), module.exports);
|
|
155
|
+
__reExport(src_exports, require("@biodiv-platform/naksha-maplibre-draw"), module.exports);
|
|
156
|
+
__reExport(src_exports, require("@biodiv-platform/naksha-maplibre-layers"), module.exports);
|
|
157
|
+
__reExport(src_exports, require("@biodiv-platform/naksha-maplibre-view"), module.exports);
|
|
158
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
159
|
+
0 && (module.exports = {
|
|
160
|
+
GMAPS_AUTOCOMPLETE_FIELDS,
|
|
161
|
+
GMAPS_LIBRARIES,
|
|
162
|
+
LICENSES,
|
|
163
|
+
MapStyles,
|
|
164
|
+
TranslationProvider,
|
|
165
|
+
adminBoundries,
|
|
166
|
+
defaultMapStyles,
|
|
167
|
+
defaultViewState,
|
|
168
|
+
formatDate,
|
|
169
|
+
getByPath,
|
|
170
|
+
mapboxToGmapsViewState,
|
|
171
|
+
useDebounce,
|
|
172
|
+
useT
|
|
173
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "naksha-components-react",
|
|
3
|
-
"version": "4.6.1-beta.
|
|
3
|
+
"version": "4.6.1-beta.15",
|
|
4
4
|
"author": "harshzalavadiya",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@biodiv-platform/eslint-preset": "4.4.9",
|
|
24
24
|
"@biodiv-platform/naksha-gmaps-draw": "4.5.3",
|
|
25
25
|
"@biodiv-platform/naksha-gmaps-view": "4.4.9",
|
|
26
|
-
"@biodiv-platform/naksha-maplibre-draw": "5.0.
|
|
26
|
+
"@biodiv-platform/naksha-maplibre-draw": "5.0.2",
|
|
27
27
|
"@biodiv-platform/naksha-maplibre-layers": "5.0.1",
|
|
28
28
|
"@biodiv-platform/naksha-maplibre-view": "5.0.1",
|
|
29
29
|
"@biodiv-platform/tsconfig": "4.4.9"
|