@tpzdsp/next-toolkit 1.2.3 → 1.2.5
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 +64 -1
- package/package.json +42 -7
- package/src/assets/styles/globals.css +0 -2
- package/src/components/index.ts +3 -2
- package/src/components/select/Select.tsx +1 -1
- package/src/components/select/SelectSkeleton.tsx +6 -2
- package/src/components/select/index.ts +18 -0
- package/src/index.ts +0 -11
- package/src/map/{Map.tsx → MapComponent.tsx} +1 -1
- package/src/map/MapContext.tsx +1 -1
- package/src/map/index.ts +2 -2
- /package/src/map/{map.ts → utils.ts} +0 -0
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'; //
|
|
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
|
+
"version": "1.2.5",
|
|
4
4
|
"description": "A reusable React component library for Next.js applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -28,11 +28,6 @@
|
|
|
28
28
|
"import": "./src/index.ts",
|
|
29
29
|
"require": "./src/index.ts"
|
|
30
30
|
},
|
|
31
|
-
"./test": {
|
|
32
|
-
"types": "./src/test/index.ts",
|
|
33
|
-
"import": "./src/test/index.ts",
|
|
34
|
-
"require": "./src/test/index.ts"
|
|
35
|
-
},
|
|
36
31
|
"./utils": {
|
|
37
32
|
"types": "./src/utils/index.ts",
|
|
38
33
|
"import": "./src/utils/index.ts",
|
|
@@ -48,6 +43,11 @@
|
|
|
48
43
|
"import": "./src/components/index.ts",
|
|
49
44
|
"require": "./src/components/index.ts"
|
|
50
45
|
},
|
|
46
|
+
"./components/select": {
|
|
47
|
+
"types": "./src/components/select/index.ts",
|
|
48
|
+
"import": "./src/components/select/index.ts",
|
|
49
|
+
"require": "./src/components/select/index.ts"
|
|
50
|
+
},
|
|
51
51
|
"./map": {
|
|
52
52
|
"types": "./src/map/index.ts",
|
|
53
53
|
"import": "./src/map/index.ts",
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
"require": "./src/types/auth.ts"
|
|
80
80
|
},
|
|
81
81
|
"./styles": "./src/assets/styles/globals.css",
|
|
82
|
+
"./styles/ol": "./src/assets/styles/ol.css",
|
|
82
83
|
"./fonts/*": "./src/assets/fonts/*",
|
|
83
84
|
"./images/*": "./src/assets/images/*"
|
|
84
85
|
},
|
|
@@ -186,7 +187,41 @@
|
|
|
186
187
|
"proj4": "^2.19.10",
|
|
187
188
|
"react": "^19.1.0",
|
|
188
189
|
"react-dom": "^19.1.0",
|
|
189
|
-
"react-icons": "^5.5.0"
|
|
190
|
+
"react-icons": "^5.5.0"
|
|
191
|
+
},
|
|
192
|
+
"peerDependenciesMeta": {
|
|
193
|
+
"@turf/turf": {
|
|
194
|
+
"optional": true
|
|
195
|
+
},
|
|
196
|
+
"@types/geojson": {
|
|
197
|
+
"optional": true
|
|
198
|
+
},
|
|
199
|
+
"@types/jsonwebtoken": {
|
|
200
|
+
"optional": true
|
|
201
|
+
},
|
|
202
|
+
"geojson": {
|
|
203
|
+
"optional": true
|
|
204
|
+
},
|
|
205
|
+
"jsonwebtoken": {
|
|
206
|
+
"optional": true
|
|
207
|
+
},
|
|
208
|
+
"ol": {
|
|
209
|
+
"optional": true
|
|
210
|
+
},
|
|
211
|
+
"ol-geocoder": {
|
|
212
|
+
"optional": true
|
|
213
|
+
},
|
|
214
|
+
"ol-mapbox-style": {
|
|
215
|
+
"optional": true
|
|
216
|
+
},
|
|
217
|
+
"proj4": {
|
|
218
|
+
"optional": true
|
|
219
|
+
},
|
|
220
|
+
"react-select": {
|
|
221
|
+
"optional": true
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
"optionalDependencies": {
|
|
190
225
|
"react-select": "^5.10.2"
|
|
191
226
|
},
|
|
192
227
|
"release": {
|
package/src/components/index.ts
CHANGED
|
@@ -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
|
-
|
|
35
|
-
export {
|
|
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
|
|
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 +0,0 @@
|
|
|
1
|
-
// Export all components.
|
|
2
|
-
export * from './components';
|
|
3
|
-
|
|
4
|
-
// Export all utilities (these can be used in both client and server)
|
|
5
|
-
export * from './utils';
|
|
6
|
-
|
|
7
|
-
// Export all map related code (these can be used in both client and server)
|
|
8
|
-
export * from './map';
|
|
9
|
-
|
|
10
|
-
// Export all types
|
|
11
|
-
export * from './types';
|
|
@@ -9,9 +9,9 @@ import { fromLonLat } from 'ol/proj';
|
|
|
9
9
|
import { initializeBasemapLayers } from './basemaps';
|
|
10
10
|
import { initializeGeocoder } from './geocoder';
|
|
11
11
|
import { LayerSwitcherControl } from './LayerSwitcherControl';
|
|
12
|
-
import { getPopupPositionClass } from './map';
|
|
13
12
|
import { useMap } from './MapContext';
|
|
14
13
|
import { Popup } from './Popup';
|
|
14
|
+
import { getPopupPositionClass } from './utils';
|
|
15
15
|
import type { MapConfig, PopupDirection } from '../types/map';
|
|
16
16
|
|
|
17
17
|
export type MapComponentProps = {
|
package/src/map/MapContext.tsx
CHANGED
|
@@ -12,7 +12,7 @@ import ClusterSource from 'ol/source/Cluster';
|
|
|
12
12
|
import VectorSource from 'ol/source/Vector';
|
|
13
13
|
|
|
14
14
|
import './projections';
|
|
15
|
-
import { LAYER_NAMES } from './
|
|
15
|
+
import { LAYER_NAMES } from './utils';
|
|
16
16
|
import type { MapConfig } from '../types/map';
|
|
17
17
|
|
|
18
18
|
export type MapContextType = {
|
package/src/map/index.ts
CHANGED
|
@@ -2,8 +2,8 @@ export * from './basemaps';
|
|
|
2
2
|
export * from './geocoder';
|
|
3
3
|
export * from './geometries';
|
|
4
4
|
export * from './LayerSwitcherControl';
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
5
|
+
export * from './utils';
|
|
6
|
+
export * from './MapComponent';
|
|
7
7
|
export * from './MapContext';
|
|
8
8
|
export * from './osOpenNamesSearch';
|
|
9
9
|
export * from './Popup';
|
|
File without changes
|