@tpzdsp/next-toolkit 1.2.5 → 1.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tpzdsp/next-toolkit",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "description": "A reusable React component library for Next.js applications",
5
5
  "type": "module",
6
6
  "private": false,
@@ -4,6 +4,13 @@ export type SearchOption = {
4
4
  url?: string;
5
5
  };
6
6
 
7
+ export type SearchResult = {
8
+ lon: number;
9
+ lat: number;
10
+ address?: string;
11
+ bbox?: number[];
12
+ };
13
+
7
14
  /**
8
15
  * Custom provider for OS OpenNames search.
9
16
  */
@@ -37,18 +44,28 @@ export const osOpenNamesSearch = (options?: SearchOption) => {
37
44
  return [];
38
45
  }
39
46
 
40
- return features.map((feature) => {
41
- if (feature.geometry.type === 'Point') {
42
- return {
43
- lon: feature.geometry.coordinates[0],
44
- lat: feature.geometry.coordinates[1],
45
- address: feature?.properties?.address,
46
- bbox: feature.bbox,
47
- };
48
- }
49
-
50
- console.error('Geometry type is not Point');
51
- });
47
+ return features
48
+ .map((feature) => {
49
+ if (feature.geometry.type === 'Point') {
50
+ const result: SearchResult = {
51
+ lon: feature.geometry.coordinates[0],
52
+ lat: feature.geometry.coordinates[1],
53
+ address: feature?.properties?.address,
54
+ };
55
+
56
+ // Only include bbox if it's not empty
57
+ if (feature.bbox && Array.isArray(feature.bbox) && feature.bbox.length > 0) {
58
+ result.bbox = feature.bbox;
59
+ }
60
+
61
+ return result;
62
+ }
63
+
64
+ console.error('Geometry type is not Point');
65
+
66
+ return null;
67
+ })
68
+ .filter(Boolean);
52
69
  },
53
70
  };
54
71
  };