@tpzdsp/next-toolkit 1.1.0 → 1.2.0
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 +21 -2
- package/src/assets/styles/globals.css +2 -0
- package/src/assets/styles/ol.css +122 -0
- package/src/components/Modal/Modal.stories.tsx +252 -0
- package/src/components/Modal/Modal.test.tsx +248 -0
- package/src/components/Modal/Modal.tsx +61 -0
- package/src/components/accordion/Accordion.stories.tsx +235 -0
- package/src/components/accordion/Accordion.test.tsx +199 -0
- package/src/components/accordion/Accordion.tsx +47 -0
- package/src/components/divider/RuleDivider.stories.tsx +255 -0
- package/src/components/divider/RuleDivider.test.tsx +164 -0
- package/src/components/divider/RuleDivider.tsx +18 -0
- package/src/components/index.ts +9 -2
- package/src/components/layout/header/HeaderAuthClient.tsx +16 -8
- package/src/components/layout/header/HeaderNavClient.tsx +2 -2
- package/src/components/map/LayerSwitcherControl.ts +147 -0
- package/src/components/map/Map.tsx +230 -0
- package/src/components/map/MapContext.tsx +211 -0
- package/src/components/map/Popup.tsx +74 -0
- package/src/components/map/basemaps.ts +79 -0
- package/src/components/map/geocoder.ts +61 -0
- package/src/components/map/geometries.ts +60 -0
- package/src/components/map/images/basemaps/OS.png +0 -0
- package/src/components/map/images/basemaps/dark.png +0 -0
- package/src/components/map/images/basemaps/sat-map-tiler.png +0 -0
- package/src/components/map/images/basemaps/satellite-map-tiler.png +0 -0
- package/src/components/map/images/basemaps/satellite.png +0 -0
- package/src/components/map/images/basemaps/streets.png +0 -0
- package/src/components/map/images/openlayers-logo.png +0 -0
- package/src/components/map/index.ts +10 -0
- package/src/components/map/map.ts +40 -0
- package/src/components/map/osOpenNamesSearch.ts +54 -0
- package/src/components/map/projections.ts +14 -0
- package/src/components/select/Select.stories.tsx +336 -0
- package/src/components/select/Select.test.tsx +473 -0
- package/src/components/select/Select.tsx +132 -0
- package/src/components/select/SelectSkeleton.stories.tsx +195 -0
- package/src/components/select/SelectSkeleton.test.tsx +105 -0
- package/src/components/select/SelectSkeleton.tsx +16 -0
- package/src/components/select/common.ts +4 -0
- package/src/contexts/index.ts +0 -5
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useClickOutside.test.ts +290 -0
- package/src/hooks/useClickOutside.ts +26 -0
- package/src/types.ts +51 -1
- package/src/utils/http.ts +143 -0
- package/src/utils/index.ts +1 -0
- package/src/components/link/NextLinkWrapper.tsx +0 -66
- package/src/contexts/ThemeContext.tsx +0 -72
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/* eslint-disable storybook/no-renderer-packages */
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { RuleDivider } from './RuleDivider';
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Components/RuleDivider',
|
|
8
|
+
component: RuleDivider,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'centered',
|
|
11
|
+
},
|
|
12
|
+
tags: ['autodocs'],
|
|
13
|
+
} satisfies Meta<typeof RuleDivider>;
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
type Story = StoryObj<typeof meta>;
|
|
17
|
+
|
|
18
|
+
export const Default: Story = {
|
|
19
|
+
render: () => (
|
|
20
|
+
<div className="w-96">
|
|
21
|
+
<RuleDivider />
|
|
22
|
+
</div>
|
|
23
|
+
),
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const WithText: Story = {
|
|
27
|
+
render: () => (
|
|
28
|
+
<div className="w-96">
|
|
29
|
+
<RuleDivider>OR</RuleDivider>
|
|
30
|
+
</div>
|
|
31
|
+
),
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const WithLongerText: Story = {
|
|
35
|
+
render: () => (
|
|
36
|
+
<div className="w-96">
|
|
37
|
+
<RuleDivider>Continue Reading</RuleDivider>
|
|
38
|
+
</div>
|
|
39
|
+
),
|
|
40
|
+
};
|
|
41
|
+
export const WithIcon: Story = {
|
|
42
|
+
render: () => (
|
|
43
|
+
<div className="w-96">
|
|
44
|
+
<RuleDivider>
|
|
45
|
+
<svg
|
|
46
|
+
className="w-4 h-4"
|
|
47
|
+
fill="none"
|
|
48
|
+
stroke="currentColor"
|
|
49
|
+
viewBox="0 0 24 24"
|
|
50
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
51
|
+
>
|
|
52
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 4v16m8-8H4" />
|
|
53
|
+
</svg>
|
|
54
|
+
</RuleDivider>
|
|
55
|
+
</div>
|
|
56
|
+
),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const WithStyledText: Story = {
|
|
60
|
+
render: () => (
|
|
61
|
+
<div className="w-96">
|
|
62
|
+
<RuleDivider>
|
|
63
|
+
<span className="text-sm text-gray-500 uppercase tracking-wide">Section Break</span>
|
|
64
|
+
</RuleDivider>
|
|
65
|
+
</div>
|
|
66
|
+
),
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const WithBoldText: Story = {
|
|
70
|
+
render: () => (
|
|
71
|
+
<div className="w-96">
|
|
72
|
+
<RuleDivider>
|
|
73
|
+
<strong className="text-gray-700">Important</strong>
|
|
74
|
+
</RuleDivider>
|
|
75
|
+
</div>
|
|
76
|
+
),
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const WithColoredText: Story = {
|
|
80
|
+
render: () => (
|
|
81
|
+
<div className="w-96">
|
|
82
|
+
<RuleDivider>
|
|
83
|
+
<span className="text-blue-600 font-medium">New Content</span>
|
|
84
|
+
</RuleDivider>
|
|
85
|
+
</div>
|
|
86
|
+
),
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const InContainer: Story = {
|
|
90
|
+
render: () => (
|
|
91
|
+
<div className="w-96 p-4 border rounded">
|
|
92
|
+
<p className="mb-4">This is some content above the divider.</p>
|
|
93
|
+
|
|
94
|
+
<RuleDivider>
|
|
95
|
+
<span className="text-gray-500">More below</span>
|
|
96
|
+
</RuleDivider>
|
|
97
|
+
|
|
98
|
+
<p className="mt-4">This is content below the divider.</p>
|
|
99
|
+
</div>
|
|
100
|
+
),
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const FormSeparator: Story = {
|
|
104
|
+
render: () => (
|
|
105
|
+
<div className="w-80 p-6 border rounded">
|
|
106
|
+
<div className="space-y-4">
|
|
107
|
+
<div>
|
|
108
|
+
<p className="block text-sm font-medium mb-1">Email</p>
|
|
109
|
+
|
|
110
|
+
<input
|
|
111
|
+
type="email"
|
|
112
|
+
className="w-full p-2 border border-gray-300 rounded"
|
|
113
|
+
placeholder="Enter your email"
|
|
114
|
+
/>
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
<div>
|
|
118
|
+
<p className="block text-sm font-medium mb-1">Password</p>
|
|
119
|
+
|
|
120
|
+
<input
|
|
121
|
+
type="password"
|
|
122
|
+
className="w-full p-2 border border-gray-300 rounded"
|
|
123
|
+
placeholder="Enter your password"
|
|
124
|
+
/>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
|
|
128
|
+
<div className="my-6">
|
|
129
|
+
<RuleDivider>
|
|
130
|
+
<span className="text-xs text-gray-400 uppercase">OR</span>
|
|
131
|
+
</RuleDivider>
|
|
132
|
+
</div>
|
|
133
|
+
|
|
134
|
+
<button className="w-full py-2 px-4 bg-blue-500 text-white rounded hover:bg-blue-600">
|
|
135
|
+
Continue with Google
|
|
136
|
+
</button>
|
|
137
|
+
</div>
|
|
138
|
+
),
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export const ContentSections: Story = {
|
|
142
|
+
render: () => (
|
|
143
|
+
<div className="max-w-2xl p-6 space-y-6">
|
|
144
|
+
<div>
|
|
145
|
+
<h2 className="text-xl font-bold mb-2">Introduction</h2>
|
|
146
|
+
|
|
147
|
+
<p className="text-gray-600">
|
|
148
|
+
This is the introduction section with some content that explains the topic.
|
|
149
|
+
</p>
|
|
150
|
+
</div>
|
|
151
|
+
|
|
152
|
+
<RuleDivider>
|
|
153
|
+
<span className="text-sm text-gray-500">Chapter 1</span>
|
|
154
|
+
</RuleDivider>
|
|
155
|
+
|
|
156
|
+
<div>
|
|
157
|
+
<h3 className="text-lg font-semibold mb-2">Getting Started</h3>
|
|
158
|
+
|
|
159
|
+
<p className="text-gray-600">
|
|
160
|
+
Here we dive into the first chapter with detailed explanations and examples.
|
|
161
|
+
</p>
|
|
162
|
+
</div>
|
|
163
|
+
|
|
164
|
+
<RuleDivider>
|
|
165
|
+
<span className="text-sm text-gray-500">Chapter 2</span>
|
|
166
|
+
</RuleDivider>
|
|
167
|
+
|
|
168
|
+
<div>
|
|
169
|
+
<h3 className="text-lg font-semibold mb-2">Advanced Topics</h3>
|
|
170
|
+
|
|
171
|
+
<p className="text-gray-600">This section covers more advanced concepts and use cases.</p>
|
|
172
|
+
</div>
|
|
173
|
+
</div>
|
|
174
|
+
),
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export const MultipleInList: Story = {
|
|
178
|
+
render: () => (
|
|
179
|
+
<div className="w-80 space-y-4">
|
|
180
|
+
<RuleDivider />
|
|
181
|
+
|
|
182
|
+
<RuleDivider>
|
|
183
|
+
<span className="text-gray-600">Section A</span>
|
|
184
|
+
</RuleDivider>
|
|
185
|
+
|
|
186
|
+
<RuleDivider>
|
|
187
|
+
<span className="text-gray-600">Section B</span>
|
|
188
|
+
</RuleDivider>
|
|
189
|
+
|
|
190
|
+
<RuleDivider>
|
|
191
|
+
<span className="text-gray-600">Section C</span>
|
|
192
|
+
</RuleDivider>
|
|
193
|
+
|
|
194
|
+
<RuleDivider />
|
|
195
|
+
</div>
|
|
196
|
+
),
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export const DifferentWidths: Story = {
|
|
200
|
+
render: () => (
|
|
201
|
+
<div className="space-y-6">
|
|
202
|
+
<div className="w-32">
|
|
203
|
+
<div className="text-sm mb-2">Small (w-32)</div>
|
|
204
|
+
|
|
205
|
+
<RuleDivider>
|
|
206
|
+
<span className="text-xs">OR</span>
|
|
207
|
+
</RuleDivider>
|
|
208
|
+
</div>
|
|
209
|
+
|
|
210
|
+
<div className="w-64">
|
|
211
|
+
<div className="text-sm mb-2">Medium (w-64)</div>
|
|
212
|
+
|
|
213
|
+
<RuleDivider>
|
|
214
|
+
<span className="text-sm">Continue</span>
|
|
215
|
+
</RuleDivider>
|
|
216
|
+
</div>
|
|
217
|
+
|
|
218
|
+
<div className="w-96">
|
|
219
|
+
<div className="text-sm mb-2">Large (w-96)</div>
|
|
220
|
+
|
|
221
|
+
<RuleDivider>
|
|
222
|
+
<span className="text-base">Section Divider</span>
|
|
223
|
+
</RuleDivider>
|
|
224
|
+
</div>
|
|
225
|
+
</div>
|
|
226
|
+
),
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export const WithButton: Story = {
|
|
230
|
+
render: () => (
|
|
231
|
+
<RuleDivider>
|
|
232
|
+
<button className="px-3 py-1 text-xs bg-gray-100 text-gray-600 rounded hover:bg-gray-200">
|
|
233
|
+
Show More
|
|
234
|
+
</button>
|
|
235
|
+
</RuleDivider>
|
|
236
|
+
),
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
export const WithMultipleElements: Story = {
|
|
240
|
+
render: () => (
|
|
241
|
+
<RuleDivider>
|
|
242
|
+
<div className="flex items-center gap-2">
|
|
243
|
+
<svg className="w-3 h-3" fill="currentColor" viewBox="0 0 20 20">
|
|
244
|
+
<path
|
|
245
|
+
fillRule="evenodd"
|
|
246
|
+
d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z"
|
|
247
|
+
clipRule="evenodd"
|
|
248
|
+
/>
|
|
249
|
+
</svg>
|
|
250
|
+
|
|
251
|
+
<span className="text-sm text-green-600">Completed</span>
|
|
252
|
+
</div>
|
|
253
|
+
</RuleDivider>
|
|
254
|
+
),
|
|
255
|
+
};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { RuleDivider } from './RuleDivider';
|
|
2
|
+
import { render, screen } from '../../utils/renderers';
|
|
3
|
+
|
|
4
|
+
describe('RuleDivider', () => {
|
|
5
|
+
it('should render with default props', () => {
|
|
6
|
+
const { container } = render(<RuleDivider />);
|
|
7
|
+
|
|
8
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('should render single hr element when no children provided', () => {
|
|
12
|
+
const { container } = render(<RuleDivider />);
|
|
13
|
+
|
|
14
|
+
const hrElements = container.querySelectorAll('hr');
|
|
15
|
+
|
|
16
|
+
expect(hrElements).toHaveLength(1);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should have correct container classes', () => {
|
|
20
|
+
const { container } = render(<RuleDivider />);
|
|
21
|
+
|
|
22
|
+
const containerElement = container.firstChild as HTMLElement;
|
|
23
|
+
|
|
24
|
+
expect(containerElement).toHaveClass('flex', 'items-center');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should render with children', () => {
|
|
28
|
+
render(<RuleDivider>Divider Text</RuleDivider>);
|
|
29
|
+
|
|
30
|
+
expect(screen.getByText('Divider Text')).toBeInTheDocument();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should render two hr elements when children are provided', () => {
|
|
34
|
+
const { container } = render(<RuleDivider>With Text</RuleDivider>);
|
|
35
|
+
|
|
36
|
+
const hrElements = container.querySelectorAll('hr');
|
|
37
|
+
|
|
38
|
+
expect(hrElements).toHaveLength(2);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should apply correct classes to hr elements', () => {
|
|
42
|
+
const { container } = render(<RuleDivider />);
|
|
43
|
+
|
|
44
|
+
const hrElement = container.querySelector('hr');
|
|
45
|
+
|
|
46
|
+
expect(hrElement).toHaveClass('flex-grow');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should apply correct classes to span when children provided', () => {
|
|
50
|
+
const { container } = render(<RuleDivider>Test Content</RuleDivider>);
|
|
51
|
+
|
|
52
|
+
const spanElement = container.querySelector('span');
|
|
53
|
+
|
|
54
|
+
expect(spanElement).toHaveClass('px-2');
|
|
55
|
+
expect(spanElement).toHaveTextContent('Test Content');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('should render complex children correctly', () => {
|
|
59
|
+
render(
|
|
60
|
+
<RuleDivider>
|
|
61
|
+
<strong>Bold Text</strong>
|
|
62
|
+
</RuleDivider>,
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
expect(screen.getByText('Bold Text')).toBeInTheDocument();
|
|
66
|
+
expect(screen.getByText('Bold Text').tagName).toBe('STRONG');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('should handle multiple text nodes as children', () => {
|
|
70
|
+
render(<RuleDivider>Multiple words here</RuleDivider>);
|
|
71
|
+
|
|
72
|
+
expect(screen.getByText('Multiple words here')).toBeInTheDocument();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should render icon as children', () => {
|
|
76
|
+
const IconComponent = () => <svg data-testid="test-icon" />;
|
|
77
|
+
|
|
78
|
+
render(
|
|
79
|
+
<RuleDivider>
|
|
80
|
+
<IconComponent />
|
|
81
|
+
</RuleDivider>,
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
expect(screen.getByTestId('test-icon')).toBeInTheDocument();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('should have proper structure when children provided', () => {
|
|
88
|
+
const { container } = render(<RuleDivider>Content</RuleDivider>);
|
|
89
|
+
|
|
90
|
+
const containerElement = container.firstChild as HTMLElement;
|
|
91
|
+
|
|
92
|
+
expect(containerElement.children).toHaveLength(3); // hr + span + hr
|
|
93
|
+
|
|
94
|
+
const [firstHr, span, secondHr] = containerElement.children;
|
|
95
|
+
|
|
96
|
+
expect(firstHr.tagName).toBe('HR');
|
|
97
|
+
expect(span.tagName).toBe('SPAN');
|
|
98
|
+
expect(secondHr.tagName).toBe('HR');
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('should have proper structure when no children provided', () => {
|
|
102
|
+
const { container } = render(<RuleDivider />);
|
|
103
|
+
|
|
104
|
+
const containerElement = container.firstChild as HTMLElement;
|
|
105
|
+
|
|
106
|
+
expect(containerElement.children).toHaveLength(1); // only hr
|
|
107
|
+
|
|
108
|
+
const hrElement = containerElement.children[0];
|
|
109
|
+
|
|
110
|
+
expect(hrElement.tagName).toBe('HR');
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('should handle empty string as children', () => {
|
|
114
|
+
const { container } = render(<RuleDivider>{''}</RuleDivider>);
|
|
115
|
+
|
|
116
|
+
// Empty string is falsy, so should behave like no children
|
|
117
|
+
const hrElements = container.querySelectorAll('hr');
|
|
118
|
+
|
|
119
|
+
expect(hrElements).toHaveLength(1);
|
|
120
|
+
|
|
121
|
+
const spanElement = container.querySelector('span');
|
|
122
|
+
|
|
123
|
+
expect(spanElement).not.toBeInTheDocument();
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('should handle null children correctly', () => {
|
|
127
|
+
const { container } = render(<RuleDivider>{null}</RuleDivider>);
|
|
128
|
+
|
|
129
|
+
// null should be considered falsy, so only one hr should render
|
|
130
|
+
const hrElements = container.querySelectorAll('hr');
|
|
131
|
+
|
|
132
|
+
expect(hrElements).toHaveLength(1);
|
|
133
|
+
|
|
134
|
+
const spanElement = container.querySelector('span');
|
|
135
|
+
|
|
136
|
+
expect(spanElement).not.toBeInTheDocument();
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('should handle undefined children correctly', () => {
|
|
140
|
+
const { container } = render(<RuleDivider>{undefined}</RuleDivider>);
|
|
141
|
+
|
|
142
|
+
// undefined should be considered falsy, so only one hr should render
|
|
143
|
+
const hrElements = container.querySelectorAll('hr');
|
|
144
|
+
|
|
145
|
+
expect(hrElements).toHaveLength(1);
|
|
146
|
+
|
|
147
|
+
const spanElement = container.querySelector('span');
|
|
148
|
+
|
|
149
|
+
expect(spanElement).not.toBeInTheDocument();
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('should render multiple child elements', () => {
|
|
153
|
+
render(
|
|
154
|
+
<RuleDivider>
|
|
155
|
+
<span>Text 1</span>
|
|
156
|
+
|
|
157
|
+
<span>Text 2</span>
|
|
158
|
+
</RuleDivider>,
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
expect(screen.getByText('Text 1')).toBeInTheDocument();
|
|
162
|
+
expect(screen.getByText('Text 2')).toBeInTheDocument();
|
|
163
|
+
});
|
|
164
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type RuleDividerProps = {
|
|
2
|
+
children?: React.ReactNode;
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
export const RuleDivider = ({ children }: RuleDividerProps) => {
|
|
6
|
+
return (
|
|
7
|
+
<div className="flex items-center">
|
|
8
|
+
<hr className="flex-grow" />
|
|
9
|
+
{children ? (
|
|
10
|
+
<>
|
|
11
|
+
<span className="px-2">{children}</span>
|
|
12
|
+
|
|
13
|
+
<hr className="flex-grow" />
|
|
14
|
+
</>
|
|
15
|
+
) : null}
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
};
|
package/src/components/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ export { OglLogo } from './images/OglLogo';
|
|
|
11
11
|
export { ExternalLink } from './link/ExternalLink';
|
|
12
12
|
export { Link } from './link/Link';
|
|
13
13
|
export { Paragraph } from './Paragraph/Paragraph';
|
|
14
|
+
export { RuleDivider } from './divider/RuleDivider';
|
|
14
15
|
|
|
15
16
|
// Export default component types
|
|
16
17
|
export type { ButtonProps } from './Button/Button';
|
|
@@ -25,14 +26,20 @@ export type { ParagraphProps } from './Paragraph/Paragraph';
|
|
|
25
26
|
export type { SlidingPanelProps } from './SlidingPanel/SlidingPanel';
|
|
26
27
|
|
|
27
28
|
// Client components - these require 'use client' directive
|
|
28
|
-
export { NextLinkWrapper } from './link/NextLinkWrapper';
|
|
29
29
|
export { DropdownMenu } from './dropdown/DropdownMenu';
|
|
30
30
|
export { useDropdownMenu } from './dropdown/useDropdownMenu';
|
|
31
31
|
export { SlidingPanel } from './SlidingPanel/SlidingPanel';
|
|
32
|
+
export { Accordion } from './accordion/Accordion';
|
|
33
|
+
export { Modal } from './Modal/Modal';
|
|
34
|
+
export { Select } from './select/Select';
|
|
35
|
+
export { SelectSkeleton } from './select/SelectSkeleton';
|
|
32
36
|
|
|
33
37
|
// Export client component types
|
|
34
|
-
export type {
|
|
38
|
+
export type { AccordionProps } from './accordion/Accordion';
|
|
35
39
|
|
|
36
40
|
// Export layout components
|
|
37
41
|
export { Header } from './layout/header/Header';
|
|
38
42
|
export { Footer } from './layout/footer/Footer';
|
|
43
|
+
|
|
44
|
+
// Export Map components
|
|
45
|
+
export * from './map';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
|
|
3
5
|
import type { Credentials } from '../../../types';
|
|
4
6
|
import { Link } from '../../link/Link';
|
|
5
7
|
|
|
@@ -9,7 +11,11 @@ type HeaderAuthClientProps = {
|
|
|
9
11
|
};
|
|
10
12
|
|
|
11
13
|
export const HeaderAuthClient = ({ hostname, credentials }: HeaderAuthClientProps) => {
|
|
12
|
-
|
|
14
|
+
const [isClient, setIsClient] = useState(false);
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
setIsClient(true);
|
|
18
|
+
}, []);
|
|
13
19
|
|
|
14
20
|
return (
|
|
15
21
|
<span
|
|
@@ -20,13 +26,15 @@ export const HeaderAuthClient = ({ hostname, credentials }: HeaderAuthClientProp
|
|
|
20
26
|
<span>Welcome,</span> {credentials ? credentials.user.email : 'Guest'}
|
|
21
27
|
</span>
|
|
22
28
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
{isClient && (
|
|
30
|
+
<Link
|
|
31
|
+
href={`${hostname}/${credentials ? 'api/logout' : 'login'}?redirect-uri=${encodeURIComponent(window.location.href)}`}
|
|
32
|
+
className="text-white visited:text-white active:text-black hover:text-white"
|
|
33
|
+
prefetch={false}
|
|
34
|
+
>
|
|
35
|
+
<span className="text-base">{credentials ? 'Logout' : 'Login'}</span>
|
|
36
|
+
</Link>
|
|
37
|
+
)}
|
|
30
38
|
</span>
|
|
31
39
|
);
|
|
32
40
|
};
|
|
@@ -23,8 +23,8 @@ const InternalNavItem = ({ label, url, icon, ...props }: DropdownMenuItem<NavLin
|
|
|
23
23
|
</Link>
|
|
24
24
|
);
|
|
25
25
|
|
|
26
|
-
const NavItem = (props: DropdownMenuItem<NavLink>) => {
|
|
27
|
-
if (
|
|
26
|
+
const NavItem = ({ isExternal, ...props }: DropdownMenuItem<NavLink>) => {
|
|
27
|
+
if (isExternal) {
|
|
28
28
|
return <ExternalNavItem {...props} />;
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/* eslint-disable no-restricted-syntax */
|
|
2
|
+
import type { StaticImageData } from 'next/image';
|
|
3
|
+
import { Map } from 'ol';
|
|
4
|
+
import { Control } from 'ol/control';
|
|
5
|
+
import type { Options as ControlOptions } from 'ol/control/Control';
|
|
6
|
+
import BaseLayer from 'ol/layer/Base';
|
|
7
|
+
|
|
8
|
+
import OpenLayersLogo from './images/openlayers-logo.png';
|
|
9
|
+
|
|
10
|
+
export class LayerSwitcherControl extends Control {
|
|
11
|
+
map!: Map;
|
|
12
|
+
panel!: HTMLElement;
|
|
13
|
+
isCollapsed = true;
|
|
14
|
+
|
|
15
|
+
constructor(layers: BaseLayer[], options?: ControlOptions) {
|
|
16
|
+
const button = document.createElement('button');
|
|
17
|
+
|
|
18
|
+
button.setAttribute('aria-labelledby', 'Button to toggle layer switcher');
|
|
19
|
+
button.setAttribute('aria-label', 'Button to toggle layer switcher');
|
|
20
|
+
button.setAttribute('title', 'Basemap switcher');
|
|
21
|
+
button.className = 'ol-layer-switcher ol-btn';
|
|
22
|
+
|
|
23
|
+
const switcherImage = document.createElement('img');
|
|
24
|
+
|
|
25
|
+
const openLayersLogoData = OpenLayersLogo as unknown as StaticImageData;
|
|
26
|
+
|
|
27
|
+
switcherImage.src = openLayersLogoData.src;
|
|
28
|
+
switcherImage.setAttribute('alt', 'Openlayers logo');
|
|
29
|
+
switcherImage.setAttribute('width', '20px');
|
|
30
|
+
switcherImage.setAttribute('height', '20px');
|
|
31
|
+
button.appendChild(switcherImage);
|
|
32
|
+
|
|
33
|
+
const element = document.createElement('div');
|
|
34
|
+
|
|
35
|
+
element.className = 'ol-layer-switcher ol-unselectable ol-control';
|
|
36
|
+
element.appendChild(button);
|
|
37
|
+
|
|
38
|
+
super({
|
|
39
|
+
element,
|
|
40
|
+
target: options?.target,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
this.panel = document.createElement('div');
|
|
44
|
+
this.panel.className = 'ol-layer-switcher-panel';
|
|
45
|
+
|
|
46
|
+
layers.forEach((layer) => {
|
|
47
|
+
const img = document.createElement('img');
|
|
48
|
+
|
|
49
|
+
img.src = layer.get('image') as string;
|
|
50
|
+
img.setAttribute('title', layer.get('name'));
|
|
51
|
+
|
|
52
|
+
const switcherText = document.createElement('div');
|
|
53
|
+
|
|
54
|
+
switcherText.textContent = layer.get('name') as string;
|
|
55
|
+
|
|
56
|
+
const btn = document.createElement('button');
|
|
57
|
+
|
|
58
|
+
btn.appendChild(img);
|
|
59
|
+
btn.appendChild(switcherText);
|
|
60
|
+
|
|
61
|
+
btn.addEventListener(
|
|
62
|
+
'click',
|
|
63
|
+
this.selectBasemap.bind(this, layer.get('name') as string),
|
|
64
|
+
false,
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
this.panel.appendChild(btn);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
button.addEventListener('click', this.toggleLayerSwitcher.bind(this), false);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
setMap(map: Map) {
|
|
74
|
+
super.setMap(map);
|
|
75
|
+
|
|
76
|
+
if (map) {
|
|
77
|
+
// Ensure we only set the initial active layer when the map is assigned
|
|
78
|
+
map.once('rendercomplete', this.setInitialActiveLayer.bind(this));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
toggleLayerSwitcher() {
|
|
83
|
+
if (this.isCollapsed) {
|
|
84
|
+
this.element.appendChild(this.panel);
|
|
85
|
+
requestAnimationFrame(() => {
|
|
86
|
+
this.panel.classList.add('open'); // Ensure animation works after adding to DOM
|
|
87
|
+
});
|
|
88
|
+
} else {
|
|
89
|
+
this.panel.classList.remove('open');
|
|
90
|
+
setTimeout(() => {
|
|
91
|
+
this.element.removeChild(this.panel);
|
|
92
|
+
}, 300); // Matches CSS transition time to prevent flickering
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
this.isCollapsed = !this.isCollapsed;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
selectBasemap(layerName: string) {
|
|
99
|
+
const currentBasemap = this.getMap()
|
|
100
|
+
?.getLayers()
|
|
101
|
+
.getArray()
|
|
102
|
+
.filter((layer: BaseLayer) => layer.get('basemap') === true)
|
|
103
|
+
.find((layer: BaseLayer) => layer.getVisible() === true);
|
|
104
|
+
|
|
105
|
+
const newBasemap = this.getMap()
|
|
106
|
+
?.getLayers()
|
|
107
|
+
.getArray()
|
|
108
|
+
.find((layer: BaseLayer) => layer.get('name') === layerName);
|
|
109
|
+
|
|
110
|
+
currentBasemap?.setVisible(false);
|
|
111
|
+
newBasemap?.setVisible(true);
|
|
112
|
+
|
|
113
|
+
this.updateActiveButton(layerName); // Update the active button style
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
setInitialActiveLayer() {
|
|
117
|
+
const map = this.getMap();
|
|
118
|
+
|
|
119
|
+
if (!map) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const currentBasemap = this.getMap()
|
|
124
|
+
?.getLayers()
|
|
125
|
+
.getArray()
|
|
126
|
+
.filter((layer: BaseLayer) => layer.get('basemap') === true)
|
|
127
|
+
.find((layer: BaseLayer) => layer.getVisible() === true);
|
|
128
|
+
|
|
129
|
+
if (currentBasemap) {
|
|
130
|
+
const activeLayerName = currentBasemap.get('name');
|
|
131
|
+
|
|
132
|
+
this.updateActiveButton(activeLayerName);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
updateActiveButton(layerName: string) {
|
|
137
|
+
const buttons = this.panel.querySelectorAll('button');
|
|
138
|
+
|
|
139
|
+
buttons.forEach((btn: HTMLButtonElement) => {
|
|
140
|
+
if (btn.textContent?.trim() === layerName) {
|
|
141
|
+
btn.classList.add('active');
|
|
142
|
+
} else {
|
|
143
|
+
btn.classList.remove('active');
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|