@geothai/maps-react 0.0.0-stage → 0.1.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/NOTICE +14 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +44 -0
- package/package.json +47 -4
- package/README.md +0 -3
package/NOTICE
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
GeoThai boundaries
|
|
2
|
+
|
|
3
|
+
The boundary lines come from the OCHA COD-AB dataset for Thailand, on the Humanitarian
|
|
4
|
+
Data Exchange, <https://data.humdata.org/dataset/cod-ab-tha>.
|
|
5
|
+
|
|
6
|
+
- Drawn by: Royal Thai Survey Department (กรมแผนที่ทหาร), acquired by ICRC and made
|
|
7
|
+
available by OCHA Field Information Services Section
|
|
8
|
+
- License: Creative Commons Attribution 3.0 IGO (LICENSE)
|
|
9
|
+
- Changes by GeoThai: renamed the p-codes `TH…` to DOPA codes, linked 3 old-code shapes to
|
|
10
|
+
their current subdistricts, simplified the lines to 5% of the points, and dissolved the
|
|
11
|
+
district and province shapes out of the subdistrict layer
|
|
12
|
+
|
|
13
|
+
The subdistrict, district and province codes and names come from GeoThai/data, licensed
|
|
14
|
+
under CC BY 4.0: <https://github.com/GeoThai/data>
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { MapShapes, RenderOptions } from "@geothai/maps/types";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
/** Props of `<GeoThaiMap>`: the map to draw, and how. */
|
|
4
|
+
export type GeoThaiMapProps = RenderOptions & {
|
|
5
|
+
/** `provinces`, or the result of `await districtMap('84')`, from `@geothai/maps`. */
|
|
6
|
+
map: MapShapes;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* A map of Thailand as React elements. It draws the same model as `toSvg()` and
|
|
10
|
+
* `<geothai-map>`, so the markup is the same in every framework.
|
|
11
|
+
*
|
|
12
|
+
* @param props - The map and the options of `render()`.
|
|
13
|
+
* @returns The `<svg>` element.
|
|
14
|
+
* @example
|
|
15
|
+
* import { provinces } from '@geothai/maps';
|
|
16
|
+
* <GeoThaiMap map={provinces} href={(s) => `/provinces/${s.code}/`} />
|
|
17
|
+
*/
|
|
18
|
+
export declare function GeoThaiMap(props: Readonly<GeoThaiMapProps>): ReactElement;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { render } from "@geothai/maps";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
// src/index.tsx
|
|
4
|
+
function Node({ node }) {
|
|
5
|
+
if (node.kind === "line") return /* @__PURE__ */ jsx("path", {
|
|
6
|
+
d: node.d,
|
|
7
|
+
fill: "none",
|
|
8
|
+
stroke: node.stroke,
|
|
9
|
+
strokeWidth: node.width,
|
|
10
|
+
strokeLinejoin: "round",
|
|
11
|
+
vectorEffect: "non-scaling-stroke"
|
|
12
|
+
});
|
|
13
|
+
const path = /* @__PURE__ */ jsx("path", {
|
|
14
|
+
d: node.d,
|
|
15
|
+
fill: node.fill,
|
|
16
|
+
children: /* @__PURE__ */ jsx("title", { children: node.label })
|
|
17
|
+
});
|
|
18
|
+
return node.href ? /* @__PURE__ */ jsx("a", {
|
|
19
|
+
href: node.href,
|
|
20
|
+
children: path
|
|
21
|
+
}) : path;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A map of Thailand as React elements. It draws the same model as `toSvg()` and
|
|
25
|
+
* `<geothai-map>`, so the markup is the same in every framework.
|
|
26
|
+
*
|
|
27
|
+
* @param props - The map and the options of `render()`.
|
|
28
|
+
* @returns The `<svg>` element.
|
|
29
|
+
* @example
|
|
30
|
+
* import { provinces } from '@geothai/maps';
|
|
31
|
+
* <GeoThaiMap map={provinces} href={(s) => `/provinces/${s.code}/`} />
|
|
32
|
+
*/
|
|
33
|
+
function GeoThaiMap(props) {
|
|
34
|
+
const { map, ...options } = props;
|
|
35
|
+
const model = render(map, options);
|
|
36
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
37
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
38
|
+
viewBox: model.viewBox,
|
|
39
|
+
role: "img",
|
|
40
|
+
"aria-label": model.title,
|
|
41
|
+
children: [/* @__PURE__ */ jsx("title", { children: model.title }), model.nodes.map((n) => /* @__PURE__ */ jsx(Node, { node: n }, n.kind === "area" ? n.code : n.key))]
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export { GeoThaiMap };
|
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geothai/maps-react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "React component for maps of Thailand, on DOPA codes",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"choropleth",
|
|
7
|
+
"map",
|
|
8
|
+
"react",
|
|
9
|
+
"svg",
|
|
10
|
+
"thailand"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://geothai.fasu.dev",
|
|
13
|
+
"license": "MIT AND CC-BY-3.0-IGO",
|
|
14
|
+
"author": "Pongsakorn Thipayanate",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/GeoThai/maps.git",
|
|
18
|
+
"directory": "packages/react"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"NOTICE"
|
|
23
|
+
],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"exports": {
|
|
27
|
+
".": "./dist/index.js",
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsdown",
|
|
32
|
+
"test": "bun test",
|
|
33
|
+
"typecheck": "tsc"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@geothai/maps": "^0.1.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@repo/typescript": "workspace:*",
|
|
40
|
+
"@types/react": "19.3.0",
|
|
41
|
+
"@types/react-dom": "19.3.0",
|
|
42
|
+
"react": "19.3.1",
|
|
43
|
+
"react-dom": "19.3.1",
|
|
44
|
+
"tsdown": "0.23.1"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"react": ">=19"
|
|
48
|
+
}
|
|
49
|
+
}
|
package/README.md
DELETED