naksha-components-react 4.6.1-beta.4 → 4.6.1-beta.6

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 CHANGED
@@ -1,148 +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: "Streets",
39
- key: "0",
40
- style: "mapbox://styles/biodiv/cku4aoj5k1g9h17o5r3tjsntn"
41
- },
42
- {
43
- text: "Satellite",
44
- key: "1",
45
- style: "mapbox://styles/biodiv/cku49ca8q1esz18o7gxfjmh5r"
46
- },
47
- {
48
- text: "Dark",
49
- key: "2",
50
- style: "mapbox://styles/biodiv/cku4a35961fgo17mykoq76se1"
51
- },
52
- {
53
- text: "OSM",
54
- key: "3",
55
- style: "https://unpkg.com/maplibre-gl-styles@0.0.1/styles/osm-mapnik/v8/india.json"
56
- }
57
- ];
58
- var adminBoundries = [
59
- "admin-0-boundary",
60
- "admin-1-boundary",
61
- "admin-0-boundary-disputed",
62
- "admin-1-boundary-bg",
63
- "admin-0-boundary-bg"
64
- ];
65
- var getByPath = (obj, path) => {
66
- path.split(".").forEach(function(level) {
67
- if (!obj) {
68
- return;
69
- }
70
- obj = obj[level];
71
- });
72
- return obj;
73
- };
74
- var CounterContext = createContext(
75
- {}
76
- );
77
- var TranslationProvider = ({
78
- localeStrings,
79
- lang = "en",
80
- children
81
- }) => {
82
- const t = (key) => {
83
- const translatedString = getByPath(localeStrings[lang], key);
84
- if (!translatedString) {
85
- console.warn(`Translation '${key}' for locale '${lang}' not found.`);
86
- }
87
- return translatedString;
88
- };
89
- return /* @__PURE__ */ jsx(CounterContext.Provider, {
90
- value: { t },
91
- children
92
- });
93
- };
94
- function useT() {
95
- return useContext(CounterContext);
96
- }
97
- function useDebounce(value, delay) {
98
- const [debouncedValue, setDebouncedValue] = useState(value);
99
- useEffect(
100
- () => {
101
- const handler = setTimeout(() => {
102
- setDebouncedValue(value);
103
- }, delay);
104
- return () => {
105
- clearTimeout(handler);
106
- };
107
- },
108
- [value, delay]
109
- );
110
- return debouncedValue;
111
- }
112
- var mapboxToGmapsViewState = (vp = defaultViewState, zoomOffset = 1) => {
113
- return {
114
- center: {
115
- lat: vp.latitude,
116
- lng: vp.longitude
117
- },
118
- zoom: vp.zoom + zoomOffset
119
- };
120
- };
121
- var formatDate = (date) => {
122
- const year = date.getFullYear().toString();
123
- const month = (date.getMonth() + 101).toString().substring(1);
124
- const day = (date.getDate() + 100).toString().substring(1);
125
- return `${year}-${month}-${day}`;
126
- };
127
-
128
- // src/index.tsx
129
- export * from "@biodiv-platform/naksha-gmaps-draw";
130
- export * from "@biodiv-platform/naksha-gmaps-view";
131
- export * from "@biodiv-platform/naksha-mapbox-draw";
132
- export * from "@biodiv-platform/naksha-mapbox-list";
133
- export * from "@biodiv-platform/naksha-mapbox-view";
134
- export {
135
- GMAPS_AUTOCOMPLETE_FIELDS,
136
- GMAPS_LIBRARIES,
137
- LICENSES,
138
- MapStyles,
139
- TranslationProvider,
140
- adminBoundries,
141
- defaultMapStyles,
142
- defaultViewState,
143
- formatDate,
144
- getByPath,
145
- mapboxToGmapsViewState,
146
- useDebounce,
147
- useT
148
- };
1
+ import{createContext as c,useContext as u}from"react";import{jsx as l}from"react/jsx-runtime";import{useEffect as g,useState as f}from"react";var y=["formatted_address","geometry","name"],b={DEFAULT:["drawing","places"],AUTOCOMPLETE:["drawing","places"]},v={"CC-BY":"//creativecommons.org/licenses/by/4.0","BY-SA":"//creativecommons.org/licenses/by-sa/4.0","BY-ND":"//creativecommons.org/licenses/by-nd/4.0","BY-NC":"//creativecommons.org/licenses/by-nc/4.0","BY-NC-SA":"//creativecommons.org/licenses/by-nc-sa/4.0","BY-NC-ND":"//creativecommons.org/licenses/by-nc-nd/4.0"},i=(e=>(e.MAP_STREETS="0",e.MAP_SATELLITE="1",e.MAP_DARK="2",e.MAP_OSM="3",e))(i||{}),m={latitude:22.5,longitude:79,zoom:3,bearing:0,pitch:0},p=[{text:"Streets",key:"0",style:"mapbox://styles/biodiv/cku4aoj5k1g9h17o5r3tjsntn"},{text:"Satellite",key:"1",style:"mapbox://styles/biodiv/cku49ca8q1esz18o7gxfjmh5r"},{text:"Dark",key:"2",style:"mapbox://styles/biodiv/cku4a35961fgo17mykoq76se1"},{text:"OSM",key:"3",style:"https://unpkg.com/maplibre-gl-styles@0.0.1/styles/osm-mapnik/v8/india.json"}],x=["admin-0-boundary","admin-1-boundary","admin-0-boundary-disputed","admin-1-boundary-bg","admin-0-boundary-bg"],d=(e,t)=>(t.split(".").forEach(function(r){!e||(e=e[r])}),e),s=c({}),T=({localeStrings:e,lang:t="en",children:r})=>{let o=n=>{let a=d(e[t],n);return a||console.warn(`Translation '${n}' for locale '${t}' not found.`),a};return l(s.Provider,{value:{t:o},children:r})};function A(){return u(s)}function k(e,t){let[r,o]=f(e);return g(()=>{let n=setTimeout(()=>{o(e)},t);return()=>{clearTimeout(n)}},[e,t]),r}var P=(e=m,t=1)=>({center:{lat:e.latitude,lng:e.longitude},zoom:e.zoom+t}),D=e=>{let t=e.getFullYear().toString(),r=(e.getMonth()+101).toString().substring(1),o=(e.getDate()+100).toString().substring(1);return`${t}-${r}-${o}`};export*from"@biodiv-platform/naksha-gmaps-draw";export*from"@biodiv-platform/naksha-gmaps-view";export*from"@biodiv-platform/naksha-mapbox-draw";export*from"@biodiv-platform/naksha-mapbox-list";export*from"@biodiv-platform/naksha-mapbox-view";export{y as GMAPS_AUTOCOMPLETE_FIELDS,b as GMAPS_LIBRARIES,v as LICENSES,i as MapStyles,T as TranslationProvider,x as adminBoundries,p as defaultMapStyles,m as defaultViewState,D as formatDate,d as getByPath,P as mapboxToGmapsViewState,k as useDebounce,A as useT};
package/dist/index.js CHANGED
@@ -1,188 +1 @@
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: "Streets",
78
- key: "0",
79
- style: "mapbox://styles/biodiv/cku4aoj5k1g9h17o5r3tjsntn"
80
- },
81
- {
82
- text: "Satellite",
83
- key: "1",
84
- style: "mapbox://styles/biodiv/cku49ca8q1esz18o7gxfjmh5r"
85
- },
86
- {
87
- text: "Dark",
88
- key: "2",
89
- style: "mapbox://styles/biodiv/cku4a35961fgo17mykoq76se1"
90
- },
91
- {
92
- text: "OSM",
93
- key: "3",
94
- style: "https://unpkg.com/maplibre-gl-styles@0.0.1/styles/osm-mapnik/v8/india.json"
95
- }
96
- ];
97
- var adminBoundries = [
98
- "admin-0-boundary",
99
- "admin-1-boundary",
100
- "admin-0-boundary-disputed",
101
- "admin-1-boundary-bg",
102
- "admin-0-boundary-bg"
103
- ];
104
- var getByPath = (obj, path) => {
105
- path.split(".").forEach(function(level) {
106
- if (!obj) {
107
- return;
108
- }
109
- obj = obj[level];
110
- });
111
- return obj;
112
- };
113
- var CounterContext = (0, import_react.createContext)(
114
- {}
115
- );
116
- var TranslationProvider = ({
117
- localeStrings,
118
- lang = "en",
119
- children
120
- }) => {
121
- const t = (key) => {
122
- const translatedString = getByPath(localeStrings[lang], key);
123
- if (!translatedString) {
124
- console.warn(`Translation '${key}' for locale '${lang}' not found.`);
125
- }
126
- return translatedString;
127
- };
128
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CounterContext.Provider, {
129
- value: { t },
130
- children
131
- });
132
- };
133
- function useT() {
134
- return (0, import_react.useContext)(CounterContext);
135
- }
136
- function useDebounce(value, delay) {
137
- const [debouncedValue, setDebouncedValue] = (0, import_react2.useState)(value);
138
- (0, import_react2.useEffect)(
139
- () => {
140
- const handler = setTimeout(() => {
141
- setDebouncedValue(value);
142
- }, delay);
143
- return () => {
144
- clearTimeout(handler);
145
- };
146
- },
147
- [value, delay]
148
- );
149
- return debouncedValue;
150
- }
151
- var mapboxToGmapsViewState = (vp = defaultViewState, zoomOffset = 1) => {
152
- return {
153
- center: {
154
- lat: vp.latitude,
155
- lng: vp.longitude
156
- },
157
- zoom: vp.zoom + zoomOffset
158
- };
159
- };
160
- var formatDate = (date) => {
161
- const year = date.getFullYear().toString();
162
- const month = (date.getMonth() + 101).toString().substring(1);
163
- const day = (date.getDate() + 100).toString().substring(1);
164
- return `${year}-${month}-${day}`;
165
- };
166
-
167
- // src/index.tsx
168
- __reExport(src_exports, require("@biodiv-platform/naksha-gmaps-draw"), module.exports);
169
- __reExport(src_exports, require("@biodiv-platform/naksha-gmaps-view"), module.exports);
170
- __reExport(src_exports, require("@biodiv-platform/naksha-mapbox-draw"), module.exports);
171
- __reExport(src_exports, require("@biodiv-platform/naksha-mapbox-list"), module.exports);
172
- __reExport(src_exports, require("@biodiv-platform/naksha-mapbox-view"), module.exports);
173
- // Annotate the CommonJS export names for ESM import in node:
174
- 0 && (module.exports = {
175
- GMAPS_AUTOCOMPLETE_FIELDS,
176
- GMAPS_LIBRARIES,
177
- LICENSES,
178
- MapStyles,
179
- TranslationProvider,
180
- adminBoundries,
181
- defaultMapStyles,
182
- defaultViewState,
183
- formatDate,
184
- getByPath,
185
- mapboxToGmapsViewState,
186
- useDebounce,
187
- useT
188
- });
1
+ "use strict";var u=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var S=(r,o)=>{for(var n in o)u(r,n,{get:o[n],enumerable:!0})},c=(r,o,n,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of p(o))!x.call(r,a)&&a!==n&&u(r,a,{get:()=>o[a],enumerable:!(s=v(o,a))||s.enumerable});return r},t=(r,o,n)=>(c(r,o,"default"),n&&c(n,o,"default"));var E=r=>c(u({},"__esModule",{value:!0}),r);var e={};S(e,{GMAPS_AUTOCOMPLETE_FIELDS:()=>T,GMAPS_LIBRARIES:()=>A,LICENSES:()=>C,MapStyles:()=>l,TranslationProvider:()=>D,adminBoundries:()=>P,defaultMapStyles:()=>k,defaultViewState:()=>g,formatDate:()=>L,getByPath:()=>f,mapboxToGmapsViewState:()=>M,useDebounce:()=>B,useT:()=>h});module.exports=E(e);var i=require("react"),y=require("react/jsx-runtime"),m=require("react"),T=["formatted_address","geometry","name"],A={DEFAULT:["drawing","places"],AUTOCOMPLETE:["drawing","places"]},C={"CC-BY":"//creativecommons.org/licenses/by/4.0","BY-SA":"//creativecommons.org/licenses/by-sa/4.0","BY-ND":"//creativecommons.org/licenses/by-nd/4.0","BY-NC":"//creativecommons.org/licenses/by-nc/4.0","BY-NC-SA":"//creativecommons.org/licenses/by-nc-sa/4.0","BY-NC-ND":"//creativecommons.org/licenses/by-nc-nd/4.0"},l=(r=>(r.MAP_STREETS="0",r.MAP_SATELLITE="1",r.MAP_DARK="2",r.MAP_OSM="3",r))(l||{}),g={latitude:22.5,longitude:79,zoom:3,bearing:0,pitch:0},k=[{text:"Streets",key:"0",style:"mapbox://styles/biodiv/cku4aoj5k1g9h17o5r3tjsntn"},{text:"Satellite",key:"1",style:"mapbox://styles/biodiv/cku49ca8q1esz18o7gxfjmh5r"},{text:"Dark",key:"2",style:"mapbox://styles/biodiv/cku4a35961fgo17mykoq76se1"},{text:"OSM",key:"3",style:"https://unpkg.com/maplibre-gl-styles@0.0.1/styles/osm-mapnik/v8/india.json"}],P=["admin-0-boundary","admin-1-boundary","admin-0-boundary-disputed","admin-1-boundary-bg","admin-0-boundary-bg"],f=(r,o)=>(o.split(".").forEach(function(n){!r||(r=r[n])}),r),b=(0,i.createContext)({}),D=({localeStrings:r,lang:o="en",children:n})=>{let s=a=>{let d=f(r[o],a);return d||console.warn(`Translation '${a}' for locale '${o}' not found.`),d};return(0,y.jsx)(b.Provider,{value:{t:s},children:n})};function h(){return(0,i.useContext)(b)}function B(r,o){let[n,s]=(0,m.useState)(r);return(0,m.useEffect)(()=>{let a=setTimeout(()=>{s(r)},o);return()=>{clearTimeout(a)}},[r,o]),n}var M=(r=g,o=1)=>({center:{lat:r.latitude,lng:r.longitude},zoom:r.zoom+o}),L=r=>{let o=r.getFullYear().toString(),n=(r.getMonth()+101).toString().substring(1),s=(r.getDate()+100).toString().substring(1);return`${o}-${n}-${s}`};t(e,require("@biodiv-platform/naksha-gmaps-draw"),module.exports);t(e,require("@biodiv-platform/naksha-gmaps-view"),module.exports);t(e,require("@biodiv-platform/naksha-mapbox-draw"),module.exports);t(e,require("@biodiv-platform/naksha-mapbox-list"),module.exports);t(e,require("@biodiv-platform/naksha-mapbox-view"),module.exports);0&&(module.exports={GMAPS_AUTOCOMPLETE_FIELDS,GMAPS_LIBRARIES,LICENSES,MapStyles,TranslationProvider,adminBoundries,defaultMapStyles,defaultViewState,formatDate,getByPath,mapboxToGmapsViewState,useDebounce,useT});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "naksha-components-react",
3
- "version": "4.6.1-beta.4",
3
+ "version": "4.6.1-beta.6",
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-mapbox-draw": "4.4.9",
27
- "@biodiv-platform/naksha-mapbox-list": "4.5.3-beta.4",
27
+ "@biodiv-platform/naksha-mapbox-list": "4.5.3-beta.6",
28
28
  "@biodiv-platform/naksha-mapbox-view": "4.4.9",
29
29
  "@biodiv-platform/tsconfig": "4.4.9"
30
30
  },