ethio-map-kit 0.1.1 → 0.1.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/README.md +167 -319
- package/dist/components/EthiopiaMap.d.ts +11 -3
- package/dist/components/EthiopiaRegionServicesCard.d.ts +7 -1
- package/dist/components/EthiopiaRegionServicesPanel.d.ts +20 -0
- package/dist/ethio-map-kit.css +1 -1
- package/dist/ethio-map-kit.js +743 -580
- package/dist/ethio-map-kit.umd.cjs +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/types.d.ts +15 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Ethio Map Kit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React components for building interactive Ethiopia map visualizations.
|
|
4
4
|
|
|
5
|
-
Ethio Map Kit
|
|
5
|
+
Ethio Map Kit includes a regional Ethiopia map, smooth region selection, light/dark themes, terrain and heat layers, marker support, service stats, and TypeScript types.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -10,13 +10,7 @@ Ethio Map Kit ships a polished Ethiopia map surface, region legend, selected-reg
|
|
|
10
10
|
npm install ethio-map-kit
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npm install react react-dom
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Import the stylesheet once in your app:
|
|
13
|
+
Import the stylesheet once:
|
|
20
14
|
|
|
21
15
|
```tsx
|
|
22
16
|
import "ethio-map-kit/styles.css";
|
|
@@ -40,95 +34,98 @@ export function App() {
|
|
|
40
34
|
serviceStats={defaultRegionServiceStats}
|
|
41
35
|
locations={defaultLocations}
|
|
42
36
|
theme="light"
|
|
43
|
-
layer="
|
|
37
|
+
layer="regions"
|
|
44
38
|
showLabels
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
console.log(selection.regionId, selection.region);
|
|
39
|
+
onRegionSelect={({ regionId, region }) => {
|
|
40
|
+
console.log(regionId, region);
|
|
48
41
|
}}
|
|
49
42
|
/>
|
|
50
43
|
);
|
|
51
44
|
}
|
|
52
45
|
```
|
|
53
46
|
|
|
54
|
-
|
|
47
|
+
## Terrain Layer
|
|
55
48
|
|
|
56
49
|
```tsx
|
|
57
|
-
|
|
50
|
+
<EthiopiaMap
|
|
51
|
+
data={defaultRegionData}
|
|
52
|
+
layer="terrain"
|
|
53
|
+
theme="dark"
|
|
54
|
+
/>
|
|
58
55
|
```
|
|
59
56
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
Components:
|
|
57
|
+
The bundled terrain image is a transparent WebP, so it works in both light and dark mode.
|
|
63
58
|
|
|
64
|
-
|
|
65
|
-
- `EthiopiaMapSurface`
|
|
66
|
-
- `EthiopiaMapProvider`
|
|
67
|
-
- `EthiopiaMapRoot`
|
|
68
|
-
- `EthiopiaMapLegend`
|
|
69
|
-
- `EthiopiaSelectedRegionCard`
|
|
70
|
-
- `EthiopiaRegionServicesCard`
|
|
71
|
-
- `EthiopiaLocationsPanel`
|
|
72
|
-
|
|
73
|
-
Hooks:
|
|
74
|
-
|
|
75
|
-
- `useEthiopiaMap`
|
|
76
|
-
- `useSelectedRegionId`
|
|
59
|
+
## Custom Data
|
|
77
60
|
|
|
78
|
-
|
|
61
|
+
```tsx
|
|
62
|
+
import type { RegionRecord, RegionDatum } from "ethio-map-kit";
|
|
79
63
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
64
|
+
const data: RegionRecord<RegionDatum> = {
|
|
65
|
+
...defaultRegionData,
|
|
66
|
+
amhara: {
|
|
67
|
+
name: "Amhara",
|
|
68
|
+
value: 78,
|
|
69
|
+
trend: "+12%",
|
|
70
|
+
copy: "High regional index with several sample cities.",
|
|
71
|
+
},
|
|
72
|
+
};
|
|
86
73
|
|
|
87
|
-
|
|
74
|
+
<EthiopiaMap data={data} />;
|
|
75
|
+
```
|
|
88
76
|
|
|
89
|
-
|
|
77
|
+
## Common Props
|
|
78
|
+
|
|
79
|
+
| Prop | Type | Description |
|
|
80
|
+
| --- | --- | --- |
|
|
81
|
+
| `data` | `RegionRecord<RegionDatum>` | Region values and copy keyed by region ID. |
|
|
82
|
+
| `serviceStats` | `RegionServiceStats` | Optional service indicators for each region. |
|
|
83
|
+
| `locations` | `LatLngLocation[]` | Optional marker/location data. |
|
|
84
|
+
| `theme` | `"light" \| "dark"` | Map theme. |
|
|
85
|
+
| `layer` | `"regions" \| "heat" \| "terrain"` | Active visual layer. |
|
|
86
|
+
| `viewMode` | `"map" \| "bars"` | Map view or bar view. |
|
|
87
|
+
| `selectionAnimation` | `"pulse" \| "static" \| "none" \| "outline"` | Selected-region animation style. |
|
|
88
|
+
| `showLabels` | `boolean` | Show or hide region labels. |
|
|
89
|
+
| `showMarkers` | `boolean` | Show or hide location markers. |
|
|
90
|
+
| `showInMapStats` | `boolean` | Show or hide the selected region service overlay inside the map surface. |
|
|
91
|
+
| `regionColors` | `PartialRegionRecord<string>` | Override region colors. |
|
|
92
|
+
| `selectedRegionId` | `EthiopiaRegionId \| null` | Controlled selected region. |
|
|
93
|
+
| `defaultSelectedRegionId` | `EthiopiaRegionId \| null` | Initial selected region. |
|
|
94
|
+
| `onRegionSelect` | `(selection) => void` | Called when a region is selected or cleared. |
|
|
95
|
+
| `className` | `string` | Class applied to the map surface in the all-in-one `EthiopiaMap`. |
|
|
96
|
+
| `style` | `React.CSSProperties` | Inline style applied to the map surface in the all-in-one `EthiopiaMap`. Useful for height and width. |
|
|
97
|
+
| `terrainImageUrl` | `string` | Custom terrain image URL. |
|
|
98
|
+
|
|
99
|
+
## Sizing The Map
|
|
100
|
+
|
|
101
|
+
The map surface fills its own container and has a default minimum height. Use `className`, `style`, or your layout wrapper to control the rendered size.
|
|
90
102
|
|
|
91
103
|
```tsx
|
|
92
104
|
<EthiopiaMap
|
|
93
|
-
data={
|
|
94
|
-
serviceStats={
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
layer="heat"
|
|
98
|
-
selectedRegionId={selectedRegionId}
|
|
99
|
-
onRegionSelect={setSelection}
|
|
105
|
+
data={defaultRegionData}
|
|
106
|
+
serviceStats={defaultRegionServiceStats}
|
|
107
|
+
className="w-full"
|
|
108
|
+
style={{ width: "100%", height: 640, minHeight: 640 }}
|
|
100
109
|
/>
|
|
101
110
|
```
|
|
102
111
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
| `regionColors` | `PartialRegionRecord<string>` | `{}` | Override choropleth color for one or more regions. |
|
|
121
|
-
| `selectedRegionId` | `EthiopiaRegionId \| null` | Uncontrolled | Controlled selected region. |
|
|
122
|
-
| `defaultSelectedRegionId` | `EthiopiaRegionId \| null` | `null` | Initial selected region for uncontrolled usage. |
|
|
123
|
-
| `onRegionSelect` | `(selection: EthiopiaMapSelection) => void` | `undefined` | Called when the user selects or clears a region. |
|
|
124
|
-
| `className` | `string` | `undefined` | Extra class for the map surface. |
|
|
125
|
-
| `svgText` | `string` | Bundled SVG | Raw SVG text override. |
|
|
126
|
-
| `svgUrl` | `string` | `undefined` | Fetch an SVG from a URL instead of using the bundled SVG. |
|
|
127
|
-
| `terrainImageUrl` | `string` | Bundled WebP | Custom terrain image URL. |
|
|
128
|
-
|
|
129
|
-
## Composable Layout
|
|
130
|
-
|
|
131
|
-
Use the provider when you want to arrange the map and panels yourself.
|
|
112
|
+
With composable components, size `EthiopiaMapSurface` directly:
|
|
113
|
+
|
|
114
|
+
```tsx
|
|
115
|
+
<EthiopiaMapProvider data={defaultRegionData}>
|
|
116
|
+
<div className="grid gap-4 lg:grid-cols-[minmax(0,1fr)_320px]">
|
|
117
|
+
<EthiopiaMapSurface
|
|
118
|
+
className="w-full"
|
|
119
|
+
style={{ height: 620, minHeight: 620 }}
|
|
120
|
+
/>
|
|
121
|
+
<EthiopiaSelectedRegionCard />
|
|
122
|
+
</div>
|
|
123
|
+
</EthiopiaMapProvider>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Composable Components
|
|
127
|
+
|
|
128
|
+
For custom layouts, wrap components with `EthiopiaMapProvider`.
|
|
132
129
|
|
|
133
130
|
```tsx
|
|
134
131
|
import {
|
|
@@ -137,292 +134,143 @@ import {
|
|
|
137
134
|
EthiopiaMapLegend,
|
|
138
135
|
EthiopiaSelectedRegionCard,
|
|
139
136
|
EthiopiaRegionServicesCard,
|
|
137
|
+
EthiopiaRegionServicesPanel,
|
|
140
138
|
EthiopiaLocationsPanel,
|
|
141
139
|
defaultRegionData,
|
|
140
|
+
defaultRegionServiceStats,
|
|
142
141
|
} from "ethio-map-kit";
|
|
143
142
|
|
|
144
143
|
export function Dashboard() {
|
|
145
144
|
return (
|
|
146
|
-
<EthiopiaMapProvider
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
</div>
|
|
145
|
+
<EthiopiaMapProvider
|
|
146
|
+
data={defaultRegionData}
|
|
147
|
+
serviceStats={defaultRegionServiceStats}
|
|
148
|
+
>
|
|
149
|
+
<EthiopiaMapSurface />
|
|
150
|
+
<EthiopiaMapLegend />
|
|
151
|
+
<EthiopiaSelectedRegionCard />
|
|
152
|
+
<EthiopiaRegionServicesCard />
|
|
153
|
+
<EthiopiaLocationsPanel />
|
|
156
154
|
</EthiopiaMapProvider>
|
|
157
155
|
);
|
|
158
156
|
}
|
|
159
157
|
```
|
|
160
158
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
`EthiopiaMapProvider` accepts the same data, selection, theme, layer, marker, label, service-stat, and auto-tour props as `EthiopiaMap`, except it requires `children` and does not accept `className`, `svgText`, `svgUrl`, or `terrainImageUrl`.
|
|
164
|
-
|
|
165
|
-
Use this when you want shared state across multiple package components.
|
|
166
|
-
|
|
167
|
-
### `EthiopiaMapSurface` Props
|
|
168
|
-
|
|
169
|
-
| Prop | Type | Default | Description |
|
|
170
|
-
| --- | --- | --- | --- |
|
|
171
|
-
| `className` | `string` | `undefined` | Extra class for the surface wrapper. |
|
|
172
|
-
| `svgText` | `string` | Bundled SVG | Raw SVG text override. |
|
|
173
|
-
| `svgUrl` | `string` | `undefined` | Runtime SVG URL override. |
|
|
174
|
-
| `terrainImageUrl` | `string` | Bundled WebP | Terrain raster URL override. |
|
|
175
|
-
|
|
176
|
-
`EthiopiaMapSurface` reads all map behavior from `EthiopiaMapProvider`.
|
|
177
|
-
|
|
178
|
-
## Panel Components
|
|
179
|
-
|
|
180
|
-
### `EthiopiaMapLegend`
|
|
181
|
-
|
|
182
|
-
Renders a sorted clickable legend using the current provider data.
|
|
183
|
-
|
|
184
|
-
| Prop | Type | Default | Description |
|
|
185
|
-
| --- | --- | --- | --- |
|
|
186
|
-
| `className` | `string` | `undefined` | Extra class for the legend panel. |
|
|
187
|
-
| `title` | `string` | `"Region index"` | Legend heading. |
|
|
188
|
-
| `kicker` | `string` | `"Legend"` | Small label above the heading. |
|
|
189
|
-
| `maxItems` | `number` | All regions | Limit visible legend rows. |
|
|
190
|
-
| `onRegionClick` | `(regionId: EthiopiaRegionId) => void` | `undefined` | Called when a non-active region is clicked. |
|
|
191
|
-
|
|
192
|
-
### `EthiopiaSelectedRegionCard`
|
|
193
|
-
|
|
194
|
-
Shows selected-region copy, preview SVG, and summary stats.
|
|
195
|
-
|
|
196
|
-
| Prop | Type | Default | Description |
|
|
197
|
-
| --- | --- | --- | --- |
|
|
198
|
-
| `className` | `string` | `undefined` | Extra class for the panel. |
|
|
199
|
-
| `emptyTitle` | `string` | `"Click a region"` | Title shown when nothing is selected. |
|
|
200
|
-
| `emptyCopy` | `string` | Built-in helper copy | Body text shown when nothing is selected. |
|
|
201
|
-
| `showStats` | `boolean` | `true` | Show or hide the three summary-stat boxes. |
|
|
202
|
-
| `previewSelectionAnimation` | `SelectionAnimationMode` | Provider value | Override preview animation mode. |
|
|
203
|
-
| `summaryStats` | `(selection) => readonly RegionSummaryStat[]` | Built-in stats | Custom stat rows for the card. |
|
|
204
|
-
| `renderPreview` | `(selection) => ReactNode` | Built-in SVG preview | Replace the selected-region preview area. |
|
|
205
|
-
|
|
206
|
-
### `EthiopiaRegionServicesCard`
|
|
207
|
-
|
|
208
|
-
Shows service indicators for the selected region.
|
|
209
|
-
|
|
210
|
-
| Prop | Type | Default | Description |
|
|
211
|
-
| --- | --- | --- | --- |
|
|
212
|
-
| `className` | `string` | `undefined` | Extra class for the service panel. |
|
|
213
|
-
| `emptyText` | `string` | `"Select a region to inspect service statistics."` | Empty state text. |
|
|
214
|
-
|
|
215
|
-
### `EthiopiaLocationsPanel`
|
|
216
|
-
|
|
217
|
-
Lists provided locations and their coordinates.
|
|
218
|
-
|
|
219
|
-
| Prop | Type | Default | Description |
|
|
220
|
-
| --- | --- | --- | --- |
|
|
221
|
-
| `className` | `string` | `undefined` | Extra class for the locations panel. |
|
|
222
|
-
| `title` | `string` | `"Locations"` | Panel heading. |
|
|
223
|
-
| `kicker` | `string` | `"Lat/lng overlay"` | Small label above the heading. |
|
|
224
|
-
| `showMarkerToggle` | `boolean` | `true` | Show current marker on/off state. |
|
|
225
|
-
|
|
226
|
-
## Data Types
|
|
227
|
-
|
|
228
|
-
### Region Data
|
|
229
|
-
|
|
230
|
-
Each region must be present in the `data` object.
|
|
231
|
-
|
|
232
|
-
```tsx
|
|
233
|
-
import type { RegionRecord, RegionDatum } from "ethio-map-kit";
|
|
234
|
-
|
|
235
|
-
const data: RegionRecord<RegionDatum> = {
|
|
236
|
-
amhara: {
|
|
237
|
-
name: "Amhara",
|
|
238
|
-
value: 78,
|
|
239
|
-
trend: "+12%",
|
|
240
|
-
copy: "High regional index with several sample cities.",
|
|
241
|
-
color: "#176b54",
|
|
242
|
-
summaryStats: [
|
|
243
|
-
{ label: "Index", value: 78 },
|
|
244
|
-
{ label: "Trend", value: "+12%" },
|
|
245
|
-
],
|
|
246
|
-
},
|
|
247
|
-
// include the remaining EthiopiaRegionId keys...
|
|
248
|
-
};
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
Valid region IDs:
|
|
159
|
+
## Service Stats Layouts
|
|
252
160
|
|
|
253
|
-
|
|
254
|
-
tigray
|
|
255
|
-
afar
|
|
256
|
-
amhara
|
|
257
|
-
benishangul-gumuz
|
|
258
|
-
gambela
|
|
259
|
-
south-west-ethiopia
|
|
260
|
-
central-ethiopia
|
|
261
|
-
sidama
|
|
262
|
-
south-ethiopia
|
|
263
|
-
oromia
|
|
264
|
-
addis-ababa
|
|
265
|
-
somali
|
|
266
|
-
dire-dawa
|
|
267
|
-
harari
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
### Service Stats
|
|
271
|
-
|
|
272
|
-
```tsx
|
|
273
|
-
import type { RegionServiceStats } from "ethio-map-kit";
|
|
274
|
-
|
|
275
|
-
const serviceStats: RegionServiceStats = {
|
|
276
|
-
amhara: [
|
|
277
|
-
{
|
|
278
|
-
label: "Maternal death rate",
|
|
279
|
-
valueKind: "percent",
|
|
280
|
-
value: 67,
|
|
281
|
-
comparison: {
|
|
282
|
-
enabled: true,
|
|
283
|
-
percent: 12,
|
|
284
|
-
direction: "increase",
|
|
285
|
-
period: "last month",
|
|
286
|
-
outcome: "negative",
|
|
287
|
-
},
|
|
288
|
-
},
|
|
289
|
-
{
|
|
290
|
-
label: "Hospitals",
|
|
291
|
-
valueKind: "number",
|
|
292
|
-
value: 86,
|
|
293
|
-
comparison: {
|
|
294
|
-
enabled: true,
|
|
295
|
-
percent: 5,
|
|
296
|
-
direction: "increase",
|
|
297
|
-
period: "last year",
|
|
298
|
-
outcome: "positive",
|
|
299
|
-
},
|
|
300
|
-
},
|
|
301
|
-
],
|
|
302
|
-
};
|
|
303
|
-
```
|
|
161
|
+
Service stats can appear inside the map surface, outside the map, or in a standalone details page. Use either the in-map overlay or the external card unless you intentionally want both.
|
|
304
162
|
|
|
305
|
-
|
|
163
|
+
In-map overlay only:
|
|
306
164
|
|
|
307
165
|
```tsx
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
category: "hospital",
|
|
317
|
-
color: "#f7c948",
|
|
318
|
-
radius: 5,
|
|
319
|
-
intensity: 76,
|
|
320
|
-
},
|
|
321
|
-
];
|
|
166
|
+
<EthiopiaMapProvider
|
|
167
|
+
data={defaultRegionData}
|
|
168
|
+
serviceStats={defaultRegionServiceStats}
|
|
169
|
+
showInMapStats
|
|
170
|
+
>
|
|
171
|
+
<EthiopiaMapSurface />
|
|
172
|
+
<EthiopiaSelectedRegionCard />
|
|
173
|
+
</EthiopiaMapProvider>
|
|
322
174
|
```
|
|
323
175
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
### Controlled Selection
|
|
176
|
+
External service card only:
|
|
327
177
|
|
|
328
178
|
```tsx
|
|
329
|
-
|
|
330
|
-
useState<EthiopiaRegionId | null>(null);
|
|
331
|
-
|
|
332
|
-
<EthiopiaMap
|
|
179
|
+
<EthiopiaMapProvider
|
|
333
180
|
data={defaultRegionData}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
181
|
+
serviceStats={defaultRegionServiceStats}
|
|
182
|
+
showInMapStats={false}
|
|
183
|
+
>
|
|
184
|
+
<div className="grid gap-4 lg:grid-cols-[minmax(0,1fr)_320px]">
|
|
185
|
+
<EthiopiaMapSurface className="w-full" style={{ height: 620 }} />
|
|
186
|
+
<EthiopiaRegionServicesCard />
|
|
187
|
+
</div>
|
|
188
|
+
</EthiopiaMapProvider>
|
|
337
189
|
```
|
|
338
190
|
|
|
339
|
-
|
|
191
|
+
Customize the in-map overlay and its scroll list from `EthiopiaMapSurface`:
|
|
340
192
|
|
|
341
193
|
```tsx
|
|
342
|
-
<
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
"addis-ababa": "#dc2626",
|
|
348
|
-
}}
|
|
194
|
+
<EthiopiaMapSurface
|
|
195
|
+
inMapStatsClassName="my-map-stats"
|
|
196
|
+
inMapStatsStyle={{ maxHeight: 320 }}
|
|
197
|
+
inMapStatsListClassName="my-map-stats-list"
|
|
198
|
+
inMapStatsListStyle={{ maxHeight: 240 }}
|
|
349
199
|
/>
|
|
350
200
|
```
|
|
351
201
|
|
|
352
|
-
|
|
202
|
+
Opt in to incremental row rendering when a region has many indicators:
|
|
353
203
|
|
|
354
204
|
```tsx
|
|
355
|
-
<
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
205
|
+
<EthiopiaRegionServicesCard
|
|
206
|
+
incrementalRows={{
|
|
207
|
+
enabled: true,
|
|
208
|
+
initialCount: 8,
|
|
209
|
+
step: 8,
|
|
210
|
+
}}
|
|
359
211
|
/>
|
|
360
212
|
```
|
|
361
213
|
|
|
362
|
-
The
|
|
363
|
-
|
|
364
|
-
### Auto Tour
|
|
214
|
+
The same option works on the in-map overlay:
|
|
365
215
|
|
|
366
216
|
```tsx
|
|
367
|
-
<
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
217
|
+
<EthiopiaMapSurface
|
|
218
|
+
incrementalRows={{
|
|
219
|
+
enabled: true,
|
|
220
|
+
initialCount: 8,
|
|
221
|
+
step: 8,
|
|
222
|
+
thresholdPx: 80,
|
|
223
|
+
}}
|
|
372
224
|
/>
|
|
373
225
|
```
|
|
374
226
|
|
|
375
|
-
The
|
|
376
|
-
|
|
377
|
-
```text
|
|
378
|
-
Afar -> Tigray -> Amhara -> Benishangul-Gumuz -> Gambela -> South West Ethiopia -> South Ethiopia -> Sidama -> Central Ethiopia -> Addis Ababa -> Dire Dawa -> Harari -> Somali -> Oromia -> reset
|
|
379
|
-
```
|
|
380
|
-
|
|
381
|
-
### Custom Selected-Region Preview
|
|
227
|
+
For server-rendered detail pages, fetch data in your app and pass it directly to the context-free panel. The package does not include Prisma, Next.js caching, route generation, ISR, or database fetching.
|
|
382
228
|
|
|
383
229
|
```tsx
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
230
|
+
const services = await getCachedMapsData("afar", 2021, true);
|
|
231
|
+
|
|
232
|
+
return (
|
|
233
|
+
<EthiopiaRegionServicesPanel
|
|
234
|
+
regionName="Afar"
|
|
235
|
+
regionValue={34}
|
|
236
|
+
services={services.afar ?? []}
|
|
237
|
+
/>
|
|
238
|
+
);
|
|
389
239
|
```
|
|
390
240
|
|
|
391
|
-
##
|
|
392
|
-
|
|
393
|
-
The published npm package contains compiled output from `dist` and this README. It does not publish the TypeScript source files or the original private repository structure.
|
|
394
|
-
|
|
395
|
-
This is the normal model for frontend npm packages: consumers receive JavaScript, CSS, type declarations, and assets needed to run the component. The code can still be inspected by determined users after installation, even when it is compiled or minified. Minification and narrow package exports are useful for distribution and casual obfuscation, but they are not a security boundary.
|
|
396
|
-
|
|
397
|
-
The same rule applies to browser deployments: any JavaScript, SVG, image, or CSS needed by a public client-side page can be downloaded by the browser. Keep sensitive business logic on a server if it must be private.
|
|
398
|
-
|
|
399
|
-
## Local Development
|
|
400
|
-
|
|
401
|
-
From the repository root:
|
|
241
|
+
## Exports
|
|
402
242
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
243
|
+
- `EthiopiaMap`
|
|
244
|
+
- `EthiopiaMapProvider`
|
|
245
|
+
- `EthiopiaMapSurface`
|
|
246
|
+
- `EthiopiaMapLegend`
|
|
247
|
+
- `EthiopiaSelectedRegionCard`
|
|
248
|
+
- `EthiopiaRegionServicesCard`
|
|
249
|
+
- `EthiopiaRegionServicesPanel`
|
|
250
|
+
- `EthiopiaLocationsPanel`
|
|
251
|
+
- `useEthiopiaMap`
|
|
252
|
+
- `useSelectedRegionId`
|
|
253
|
+
- `defaultRegionData`
|
|
254
|
+
- `defaultRegionServiceStats`
|
|
255
|
+
- `defaultLocations`
|
|
256
|
+
- `ETHIOPIA_REGION_IDS`
|
|
257
|
+
- `ETHIOPIA_AUTO_TOUR_SEQUENCE`
|
|
409
258
|
|
|
410
|
-
|
|
259
|
+
## Region IDs
|
|
411
260
|
|
|
412
261
|
```text
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
262
|
+
tigray
|
|
263
|
+
afar
|
|
264
|
+
amhara
|
|
265
|
+
benishangul-gumuz
|
|
266
|
+
gambela
|
|
267
|
+
south-west-ethiopia
|
|
268
|
+
central-ethiopia
|
|
269
|
+
sidama
|
|
270
|
+
south-ethiopia
|
|
271
|
+
oromia
|
|
272
|
+
addis-ababa
|
|
273
|
+
somali
|
|
274
|
+
dire-dawa
|
|
275
|
+
harari
|
|
426
276
|
```
|
|
427
|
-
|
|
428
|
-
npm package versions are immutable. If `ethio-map-kit@0.1.0` has already been published, publish the next patch, minor, or major version instead of trying to overwrite it.
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type CSSProperties } from "react";
|
|
2
|
+
import type { EthiopiaMapProps, EthiopiaRegionId, EthiopiaServiceRowsIncrementalConfig } from "../types";
|
|
2
3
|
export interface EthiopiaMapSurfaceProps {
|
|
3
4
|
className?: string;
|
|
5
|
+
style?: CSSProperties;
|
|
4
6
|
svgText?: string;
|
|
5
7
|
svgUrl?: string;
|
|
6
8
|
terrainImageUrl?: string;
|
|
9
|
+
inMapStatsClassName?: string;
|
|
10
|
+
inMapStatsStyle?: CSSProperties;
|
|
11
|
+
inMapStatsListClassName?: string;
|
|
12
|
+
inMapStatsListStyle?: CSSProperties;
|
|
13
|
+
inMapStatsEmptyText?: string;
|
|
14
|
+
incrementalRows?: EthiopiaServiceRowsIncrementalConfig;
|
|
7
15
|
}
|
|
8
|
-
export declare function EthiopiaMapSurface({ className, svgText, svgUrl, terrainImageUrl, }: EthiopiaMapSurfaceProps): import("react").JSX.Element;
|
|
9
|
-
export declare function EthiopiaMap({ className, svgText, svgUrl, terrainImageUrl, ...providerProps }: EthiopiaMapProps): import("react").JSX.Element;
|
|
16
|
+
export declare function EthiopiaMapSurface({ className, style, svgText, svgUrl, terrainImageUrl, inMapStatsClassName, inMapStatsStyle, inMapStatsListClassName, inMapStatsListStyle, inMapStatsEmptyText, incrementalRows, }: EthiopiaMapSurfaceProps): import("react").JSX.Element;
|
|
17
|
+
export declare function EthiopiaMap({ className, style, svgText, svgUrl, terrainImageUrl, inMapStatsClassName, inMapStatsStyle, inMapStatsListClassName, inMapStatsListStyle, inMapStatsEmptyText, incrementalRows, ...providerProps }: EthiopiaMapProps): import("react").JSX.Element;
|
|
10
18
|
export declare function useSelectedRegionId(): EthiopiaRegionId | null;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
import type { EthiopiaServiceRowsIncrementalConfig } from "../types";
|
|
1
3
|
export interface EthiopiaRegionServicesCardProps {
|
|
2
4
|
className?: string;
|
|
5
|
+
style?: CSSProperties;
|
|
6
|
+
listClassName?: string;
|
|
7
|
+
listStyle?: CSSProperties;
|
|
3
8
|
emptyText?: string;
|
|
9
|
+
incrementalRows?: EthiopiaServiceRowsIncrementalConfig;
|
|
4
10
|
}
|
|
5
|
-
export declare function EthiopiaRegionServicesCard({ className, emptyText, }: EthiopiaRegionServicesCardProps): import("react").JSX.Element;
|
|
11
|
+
export declare function EthiopiaRegionServicesCard({ className, style, listClassName, listStyle, emptyText, incrementalRows, }: EthiopiaRegionServicesCardProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type CSSProperties } from "react";
|
|
2
|
+
import type { EthiopiaServiceRowsIncrementalConfig, ServiceStat } from "../types";
|
|
3
|
+
type ServicesPanelVariant = "card" | "overlay";
|
|
4
|
+
export interface EthiopiaRegionServicesPanelProps {
|
|
5
|
+
className?: string;
|
|
6
|
+
style?: CSSProperties;
|
|
7
|
+
listClassName?: string;
|
|
8
|
+
listStyle?: CSSProperties;
|
|
9
|
+
title?: string;
|
|
10
|
+
kicker?: string;
|
|
11
|
+
regionName?: string | null;
|
|
12
|
+
regionValue?: number | null;
|
|
13
|
+
services?: readonly ServiceStat[];
|
|
14
|
+
emptyText?: string;
|
|
15
|
+
variant?: ServicesPanelVariant;
|
|
16
|
+
incrementalRows?: EthiopiaServiceRowsIncrementalConfig;
|
|
17
|
+
getBarPercent?: (stat: ServiceStat) => number;
|
|
18
|
+
}
|
|
19
|
+
export declare function EthiopiaRegionServicesPanel({ className, style, listClassName, listStyle, title, kicker, regionName, regionValue, services, emptyText, variant, incrementalRows, getBarPercent, }: EthiopiaRegionServicesPanelProps): import("react").JSX.Element;
|
|
20
|
+
export {};
|