@tpzdsp/next-toolkit 1.2.5 → 1.2.7
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 +1 -1
- package/src/components/index.ts +2 -0
- package/src/map/MapComponent.tsx +3 -0
- package/src/map/osOpenNamesSearch.ts +29 -12
- package/src/types/api.ts +1 -1
- package/src/utils/http.ts +1 -0
- package/src/utils/utils.ts +4 -0
package/package.json
CHANGED
package/src/components/index.ts
CHANGED
|
@@ -37,6 +37,8 @@ export { Modal } from './Modal/Modal';
|
|
|
37
37
|
|
|
38
38
|
// Export client component types
|
|
39
39
|
export type { AccordionProps } from './accordion/Accordion';
|
|
40
|
+
export type { ItemRendererProps } from './dropdown/useDropdownMenu';
|
|
41
|
+
export type { DropdownMenuItem } from './dropdown/DropdownMenu';
|
|
40
42
|
|
|
41
43
|
// Export layout components
|
|
42
44
|
export { Header } from './layout/header/Header';
|
package/src/map/MapComponent.tsx
CHANGED
|
@@ -19,6 +19,7 @@ export type MapComponentProps = {
|
|
|
19
19
|
geocoderUrl: string;
|
|
20
20
|
basePath: string;
|
|
21
21
|
isLoading?: boolean;
|
|
22
|
+
error?: Error;
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
const positionTransforms: Record<PopupDirection, string> = {
|
|
@@ -47,7 +48,9 @@ export const MapComponent = ({
|
|
|
47
48
|
geocoderUrl,
|
|
48
49
|
basePath,
|
|
49
50
|
isLoading,
|
|
51
|
+
error,
|
|
50
52
|
}: MapComponentProps) => {
|
|
53
|
+
console.log('ERROR: ', error);
|
|
51
54
|
const [popupFeatures, setPopupFeatures] = useState([]);
|
|
52
55
|
const [popupCoordinate, setPopupCoordinate] = useState<number[] | null>(null);
|
|
53
56
|
const [popupPositionClass, setPopupPositionClass] = useState<PopupDirection>('bottom-right');
|
|
@@ -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
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
};
|
package/src/types/api.ts
CHANGED
|
@@ -19,7 +19,7 @@ export type PaginatedResponse<T = unknown> = {
|
|
|
19
19
|
|
|
20
20
|
// Since we only ever fetch a single API we don't need multiple failure types,
|
|
21
21
|
// so defining a global one as the default is fine. This can be changed per-app.
|
|
22
|
-
export type ApiFailure = { message: string };
|
|
22
|
+
export type ApiFailure = { message: string; status?: number; code?: string; details?: unknown };
|
|
23
23
|
|
|
24
24
|
type GenericResponse<Ok, Error> =
|
|
25
25
|
| ({
|
package/src/utils/http.ts
CHANGED
package/src/utils/utils.ts
CHANGED
|
@@ -17,6 +17,10 @@ export const decodeAuthToken = (token: string): Credentials | null => {
|
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
export const isStringArray = (value: unknown): value is string[] => {
|
|
21
|
+
return Array.isArray(value) && value.every((item) => typeof item === 'string');
|
|
22
|
+
};
|
|
23
|
+
|
|
20
24
|
/**
|
|
21
25
|
* Utility function to merge Tailwind CSS classes with conflict resolution
|
|
22
26
|
* Uses tailwind-merge to handle conflicting utility classes
|