@tpzdsp/next-toolkit 1.2.1 → 1.2.3
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
|
@@ -18,7 +18,7 @@ const hiddenPositionClasses = {
|
|
|
18
18
|
describe('SlidingPanel', () => {
|
|
19
19
|
it.each(positions)('should render closed panel by default at %s', (position) => {
|
|
20
20
|
render(
|
|
21
|
-
<SlidingPanel position={position} tabLabel="
|
|
21
|
+
<SlidingPanel position={position} tabLabel="Test">
|
|
22
22
|
<p>Panel Content</p>
|
|
23
23
|
</SlidingPanel>,
|
|
24
24
|
);
|
|
@@ -38,7 +38,7 @@ describe('SlidingPanel', () => {
|
|
|
38
38
|
const user = userEvent.setup();
|
|
39
39
|
|
|
40
40
|
render(
|
|
41
|
-
<SlidingPanel position={position} tabLabel="
|
|
41
|
+
<SlidingPanel position={position} tabLabel="Me">
|
|
42
42
|
<div>My content</div>
|
|
43
43
|
</SlidingPanel>,
|
|
44
44
|
);
|
|
@@ -72,7 +72,7 @@ describe('SlidingPanel', () => {
|
|
|
72
72
|
|
|
73
73
|
expect(panelContent).toBeVisible();
|
|
74
74
|
|
|
75
|
-
await user.click(screen.getByRole('button', { name: 'Close' }));
|
|
75
|
+
await user.click(screen.getByRole('button', { name: 'Close Trigger' }));
|
|
76
76
|
|
|
77
77
|
await waitFor(() => {
|
|
78
78
|
expect(panelContent).toBeInTheDocument();
|
package/src/map/Map.tsx
CHANGED
|
@@ -18,6 +18,7 @@ export type MapComponentProps = {
|
|
|
18
18
|
osMapsApiKey?: string;
|
|
19
19
|
geocoderUrl: string;
|
|
20
20
|
basePath: string;
|
|
21
|
+
isLoading?: boolean;
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
const positionTransforms: Record<PopupDirection, string> = {
|
|
@@ -41,7 +42,12 @@ const arrowStyles: Record<PopupDirection, string> = {
|
|
|
41
42
|
*
|
|
42
43
|
* @return {*}
|
|
43
44
|
*/
|
|
44
|
-
export const MapComponent = ({
|
|
45
|
+
export const MapComponent = ({
|
|
46
|
+
osMapsApiKey,
|
|
47
|
+
geocoderUrl,
|
|
48
|
+
basePath,
|
|
49
|
+
isLoading,
|
|
50
|
+
}: MapComponentProps) => {
|
|
45
51
|
const [popupFeatures, setPopupFeatures] = useState([]);
|
|
46
52
|
const [popupCoordinate, setPopupCoordinate] = useState<number[] | null>(null);
|
|
47
53
|
const [popupPositionClass, setPopupPositionClass] = useState<PopupDirection>('bottom-right');
|
|
@@ -57,7 +63,6 @@ export const MapComponent = ({ osMapsApiKey, geocoderUrl, basePath }: MapCompone
|
|
|
57
63
|
setMapConfig,
|
|
58
64
|
map,
|
|
59
65
|
isDrawing,
|
|
60
|
-
isSamplingPointsLoading,
|
|
61
66
|
} = useMap();
|
|
62
67
|
|
|
63
68
|
useEffect(() => {
|
|
@@ -199,7 +204,7 @@ export const MapComponent = ({ osMapsApiKey, geocoderUrl, basePath }: MapCompone
|
|
|
199
204
|
return (
|
|
200
205
|
<div className="flex flex-grow min-h-0">
|
|
201
206
|
<div ref={mapRef} className="flex flex-grow relative z-10" id="map">
|
|
202
|
-
{
|
|
207
|
+
{isLoading ? (
|
|
203
208
|
<div className="absolute inset-0 flex items-center justify-center bg-white/50 z-10">
|
|
204
209
|
<div
|
|
205
210
|
className="w-9 h-9 border-4 border-gray-200 border-t-blue-500 rounded-full
|
package/src/map/MapContext.tsx
CHANGED
|
@@ -25,7 +25,7 @@ export type MapContextType = {
|
|
|
25
25
|
addLayer: (layer: Layer) => void;
|
|
26
26
|
removeLayer: (name: string) => void;
|
|
27
27
|
clearLayer: (name: string) => void;
|
|
28
|
-
resetMap: () => void;
|
|
28
|
+
resetMap: (onReset?: () => void) => void;
|
|
29
29
|
getLayerByName: (name: string) => BaseLayer | undefined;
|
|
30
30
|
aoi: Coordinate[][] | null;
|
|
31
31
|
setAoi: Dispatch<SetStateAction<Coordinate[][] | null>>;
|
|
@@ -33,12 +33,6 @@ export type MapContextType = {
|
|
|
33
33
|
setSelectedLayer: Dispatch<SetStateAction<Layer | null>>;
|
|
34
34
|
isDrawing: boolean;
|
|
35
35
|
setIsDrawing: Dispatch<SetStateAction<boolean>>;
|
|
36
|
-
samplingPoints: string[] | null;
|
|
37
|
-
setSamplingPoints: Dispatch<SetStateAction<string[] | null>>;
|
|
38
|
-
isTooManySamplingPoints: boolean;
|
|
39
|
-
setIsTooManySamplingPoints: Dispatch<SetStateAction<boolean>>;
|
|
40
|
-
isSamplingPointsLoading: boolean;
|
|
41
|
-
setIsSamplingPointsLoading: Dispatch<SetStateAction<boolean>>;
|
|
42
36
|
};
|
|
43
37
|
|
|
44
38
|
type MapProviderProps = {
|
|
@@ -66,9 +60,6 @@ export const MapProvider = ({ initialState = {}, children }: MapProviderProps) =
|
|
|
66
60
|
const [aoi, setAoi] = useState<Coordinate[][] | null>(null);
|
|
67
61
|
const [selectedLayer, setSelectedLayer] = useState<Layer | null>(null);
|
|
68
62
|
const [isDrawing, setIsDrawing] = useState(false);
|
|
69
|
-
const [samplingPoints, setSamplingPoints] = useState<string[] | null>(null);
|
|
70
|
-
const [isTooManySamplingPoints, setIsTooManySamplingPoints] = useState(false);
|
|
71
|
-
const [isSamplingPointsLoading, setIsSamplingPointsLoading] = useState(false);
|
|
72
63
|
|
|
73
64
|
const getLayers = useCallback(() => map?.getLayers().getArray(), [map]);
|
|
74
65
|
|
|
@@ -126,30 +117,32 @@ export const MapProvider = ({ initialState = {}, children }: MapProviderProps) =
|
|
|
126
117
|
[getLayerByName],
|
|
127
118
|
);
|
|
128
119
|
|
|
129
|
-
const resetMap = useCallback(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
120
|
+
const resetMap = useCallback(
|
|
121
|
+
(onReset?: () => void) => {
|
|
122
|
+
if (map) {
|
|
123
|
+
const view = map.getView();
|
|
124
|
+
|
|
125
|
+
// Animate view to default
|
|
126
|
+
view.animate(
|
|
127
|
+
{
|
|
128
|
+
center: fromLonLat(DEFAULT_LON_LAT),
|
|
129
|
+
duration: DEFAULT_DURATION,
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
zoom: DEFAULT_ZOOM,
|
|
133
|
+
duration: DEFAULT_DURATION,
|
|
134
|
+
},
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Remove all defined layers
|
|
139
|
+
Object.values(LAYER_NAMES).forEach(clearLayer);
|
|
140
|
+
|
|
141
|
+
// Call app-specific reset logic
|
|
142
|
+
onReset?.();
|
|
143
|
+
},
|
|
144
|
+
[map, clearLayer],
|
|
145
|
+
);
|
|
153
146
|
|
|
154
147
|
const contextValue = useMemo(
|
|
155
148
|
() => ({
|
|
@@ -168,12 +161,6 @@ export const MapProvider = ({ initialState = {}, children }: MapProviderProps) =
|
|
|
168
161
|
setSelectedLayer,
|
|
169
162
|
isDrawing,
|
|
170
163
|
setIsDrawing,
|
|
171
|
-
samplingPoints,
|
|
172
|
-
setSamplingPoints,
|
|
173
|
-
isTooManySamplingPoints,
|
|
174
|
-
setIsTooManySamplingPoints,
|
|
175
|
-
isSamplingPointsLoading,
|
|
176
|
-
setIsSamplingPointsLoading,
|
|
177
164
|
clearLayer,
|
|
178
165
|
resetMap,
|
|
179
166
|
...initialState,
|
|
@@ -188,9 +175,6 @@ export const MapProvider = ({ initialState = {}, children }: MapProviderProps) =
|
|
|
188
175
|
aoi,
|
|
189
176
|
selectedLayer,
|
|
190
177
|
isDrawing,
|
|
191
|
-
samplingPoints,
|
|
192
|
-
isTooManySamplingPoints,
|
|
193
|
-
isSamplingPointsLoading,
|
|
194
178
|
clearLayer,
|
|
195
179
|
resetMap,
|
|
196
180
|
initialState,
|