strapi-plugin-map-box 0.0.1

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.
Files changed (44) hide show
  1. package/README.md +4 -0
  2. package/dist/_chunks/en-B4KWt_jN.js +5 -0
  3. package/dist/_chunks/en-B4KWt_jN.js.map +1 -0
  4. package/dist/_chunks/en-Byx4XI2L.mjs +5 -0
  5. package/dist/_chunks/en-Byx4XI2L.mjs.map +1 -0
  6. package/dist/admin/index.js +419 -0
  7. package/dist/admin/index.js.map +1 -0
  8. package/dist/admin/index.mjs +417 -0
  9. package/dist/admin/index.mjs.map +1 -0
  10. package/dist/admin/src/components/Initializer.d.ts +5 -0
  11. package/dist/admin/src/components/PluginIcon.d.ts +2 -0
  12. package/dist/admin/src/components/custom-field/MapBoxField/DebugInfo.d.ts +14 -0
  13. package/dist/admin/src/components/custom-field/MapBoxField/MapSearch.d.ts +9 -0
  14. package/dist/admin/src/components/custom-field/MapBoxField/hooks.d.ts +29 -0
  15. package/dist/admin/src/components/custom-field/MapBoxField/index.d.ts +19 -0
  16. package/dist/admin/src/components/custom-field/MapBoxField/styles.d.ts +6 -0
  17. package/dist/admin/src/components/custom-field/MapBoxField/types.d.ts +22 -0
  18. package/dist/admin/src/index.d.ts +10 -0
  19. package/dist/admin/src/pages/App.d.ts +2 -0
  20. package/dist/admin/src/pages/HomePage.d.ts +2 -0
  21. package/dist/admin/src/pluginId.d.ts +1 -0
  22. package/dist/admin/src/utils/getTranslation.d.ts +2 -0
  23. package/dist/server/index.js +116 -0
  24. package/dist/server/index.js.map +1 -0
  25. package/dist/server/index.mjs +117 -0
  26. package/dist/server/index.mjs.map +1 -0
  27. package/dist/server/src/bootstrap.d.ts +5 -0
  28. package/dist/server/src/config/index.d.ts +5 -0
  29. package/dist/server/src/content-types/index.d.ts +2 -0
  30. package/dist/server/src/controllers/controller.d.ts +8 -0
  31. package/dist/server/src/controllers/index.d.ts +9 -0
  32. package/dist/server/src/destroy.d.ts +5 -0
  33. package/dist/server/src/index.d.ts +54 -0
  34. package/dist/server/src/middlewares/index.d.ts +2 -0
  35. package/dist/server/src/policies/index.d.ts +2 -0
  36. package/dist/server/src/register.d.ts +5 -0
  37. package/dist/server/src/routes/admin-api.d.ts +9 -0
  38. package/dist/server/src/routes/content-api.d.ts +2 -0
  39. package/dist/server/src/routes/index.d.ts +18 -0
  40. package/dist/server/src/services/index.d.ts +11 -0
  41. package/dist/server/src/services/service.d.ts +33 -0
  42. package/dist/server/src/utils/index.d.ts +4 -0
  43. package/dist/types.d.ts +6 -0
  44. package/package.json +89 -0
@@ -0,0 +1,417 @@
1
+ import { useRef, useEffect, useState } from "react";
2
+ import { PinMap } from "@strapi/icons";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { Field, JSONInput } from "@strapi/design-system";
5
+ import Map, { FullscreenControl, NavigationControl, GeolocateControl, Marker } from "react-map-gl/mapbox";
6
+ import "mapbox-gl/dist/mapbox-gl.css";
7
+ import { useFetchClient } from "@strapi/strapi/admin";
8
+ import styled from "styled-components";
9
+ const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
10
+ const v = glob[path];
11
+ if (v) {
12
+ return typeof v === "function" ? v() : Promise.resolve(v);
13
+ }
14
+ return new Promise((_, reject) => {
15
+ (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
16
+ reject.bind(
17
+ null,
18
+ new Error(
19
+ "Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
20
+ )
21
+ )
22
+ );
23
+ });
24
+ };
25
+ const PLUGIN_ID = "map-box";
26
+ const Initializer = ({ setPlugin }) => {
27
+ const ref = useRef(setPlugin);
28
+ useEffect(() => {
29
+ ref.current(PLUGIN_ID);
30
+ }, []);
31
+ return null;
32
+ };
33
+ const ControlsContainer = styled.div`
34
+ position: absolute;
35
+ top: 1rem;
36
+ left: 1rem;
37
+ z-index: 1;
38
+ width: 300px;
39
+ `;
40
+ const ControlsWrapper = styled.div`
41
+ display: flex;
42
+ gap: 0.5rem;
43
+ `;
44
+ const SearchInput = styled.input`
45
+ flex: 1;
46
+ padding: 0.5rem;
47
+ border: 1px solid #dcdce4;
48
+ border-radius: 4px;
49
+ font-size: 14px;
50
+ `;
51
+ const SearchButton = styled.button`
52
+ padding: 0.5rem 1rem;
53
+ background-color: #4945ff;
54
+ color: white;
55
+ border: none;
56
+ border-radius: 4px;
57
+ cursor: pointer;
58
+ font-size: 14px;
59
+
60
+ &:hover {
61
+ background-color: #3832e0;
62
+ }
63
+ `;
64
+ const MapSearch = ({
65
+ onSearch,
66
+ searchQuery,
67
+ setSearchQuery,
68
+ handleKeyDown
69
+ }) => {
70
+ return /* @__PURE__ */ jsx(ControlsContainer, { children: /* @__PURE__ */ jsxs(ControlsWrapper, { children: [
71
+ /* @__PURE__ */ jsx(
72
+ SearchInput,
73
+ {
74
+ type: "text",
75
+ value: searchQuery,
76
+ onChange: (e) => setSearchQuery(e.target.value),
77
+ onKeyDown: handleKeyDown,
78
+ placeholder: "Search for a location..."
79
+ }
80
+ ),
81
+ /* @__PURE__ */ jsx(
82
+ SearchButton,
83
+ {
84
+ type: "button",
85
+ onClick: onSearch,
86
+ children: "Search"
87
+ }
88
+ )
89
+ ] }) });
90
+ };
91
+ const DEFAULT_VIEW_STATE = {
92
+ longitude: -122.4194,
93
+ latitude: 37.7749,
94
+ zoom: 13,
95
+ pitch: 0,
96
+ bearing: 0,
97
+ padding: {
98
+ top: 0,
99
+ bottom: 0,
100
+ left: 0,
101
+ right: 0
102
+ }
103
+ };
104
+ const useMapBoxSettings = () => {
105
+ const { get } = useFetchClient();
106
+ const [config, setConfig] = useState(null);
107
+ const [isLoading, setIsLoading] = useState(true);
108
+ const [error, setError] = useState(null);
109
+ useEffect(() => {
110
+ const fetchSettings = async () => {
111
+ try {
112
+ setIsLoading(true);
113
+ const { data } = await get("/strapi-plugin-map-box/get-settings");
114
+ console.log("data from getSettings", data);
115
+ setConfig(data);
116
+ setError(null);
117
+ } catch (err) {
118
+ setError(err instanceof Error ? err.message : "Failed to fetch MapBox settings");
119
+ } finally {
120
+ setIsLoading(false);
121
+ }
122
+ };
123
+ fetchSettings();
124
+ }, []);
125
+ return { config, isLoading, error };
126
+ };
127
+ const useMapLocationHook = (initialValue) => {
128
+ const [viewState, setViewState] = useState(DEFAULT_VIEW_STATE);
129
+ const [markerPosition, setMarkerPosition] = useState({
130
+ longitude: DEFAULT_VIEW_STATE.longitude,
131
+ latitude: DEFAULT_VIEW_STATE.latitude
132
+ });
133
+ useEffect(() => {
134
+ if (initialValue) {
135
+ console.log("Initializing from previous value:", initialValue);
136
+ const previousValue = initialValue;
137
+ setViewState((prev) => ({
138
+ ...prev,
139
+ longitude: previousValue.longitude,
140
+ latitude: previousValue.latitude,
141
+ zoom: previousValue.zoom,
142
+ pitch: previousValue.pitch,
143
+ bearing: previousValue.bearing
144
+ }));
145
+ setMarkerPosition({
146
+ longitude: previousValue.longitude,
147
+ latitude: previousValue.latitude
148
+ });
149
+ }
150
+ }, []);
151
+ return { viewState, setViewState, markerPosition, setMarkerPosition };
152
+ };
153
+ function DebugInfo({
154
+ searchResults,
155
+ searchError,
156
+ viewState,
157
+ markerPosition,
158
+ searchQuery,
159
+ value
160
+ }) {
161
+ return /* @__PURE__ */ jsxs(DebugContainer, { children: [
162
+ /* @__PURE__ */ jsx("h4", { children: "Debug Information:" }),
163
+ /* @__PURE__ */ jsxs(DebugSection, { children: [
164
+ /* @__PURE__ */ jsx("strong", { children: "Search Results:" }),
165
+ /* @__PURE__ */ jsx(DebugPre, { children: searchResults ? JSON.stringify(searchResults, null, 2) : "No search results yet" })
166
+ ] }),
167
+ searchError && /* @__PURE__ */ jsxs(ErrorMessage, { children: [
168
+ /* @__PURE__ */ jsx("strong", { children: "Error:" }),
169
+ " ",
170
+ searchError
171
+ ] }),
172
+ /* @__PURE__ */ jsxs(DebugSection, { children: [
173
+ /* @__PURE__ */ jsx("strong", { children: "Current View State:" }),
174
+ /* @__PURE__ */ jsx(DebugPre, { children: JSON.stringify(viewState, null, 2) })
175
+ ] }),
176
+ /* @__PURE__ */ jsxs(DebugSection, { children: [
177
+ /* @__PURE__ */ jsx("strong", { children: "Marker Position:" }),
178
+ /* @__PURE__ */ jsx(DebugPre, { children: JSON.stringify(markerPosition, null, 2) })
179
+ ] }),
180
+ /* @__PURE__ */ jsxs(DebugSection, { children: [
181
+ /* @__PURE__ */ jsx("strong", { children: "Search Query:" }),
182
+ /* @__PURE__ */ jsx(DebugPre, { children: searchQuery || "No search query" })
183
+ ] }),
184
+ /* @__PURE__ */ jsxs(DebugSection, { children: [
185
+ /* @__PURE__ */ jsx("strong", { children: "Current Value:" }),
186
+ /* @__PURE__ */ jsx(DebugPre, { children: value ? JSON.stringify(value, null, 2) : "No value set" })
187
+ ] })
188
+ ] });
189
+ }
190
+ const DebugContainer = styled.div`
191
+ margin-top: 20px;
192
+ padding: 1rem;
193
+ background-color: #f5f5f5;
194
+ border-radius: 4px;
195
+ `;
196
+ const DebugSection = styled.div`
197
+ margin-bottom: 10px;
198
+ `;
199
+ const DebugPre = styled.pre`
200
+ background: #ffffff;
201
+ padding: 10px;
202
+ border-radius: 4px;
203
+ max-height: 200px;
204
+ overflow: auto;
205
+ margin: 5px 0;
206
+ border: 1px solid #dcdce4;
207
+ `;
208
+ const ErrorMessage = styled.div`
209
+ color: #d02b20;
210
+ margin-bottom: 10px;
211
+ padding: 10px;
212
+ background-color: #fff5f5;
213
+ border: 1px solid #ffd7d5;
214
+ border-radius: 4px;
215
+ `;
216
+ function MapBoxField({ name, onChange, value, intlLabel, required }) {
217
+ const { get } = useFetchClient();
218
+ const { config, isLoading, error } = useMapBoxSettings();
219
+ const { viewState, markerPosition, setViewState, setMarkerPosition } = useMapLocationHook(value);
220
+ const { accessToken, debugMode } = config || {};
221
+ const [searchQuery, setSearchQuery] = useState("");
222
+ const [searchResults, setSearchResults] = useState(null);
223
+ const [searchError, setSearchError] = useState(null);
224
+ const updateMarkerPosition = (lng, lat, address) => {
225
+ setMarkerPosition({ longitude: lng, latitude: lat });
226
+ const newValue = {
227
+ longitude: lng,
228
+ latitude: lat,
229
+ address: address || "Selected location",
230
+ zoom: viewState.zoom,
231
+ pitch: viewState.pitch,
232
+ bearing: viewState.bearing
233
+ };
234
+ onChange({ target: { name, value: newValue, type: "json" } });
235
+ };
236
+ const handleSearch = async () => {
237
+ if (!searchQuery.trim()) return;
238
+ try {
239
+ setSearchError(null);
240
+ const encodedQuery = encodeURIComponent(searchQuery.trim());
241
+ const url = `/strapi-plugin-map-box/location-search/${encodedQuery}`;
242
+ const { data } = await get(url);
243
+ setSearchResults(data);
244
+ if (data.features && data.features[0]) {
245
+ const [longitude, latitude] = data.features[0].center;
246
+ setViewState((prev) => ({
247
+ ...prev,
248
+ longitude,
249
+ latitude,
250
+ zoom: 14,
251
+ transitionDuration: 1e3
252
+ }));
253
+ updateMarkerPosition(longitude, latitude, data.features[0].place_name);
254
+ } else if (data.error) {
255
+ setSearchError(data.error);
256
+ } else {
257
+ setSearchError("No results found");
258
+ }
259
+ } catch (error2) {
260
+ console.error("Error searching location:", error2);
261
+ setSearchError(error2 instanceof Error ? error2.message : "An error occurred");
262
+ }
263
+ };
264
+ const handleKeyDown = (e) => {
265
+ if (e.key === "Enter") {
266
+ e.preventDefault();
267
+ handleSearch();
268
+ }
269
+ };
270
+ const handleMapClick = (event) => {
271
+ const { lngLat } = event;
272
+ updateMarkerPosition(lngLat.lng, lngLat.lat);
273
+ };
274
+ const handleMapMove = (evt) => {
275
+ setViewState(evt.viewState);
276
+ };
277
+ const handleMarkerDragEnd = (event) => {
278
+ const { lngLat } = event;
279
+ updateMarkerPosition(lngLat.lng, lngLat.lat);
280
+ };
281
+ const handlePositionChange = (input) => {
282
+ try {
283
+ const value2 = JSON.parse(input);
284
+ setViewState((prev) => ({
285
+ ...prev,
286
+ longitude: value2.longitude,
287
+ latitude: value2.latitude,
288
+ zoom: value2.zoom || prev.zoom,
289
+ pitch: value2.pitch || prev.pitch,
290
+ bearing: value2.bearing || prev.bearing
291
+ }));
292
+ setMarkerPosition({
293
+ longitude: value2.longitude,
294
+ latitude: value2.latitude
295
+ });
296
+ onChange({ target: { name, value: value2, type: "json" } });
297
+ } catch {
298
+ }
299
+ };
300
+ const finalValue = {
301
+ longitude: markerPosition.longitude,
302
+ latitude: markerPosition.latitude,
303
+ zoom: viewState.zoom,
304
+ pitch: viewState.pitch,
305
+ bearing: viewState.bearing,
306
+ address: value?.address || "Selected location"
307
+ };
308
+ const strValue = JSON.stringify(value || finalValue, null, 2);
309
+ if (!accessToken || isLoading) {
310
+ return /* @__PURE__ */ jsx("div", { children: "Loading..." });
311
+ }
312
+ if (error) {
313
+ return /* @__PURE__ */ jsxs("div", { children: [
314
+ "Error: ",
315
+ error
316
+ ] });
317
+ }
318
+ return /* @__PURE__ */ jsxs("div", { children: [
319
+ /* @__PURE__ */ jsxs("div", { style: { position: "relative", height: "500px", width: "100%" }, children: [
320
+ /* @__PURE__ */ jsx(
321
+ MapSearch,
322
+ {
323
+ onSearch: handleSearch,
324
+ searchQuery,
325
+ setSearchQuery,
326
+ handleKeyDown
327
+ }
328
+ ),
329
+ /* @__PURE__ */ jsxs(
330
+ Map,
331
+ {
332
+ ...viewState,
333
+ onMove: handleMapMove,
334
+ onClick: handleMapClick,
335
+ mapStyle: "mapbox://styles/mapbox/streets-v12",
336
+ mapboxAccessToken: accessToken,
337
+ attributionControl: false,
338
+ style: { height: "100%", width: "100%" },
339
+ children: [
340
+ /* @__PURE__ */ jsx(FullscreenControl, {}),
341
+ /* @__PURE__ */ jsx(NavigationControl, {}),
342
+ /* @__PURE__ */ jsx(GeolocateControl, {}),
343
+ /* @__PURE__ */ jsx(
344
+ Marker,
345
+ {
346
+ longitude: markerPosition.longitude,
347
+ latitude: markerPosition.latitude,
348
+ color: "#4945ff",
349
+ draggable: true,
350
+ onDragEnd: handleMarkerDragEnd
351
+ }
352
+ )
353
+ ]
354
+ }
355
+ )
356
+ ] }),
357
+ debugMode && /* @__PURE__ */ jsxs(Field.Root, { name, required, children: [
358
+ /* @__PURE__ */ jsx(Field.Label, { children: intlLabel?.defaultMessage ?? "Location" }),
359
+ /* @__PURE__ */ jsx(JSONInput, { value: strValue, onChange: handlePositionChange }),
360
+ /* @__PURE__ */ jsx(Field.Error, {}),
361
+ /* @__PURE__ */ jsx(Field.Hint, {})
362
+ ] }),
363
+ debugMode && /* @__PURE__ */ jsx(
364
+ DebugInfo,
365
+ {
366
+ viewState,
367
+ searchResults,
368
+ searchError,
369
+ markerPosition,
370
+ searchQuery,
371
+ value
372
+ }
373
+ )
374
+ ] });
375
+ }
376
+ const index = {
377
+ register(app) {
378
+ app.customFields.register({
379
+ name: "map-box",
380
+ type: "json",
381
+ icon: PinMap,
382
+ intlLabel: {
383
+ id: "custom.fields.map-box.label",
384
+ defaultMessage: "Map Box"
385
+ },
386
+ intlDescription: {
387
+ id: "custom.fields.map-box.description",
388
+ defaultMessage: "Enter geographic coordinates"
389
+ },
390
+ components: {
391
+ Input: () => ({ default: MapBoxField })
392
+ }
393
+ });
394
+ app.registerPlugin({
395
+ id: PLUGIN_ID,
396
+ initializer: Initializer,
397
+ isReady: false,
398
+ name: PLUGIN_ID
399
+ });
400
+ },
401
+ async registerTrads({ locales }) {
402
+ return Promise.all(
403
+ locales.map(async (locale) => {
404
+ try {
405
+ const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => import("../_chunks/en-Byx4XI2L.mjs") }), `./translations/${locale}.json`, 3);
406
+ return { data, locale };
407
+ } catch {
408
+ return { data: {}, locale };
409
+ }
410
+ })
411
+ );
412
+ }
413
+ };
414
+ export {
415
+ index as default
416
+ };
417
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../../admin/src/pluginId.ts","../../admin/src/components/Initializer.tsx","../../admin/src/components/custom-field/MapBoxField/MapSearch.tsx","../../admin/src/components/custom-field/MapBoxField/types.ts","../../admin/src/components/custom-field/MapBoxField/hooks.ts","../../admin/src/components/custom-field/MapBoxField/DebugInfo.tsx","../../admin/src/components/custom-field/MapBoxField/index.tsx","../../admin/src/index.ts"],"sourcesContent":["export const PLUGIN_ID = 'map-box';\n","import { useEffect, useRef } from 'react';\n\nimport { PLUGIN_ID } from '../pluginId';\n\ntype InitializerProps = {\n setPlugin: (id: string) => void;\n};\n\nconst Initializer = ({ setPlugin }: InitializerProps) => {\n const ref = useRef(setPlugin);\n\n useEffect(() => {\n ref.current(PLUGIN_ID);\n }, []);\n\n return null;\n};\n\nexport { Initializer };\n","import React from 'react';\nimport styled from 'styled-components';\n\nconst ControlsContainer = styled.div`\n position: absolute;\n top: 1rem;\n left: 1rem;\n z-index: 1;\n width: 300px;\n`;\n\nconst ControlsWrapper = styled.div`\n display: flex;\n gap: 0.5rem;\n`;\n\nconst SearchInput = styled.input`\n flex: 1;\n padding: 0.5rem;\n border: 1px solid #dcdce4;\n border-radius: 4px;\n font-size: 14px;\n`;\n\nconst SearchButton = styled.button`\n padding: 0.5rem 1rem;\n background-color: #4945ff;\n color: white;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n\n &:hover {\n background-color: #3832e0;\n }\n`;\n\ninterface MapSearchProps {\n onSearch: () => void;\n searchQuery: string;\n setSearchQuery: (query: string) => void;\n handleKeyDown: (e: React.KeyboardEvent) => void;\n}\n\nexport const MapSearch: React.FC<MapSearchProps> = ({\n onSearch,\n searchQuery,\n setSearchQuery,\n handleKeyDown\n}) => {\n return (\n <ControlsContainer>\n <ControlsWrapper>\n <SearchInput\n type=\"text\"\n value={searchQuery}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => setSearchQuery(e.target.value)}\n onKeyDown={handleKeyDown}\n placeholder=\"Search for a location...\"\n />\n <SearchButton\n type=\"button\"\n onClick={onSearch}\n >\n Search\n </SearchButton>\n </ControlsWrapper>\n </ControlsContainer>\n );\n};","export type MapBoxValue = {\n longitude: number;\n latitude: number;\n zoom: number;\n pitch: number;\n bearing: number;\n address: string;\n}\n\n\nexport interface ViewState {\n longitude: number;\n latitude: number;\n zoom: number;\n pitch: number;\n bearing: number;\n padding?: {\n top: number;\n bottom: number;\n left: number;\n right: number;\n };\n}\n\nexport const DEFAULT_VIEW_STATE: ViewState = {\n longitude: -122.4194,\n latitude: 37.7749,\n zoom: 13,\n pitch: 0,\n bearing: 0,\n padding: {\n top: 0,\n bottom: 0,\n left: 0,\n right: 0\n }\n};","import { type MapBoxValue, type ViewState, DEFAULT_VIEW_STATE } from './types';\n\nimport { useEffect, useState } from 'react';\nimport { useFetchClient } from '@strapi/strapi/admin';\n\ntype config = {\n accessToken: string;\n debugMode: boolean;\n};\n\nexport const useMapBoxSettings = () => {\n const { get } = useFetchClient();\n const [config, setConfig] = useState<config | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<string | null>(null);\n\n useEffect(() => {\n const fetchSettings = async () => {\n try {\n setIsLoading(true);\n const { data } = await get('/strapi-plugin-map-box/get-settings');\n console.log('data from getSettings', data);\n setConfig(data);\n setError(null);\n } catch (err) {\n setError(err instanceof Error ? err.message : 'Failed to fetch MapBox settings');\n } finally {\n setIsLoading(false);\n }\n };\n fetchSettings();\n }, []);\n\n return { config, isLoading, error };\n};\n\nexport const useMapLocationHook = (initialValue?: MapBoxValue) => {\n const [viewState, setViewState] = useState<ViewState>(DEFAULT_VIEW_STATE);\n const [markerPosition, setMarkerPosition] = useState({\n longitude: DEFAULT_VIEW_STATE.longitude,\n latitude: DEFAULT_VIEW_STATE.latitude,\n });\n\n useEffect(() => {\n if (initialValue) {\n console.log('Initializing from previous value:', initialValue);\n const previousValue = initialValue as MapBoxValue;\n\n setViewState((prev) => ({\n ...prev,\n longitude: previousValue.longitude,\n latitude: previousValue.latitude,\n zoom: previousValue.zoom,\n pitch: previousValue.pitch,\n bearing: previousValue.bearing,\n }));\n\n setMarkerPosition({\n longitude: previousValue.longitude,\n latitude: previousValue.latitude,\n });\n }\n }, []);\n\n return { viewState, setViewState, markerPosition, setMarkerPosition };\n};\n\nexport const useLocationService = () => {\n const { get } = useFetchClient();\n const [searchError, setSearchError] = useState<string | null>(null);\n const [searchResults, setSearchResults] = useState<any>(null);\n\n const searchLocation = async (query: string) => {\n try {\n setSearchError(null);\n const encodedQuery = encodeURIComponent(query.trim());\n const { data } = await get(`/strapi-plugin-map-box/location-search/${encodedQuery}`);\n setSearchResults(data);\n return data;\n } catch (error) {\n setSearchError(error instanceof Error ? error.message : 'An error occurred');\n return null;\n }\n };\n\n return { searchLocation, searchError, searchResults };\n};\n","import styled from 'styled-components';\nimport { ViewState } from './types';\n\n\ninterface DebugInfoProps {\n searchResults: any;\n searchError: string | null;\n viewState: ViewState;\n markerPosition: { longitude: number; latitude: number };\n searchQuery: string;\n value?: any;\n}\n\nexport function DebugInfo({ \n searchResults, \n searchError, \n viewState,\n markerPosition,\n searchQuery,\n value \n}: DebugInfoProps) {\n return (\n <DebugContainer>\n <h4>Debug Information:</h4>\n \n <DebugSection>\n <strong>Search Results:</strong>\n <DebugPre>\n {searchResults ? JSON.stringify(searchResults, null, 2) : 'No search results yet'}\n </DebugPre>\n </DebugSection>\n\n {searchError && (\n <ErrorMessage>\n <strong>Error:</strong> {searchError}\n </ErrorMessage>\n )}\n\n <DebugSection>\n <strong>Current View State:</strong>\n <DebugPre>\n {JSON.stringify(viewState, null, 2)}\n </DebugPre>\n </DebugSection>\n\n <DebugSection>\n <strong>Marker Position:</strong>\n <DebugPre>\n {JSON.stringify(markerPosition, null, 2)}\n </DebugPre>\n </DebugSection>\n\n <DebugSection>\n <strong>Search Query:</strong>\n <DebugPre>\n {searchQuery || 'No search query'}\n </DebugPre>\n </DebugSection>\n\n <DebugSection>\n <strong>Current Value:</strong>\n <DebugPre>\n {value ? JSON.stringify(value, null, 2) : 'No value set'}\n </DebugPre>\n </DebugSection>\n </DebugContainer>\n );\n}\n\nconst DebugContainer = styled.div`\n margin-top: 20px;\n padding: 1rem;\n background-color: #f5f5f5;\n border-radius: 4px;\n`;\n\nconst DebugSection = styled.div`\n margin-bottom: 10px;\n`;\n\nconst DebugPre = styled.pre`\n background: #ffffff;\n padding: 10px;\n border-radius: 4px;\n max-height: 200px;\n overflow: auto;\n margin: 5px 0;\n border: 1px solid #dcdce4;\n`;\n\nconst ErrorMessage = styled.div`\n color: #d02b20;\n margin-bottom: 10px;\n padding: 10px;\n background-color: #fff5f5;\n border: 1px solid #ffd7d5;\n border-radius: 4px;\n`;","import { MapBoxValue } from './types';\nimport { Field, JSONInput } from '@strapi/design-system';\n\nimport Map, {\n FullscreenControl,\n GeolocateControl,\n Marker,\n NavigationControl,\n} from 'react-map-gl/mapbox';\n\nimport 'mapbox-gl/dist/mapbox-gl.css';\nimport { useState } from 'react';\nimport { useFetchClient } from '@strapi/strapi/admin';\nimport { MapSearch } from './MapSearch';\n\nimport { useMapBoxSettings, useMapLocationHook } from './hooks';\nimport { DebugInfo } from './DebugInfo';\n\ninterface MapBoxFieldProps {\n name: string;\n onChange: (event: { target: { name: string; value: object; type: string } }) => void;\n value?: MapBoxValue;\n intlLabel?: {\n defaultMessage: string;\n };\n required?: boolean;\n}\n\n// #endregion\n\nexport function MapBoxField({ name, onChange, value, intlLabel, required }: MapBoxFieldProps) {\n const { get } = useFetchClient();\n const { config, isLoading, error } = useMapBoxSettings();\n const { viewState, markerPosition, setViewState, setMarkerPosition } = useMapLocationHook(value);\n\n const { accessToken, debugMode } = config || {};\n\n const [searchQuery, setSearchQuery] = useState('');\n const [searchResults, setSearchResults] = useState<any>(null);\n const [searchError, setSearchError] = useState<string | null>(null);\n\n const updateMarkerPosition = (lng: number, lat: number, address?: string) => {\n setMarkerPosition({ longitude: lng, latitude: lat });\n\n // Update the JSON value with all necessary data\n const newValue = {\n longitude: lng,\n latitude: lat,\n address: address || 'Selected location',\n zoom: viewState.zoom,\n pitch: viewState.pitch,\n bearing: viewState.bearing,\n };\n\n onChange({ target: { name, value: newValue, type: 'json' } });\n };\n\n const handleSearch = async () => {\n if (!searchQuery.trim()) return;\n\n try {\n setSearchError(null);\n const encodedQuery = encodeURIComponent(searchQuery.trim());\n const url = `/strapi-plugin-map-box/location-search/${encodedQuery}`;\n const { data } = await get(url);\n\n setSearchResults(data);\n\n if (data.features && data.features[0]) {\n const [longitude, latitude] = data.features[0].center;\n // Update both the view and marker position\n setViewState((prev) => ({\n ...prev,\n longitude,\n latitude,\n zoom: 14,\n transitionDuration: 1000,\n }));\n updateMarkerPosition(longitude, latitude, data.features[0].place_name);\n } else if (data.error) {\n setSearchError(data.error);\n } else {\n setSearchError('No results found');\n }\n } catch (error) {\n console.error('Error searching location:', error);\n setSearchError(error instanceof Error ? error.message : 'An error occurred');\n }\n };\n\n const handleKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === 'Enter') {\n e.preventDefault();\n handleSearch();\n }\n };\n\n const handleMapClick = (event: any) => {\n const { lngLat } = event;\n updateMarkerPosition(lngLat.lng, lngLat.lat);\n };\n\n const handleMapMove = (evt: any) => {\n setViewState(evt.viewState);\n };\n\n const handleMarkerDragEnd = (event: any) => {\n const { lngLat } = event;\n updateMarkerPosition(lngLat.lng, lngLat.lat);\n };\n\n const handlePositionChange = (input: string) => {\n try {\n const value = JSON.parse(input);\n setViewState((prev) => ({\n ...prev,\n longitude: value.longitude,\n latitude: value.latitude,\n zoom: value.zoom || prev.zoom,\n pitch: value.pitch || prev.pitch,\n bearing: value.bearing || prev.bearing,\n }));\n setMarkerPosition({\n longitude: value.longitude,\n latitude: value.latitude,\n });\n onChange({ target: { name, value, type: 'json' } });\n } catch {\n // Handle invalid JSON\n }\n };\n\n // Construct the final JSON value to be saved\n const finalValue: MapBoxValue = {\n longitude: markerPosition.longitude,\n latitude: markerPosition.latitude,\n zoom: viewState.zoom,\n pitch: viewState.pitch,\n bearing: viewState.bearing,\n address: (value as MapBoxValue)?.address || 'Selected location',\n };\n\n const strValue = JSON.stringify(value || finalValue, null, 2);\n\n if (!accessToken || isLoading) {\n return <div>Loading...</div>;\n }\n\n if (error) {\n return <div>Error: {error}</div>;\n }\n\n return (\n <div>\n <div style={{ position: 'relative', height: '500px', width: '100%' }}>\n <MapSearch\n onSearch={handleSearch}\n searchQuery={searchQuery}\n setSearchQuery={setSearchQuery}\n handleKeyDown={handleKeyDown}\n />\n <Map\n {...viewState}\n onMove={handleMapMove}\n onClick={handleMapClick}\n mapStyle=\"mapbox://styles/mapbox/streets-v12\"\n // mapStyle=\"mapbox://styles/mapbox/light-v11\"\n mapboxAccessToken={accessToken}\n attributionControl={false}\n style={{ height: '100%', width: '100%' }}\n >\n <FullscreenControl />\n <NavigationControl />\n <GeolocateControl />\n <Marker\n longitude={markerPosition.longitude}\n latitude={markerPosition.latitude}\n color=\"#4945ff\"\n draggable\n onDragEnd={handleMarkerDragEnd}\n />\n </Map>\n </div>\n {debugMode && (\n <Field.Root name={name} required={required}>\n <Field.Label>{intlLabel?.defaultMessage ?? 'Location'}</Field.Label>\n <JSONInput value={strValue} onChange={handlePositionChange}></JSONInput>\n <Field.Error />\n <Field.Hint />\n </Field.Root>\n )}\n\n {debugMode && (\n <DebugInfo\n viewState={viewState}\n searchResults={searchResults}\n searchError={searchError}\n markerPosition={markerPosition}\n searchQuery={searchQuery}\n value={value}\n />\n )}\n </div>\n );\n}\n","import { getTranslation } from './utils/getTranslation';\nimport { PLUGIN_ID } from './pluginId';\nimport { Initializer } from './components/Initializer';\nimport { PinMap } from '@strapi/icons';\nimport { MapBoxField } from './components/custom-field/MapBoxField/index';\n\nexport default {\n register(app: any) {\n \n app.customFields.register({\n name: 'map-box',\n type: 'json',\n icon: PinMap,\n intlLabel: {\n id: 'custom.fields.map-box.label',\n defaultMessage: 'Map Box',\n },\n intlDescription: {\n id: 'custom.fields.map-box.description',\n defaultMessage: 'Enter geographic coordinates',\n },\n components: {\n Input: () => ({ default: MapBoxField as React.ComponentType }) as any,\n },\n });\n\n app.registerPlugin({\n id: PLUGIN_ID,\n initializer: Initializer,\n isReady: false,\n name: PLUGIN_ID,\n });\n },\n\n async registerTrads({ locales }: { locales: string[] }) {\n return Promise.all(\n locales.map(async (locale) => {\n try {\n const { default: data } = await import(`./translations/${locale}.json`);\n\n return { data, locale };\n } catch {\n return { data: {}, locale };\n }\n })\n );\n },\n};\n"],"names":["error","value"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAO,MAAM,YAAY;ACQzB,MAAM,cAAc,CAAC,EAAE,gBAAkC;AACjD,QAAA,MAAM,OAAO,SAAS;AAE5B,YAAU,MAAM;AACd,QAAI,QAAQ,SAAS;AAAA,EACvB,GAAG,EAAE;AAEE,SAAA;AACT;ACbA,MAAM,oBAAoB,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQjC,MAAM,kBAAkB,OAAO;AAAA;AAAA;AAAA;AAK/B,MAAM,cAAc,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQ3B,MAAM,eAAe,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBrB,MAAM,YAAsC,CAAC;AAAA,EAClD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AAEF,SAAA,oBAAC,mBACC,EAAA,UAAA,qBAAC,iBACC,EAAA,UAAA;AAAA,IAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,OAAO;AAAA,QACP,UAAU,CAAC,MAA2C,eAAe,EAAE,OAAO,KAAK;AAAA,QACnF,WAAW;AAAA,QACX,aAAY;AAAA,MAAA;AAAA,IACd;AAAA,IACA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,SAAS;AAAA,QACV,UAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAED,EAAA,CACF,EACF,CAAA;AAEJ;AC9CO,MAAM,qBAAgC;AAAA,EAC3C,WAAW;AAAA,EACX,UAAU;AAAA,EACV,MAAM;AAAA,EACN,OAAO;AAAA,E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AS,MAAM,qCAAA,uBAAA,OAAA,EAAA,0BAAA,MAAA,OAAA,4BAAA,EAAA,CAAA,GAAA,kBAAA,MAAA,SAAA,CAAA;AAEzB,iBAAA,EAAE,MAAM,OAAO;AAAA,QAAA,QAChB;AACN,iBAAO,EAAE,MAAM,CAAC,GAAG,OAAO;AAAA,QAAA;AAAA,MAE7B,CAAA;AAAA,IACH;AAAA,EAAA;AAEJ;"}
@@ -0,0 +1,5 @@
1
+ type InitializerProps = {
2
+ setPlugin: (id: string) => void;
3
+ };
4
+ declare const Initializer: ({ setPlugin }: InitializerProps) => null;
5
+ export { Initializer };
@@ -0,0 +1,2 @@
1
+ declare const PluginIcon: () => import("react/jsx-runtime").JSX.Element;
2
+ export { PluginIcon };
@@ -0,0 +1,14 @@
1
+ import { ViewState } from './types';
2
+ interface DebugInfoProps {
3
+ searchResults: any;
4
+ searchError: string | null;
5
+ viewState: ViewState;
6
+ markerPosition: {
7
+ longitude: number;
8
+ latitude: number;
9
+ };
10
+ searchQuery: string;
11
+ value?: any;
12
+ }
13
+ export declare function DebugInfo({ searchResults, searchError, viewState, markerPosition, searchQuery, value }: DebugInfoProps): import("react/jsx-runtime").JSX.Element;
14
+ export {};
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ interface MapSearchProps {
3
+ onSearch: () => void;
4
+ searchQuery: string;
5
+ setSearchQuery: (query: string) => void;
6
+ handleKeyDown: (e: React.KeyboardEvent) => void;
7
+ }
8
+ export declare const MapSearch: React.FC<MapSearchProps>;
9
+ export {};
@@ -0,0 +1,29 @@
1
+ /// <reference types="react" />
2
+ import { type MapBoxValue, type ViewState } from './types';
3
+ type config = {
4
+ accessToken: string;
5
+ debugMode: boolean;
6
+ };
7
+ export declare const useMapBoxSettings: () => {
8
+ config: config | null;
9
+ isLoading: boolean;
10
+ error: string | null;
11
+ };
12
+ export declare const useMapLocationHook: (initialValue?: MapBoxValue) => {
13
+ viewState: ViewState;
14
+ setViewState: import("react").Dispatch<import("react").SetStateAction<ViewState>>;
15
+ markerPosition: {
16
+ longitude: number;
17
+ latitude: number;
18
+ };
19
+ setMarkerPosition: import("react").Dispatch<import("react").SetStateAction<{
20
+ longitude: number;
21
+ latitude: number;
22
+ }>>;
23
+ };
24
+ export declare const useLocationService: () => {
25
+ searchLocation: (query: string) => Promise<any>;
26
+ searchError: string | null;
27
+ searchResults: any;
28
+ };
29
+ export {};
@@ -0,0 +1,19 @@
1
+ import { MapBoxValue } from './types';
2
+ import 'mapbox-gl/dist/mapbox-gl.css';
3
+ interface MapBoxFieldProps {
4
+ name: string;
5
+ onChange: (event: {
6
+ target: {
7
+ name: string;
8
+ value: object;
9
+ type: string;
10
+ };
11
+ }) => void;
12
+ value?: MapBoxValue;
13
+ intlLabel?: {
14
+ defaultMessage: string;
15
+ };
16
+ required?: boolean;
17
+ }
18
+ export declare function MapBoxField({ name, onChange, value, intlLabel, required }: MapBoxFieldProps): import("react/jsx-runtime").JSX.Element;
19
+ export {};
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export declare const MapContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
3
+ export declare const ControlsContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
4
+ export declare const ControlsWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
5
+ export declare const SearchInput: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, never>> & string;
6
+ export declare const SearchButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never>> & string;
@@ -0,0 +1,22 @@
1
+ export type MapBoxValue = {
2
+ longitude: number;
3
+ latitude: number;
4
+ zoom: number;
5
+ pitch: number;
6
+ bearing: number;
7
+ address: string;
8
+ };
9
+ export interface ViewState {
10
+ longitude: number;
11
+ latitude: number;
12
+ zoom: number;
13
+ pitch: number;
14
+ bearing: number;
15
+ padding?: {
16
+ top: number;
17
+ bottom: number;
18
+ left: number;
19
+ right: number;
20
+ };
21
+ }
22
+ export declare const DEFAULT_VIEW_STATE: ViewState;
@@ -0,0 +1,10 @@
1
+ declare const _default: {
2
+ register(app: any): void;
3
+ registerTrads({ locales }: {
4
+ locales: string[];
5
+ }): Promise<{
6
+ data: any;
7
+ locale: string;
8
+ }[]>;
9
+ };
10
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const App: () => import("react/jsx-runtime").JSX.Element;
2
+ export { App };
@@ -0,0 +1,2 @@
1
+ declare const HomePage: () => import("react/jsx-runtime").JSX.Element;
2
+ export { HomePage };
@@ -0,0 +1 @@
1
+ export declare const PLUGIN_ID = "map-box";
@@ -0,0 +1,2 @@
1
+ declare const getTranslation: (id: string) => string;
2
+ export { getTranslation };