@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tpzdsp/next-toolkit",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "A reusable React component library for Next.js applications",
5
5
  "type": "module",
6
6
  "private": false,
@@ -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';
@@ -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.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
  };
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
@@ -2,6 +2,7 @@ import type { Response, ApiFailure } from '../types/api';
2
2
 
3
3
  export const MimeTypes = {
4
4
  Json: 'application/json',
5
+ JsonLd: 'application/ld+json',
5
6
  GeoJson: 'application/geo+json',
6
7
  Png: 'image/png',
7
8
  XJsonLines: 'application/x-jsonlines',
@@ -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