@tpzdsp/next-toolkit 1.2.3 → 1.2.4

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/README.md CHANGED
@@ -42,6 +42,9 @@ import { Button, Card, useLocalStorage } from '@your-org/nextjs-library';
42
42
  import '@your-org/nextjs-library/styles';
43
43
  // OR if the above doesn't work:
44
44
  // import '@your-org/nextjs-library/src/assets/styles/globals.css';
45
+
46
+ // If you're using map components, also import OpenLayers styles:
47
+ import '@your-org/nextjs-library/styles/ol';
45
48
  ```
46
49
 
47
50
  ### Selective Imports (Recommended)
@@ -53,6 +56,9 @@ import { Button, NextLinkWrapper } from '@your-org/nextjs-library/client';
53
56
  // Import only server components
54
57
  import { Card, Container } from '@your-org/nextjs-library/server';
55
58
 
59
+ // Import components with heavy dependencies separately
60
+ import { Select } from '@your-org/nextjs-library/components/select';
61
+
56
62
  // Import only types
57
63
  import type { ButtonProps, ApiResponse, FormFieldProps } from '@your-org/nextjs-library/types';
58
64
  ```
@@ -62,7 +68,9 @@ import type { ButtonProps, ApiResponse, FormFieldProps } from '@your-org/nextjs-
62
68
  ```tsx
63
69
  import { Button } from '@your-org/nextjs-library/client';
64
70
  import { Card } from '@your-org/nextjs-library/server';
65
- import '@your-org/nextjs-library/styles'; // or the src path if this doesn't work
71
+ import '@your-org/nextjs-library/styles'; // Base styles
72
+ // Import map styles only if you're using map components:
73
+ // import '@your-org/nextjs-library/styles/ol';
66
74
 
67
75
  export default function MyPage() {
68
76
  return (
@@ -120,6 +128,45 @@ interface MyComponentProps extends BaseProps {
120
128
  - **useLocalStorage**: localStorage hook with SSR support
121
129
  - **useDebounce**: Debounce values and functions
122
130
 
131
+ ### Map Components
132
+
133
+ - **Map**: OpenLayers-based interactive map component
134
+ - **MapContext**: React context for map state management
135
+ - **Popup**: Map popup component for displaying information
136
+ - **LayerSwitcherControl**: Control for switching between map layers
137
+
138
+ **Note**: Map components require additional dependencies and styles:
139
+
140
+ ```bash
141
+ # Install OpenLayers dependencies
142
+ npm install ol ol-geocoder ol-mapbox-style proj4
143
+ ```
144
+
145
+ ```typescript
146
+ // Import map styles when using map components
147
+ import '@your-org/nextjs-library/styles/ol';
148
+ ```
149
+
150
+ ### Components with Optional Dependencies
151
+
152
+ Some components require additional peer dependencies that are marked as optional:
153
+
154
+ - **Select components**: Require `react-select`
155
+ - **Map components**: Require OpenLayers packages (`ol`, `ol-geocoder`, etc.)
156
+
157
+ ```bash
158
+ # For Select components
159
+ npm install react-select
160
+
161
+ # For Map components
162
+ npm install ol ol-geocoder ol-mapbox-style proj4 @turf/turf geojson
163
+ ```
164
+
165
+ ```typescript
166
+ // Import Select components separately to avoid forcing dependency
167
+ import { Select } from '@your-org/nextjs-library/components/select';
168
+ ```
169
+
123
170
  ### Utilities
124
171
 
125
172
  - **cn()**: Tailwind class merging utility using tailwind-merge
@@ -418,6 +465,22 @@ yalc publish
418
465
  yalc add @your-org/nextjs-library
419
466
  ```
420
467
 
468
+ **Optional dependency errors:**
469
+
470
+ ```bash
471
+ # Error: Cannot resolve module 'react-select'
472
+ # Solution: Install the required dependency
473
+ npm install react-select
474
+
475
+ # Error: Cannot resolve module 'ol/ol.css'
476
+ # Solution: Install OpenLayers dependencies
477
+ npm install ol ol-geocoder ol-mapbox-style proj4
478
+
479
+ # Or import components selectively to avoid these dependencies:
480
+ import { Button, Card } from '@your-org/nextjs-library'; // ✅ No extra deps needed
481
+ import { Select } from '@your-org/nextjs-library/components/select'; // ❌ Requires react-select
482
+ ```
483
+
421
484
  ## Testing
422
485
 
423
486
  This library uses Vitest and React Testing Library for testing:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tpzdsp/next-toolkit",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "A reusable React component library for Next.js applications",
5
5
  "type": "module",
6
6
  "private": false,
@@ -48,6 +48,11 @@
48
48
  "import": "./src/components/index.ts",
49
49
  "require": "./src/components/index.ts"
50
50
  },
51
+ "./components/select": {
52
+ "types": "./src/components/select/index.ts",
53
+ "import": "./src/components/select/index.ts",
54
+ "require": "./src/components/select/index.ts"
55
+ },
51
56
  "./map": {
52
57
  "types": "./src/map/index.ts",
53
58
  "import": "./src/map/index.ts",
@@ -79,6 +84,7 @@
79
84
  "require": "./src/types/auth.ts"
80
85
  },
81
86
  "./styles": "./src/assets/styles/globals.css",
87
+ "./styles/ol": "./src/assets/styles/ol.css",
82
88
  "./fonts/*": "./src/assets/fonts/*",
83
89
  "./images/*": "./src/assets/images/*"
84
90
  },
@@ -186,7 +192,41 @@
186
192
  "proj4": "^2.19.10",
187
193
  "react": "^19.1.0",
188
194
  "react-dom": "^19.1.0",
189
- "react-icons": "^5.5.0",
195
+ "react-icons": "^5.5.0"
196
+ },
197
+ "peerDependenciesMeta": {
198
+ "@turf/turf": {
199
+ "optional": true
200
+ },
201
+ "@types/geojson": {
202
+ "optional": true
203
+ },
204
+ "@types/jsonwebtoken": {
205
+ "optional": true
206
+ },
207
+ "geojson": {
208
+ "optional": true
209
+ },
210
+ "jsonwebtoken": {
211
+ "optional": true
212
+ },
213
+ "ol": {
214
+ "optional": true
215
+ },
216
+ "ol-geocoder": {
217
+ "optional": true
218
+ },
219
+ "ol-mapbox-style": {
220
+ "optional": true
221
+ },
222
+ "proj4": {
223
+ "optional": true
224
+ },
225
+ "react-select": {
226
+ "optional": true
227
+ }
228
+ },
229
+ "optionalDependencies": {
190
230
  "react-select": "^5.10.2"
191
231
  },
192
232
  "release": {
@@ -1,5 +1,3 @@
1
- @import './ol.css';
2
-
3
1
  /* Global CSS for the component library */
4
2
  @tailwind base;
5
3
  @tailwind components;
@@ -31,8 +31,9 @@ export { useDropdownMenu } from './dropdown/useDropdownMenu';
31
31
  export { SlidingPanel } from './SlidingPanel/SlidingPanel';
32
32
  export { Accordion } from './accordion/Accordion';
33
33
  export { Modal } from './Modal/Modal';
34
- export { Select } from './select/Select';
35
- export { SelectSkeleton } from './select/SelectSkeleton';
34
+ // NOTE: Select components moved to separate entry point '@tpzdsp/next-toolkit/components/select'
35
+ // export { Select } from './select/Select';
36
+ // export { SelectSkeleton } from './select/SelectSkeleton';
36
37
 
37
38
  // Export client component types
38
39
  export type { AccordionProps } from './accordion/Accordion';
@@ -17,7 +17,7 @@ import { twMerge } from 'tailwind-merge';
17
17
  import { SELECT_CONTAINER_CLASSES, SELECT_CONTROL_CLASSES, SELECT_MIN_HEIGHT } from './common';
18
18
 
19
19
  // extends the react-select props with some of our own
20
- type SelectProps<Option, IsMulti extends boolean, Group extends GroupBase<Option>> = Omit<
20
+ export type SelectProps<Option, IsMulti extends boolean, Group extends GroupBase<Option>> = Omit<
21
21
  ReactSelectProps<Option, IsMulti, Group>,
22
22
  'className'
23
23
  >;
@@ -2,9 +2,13 @@ import { twMerge } from 'tailwind-merge';
2
2
 
3
3
  import { SELECT_CONTAINER_CLASSES, SELECT_CONTROL_CLASSES, SELECT_MIN_HEIGHT } from './common';
4
4
 
5
- export const SelectSkeleton = () => {
5
+ export type SelectSkeletonProps = {
6
+ className?: string;
7
+ };
8
+
9
+ export const SelectSkeleton = ({ className }: SelectSkeletonProps = {}) => {
6
10
  return (
7
- <div className={SELECT_CONTAINER_CLASSES}>
11
+ <div className={twMerge(SELECT_CONTAINER_CLASSES, className)}>
8
12
  <div className={twMerge(SELECT_CONTROL_CLASSES, SELECT_MIN_HEIGHT)}>
9
13
  <div
10
14
  className="w-full h-full bg-gray-100 animate-pulse rounded-md col-span-2"
@@ -0,0 +1,18 @@
1
+ // Select components with react-select dependency
2
+ export { Select } from './Select';
3
+ export { SelectSkeleton } from './SelectSkeleton';
4
+
5
+ // Export types
6
+ export type { SelectProps } from './Select';
7
+ export type { SelectSkeletonProps } from './SelectSkeleton';
8
+
9
+ // Re-export useful types from react-select for convenience
10
+ export type {
11
+ Props as ReactSelectProps,
12
+ GroupBase,
13
+ OptionsOrGroups,
14
+ SingleValue,
15
+ MultiValue,
16
+ ActionMeta,
17
+ OnChangeValue,
18
+ } from 'react-select';
package/src/index.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  // Export all components.
2
- export * from './components';
2
+ // export * from './components';
3
3
 
4
4
  // Export all utilities (these can be used in both client and server)
5
- export * from './utils';
5
+ // export * from './utils';
6
6
 
7
7
  // Export all map related code (these can be used in both client and server)
8
- export * from './map';
8
+ // export * from './map';
9
9
 
10
10
  // Export all types
11
- export * from './types';
11
+ // export * from './types';