naksha-components-react 5.0.0 → 5.0.2

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.
@@ -0,0 +1,138 @@
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
+ text: "Satellite",
44
+ key: "1",
45
+ style: "https://raw.githubusercontent.com/go2garret/maps/main/src/assets/json/arcgis_hybrid.json"
46
+ }
47
+ ];
48
+ var adminBoundries = [
49
+ "admin-0-boundary",
50
+ "admin-1-boundary",
51
+ "admin-0-boundary-disputed",
52
+ "admin-1-boundary-bg",
53
+ "admin-0-boundary-bg"
54
+ ];
55
+ var getByPath = (obj, path) => {
56
+ path.split(".").forEach(function(level) {
57
+ if (!obj) {
58
+ return;
59
+ }
60
+ obj = obj[level];
61
+ });
62
+ return obj;
63
+ };
64
+ var CounterContext = createContext(
65
+ {}
66
+ );
67
+ var TranslationProvider = ({
68
+ localeStrings,
69
+ lang = "en",
70
+ children
71
+ }) => {
72
+ const t = (key) => {
73
+ const translatedString = getByPath(localeStrings[lang], key);
74
+ if (!translatedString) {
75
+ console.warn(`Translation '${key}' for locale '${lang}' not found.`);
76
+ }
77
+ return translatedString;
78
+ };
79
+ return /* @__PURE__ */ jsx(CounterContext.Provider, {
80
+ value: { t },
81
+ children
82
+ });
83
+ };
84
+ function useT() {
85
+ return useContext(CounterContext);
86
+ }
87
+ function useDebounce(value, delay) {
88
+ const [debouncedValue, setDebouncedValue] = useState(value);
89
+ useEffect(
90
+ () => {
91
+ const handler = setTimeout(() => {
92
+ setDebouncedValue(value);
93
+ }, delay);
94
+ return () => {
95
+ clearTimeout(handler);
96
+ };
97
+ },
98
+ [value, delay]
99
+ );
100
+ return debouncedValue;
101
+ }
102
+ var mapboxToGmapsViewState = (vp = defaultViewState, zoomOffset = 1) => {
103
+ return {
104
+ center: {
105
+ lat: vp.latitude,
106
+ lng: vp.longitude
107
+ },
108
+ zoom: vp.zoom + zoomOffset
109
+ };
110
+ };
111
+ var formatDate = (date) => {
112
+ const year = date.getFullYear().toString();
113
+ const month = (date.getMonth() + 101).toString().substring(1);
114
+ const day = (date.getDate() + 100).toString().substring(1);
115
+ return `${year}-${month}-${day}`;
116
+ };
117
+
118
+ // src/index.tsx
119
+ export * from "@biodiv-platform/naksha-gmaps-draw";
120
+ export * from "@biodiv-platform/naksha-gmaps-view";
121
+ export * from "@biodiv-platform/naksha-maplibre-draw";
122
+ export * from "@biodiv-platform/naksha-maplibre-layers";
123
+ export * from "@biodiv-platform/naksha-maplibre-view";
124
+ export {
125
+ GMAPS_AUTOCOMPLETE_FIELDS,
126
+ GMAPS_LIBRARIES,
127
+ LICENSES,
128
+ MapStyles,
129
+ TranslationProvider,
130
+ adminBoundries,
131
+ defaultMapStyles,
132
+ defaultViewState,
133
+ formatDate,
134
+ getByPath,
135
+ mapboxToGmapsViewState,
136
+ useDebounce,
137
+ useT
138
+ };
@@ -0,0 +1,6 @@
1
+ export * from '@biodiv-platform/naksha-commons';
2
+ export * from '@biodiv-platform/naksha-gmaps-draw';
3
+ export * from '@biodiv-platform/naksha-gmaps-view';
4
+ export * from '@biodiv-platform/naksha-maplibre-draw';
5
+ export * from '@biodiv-platform/naksha-maplibre-layers';
6
+ export * from '@biodiv-platform/naksha-maplibre-view';
package/dist/index.js ADDED
@@ -0,0 +1,178 @@
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
+ text: "Satellite",
83
+ key: "1",
84
+ style: "https://raw.githubusercontent.com/go2garret/maps/main/src/assets/json/arcgis_hybrid.json"
85
+ }
86
+ ];
87
+ var adminBoundries = [
88
+ "admin-0-boundary",
89
+ "admin-1-boundary",
90
+ "admin-0-boundary-disputed",
91
+ "admin-1-boundary-bg",
92
+ "admin-0-boundary-bg"
93
+ ];
94
+ var getByPath = (obj, path) => {
95
+ path.split(".").forEach(function(level) {
96
+ if (!obj) {
97
+ return;
98
+ }
99
+ obj = obj[level];
100
+ });
101
+ return obj;
102
+ };
103
+ var CounterContext = (0, import_react.createContext)(
104
+ {}
105
+ );
106
+ var TranslationProvider = ({
107
+ localeStrings,
108
+ lang = "en",
109
+ children
110
+ }) => {
111
+ const t = (key) => {
112
+ const translatedString = getByPath(localeStrings[lang], key);
113
+ if (!translatedString) {
114
+ console.warn(`Translation '${key}' for locale '${lang}' not found.`);
115
+ }
116
+ return translatedString;
117
+ };
118
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CounterContext.Provider, {
119
+ value: { t },
120
+ children
121
+ });
122
+ };
123
+ function useT() {
124
+ return (0, import_react.useContext)(CounterContext);
125
+ }
126
+ function useDebounce(value, delay) {
127
+ const [debouncedValue, setDebouncedValue] = (0, import_react2.useState)(value);
128
+ (0, import_react2.useEffect)(
129
+ () => {
130
+ const handler = setTimeout(() => {
131
+ setDebouncedValue(value);
132
+ }, delay);
133
+ return () => {
134
+ clearTimeout(handler);
135
+ };
136
+ },
137
+ [value, delay]
138
+ );
139
+ return debouncedValue;
140
+ }
141
+ var mapboxToGmapsViewState = (vp = defaultViewState, zoomOffset = 1) => {
142
+ return {
143
+ center: {
144
+ lat: vp.latitude,
145
+ lng: vp.longitude
146
+ },
147
+ zoom: vp.zoom + zoomOffset
148
+ };
149
+ };
150
+ var formatDate = (date) => {
151
+ const year = date.getFullYear().toString();
152
+ const month = (date.getMonth() + 101).toString().substring(1);
153
+ const day = (date.getDate() + 100).toString().substring(1);
154
+ return `${year}-${month}-${day}`;
155
+ };
156
+
157
+ // src/index.tsx
158
+ __reExport(src_exports, require("@biodiv-platform/naksha-gmaps-draw"), module.exports);
159
+ __reExport(src_exports, require("@biodiv-platform/naksha-gmaps-view"), module.exports);
160
+ __reExport(src_exports, require("@biodiv-platform/naksha-maplibre-draw"), module.exports);
161
+ __reExport(src_exports, require("@biodiv-platform/naksha-maplibre-layers"), module.exports);
162
+ __reExport(src_exports, require("@biodiv-platform/naksha-maplibre-view"), module.exports);
163
+ // Annotate the CommonJS export names for ESM import in node:
164
+ 0 && (module.exports = {
165
+ GMAPS_AUTOCOMPLETE_FIELDS,
166
+ GMAPS_LIBRARIES,
167
+ LICENSES,
168
+ MapStyles,
169
+ TranslationProvider,
170
+ adminBoundries,
171
+ defaultMapStyles,
172
+ defaultViewState,
173
+ formatDate,
174
+ getByPath,
175
+ mapboxToGmapsViewState,
176
+ useDebounce,
177
+ useT
178
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "naksha-components-react",
3
- "version": "5.0.0",
3
+ "version": "5.0.2",
4
4
  "author": "harshzalavadiya",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -24,7 +24,7 @@
24
24
  "@biodiv-platform/naksha-gmaps-draw": "4.5.3",
25
25
  "@biodiv-platform/naksha-gmaps-view": "4.4.9",
26
26
  "@biodiv-platform/naksha-maplibre-draw": "5.0.10",
27
- "@biodiv-platform/naksha-maplibre-layers": "5.0.3",
27
+ "@biodiv-platform/naksha-maplibre-layers": "5.0.4",
28
28
  "@biodiv-platform/naksha-maplibre-view": "5.0.3",
29
29
  "@biodiv-platform/tsconfig": "4.4.9"
30
30
  },