@travel-match/ui 0.5.1 → 0.7.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/README.md +26 -0
- package/dist/components/ArmeniaRouteMap/ArmeniaRouteMap.cjs +2 -0
- package/dist/components/ArmeniaRouteMap/ArmeniaRouteMap.cjs.map +1 -0
- package/dist/components/ArmeniaRouteMap/ArmeniaRouteMap.js +106 -0
- package/dist/components/ArmeniaRouteMap/ArmeniaRouteMap.js.map +1 -0
- package/dist/components/ArmeniaRouteMap/regionNames.cjs +2 -0
- package/dist/components/ArmeniaRouteMap/regionNames.cjs.map +1 -0
- package/dist/components/ArmeniaRouteMap/regionNames.js +49 -0
- package/dist/components/ArmeniaRouteMap/regionNames.js.map +1 -0
- package/dist/components/GlobeMap/GlobeMap.cjs +2 -0
- package/dist/components/GlobeMap/GlobeMap.cjs.map +1 -0
- package/dist/components/GlobeMap/GlobeMap.js +202 -0
- package/dist/components/GlobeMap/GlobeMap.js.map +1 -0
- package/dist/components/GlobeMap/geo.cjs +2 -0
- package/dist/components/GlobeMap/geo.cjs.map +1 -0
- package/dist/components/GlobeMap/geo.js +150 -0
- package/dist/components/GlobeMap/geo.js.map +1 -0
- package/dist/components/GlobeMap/world.json.cjs +2 -0
- package/dist/components/GlobeMap/world.json.cjs.map +1 -0
- package/dist/components/GlobeMap/world.json.js +28990 -0
- package/dist/components/GlobeMap/world.json.js.map +1 -0
- package/dist/countries/ad.webp +0 -0
- package/dist/countries/ae.webp +0 -0
- package/dist/countries/af.webp +0 -0
- package/dist/countries/al.webp +0 -0
- package/dist/countries/am.webp +0 -0
- package/dist/countries/at.webp +0 -0
- package/dist/countries/az.webp +0 -0
- package/dist/countries/ba.webp +0 -0
- package/dist/countries/bd.webp +0 -0
- package/dist/countries/be.webp +0 -0
- package/dist/countries/bg.webp +0 -0
- package/dist/countries/bn.webp +0 -0
- package/dist/countries/bt.webp +0 -0
- package/dist/countries/by.webp +0 -0
- package/dist/countries/ch.webp +0 -0
- package/dist/countries/cn.webp +0 -0
- package/dist/countries/cy.webp +0 -0
- package/dist/countries/cz.webp +0 -0
- package/dist/countries/de.webp +0 -0
- package/dist/countries/dk.webp +0 -0
- package/dist/countries/ee.webp +0 -0
- package/dist/countries/es.webp +0 -0
- package/dist/countries/fi.webp +0 -0
- package/dist/countries/fr.webp +0 -0
- package/dist/countries/gb.webp +0 -0
- package/dist/countries/ge.webp +0 -0
- package/dist/countries/gr.webp +0 -0
- package/dist/countries/hr.webp +0 -0
- package/dist/countries/hu.webp +0 -0
- package/dist/countries/id.webp +0 -0
- package/dist/countries/ie.webp +0 -0
- package/dist/countries/il.webp +0 -0
- package/dist/countries/in.webp +0 -0
- package/dist/countries/iq.webp +0 -0
- package/dist/countries/ir.webp +0 -0
- package/dist/countries/is.webp +0 -0
- package/dist/countries/it.webp +0 -0
- package/dist/countries/jo.webp +0 -0
- package/dist/countries/jp.webp +0 -0
- package/dist/countries/kg.webp +0 -0
- package/dist/countries/kh.webp +0 -0
- package/dist/countries/kp.webp +0 -0
- package/dist/countries/kr.webp +0 -0
- package/dist/countries/kz.webp +0 -0
- package/dist/countries/la.webp +0 -0
- package/dist/countries/lb.webp +0 -0
- package/dist/countries/li.webp +0 -0
- package/dist/countries/lk.webp +0 -0
- package/dist/countries/lt.webp +0 -0
- package/dist/countries/lu.webp +0 -0
- package/dist/countries/lv.webp +0 -0
- package/dist/countries/mc.webp +0 -0
- package/dist/countries/md.webp +0 -0
- package/dist/countries/me.webp +0 -0
- package/dist/countries/mk.webp +0 -0
- package/dist/countries/mm.webp +0 -0
- package/dist/countries/mn.webp +0 -0
- package/dist/countries/mt.webp +0 -0
- package/dist/countries/mv.webp +0 -0
- package/dist/countries/my.webp +0 -0
- package/dist/countries/nl.webp +0 -0
- package/dist/countries/no.webp +0 -0
- package/dist/countries/np.webp +0 -0
- package/dist/countries/om.webp +0 -0
- package/dist/countries/ph.webp +0 -0
- package/dist/countries/pk.webp +0 -0
- package/dist/countries/pl.webp +0 -0
- package/dist/countries/ps.webp +0 -0
- package/dist/countries/pt.webp +0 -0
- package/dist/countries/ro.webp +0 -0
- package/dist/countries/rs.webp +0 -0
- package/dist/countries/ru.webp +0 -0
- package/dist/countries/sa.webp +0 -0
- package/dist/countries/se.webp +0 -0
- package/dist/countries/sg.webp +0 -0
- package/dist/countries/si.webp +0 -0
- package/dist/countries/sk.webp +0 -0
- package/dist/countries/sm.webp +0 -0
- package/dist/countries/th.webp +0 -0
- package/dist/countries/tj.webp +0 -0
- package/dist/countries/tl.webp +0 -0
- package/dist/countries/tm.webp +0 -0
- package/dist/countries/tr.webp +0 -0
- package/dist/countries/tw.webp +0 -0
- package/dist/countries/ua.webp +0 -0
- package/dist/countries/us.webp +0 -0
- package/dist/countries/uz.webp +0 -0
- package/dist/countries/va.webp +0 -0
- package/dist/countries/vn.webp +0 -0
- package/dist/countries.cjs +2 -0
- package/dist/countries.cjs.map +1 -0
- package/dist/countries.d.cts +101 -0
- package/dist/countries.d.ts +101 -0
- package/dist/countries.js +9 -0
- package/dist/countries.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +80 -0
- package/dist/index.d.ts +80 -0
- package/dist/index.js +34 -31
- package/dist/node_modules/d3-array/dist/d3-array.cjs +2 -0
- package/dist/node_modules/d3-array/dist/d3-array.cjs.map +1 -0
- package/dist/node_modules/d3-array/dist/d3-array.js +90 -0
- package/dist/node_modules/d3-array/dist/d3-array.js.map +1 -0
- package/dist/node_modules/d3-geo/src/area.cjs +2 -0
- package/dist/node_modules/d3-geo/src/area.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/area.js +41 -0
- package/dist/node_modules/d3-geo/src/area.js.map +1 -0
- package/dist/node_modules/d3-geo/src/cartesian.cjs +2 -0
- package/dist/node_modules/d3-geo/src/cartesian.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/cartesian.js +41 -0
- package/dist/node_modules/d3-geo/src/cartesian.js.map +1 -0
- package/dist/node_modules/d3-geo/src/centroid.cjs +2 -0
- package/dist/node_modules/d3-geo/src/centroid.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/centroid.js +66 -0
- package/dist/node_modules/d3-geo/src/centroid.js.map +1 -0
- package/dist/node_modules/d3-geo/src/circle.cjs +2 -0
- package/dist/node_modules/d3-geo/src/circle.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/circle.js +23 -0
- package/dist/node_modules/d3-geo/src/circle.js.map +1 -0
- package/dist/node_modules/d3-geo/src/clip/antimeridian.cjs +2 -0
- package/dist/node_modules/d3-geo/src/clip/antimeridian.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/clip/antimeridian.js +40 -0
- package/dist/node_modules/d3-geo/src/clip/antimeridian.js.map +1 -0
- package/dist/node_modules/d3-geo/src/clip/buffer.cjs +2 -0
- package/dist/node_modules/d3-geo/src/clip/buffer.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/clip/buffer.js +29 -0
- package/dist/node_modules/d3-geo/src/clip/buffer.js.map +1 -0
- package/dist/node_modules/d3-geo/src/clip/circle.cjs +2 -0
- package/dist/node_modules/d3-geo/src/clip/circle.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/clip/circle.js +69 -0
- package/dist/node_modules/d3-geo/src/clip/circle.js.map +1 -0
- package/dist/node_modules/d3-geo/src/clip/index.cjs +2 -0
- package/dist/node_modules/d3-geo/src/clip/index.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/clip/index.js +67 -0
- package/dist/node_modules/d3-geo/src/clip/index.js.map +1 -0
- package/dist/node_modules/d3-geo/src/clip/line.cjs +2 -0
- package/dist/node_modules/d3-geo/src/clip/line.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/clip/line.js +45 -0
- package/dist/node_modules/d3-geo/src/clip/line.js.map +1 -0
- package/dist/node_modules/d3-geo/src/clip/rectangle.cjs +2 -0
- package/dist/node_modules/d3-geo/src/clip/rectangle.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/clip/rectangle.js +73 -0
- package/dist/node_modules/d3-geo/src/clip/rectangle.js.map +1 -0
- package/dist/node_modules/d3-geo/src/clip/rejoin.cjs +2 -0
- package/dist/node_modules/d3-geo/src/clip/rejoin.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/clip/rejoin.js +52 -0
- package/dist/node_modules/d3-geo/src/clip/rejoin.js.map +1 -0
- package/dist/node_modules/d3-geo/src/compose.cjs +2 -0
- package/dist/node_modules/d3-geo/src/compose.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/compose.js +13 -0
- package/dist/node_modules/d3-geo/src/compose.js.map +1 -0
- package/dist/node_modules/d3-geo/src/distance.cjs +2 -0
- package/dist/node_modules/d3-geo/src/distance.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/distance.js +13 -0
- package/dist/node_modules/d3-geo/src/distance.js.map +1 -0
- package/dist/node_modules/d3-geo/src/identity.cjs +2 -0
- package/dist/node_modules/d3-geo/src/identity.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/identity.js +6 -0
- package/dist/node_modules/d3-geo/src/identity.js.map +1 -0
- package/dist/node_modules/d3-geo/src/interpolate.cjs +2 -0
- package/dist/node_modules/d3-geo/src/interpolate.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/interpolate.js +15 -0
- package/dist/node_modules/d3-geo/src/interpolate.js.map +1 -0
- package/dist/node_modules/d3-geo/src/length.cjs +2 -0
- package/dist/node_modules/d3-geo/src/length.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/length.js +34 -0
- package/dist/node_modules/d3-geo/src/length.js.map +1 -0
- package/dist/node_modules/d3-geo/src/math.cjs +2 -0
- package/dist/node_modules/d3-geo/src/math.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/math.js +17 -0
- package/dist/node_modules/d3-geo/src/math.js.map +1 -0
- package/dist/node_modules/d3-geo/src/noop.cjs +2 -0
- package/dist/node_modules/d3-geo/src/noop.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/noop.js +6 -0
- package/dist/node_modules/d3-geo/src/noop.js.map +1 -0
- package/dist/node_modules/d3-geo/src/path/area.cjs +2 -0
- package/dist/node_modules/d3-geo/src/path/area.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/path/area.js +35 -0
- package/dist/node_modules/d3-geo/src/path/area.js.map +1 -0
- package/dist/node_modules/d3-geo/src/path/bounds.cjs +2 -0
- package/dist/node_modules/d3-geo/src/path/bounds.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/path/bounds.js +20 -0
- package/dist/node_modules/d3-geo/src/path/bounds.js.map +1 -0
- package/dist/node_modules/d3-geo/src/path/centroid.cjs +2 -0
- package/dist/node_modules/d3-geo/src/path/centroid.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/path/centroid.js +50 -0
- package/dist/node_modules/d3-geo/src/path/centroid.js.map +1 -0
- package/dist/node_modules/d3-geo/src/path/context.cjs +2 -0
- package/dist/node_modules/d3-geo/src/path/context.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/path/context.js +40 -0
- package/dist/node_modules/d3-geo/src/path/context.js.map +1 -0
- package/dist/node_modules/d3-geo/src/path/index.cjs +2 -0
- package/dist/node_modules/d3-geo/src/path/index.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/path/index.js +43 -0
- package/dist/node_modules/d3-geo/src/path/index.js.map +1 -0
- package/dist/node_modules/d3-geo/src/path/measure.cjs +2 -0
- package/dist/node_modules/d3-geo/src/path/measure.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/path/measure.js +33 -0
- package/dist/node_modules/d3-geo/src/path/measure.js.map +1 -0
- package/dist/node_modules/d3-geo/src/path/string.cjs +2 -0
- package/dist/node_modules/d3-geo/src/path/string.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/path/string.js +64 -0
- package/dist/node_modules/d3-geo/src/path/string.js.map +1 -0
- package/dist/node_modules/d3-geo/src/pointEqual.cjs +2 -0
- package/dist/node_modules/d3-geo/src/pointEqual.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/pointEqual.js +9 -0
- package/dist/node_modules/d3-geo/src/pointEqual.js.map +1 -0
- package/dist/node_modules/d3-geo/src/polygonContains.cjs +2 -0
- package/dist/node_modules/d3-geo/src/polygonContains.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/polygonContains.js +31 -0
- package/dist/node_modules/d3-geo/src/polygonContains.js.map +1 -0
- package/dist/node_modules/d3-geo/src/projection/azimuthal.cjs +2 -0
- package/dist/node_modules/d3-geo/src/projection/azimuthal.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/projection/azimuthal.js +12 -0
- package/dist/node_modules/d3-geo/src/projection/azimuthal.js.map +1 -0
- package/dist/node_modules/d3-geo/src/projection/fit.cjs +2 -0
- package/dist/node_modules/d3-geo/src/projection/fit.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/projection/fit.js +32 -0
- package/dist/node_modules/d3-geo/src/projection/fit.js.map +1 -0
- package/dist/node_modules/d3-geo/src/projection/index.cjs +2 -0
- package/dist/node_modules/d3-geo/src/projection/index.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/projection/index.js +105 -0
- package/dist/node_modules/d3-geo/src/projection/index.js.map +1 -0
- package/dist/node_modules/d3-geo/src/projection/orthographic.cjs +2 -0
- package/dist/node_modules/d3-geo/src/projection/orthographic.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/projection/orthographic.js +15 -0
- package/dist/node_modules/d3-geo/src/projection/orthographic.js.map +1 -0
- package/dist/node_modules/d3-geo/src/projection/resample.cjs +2 -0
- package/dist/node_modules/d3-geo/src/projection/resample.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/projection/resample.js +62 -0
- package/dist/node_modules/d3-geo/src/projection/resample.js.map +1 -0
- package/dist/node_modules/d3-geo/src/rotation.cjs +2 -0
- package/dist/node_modules/d3-geo/src/rotation.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/rotation.js +34 -0
- package/dist/node_modules/d3-geo/src/rotation.js.map +1 -0
- package/dist/node_modules/d3-geo/src/stream.cjs +2 -0
- package/dist/node_modules/d3-geo/src/stream.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/stream.js +54 -0
- package/dist/node_modules/d3-geo/src/stream.js.map +1 -0
- package/dist/node_modules/d3-geo/src/transform.cjs +2 -0
- package/dist/node_modules/d3-geo/src/transform.cjs.map +1 -0
- package/dist/node_modules/d3-geo/src/transform.js +34 -0
- package/dist/node_modules/d3-geo/src/transform.js.map +1 -0
- package/dist/node_modules/topojson-client/src/feature.cjs +2 -0
- package/dist/node_modules/topojson-client/src/feature.cjs.map +1 -0
- package/dist/node_modules/topojson-client/src/feature.js +89 -0
- package/dist/node_modules/topojson-client/src/feature.js.map +1 -0
- package/dist/node_modules/topojson-client/src/identity.cjs +2 -0
- package/dist/node_modules/topojson-client/src/identity.cjs.map +1 -0
- package/dist/node_modules/topojson-client/src/identity.js +8 -0
- package/dist/node_modules/topojson-client/src/identity.js.map +1 -0
- package/dist/node_modules/topojson-client/src/reverse.cjs +2 -0
- package/dist/node_modules/topojson-client/src/reverse.cjs.map +1 -0
- package/dist/node_modules/topojson-client/src/reverse.js +8 -0
- package/dist/node_modules/topojson-client/src/reverse.js.map +1 -0
- package/dist/node_modules/topojson-client/src/transform.cjs +2 -0
- package/dist/node_modules/topojson-client/src/transform.cjs.map +1 -0
- package/dist/node_modules/topojson-client/src/transform.js +16 -0
- package/dist/node_modules/topojson-client/src/transform.js.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +22 -2
package/README.md
CHANGED
|
@@ -80,6 +80,32 @@ Components are client components (`'use client'` is baked into the bundle) and c
|
|
|
80
80
|
|
|
81
81
|
Naming rule: take the Figma variable name, lower-case it, replace `/` and spaces with `-`, prefix `--tm-`. `Line Height/H1` → `--tm-line-height-h1`. This is also how Figma MCP output (`var(--primary\/default)`) maps to code.
|
|
82
82
|
|
|
83
|
+
### Country photos
|
|
84
|
+
|
|
85
|
+
89 country card photos (1536×1024 WebP, about 330 KB each) ship in the package as `@travel-match/ui/countries/<code>.webp` (lowercase ISO 3166-1 alpha-2 code, e.g. `am.webp`). The prompts they were generated from are in `assets/countries/generation.json` (repo only, not published).
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
import { getCountryImage, countryImageCodes } from '@travel-match/ui/countries';
|
|
89
|
+
|
|
90
|
+
getCountryImage('AM'); // '/images/countries/am.webp'
|
|
91
|
+
getCountryImage('am', { baseUrl: 'https://cdn.example/countries' }); // 'https://cdn.example/countries/am.webp'
|
|
92
|
+
getCountryImage('ZZ'); // undefined — no photo, show a fallback
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The helper only builds URLs; the app serves the files. In a Next.js app, copy them into `public/` before `dev` and `build` and keep the copy out of git:
|
|
96
|
+
|
|
97
|
+
```jsonc
|
|
98
|
+
// package.json
|
|
99
|
+
"predev": "cp -r node_modules/@travel-match/ui/dist/countries public/images/",
|
|
100
|
+
"prebuild": "cp -r node_modules/@travel-match/ui/dist/countries public/images/"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
```gitignore
|
|
104
|
+
/public/images/countries
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
To serve them from object storage or a CDN instead, upload `dist/countries` and pass its URL as `baseUrl`. New photos go into `assets/countries/` (same size and style); the test fails until the file and `countryImageCodes` in `src/countries/index.ts` match.
|
|
108
|
+
|
|
83
109
|
## Develop
|
|
84
110
|
|
|
85
111
|
```bash
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";const e=require("../../utils/cn.cjs"),t=require("../RegionMap/mapPaths.cjs"),n=require("./regionNames.cjs");;/* empty css */let r=require("react"),i=require("react/jsx-runtime");var a=390,o=300,s=50,c=4,l=292/t.ARMENIA_MAP.width,u={Yerevan:[149,141],Kotayk:[165,109],Aragatsotn:[119,111],Gegharkunik:[223,124],Armavir:[103,142],Shirak:[87,62],Ararat:[173,166],Tavush:[203,51],Lori:[143,43],Syunik:[299,237],"Vayots Dzor":[233,189]};function d([e,t],[n,r]){let i=.1,a=(e+n)/2+(r-t)*i,o=(t+r)/2-(n-e)*i;return`M${e} ${t}Q${a.toFixed(1)} ${o.toFixed(1)} ${n} ${r}`}var f=(0,r.forwardRef)(function({start:f=null,stops:p=[],locale:m=`en`,className:h,...g},_){let v=`tm-route-map${(0,r.useId)().replace(/[^a-zA-Z0-9_-]/g,``)}`,y=p.filter((e,t)=>e!==f&&p.indexOf(e)===t),b=new Set(y),x=f?u[f]:null,S=(e,t)=>{let[r,s]=u[e],c={"--_x":`${r/a*100}%`,"--_y":`${s/o*100}%`};return(0,i.jsx)(`span`,{className:`tm-route-map__label`,"data-side":t,"data-region":e,style:c,children:n.getArmeniaRegionName(e,m)},e)};return(0,i.jsx)(`div`,{ref:_,className:e.cn(`tm-route-map`,h),...g,children:(0,i.jsxs)(`div`,{className:`tm-route-map__area`,children:[(0,i.jsxs)(`svg`,{className:`tm-route-map__svg`,viewBox:`0 0 ${a} ${o}`,"aria-hidden":`true`,focusable:`false`,children:[(0,i.jsx)(`defs`,{children:t.ARMENIA_MAP.regions.map(([e,t],n)=>(0,i.jsx)(`clipPath`,{id:`${v}-${n}`,children:(0,i.jsx)(`path`,{d:t})},e))}),(0,i.jsx)(`g`,{transform:`translate(${s} ${c}) scale(${l})`,children:t.ARMENIA_MAP.regions.map(([e,n],r)=>(0,i.jsx)(`path`,{className:`tm-route-map__region`,d:n,"data-region":e,"data-state":e===f?`start`:b.has(e)?`stop`:void 0,strokeWidth:t.ARMENIA_MAP.strokeWidth*2,clipPath:`url(#${v}-${r})`},e))}),x?y.map(e=>{let t=d(x,u[e]);return(0,i.jsxs)(`g`,{className:`tm-route-map__route`,"data-region":e,children:[(0,i.jsx)(`path`,{className:`tm-route-map__route-edge`,d:t}),(0,i.jsx)(`path`,{className:`tm-route-map__route-dots`,d:t})]},e)}):null,y.map(e=>(0,i.jsx)(`circle`,{className:`tm-route-map__pin`,"data-kind":`stop`,cx:u[e][0],cy:u[e][1],r:3.25},e)),x?(0,i.jsx)(`circle`,{className:`tm-route-map__pin`,"data-kind":`start`,cx:x[0],cy:x[1],r:4}):null]}),y.map(e=>S(e,x&&u[e][0]<x[0]?`left`:`right`)),f?S(f,`below`):null]})})});exports.ArmeniaRouteMap=f;
|
|
2
|
+
//# sourceMappingURL=ArmeniaRouteMap.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArmeniaRouteMap.cjs","names":["ARMENIA_MAP","useId","getArmeniaRegionName","cn","require_cn","require_mapPaths","require_regionNames","react","react_jsx_runtime","WIDTH","HEIGHT","MAP_X","MAP_Y","MAP_SCALE","PINS","routePath","x0","y0","x1","y1","bow","cx","cy","ArmeniaRouteMap","props","prefix","destinations","stops","region","start","index","chosen","origin","label","x","y","style","side","locale","className","name","d"],"sources":["../../../src/components/ArmeniaRouteMap/ArmeniaRouteMap.tsx"],"sourcesContent":["import { forwardRef, useId, type CSSProperties, type HTMLAttributes } from 'react';\nimport { cn } from '../../utils/cn';\nimport type { ArmeniaRegion } from '../RegionMap/RegionMap';\nimport { ARMENIA_MAP } from '../RegionMap/mapPaths';\nimport { getArmeniaRegionName } from './regionNames';\nimport './ArmeniaRouteMap.css';\n\nexport interface ArmeniaRouteMapProps extends HTMLAttributes<HTMLDivElement> {\n /** Region the trip starts from: filled in blue with a white pin, every route begins here. */\n start?: ArmeniaRegion | null;\n /** Regions the trip goes to, in order: filled in navy, each with a pin and a dotted route from `start`. */\n stops?: readonly ArmeniaRegion[];\n /** Language of the region labels: `'en'`, `'hy'` or `'ru'` (any BCP 47 tag such as `'hy-AM'` works). Default `'en'`. */\n locale?: string;\n}\n\n/* Frame \"Map area\" in Figma: 390×300 px; \"Map / Armenia\" is placed at 50,4 and scaled to 292 px wide. */\nconst WIDTH = 390;\nconst HEIGHT = 300;\nconst MAP_X = 50;\nconst MAP_Y = 4;\nconst MAP_SCALE = 292 / ARMENIA_MAP.width;\n\n/**\n * Pin position of each region, in px of the 390×300 frame. Yerevan, Kotayk and Aragatsotn are the Figma pins\n * (2978:23664…23666); the others are the centroid of the region's main outline.\n */\nconst PINS: Record<ArmeniaRegion, readonly [number, number]> = {\n Yerevan: [149, 141],\n Kotayk: [165, 109],\n Aragatsotn: [119, 111],\n Gegharkunik: [223, 124],\n Armavir: [103, 142],\n Shirak: [87, 62],\n Ararat: [173, 166],\n Tavush: [203, 51],\n Lori: [143, 43],\n Syunik: [299, 237],\n 'Vayots Dzor': [233, 189],\n};\n\ntype LabelSide = 'below' | 'left' | 'right';\n\n/**\n * A route from the start to a stop: a slight arc, bowed to the left by 10% of its length. Figma's two short routes\n * are almost straight; the bow grows with the length so long routes in the same direction do not overlap.\n */\nfunction routePath([x0, y0]: readonly [number, number], [x1, y1]: readonly [number, number]): string {\n const bow = 0.1;\n const cx = (x0 + x1) / 2 + (y1 - y0) * bow;\n const cy = (y0 + y1) / 2 - (x1 - x0) * bow;\n return `M${x0} ${y0}Q${cx.toFixed(1)} ${cy.toFixed(1)} ${x1} ${y1}`;\n}\n\n/**\n * Figma \"Map\" with a route (2978:23659): the Armenia map in a card, with the starting region in blue, the chosen\n * regions in navy, a pin and a label on each, and a dotted route from the start to every stop. Pass the\n * selection from the request form; the map updates as it changes. Scales to the width of its container.\n */\nexport const ArmeniaRouteMap = /* @__PURE__ */ forwardRef<HTMLDivElement, ArmeniaRouteMapProps>(function ArmeniaRouteMap(\n { start = null, stops = [], locale = 'en', className, ...props },\n ref,\n) {\n // useId() returns characters (\":\", \"«\") that are awkward inside url(#…); keep only safe ones.\n const prefix = `tm-route-map${useId().replace(/[^a-zA-Z0-9_-]/g, '')}`;\n const destinations = stops.filter((region, index) => region !== start && stops.indexOf(region) === index);\n const chosen = new Set(destinations);\n const origin = start ? PINS[start] : null;\n\n const label = (region: ArmeniaRegion, side: LabelSide) => {\n const [x, y] = PINS[region];\n const style = { '--_x': `${(x / WIDTH) * 100}%`, '--_y': `${(y / HEIGHT) * 100}%` } as CSSProperties;\n return (\n <span key={region} className=\"tm-route-map__label\" data-side={side} data-region={region} style={style}>\n {getArmeniaRegionName(region, locale)}\n </span>\n );\n };\n\n return (\n <div ref={ref} className={cn('tm-route-map', className)} {...props}>\n <div className=\"tm-route-map__area\">\n <svg className=\"tm-route-map__svg\" viewBox={`0 0 ${WIDTH} ${HEIGHT}`} aria-hidden=\"true\" focusable=\"false\">\n <defs>\n {ARMENIA_MAP.regions.map(([name, d], index) => (\n <clipPath key={name} id={`${prefix}-${index}`}>\n <path d={d} />\n </clipPath>\n ))}\n </defs>\n <g transform={`translate(${MAP_X} ${MAP_Y}) scale(${MAP_SCALE})`}>\n {ARMENIA_MAP.regions.map(([name, d], index) => (\n <path\n key={name}\n className=\"tm-route-map__region\"\n d={d}\n data-region={name}\n data-state={name === start ? 'start' : chosen.has(name) ? 'stop' : undefined}\n // Figma strokes the regions on the inside: a centred stroke of twice the width, clipped to the shape.\n strokeWidth={ARMENIA_MAP.strokeWidth * 2}\n clipPath={`url(#${prefix}-${index})`}\n />\n ))}\n </g>\n {origin\n ? destinations.map((region) => {\n const d = routePath(origin, PINS[region]);\n return (\n <g key={region} className=\"tm-route-map__route\" data-region={region}>\n <path className=\"tm-route-map__route-edge\" d={d} />\n <path className=\"tm-route-map__route-dots\" d={d} />\n </g>\n );\n })\n : null}\n {destinations.map((region) => (\n <circle key={region} className=\"tm-route-map__pin\" data-kind=\"stop\" cx={PINS[region][0]} cy={PINS[region][1]} r={3.25} />\n ))}\n {origin ? <circle className=\"tm-route-map__pin\" data-kind=\"start\" cx={origin[0]} cy={origin[1]} r={4} /> : null}\n </svg>\n {destinations.map((region) => label(region, origin && PINS[region][0] < origin[0] ? 'left' : 'right'))}\n {start ? label(start, 'below') : null}\n </div>\n </div>\n );\n});\n"],"mappings":"A,oNAiBA,IAAMS,EAAQ,IACRC,EAAS,IACTC,EAAQ,GACRC,EAAQ,EACRC,EAAY,IAAMb,EAAAA,YAAY,MAM9Bc,EAAyD,CAC7D,QAAS,CAAC,IAAK,GAAG,EAClB,O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A,IAAA,CAAC,OAAD,CAAM,UAAU,2BAA8B,GAAI,CAAA,GAClD,EAAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,2BAA8B,GAAI,CAAA,CACjD,CAHK,EAAAoB,CAGL,CAEP,CAAC,EACD,KACHF,EAAa,IAAK,IACjB,EAAAlB,EAAA,IAAA,CAAC,SAAD,CAAqB,UAAU,oBAAoB,YAAU,OAAO,GAAIM,EAAKc,EAAO,CAAC,GAAI,GAAId,EAAKc,EAAO,CAAC,GAAI,EAAG,IAAO,EAA3GA,CAA2G,CACzH,EACAI,GAAS,EAAAxB,EAAA,IAAA,CAAC,SAAD,CAAQ,UAAU,oBAAoB,YAAU,QAAQ,GAAIwB,EAAO,GAAI,GAAIA,EAAO,GAAI,EAAG,CAAI,CAAA,EAAI,IACxG,C,GACJN,EAAa,IAAK,GAAWO,EAAML,EAAQI,GAAUlB,EAAKc,EAAO,CAAC,GAAKI,EAAO,GAAK,OAAS,OAAO,CAAC,EACpGH,EAAQI,EAAMJ,EAAO,OAAO,EAAI,IAC9B,C,EACF,CAAA,CAET,CAAC,E"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../utils/cn.js";
|
|
3
|
+
import { ARMENIA_MAP as t } from "../RegionMap/mapPaths.js";
|
|
4
|
+
import { getArmeniaRegionName as n } from "./regionNames.js";
|
|
5
|
+
/* empty css */
|
|
6
|
+
import { forwardRef as r, useId as i } from "react";
|
|
7
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
8
|
+
// src/components/ArmeniaRouteMap/ArmeniaRouteMap.tsx
|
|
9
|
+
var s = 390, c = 300, l = 50, u = 4, d = 292 / t.width, f = {
|
|
10
|
+
Yerevan: [149, 141],
|
|
11
|
+
Kotayk: [165, 109],
|
|
12
|
+
Aragatsotn: [119, 111],
|
|
13
|
+
Gegharkunik: [223, 124],
|
|
14
|
+
Armavir: [103, 142],
|
|
15
|
+
Shirak: [87, 62],
|
|
16
|
+
Ararat: [173, 166],
|
|
17
|
+
Tavush: [203, 51],
|
|
18
|
+
Lori: [143, 43],
|
|
19
|
+
Syunik: [299, 237],
|
|
20
|
+
"Vayots Dzor": [233, 189]
|
|
21
|
+
};
|
|
22
|
+
function p([e, t], [n, r]) {
|
|
23
|
+
let i = .1, a = (e + n) / 2 + (r - t) * i, o = (t + r) / 2 - (n - e) * i;
|
|
24
|
+
return `M${e} ${t}Q${a.toFixed(1)} ${o.toFixed(1)} ${n} ${r}`;
|
|
25
|
+
}
|
|
26
|
+
var m = /* @__PURE__ */ r(function({ start: r = null, stops: m = [], locale: h = "en", className: g, ..._ }, v) {
|
|
27
|
+
let y = `tm-route-map${i().replace(/[^a-zA-Z0-9_-]/g, "")}`, b = m.filter((e, t) => e !== r && m.indexOf(e) === t), x = new Set(b), S = r ? f[r] : null, C = (e, t) => {
|
|
28
|
+
let [r, i] = f[e], o = {
|
|
29
|
+
"--_x": `${r / s * 100}%`,
|
|
30
|
+
"--_y": `${i / c * 100}%`
|
|
31
|
+
};
|
|
32
|
+
return /* @__PURE__ */ a("span", {
|
|
33
|
+
className: "tm-route-map__label",
|
|
34
|
+
"data-side": t,
|
|
35
|
+
"data-region": e,
|
|
36
|
+
style: o,
|
|
37
|
+
children: n(e, h)
|
|
38
|
+
}, e);
|
|
39
|
+
};
|
|
40
|
+
return /* @__PURE__ */ a("div", {
|
|
41
|
+
ref: v,
|
|
42
|
+
className: e("tm-route-map", g),
|
|
43
|
+
..._,
|
|
44
|
+
children: /* @__PURE__ */ o("div", {
|
|
45
|
+
className: "tm-route-map__area",
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ o("svg", {
|
|
48
|
+
className: "tm-route-map__svg",
|
|
49
|
+
viewBox: `0 0 ${s} ${c}`,
|
|
50
|
+
"aria-hidden": "true",
|
|
51
|
+
focusable: "false",
|
|
52
|
+
children: [
|
|
53
|
+
/* @__PURE__ */ a("defs", { children: t.regions.map(([e, t], n) => /* @__PURE__ */ a("clipPath", {
|
|
54
|
+
id: `${y}-${n}`,
|
|
55
|
+
children: /* @__PURE__ */ a("path", { d: t })
|
|
56
|
+
}, e)) }),
|
|
57
|
+
/* @__PURE__ */ a("g", {
|
|
58
|
+
transform: `translate(${l} ${u}) scale(${d})`,
|
|
59
|
+
children: t.regions.map(([e, n], i) => /* @__PURE__ */ a("path", {
|
|
60
|
+
className: "tm-route-map__region",
|
|
61
|
+
d: n,
|
|
62
|
+
"data-region": e,
|
|
63
|
+
"data-state": e === r ? "start" : x.has(e) ? "stop" : void 0,
|
|
64
|
+
strokeWidth: t.strokeWidth * 2,
|
|
65
|
+
clipPath: `url(#${y}-${i})`
|
|
66
|
+
}, e))
|
|
67
|
+
}),
|
|
68
|
+
S ? b.map((e) => {
|
|
69
|
+
let t = p(S, f[e]);
|
|
70
|
+
return /* @__PURE__ */ o("g", {
|
|
71
|
+
className: "tm-route-map__route",
|
|
72
|
+
"data-region": e,
|
|
73
|
+
children: [/* @__PURE__ */ a("path", {
|
|
74
|
+
className: "tm-route-map__route-edge",
|
|
75
|
+
d: t
|
|
76
|
+
}), /* @__PURE__ */ a("path", {
|
|
77
|
+
className: "tm-route-map__route-dots",
|
|
78
|
+
d: t
|
|
79
|
+
})]
|
|
80
|
+
}, e);
|
|
81
|
+
}) : null,
|
|
82
|
+
b.map((e) => /* @__PURE__ */ a("circle", {
|
|
83
|
+
className: "tm-route-map__pin",
|
|
84
|
+
"data-kind": "stop",
|
|
85
|
+
cx: f[e][0],
|
|
86
|
+
cy: f[e][1],
|
|
87
|
+
r: 3.25
|
|
88
|
+
}, e)),
|
|
89
|
+
S ? /* @__PURE__ */ a("circle", {
|
|
90
|
+
className: "tm-route-map__pin",
|
|
91
|
+
"data-kind": "start",
|
|
92
|
+
cx: S[0],
|
|
93
|
+
cy: S[1],
|
|
94
|
+
r: 4
|
|
95
|
+
}) : null
|
|
96
|
+
]
|
|
97
|
+
}),
|
|
98
|
+
b.map((e) => C(e, S && f[e][0] < S[0] ? "left" : "right")),
|
|
99
|
+
r ? C(r, "below") : null
|
|
100
|
+
]
|
|
101
|
+
})
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
export { m as ArmeniaRouteMap };
|
|
105
|
+
|
|
106
|
+
//# sourceMappingURL=ArmeniaRouteMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArmeniaRouteMap.js","names":["WIDTH","HEIGHT","MAP_X","MAP_Y","MAP_SCALE","ARMENIA_MAP","PINS","routePath","x0","y0","x1","y1","bow","cx","cy","ArmeniaRouteMap","props","prefix","useId","destinations","stops","region","start","index","chosen","origin","label","x","y","style","side","getArmeniaRegionName","locale","cn","className","name","d"],"sources":["../../../src/components/ArmeniaRouteMap/ArmeniaRouteMap.tsx"],"sourcesContent":["import { forwardRef, useId, type CSSProperties, type HTMLAttributes } from 'react';\nimport { cn } from '../../utils/cn';\nimport type { ArmeniaRegion } from '../RegionMap/RegionMap';\nimport { ARMENIA_MAP } from '../RegionMap/mapPaths';\nimport { getArmeniaRegionName } from './regionNames';\nimport './ArmeniaRouteMap.css';\n\nexport interface ArmeniaRouteMapProps extends HTMLAttributes<HTMLDivElement> {\n /** Region the trip starts from: filled in blue with a white pin, every route begins here. */\n start?: ArmeniaRegion | null;\n /** Regions the trip goes to, in order: filled in navy, each with a pin and a dotted route from `start`. */\n stops?: readonly ArmeniaRegion[];\n /** Language of the region labels: `'en'`, `'hy'` or `'ru'` (any BCP 47 tag such as `'hy-AM'` works). Default `'en'`. */\n locale?: string;\n}\n\n/* Frame \"Map area\" in Figma: 390×300 px; \"Map / Armenia\" is placed at 50,4 and scaled to 292 px wide. */\nconst WIDTH = 390;\nconst HEIGHT = 300;\nconst MAP_X = 50;\nconst MAP_Y = 4;\nconst MAP_SCALE = 292 / ARMENIA_MAP.width;\n\n/**\n * Pin position of each region, in px of the 390×300 frame. Yerevan, Kotayk and Aragatsotn are the Figma pins\n * (2978:23664…23666); the others are the centroid of the region's main outline.\n */\nconst PINS: Record<ArmeniaRegion, readonly [number, number]> = {\n Yerevan: [149, 141],\n Kotayk: [165, 109],\n Aragatsotn: [119, 111],\n Gegharkunik: [223, 124],\n Armavir: [103, 142],\n Shirak: [87, 62],\n Ararat: [173, 166],\n Tavush: [203, 51],\n Lori: [143, 43],\n Syunik: [299, 237],\n 'Vayots Dzor': [233, 189],\n};\n\ntype LabelSide = 'below' | 'left' | 'right';\n\n/**\n * A route from the start to a stop: a slight arc, bowed to the left by 10% of its length. Figma's two short routes\n * are almost straight; the bow grows with the length so long routes in the same direction do not overlap.\n */\nfunction routePath([x0, y0]: readonly [number, number], [x1, y1]: readonly [number, number]): string {\n const bow = 0.1;\n const cx = (x0 + x1) / 2 + (y1 - y0) * bow;\n const cy = (y0 + y1) / 2 - (x1 - x0) * bow;\n return `M${x0} ${y0}Q${cx.toFixed(1)} ${cy.toFixed(1)} ${x1} ${y1}`;\n}\n\n/**\n * Figma \"Map\" with a route (2978:23659): the Armenia map in a card, with the starting region in blue, the chosen\n * regions in navy, a pin and a label on each, and a dotted route from the start to every stop. Pass the\n * selection from the request form; the map updates as it changes. Scales to the width of its container.\n */\nexport const ArmeniaRouteMap = /* @__PURE__ */ forwardRef<HTMLDivElement, ArmeniaRouteMapProps>(function ArmeniaRouteMap(\n { start = null, stops = [], locale = 'en', className, ...props },\n ref,\n) {\n // useId() returns characters (\":\", \"«\") that are awkward inside url(#…); keep only safe ones.\n const prefix = `tm-route-map${useId().replace(/[^a-zA-Z0-9_-]/g, '')}`;\n const destinations = stops.filter((region, index) => region !== start && stops.indexOf(region) === index);\n const chosen = new Set(destinations);\n const origin = start ? PINS[start] : null;\n\n const label = (region: ArmeniaRegion, side: LabelSide) => {\n const [x, y] = PINS[region];\n const style = { '--_x': `${(x / WIDTH) * 100}%`, '--_y': `${(y / HEIGHT) * 100}%` } as CSSProperties;\n return (\n <span key={region} className=\"tm-route-map__label\" data-side={side} data-region={region} style={style}>\n {getArmeniaRegionName(region, locale)}\n </span>\n );\n };\n\n return (\n <div ref={ref} className={cn('tm-route-map', className)} {...props}>\n <div className=\"tm-route-map__area\">\n <svg className=\"tm-route-map__svg\" viewBox={`0 0 ${WIDTH} ${HEIGHT}`} aria-hidden=\"true\" focusable=\"false\">\n <defs>\n {ARMENIA_MAP.regions.map(([name, d], index) => (\n <clipPath key={name} id={`${prefix}-${index}`}>\n <path d={d} />\n </clipPath>\n ))}\n </defs>\n <g transform={`translate(${MAP_X} ${MAP_Y}) scale(${MAP_SCALE})`}>\n {ARMENIA_MAP.regions.map(([name, d], index) => (\n <path\n key={name}\n className=\"tm-route-map__region\"\n d={d}\n data-region={name}\n data-state={name === start ? 'start' : chosen.has(name) ? 'stop' : undefined}\n // Figma strokes the regions on the inside: a centred stroke of twice the width, clipped to the shape.\n strokeWidth={ARMENIA_MAP.strokeWidth * 2}\n clipPath={`url(#${prefix}-${index})`}\n />\n ))}\n </g>\n {origin\n ? destinations.map((region) => {\n const d = routePath(origin, PINS[region]);\n return (\n <g key={region} className=\"tm-route-map__route\" data-region={region}>\n <path className=\"tm-route-map__route-edge\" d={d} />\n <path className=\"tm-route-map__route-dots\" d={d} />\n </g>\n );\n })\n : null}\n {destinations.map((region) => (\n <circle key={region} className=\"tm-route-map__pin\" data-kind=\"stop\" cx={PINS[region][0]} cy={PINS[region][1]} r={3.25} />\n ))}\n {origin ? <circle className=\"tm-route-map__pin\" data-kind=\"start\" cx={origin[0]} cy={origin[1]} r={4} /> : null}\n </svg>\n {destinations.map((region) => label(region, origin && PINS[region][0] < origin[0] ? 'left' : 'right'))}\n {start ? label(start, 'below') : null}\n </div>\n </div>\n );\n});\n"],"mappings":";;;;;;;;AAiBA,IAAMA,IAAQ,KACRC,IAAS,KACTC,IAAQ,IACRC,IAAQ,GACRC,IAAY,MAAMC,EAAY,OAM9BC,IAAyD;CAC7D,SAAS,CAAC,KAAK,GAAG;CAClB,QAAQ,CAAC,KAAK,GAAG;CACjB,YAAY,CAAC,KAAK,GAAG;C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,WAAU;OAAoB,aAAU;OAAQ,IAAIA,EAAO;OAAI,IAAIA,EAAO;OAAI,GAAG;MAAI,CAAA,IAAI;KACxG;;IACJN,EAAa,KAAK,MAAWO,EAAML,GAAQI,KAAUnB,EAAKe,EAAO,CAAC,KAAKI,EAAO,KAAK,SAAS,OAAO,CAAC;IACpGH,IAAQI,EAAMJ,GAAO,OAAO,IAAI;GAC9B;;CACF,CAAA;AAET,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";var e={en:{Yerevan:`Yerevan`,Aragatsotn:`Aragatsotn`,Ararat:`Ararat`,Armavir:`Armavir`,Gegharkunik:`Gegharkunik`,Lori:`Lori`,Kotayk:`Kotayk`,Shirak:`Shirak`,Syunik:`Syunik`,"Vayots Dzor":`Vayots Dzor`,Tavush:`Tavush`},hy:{Yerevan:`Երևան`,Aragatsotn:`Արագածոտն`,Ararat:`Արարատ`,Armavir:`Արմավիր`,Gegharkunik:`Գեղարքունիք`,Lori:`Լոռի`,Kotayk:`Կոտայք`,Shirak:`Շիրակ`,Syunik:`Սյունիք`,"Vayots Dzor":`Վայոց Ձոր`,Tavush:`Տավուշ`},ru:{Yerevan:`Ереван`,Aragatsotn:`Арагацотн`,Ararat:`Арарат`,Armavir:`Армавир`,Gegharkunik:`Гегаркуник`,Lori:`Лори`,Kotayk:`Котайк`,Shirak:`Ширак`,Syunik:`Сюник`,"Vayots Dzor":`Вайоц Дзор`,Tavush:`Тавуш`}};function t(t,n=`en`){return(e[n.trim().toLowerCase().split(/[-_]/)[0]]??e.en)[t]}exports.ARMENIA_REGION_NAMES=e,exports.getArmeniaRegionName=t;
|
|
2
|
+
//# sourceMappingURL=regionNames.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regionNames.cjs","names":["ARMENIA_REGION_NAMES","getArmeniaRegionName","locale","region"],"sources":["../../../src/components/ArmeniaRouteMap/regionNames.ts"],"sourcesContent":["import type { ArmeniaRegion } from '../RegionMap/RegionMap';\n\n/** Languages the region names are translated into. */\nexport type ArmeniaRegionLocale = 'en' | 'hy' | 'ru';\n\n/** Names of the Armenia map regions per language (same wording as the web app's `regions.*` translations). */\nexport const ARMENIA_REGION_NAMES: Readonly<Record<ArmeniaRegionLocale, Readonly<Record<ArmeniaRegion, string>>>> = {\n en: {\n Yerevan: 'Yerevan',\n Aragatsotn: 'Aragatsotn',\n Ararat: 'Ararat',\n Armavir: 'Armavir',\n Gegharkunik: 'Gegharkunik',\n Lori: 'Lori',\n Kotayk: 'Kotayk',\n Shirak: 'Shirak',\n Syunik: 'Syunik',\n 'Vayots Dzor': 'Vayots Dzor',\n Tavush: 'Tavush',\n },\n hy: {\n Yerevan: 'Երևան',\n Aragatsotn: 'Արագածոտն',\n Ararat: 'Արարատ',\n Armavir: 'Արմավիր',\n Gegharkunik: 'Գեղարքունիք',\n Lori: 'Լոռի',\n Kotayk: 'Կոտայք',\n Shirak: 'Շիրակ',\n Syunik: 'Սյունիք',\n 'Vayots Dzor': 'Վայոց Ձոր',\n Tavush: 'Տավուշ',\n },\n ru: {\n Yerevan: 'Ереван',\n Aragatsotn: 'Арагацотн',\n Ararat: 'Арарат',\n Armavir: 'Армавир',\n Gegharkunik: 'Гегаркуник',\n Lori: 'Лори',\n Kotayk: 'Котайк',\n Shirak: 'Ширак',\n Syunik: 'Сюник',\n 'Vayots Dzor': 'Вайоц Дзор',\n Tavush: 'Тавуш',\n },\n};\n\n/**\n * Region name in the given language. Takes any BCP 47 tag (`'hy'`, `'hy-AM'`, `'ru-RU'` …) and falls back to\n * English for languages without a translation.\n */\nexport function getArmeniaRegionName(region: ArmeniaRegion, locale = 'en'): string {\n const language = locale.trim().toLowerCase().split(/[-_]/)[0] as ArmeniaRegionLocale;\n return (ARMENIA_REGION_NAMES[language] ?? ARMENIA_REGION_NAMES.en)[region];\n}\n"],"mappings":"A,aAMA,IAAaA,EAAuG,CAClH,GAAI,CACF,QAAS,UACT,WAAY,aACZ,OAAQ,SACR,QAAS,UACT,YAAa,cACb,KAAM,OACN,OAAQ,SACR,OAAQ,SACR,OAAQ,SACR,cAAe,cACf,OAAQ,QACV,EACA,GAAI,CACF,QAAS,QACT,WAAY,YACZ,OAAQ,SACR,QAAS,UACT,YAAa,cACb,KAAM,OACN,OAAQ,SACR,OAAQ,QACR,OAAQ,UACR,cAAe,YACf,OAAQ,QACV,EACA,GAAI,CACF,QAAS,SACT,WAAY,YACZ,OAAQ,SACR,QAAS,UACT,YAAa,aACb,KAAM,OACN,OAAQ,SACR,OAAQ,QACR,OAAQ,QACR,cAAe,aACf,OAAQ,OACV,CACF,EAMA,SAAgBC,EAAqB,EAAuB,EAAS,KAAc,CAEjF,OAAQD,EADSE,EAAO,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC,KACjBF,EAAqB,GAAA,CAAIG,EACrE,C"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// src/components/ArmeniaRouteMap/regionNames.ts
|
|
3
|
+
var e = {
|
|
4
|
+
en: {
|
|
5
|
+
Yerevan: "Yerevan",
|
|
6
|
+
Aragatsotn: "Aragatsotn",
|
|
7
|
+
Ararat: "Ararat",
|
|
8
|
+
Armavir: "Armavir",
|
|
9
|
+
Gegharkunik: "Gegharkunik",
|
|
10
|
+
Lori: "Lori",
|
|
11
|
+
Kotayk: "Kotayk",
|
|
12
|
+
Shirak: "Shirak",
|
|
13
|
+
Syunik: "Syunik",
|
|
14
|
+
"Vayots Dzor": "Vayots Dzor",
|
|
15
|
+
Tavush: "Tavush"
|
|
16
|
+
},
|
|
17
|
+
hy: {
|
|
18
|
+
Yerevan: "Երևան",
|
|
19
|
+
Aragatsotn: "Արագածոտն",
|
|
20
|
+
Ararat: "Արարատ",
|
|
21
|
+
Armavir: "Արմավիր",
|
|
22
|
+
Gegharkunik: "Գեղարքունիք",
|
|
23
|
+
Lori: "Լոռի",
|
|
24
|
+
Kotayk: "Կոտայք",
|
|
25
|
+
Shirak: "Շիրակ",
|
|
26
|
+
Syunik: "Սյունիք",
|
|
27
|
+
"Vayots Dzor": "Վայոց Ձոր",
|
|
28
|
+
Tavush: "Տավուշ"
|
|
29
|
+
},
|
|
30
|
+
ru: {
|
|
31
|
+
Yerevan: "Ереван",
|
|
32
|
+
Aragatsotn: "Арагацотн",
|
|
33
|
+
Ararat: "Арарат",
|
|
34
|
+
Armavir: "Армавир",
|
|
35
|
+
Gegharkunik: "Гегаркуник",
|
|
36
|
+
Lori: "Лори",
|
|
37
|
+
Kotayk: "Котайк",
|
|
38
|
+
Shirak: "Ширак",
|
|
39
|
+
Syunik: "Сюник",
|
|
40
|
+
"Vayots Dzor": "Вайоц Дзор",
|
|
41
|
+
Tavush: "Тавуш"
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
function t(t, n = "en") {
|
|
45
|
+
return (e[n.trim().toLowerCase().split(/[-_]/)[0]] ?? e.en)[t];
|
|
46
|
+
}
|
|
47
|
+
export { e as ARMENIA_REGION_NAMES, t as getArmeniaRegionName };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=regionNames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regionNames.js","names":["ARMENIA_REGION_NAMES","getArmeniaRegionName","locale","region"],"sources":["../../../src/components/ArmeniaRouteMap/regionNames.ts"],"sourcesContent":["import type { ArmeniaRegion } from '../RegionMap/RegionMap';\n\n/** Languages the region names are translated into. */\nexport type ArmeniaRegionLocale = 'en' | 'hy' | 'ru';\n\n/** Names of the Armenia map regions per language (same wording as the web app's `regions.*` translations). */\nexport const ARMENIA_REGION_NAMES: Readonly<Record<ArmeniaRegionLocale, Readonly<Record<ArmeniaRegion, string>>>> = {\n en: {\n Yerevan: 'Yerevan',\n Aragatsotn: 'Aragatsotn',\n Ararat: 'Ararat',\n Armavir: 'Armavir',\n Gegharkunik: 'Gegharkunik',\n Lori: 'Lori',\n Kotayk: 'Kotayk',\n Shirak: 'Shirak',\n Syunik: 'Syunik',\n 'Vayots Dzor': 'Vayots Dzor',\n Tavush: 'Tavush',\n },\n hy: {\n Yerevan: 'Երևան',\n Aragatsotn: 'Արագածոտն',\n Ararat: 'Արարատ',\n Armavir: 'Արմավիր',\n Gegharkunik: 'Գեղարքունիք',\n Lori: 'Լոռի',\n Kotayk: 'Կոտայք',\n Shirak: 'Շիրակ',\n Syunik: 'Սյունիք',\n 'Vayots Dzor': 'Վայոց Ձոր',\n Tavush: 'Տավուշ',\n },\n ru: {\n Yerevan: 'Ереван',\n Aragatsotn: 'Арагацотн',\n Ararat: 'Арарат',\n Armavir: 'Армавир',\n Gegharkunik: 'Гегаркуник',\n Lori: 'Лори',\n Kotayk: 'Котайк',\n Shirak: 'Ширак',\n Syunik: 'Сюник',\n 'Vayots Dzor': 'Вайоц Дзор',\n Tavush: 'Тавуш',\n },\n};\n\n/**\n * Region name in the given language. Takes any BCP 47 tag (`'hy'`, `'hy-AM'`, `'ru-RU'` …) and falls back to\n * English for languages without a translation.\n */\nexport function getArmeniaRegionName(region: ArmeniaRegion, locale = 'en'): string {\n const language = locale.trim().toLowerCase().split(/[-_]/)[0] as ArmeniaRegionLocale;\n return (ARMENIA_REGION_NAMES[language] ?? ARMENIA_REGION_NAMES.en)[region];\n}\n"],"mappings":";;AAMA,IAAaA,IAAuG;CAClH,IAAI;EACF,SAAS;EACT,YAAY;EACZ,QAAQ;EACR,SAAS;EACT,aAAa;EACb,MAAM;EACN,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,eAAe;EACf,QAAQ;CACV;CACA,IAAI;EACF,SAAS;EACT,YAAY;EACZ,QAAQ;EACR,SAAS;EACT,aAAa;EACb,MAAM;EACN,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,eAAe;EACf,QAAQ;CACV;CACA,IAAI;EACF,SAAS;EACT,YAAY;EACZ,QAAQ;EACR,SAAS;EACT,aAAa;EACb,MAAM;EACN,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,eAAe;EACf,QAAQ;CACV;AACF;AAMA,SAAgBC,EAAqB,GAAuB,IAAS,MAAc;CAEjF,QAAQD,EADSE,EAAO,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC,OACjBF,EAAqB,GAAA,CAAIG;AACrE"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";const e=require("../../node_modules/d3-geo/src/path/index.cjs"),t=require("../../icons/generated/PlaneIcon.cjs"),n=require("../../utils/cn.cjs"),r=require("../HeroColumns/heroMotion.cjs"),i=require("./geo.cjs");;/* empty css */let a=require("react"),o=require("react/jsx-runtime");function s(e,t,n){let r=t.trim().toLowerCase().split(/[-_]/)[0],i=n?.names[r]?.[e];if(i)return i;try{return new Intl.DisplayNames([t,`en`],{type:`region`}).of(e)??e}catch{return e}}function c(e,t,n){return e.label?e.label:e.kind!==`country`&&e.code?e.code:s(e.countryCode.trim().toUpperCase(),t,n)}var l=e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2;function u(e,t){return getComputedStyle(e).getPropertyValue(t).trim()}var d=(0,a.forwardRef)(function({start:s=null,segments:d=[],planes:f=!1,locale:p=`en`,duration:m=900,className:h,...g},_){let[v,y]=(0,a.useState)(null),[b,x]=(0,a.useState)(i.HOME_VIEW),[S,C]=(0,a.useState)(!0),[w,T]=(0,a.useState)(390),E=(0,a.useRef)(null),D=(0,a.useRef)(null),O=(0,a.useRef)(b);O.current=b;let k=r.usePrefersReducedMotion(),A=r.useOnScreen(E),[j,M]=(0,a.useState)(0);(0,a.useEffect)(()=>{let e=!0;return i.loadWorld().then(t=>e&&y(t)),()=>{e=!1}},[]),(0,a.useEffect)(()=>{let e=E.current;if(!e)return;let t=()=>T(e.clientWidth||390);if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let N=s??d[0]?.from??null,P=(0,a.useMemo)(()=>{let e=N?[{key:i.placeKey(N),place:N,role:`start`}]:[];for(let{from:t,to:n}of d)for(let r of[t,n])e.some(e=>i.samePlace(e.place,r))||e.push({key:i.placeKey(r),place:r,role:`stop`});return e},[N,d]),F=P.map(e=>i.placePoint(e.place,v)),I=e=>F[P.findIndex(t=>i.samePlace(t.place,e))]??null,L=F.filter(e=>e!==null),R=i.fitView(L),z=`${R.lon.toFixed(3)},${R.lat.toFixed(3)},${R.r.toFixed(2)},${R.x.toFixed(2)},${R.y.toFixed(2)}`;(0,a.useEffect)(()=>{let e=O.current;if(k||m<=0||typeof requestAnimationFrame>`u`){x(R),C(!0);return}let t=i.interpolateView(e,R),n=0,r=null;C(!1);let a=e=>{r??(r=e);let i=Math.min(1,(e-r)/m);x(t(l(i))),i<1?n=requestAnimationFrame(a):C(!0)};return n=requestAnimationFrame(a),()=>cancelAnimationFrame(n)},[z,k,m]);let B=S&&d.length>0&&!k&&m>0;(0,a.useEffect)(()=>{if(M(0),!B||!A||typeof requestAnimationFrame>`u`)return;let e=f?1/0:i.drawnAfter(d.length),t=0,n=null,r=i=>{n??(n=i);let a=Math.min(e,i-n);M(a),a<e&&(t=requestAnimationFrame(r))};return t=requestAnimationFrame(r),()=>cancelAnimationFrame(t)},[B,A,f,d.length]);let V=N?.countryCode.trim().toUpperCase()??null,H=(0,a.useMemo)(()=>new Set(P.filter(e=>e.role===`stop`).map(e=>e.place.countryCode.trim().toUpperCase())),[P]);(0,a.useEffect)(()=>{let t=D.current,n=t?.getContext(`2d`);if(!t||!n)return;let r=typeof window<`u`&&window.devicePixelRatio||1,a=w/390,o=Math.round(w*r),s=Math.round(255*a*r);t.width!==o&&(t.width=o),t.height!==s&&(t.height=s),n.setTransform(r*a,0,0,r*a,0,0),n.clearRect(0,0,390,255);let c=e=>u(t,e),l=e.default(i.projectionFor(b),n);if(n.lineJoin=`round`,n.beginPath(),l({type:`Sphere`}),n.fillStyle=c(`--_sea`),n.fill(),n.lineWidth=1,n.strokeStyle=c(`--_border`),n.stroke(),!v)return;n.beginPath();for(let e of v.features)l(e);n.fillStyle=c(`--_land`),n.fill(),n.lineWidth=.5,n.stroke();let d=(e,t)=>{if(e.size!==0){n.beginPath();for(let t of v.features)typeof t.id==`string`&&e.has(t.id)&&l(t);n.fillStyle=t,n.fill()}};d(new Set([...H].filter(e=>e!==V)),c(`--_stop`)),d(new Set(V?[V]:[]),c(`--_start`))},[b,v,w,V,H]);let U=i.projectionFor(b),W=e=>!e||!i.isFacing(e,b)?null:U(e)??null,G=([e,t])=>({"--_x":`${e/390*100}%`,"--_y":`${t/255*100}%`}),K=d.flatMap((e,t)=>{let n=W(I(e.from)),r=W(I(e.to));return!n||!r||i.samePlace(e.from,e.to)?[]:[{index:t,...i.routeArc(n,r)}]}),q=P.flatMap((e,t)=>{let n=W(F[t]);return n?[{...e,at:n}]:[]}),J=d.length===0;return(0,o.jsx)(`div`,{ref:_,className:n.cn(`tm-globe-map`,h),...g,children:(0,o.jsxs)(`div`,{ref:E,className:`tm-globe-map__area`,"data-settled":S?``:void 0,children:[(0,o.jsx)(`canvas`,{ref:D,className:`tm-globe-map__canvas`,"aria-hidden":`true`}),(0,o.jsxs)(`svg`,{className:`tm-globe-map__overlay`,viewBox:`0 0 390 255`,"aria-hidden":`true`,focusable:`false`,children:[K.map(e=>(0,o.jsx)(`path`,{className:`tm-globe-map__route`,d:B?i.arcPathTo(e,i.legFrame(e.index,j).drawn):e.d},e.index)),q.map(e=>e.role===`start`?(0,o.jsxs)(`g`,{children:[J?(0,o.jsx)(`circle`,{className:`tm-globe-map__pulse`,cx:e.at[0],cy:e.at[1],r:17}):null,(0,o.jsx)(`circle`,{className:`tm-globe-map__pin`,"data-kind":`start`,cx:e.at[0],cy:e.at[1],r:4})]},e.key):(0,o.jsx)(`circle`,{className:`tm-globe-map__pin`,"data-kind":`stop`,cx:e.at[0],cy:e.at[1],r:3.25},e.key))]}),f?K.map(e=>{let n=B?i.legFrame(e.index,j):null,r=n?.plane==null?{at:e.mid,angle:e.angle}:i.arcAt(e,n.plane),a=n?n.opacity:void 0;return(0,o.jsx)(`span`,{className:`tm-globe-map__plane`,"data-flying":n?``:void 0,style:{...G(r.at),"--_angle":`${r.angle+45}deg`,opacity:a},children:(0,o.jsx)(t.PlaneIcon,{size:16})},e.index)}):null,q.map(e=>(0,o.jsx)(`span`,{className:`tm-globe-map__label`,"data-role":e.role,style:G(e.at),children:c(e.place,p,v)},e.key))]})})});exports.GlobeMap=d;
|
|
2
|
+
//# sourceMappingURL=GlobeMap.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GlobeMap.cjs","names":["useState","HOME_VIEW","useRef","usePrefersReducedMotion","useOnScreen","useMemo","placeKey","samePlace","placePoint","fitView","interpolateView","drawnAfter","geoPath","projectionFor","isFacing","routeArc","cn","arcPathTo","legFrame","arcAt","PlaneIcon","require_index","require_PlaneIcon","require_cn","require_heroMotion","require_geo","react","react_jsx_runtime","countryName","language","locale","shipped","world","code","labelOf","place","easeInOutCubic","t","readColour","element","name","GlobeMap","props","setWorld","view","setView","settled","setSettled","width","setWidth","areaRef","canvasRef","viewRef","reducedMotion","onScreenNow","elapsed","setElapsed","alive","loaded","area","measure","observer","origin","start","segments","stops","list","from","to","stop","points","pointOf","known","point","target","targetKey","duration","step","frame","started","tick","now","animateFlights","end","planes","time","startCountry","stopCountries","canvas","context","ratio","scale","pixelWidth","pixelHeight","colour","path","shape","highlight","codes","fill","projection","onScreen","percent","x","y","legs","a","segment","b","pins","at","index","alone","className","leg","pin","flight","opacity"],"sources":["../../../src/components/GlobeMap/GlobeMap.tsx"],"sourcesContent":["import { geoPath } from 'd3-geo';\nimport { forwardRef, useEffect, useMemo, useRef, useState, type CSSProperties, type HTMLAttributes } from 'react';\nimport { PlaneIcon } from '../../icons';\nimport { cn } from '../../utils/cn';\nimport { useOnScreen, usePrefersReducedMotion } from '../HeroColumns/heroMotion';\nimport {\n FRAME_HEIGHT,\n arcAt,\n arcPathTo,\n drawnAfter,\n legFrame,\n FRAME_WIDTH,\n HOME_VIEW,\n fitView,\n interpolateView,\n isFacing,\n loadWorld,\n placeKey,\n placePoint,\n projectionFor,\n routeArc,\n samePlace,\n type GlobePlace,\n type GlobeSegment,\n type GlobeView,\n type LonLat,\n type World,\n} from './geo';\nimport './GlobeMap.css';\n\nexport type { GlobeCountryPlace, GlobePlace, GlobePointPlace, GlobeSegment } from './geo';\n\nexport interface GlobeMapProps extends HTMLAttributes<HTMLDivElement> {\n /**\n * Where the trip starts (\"Departing from\"): its country is filled in blue, with a white pin. Alone, the globe zooms\n * in on it. Defaults to the `from` of the first segment.\n */\n start?: GlobePlace | null;\n /**\n * The legs of the trip, each drawn as a dotted arc: one leg for a one-way trip or a destination, there and back for\n * a round trip, any chain (or open jaw) for multi-city. Every place other than the start gets a navy country, a pin\n * and a label; the globe turns and zooms so that all of them are in view.\n */\n segments?: readonly GlobeSegment[];\n /**\n * A plane in a white circle on every leg, pointing the way (Figma flight maps 2745:43316 / 2745:43151). Once the globe\n * stops, each leg draws itself with its plane at the tip, one leg after another; then every plane keeps flying its\n * leg. Under `prefers-reduced-motion` the planes rest on the middle of their legs, as in Figma.\n */\n planes?: boolean;\n /** Language of the default labels (country names): `'en'`, `'hy'` or `'ru'` (shipped with the map), others via the browser. Default `'en'`. */\n locale?: string;\n /** Length of the turn-and-zoom animation in ms. Default 900. Skipped under `prefers-reduced-motion`. */\n duration?: number;\n}\n\ninterface Stop {\n key: string;\n place: GlobePlace;\n role: 'start' | 'stop';\n}\n\nfunction countryName(code: string, locale: string, world: World | null): string {\n const language = locale.trim().toLowerCase().split(/[-_]/)[0];\n const shipped = world?.names[language]?.[code];\n if (shipped) return shipped;\n try {\n return new Intl.DisplayNames([locale, 'en'], { type: 'region' }).of(code) ?? code;\n } catch {\n return code;\n }\n}\n\nfunction labelOf(place: GlobePlace, locale: string, world: World | null): string {\n if (place.label) return place.label;\n if (place.kind !== 'country' && place.code) return place.code;\n return countryName(place.countryCode.trim().toUpperCase(), locale, world);\n}\n\nconst easeInOutCubic = (t: number) => (t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2);\n\nfunction readColour(element: Element, name: string): string {\n return getComputedStyle(element).getPropertyValue(name).trim();\n}\n\n/**\n * Figma \"Map\" with \"Map / Globe\" (2966:17945 empty, 2966:18002 departure, 2745:11779 destination, 2745:43316 /\n * 2745:43151 flights): a 3D globe in a card. It starts facing Europe and the Middle East, turns and zooms to the\n * departure once it is chosen, then to fit the whole trip. Countries, cities and airports can be mixed: a country is\n * filled and pinned in its middle, a city or airport fills its country and is pinned at its coordinates.\n */\nexport const GlobeMap = /* @__PURE__ */ forwardRef<HTMLDivElement, GlobeMapProps>(function GlobeMap(\n { start = null, segments = [], planes = false, locale = 'en', duration = 900, className, ...props },\n ref,\n) {\n const [world, setWorld] = useState<World | null>(null);\n const [view, setView] = useState<GlobeView>(HOME_VIEW);\n const [settled, setSettled] = useState(true);\n const [width, setWidth] = useState(FRAME_WIDTH);\n const areaRef = useRef<HTMLDivElement>(null);\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const viewRef = useRef(view);\n viewRef.current = view;\n const reducedMotion = usePrefersReducedMotion();\n const onScreenNow = useOnScreen(areaRef);\n /** ms since the globe stopped: drives the routes drawing in and the planes flying. */\n const [elapsed, setElapsed] = useState(0);\n\n useEffect(() => {\n let alive = true;\n loadWorld().then((loaded) => alive && setWorld(loaded));\n return () => {\n alive = false;\n };\n }, []);\n\n useEffect(() => {\n const area = areaRef.current;\n if (!area) return;\n const measure = () => setWidth(area.clientWidth || FRAME_WIDTH);\n measure();\n if (typeof ResizeObserver === 'undefined') return;\n const observer = new ResizeObserver(measure);\n observer.observe(area);\n return () => observer.disconnect();\n }, []);\n\n /* The places on the map: the start, then every other place of the route once, in order. */\n const origin = start ?? segments[0]?.from ?? null;\n const stops = useMemo<Stop[]>(() => {\n const list: Stop[] = origin ? [{ key: placeKey(origin), place: origin, role: 'start' }] : [];\n for (const { from, to } of segments) {\n for (const place of [from, to]) {\n if (!list.some((stop) => samePlace(stop.place, place))) list.push({ key: placeKey(place), place, role: 'stop' });\n }\n }\n return list;\n }, [origin, segments]);\n\n const points = stops.map((stop) => placePoint(stop.place, world));\n const pointOf = (place: GlobePlace): LonLat | null => points[stops.findIndex((stop) => samePlace(stop.place, place))] ?? null;\n const known = points.filter((point): point is LonLat => point !== null);\n const target = fitView(known);\n const targetKey = `${target.lon.toFixed(3)},${target.lat.toFixed(3)},${target.r.toFixed(2)},${target.x.toFixed(2)},${target.y.toFixed(2)}`;\n\n /* Turn and zoom from wherever the globe is now to the view that fits the trip. */\n useEffect(() => {\n const from = viewRef.current;\n if (reducedMotion || duration <= 0 || typeof requestAnimationFrame === 'undefined') {\n setView(target);\n setSettled(true);\n return;\n }\n const step = interpolateView(from, target);\n let frame = 0;\n let started: number | null = null;\n setSettled(false);\n const tick = (now: number) => {\n started ??= now;\n const t = Math.min(1, (now - started) / duration);\n setView(step(easeInOutCubic(t)));\n if (t < 1) frame = requestAnimationFrame(tick);\n else setSettled(true);\n };\n frame = requestAnimationFrame(tick);\n return () => cancelAnimationFrame(frame);\n // targetKey stands for `target`, which is a new object on every render.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [targetKey, reducedMotion, duration]);\n\n /* Routes draw in and planes fly once the globe has stopped. Without planes the clock stops when every route is drawn. */\n const animateFlights = settled && segments.length > 0 && !reducedMotion && duration > 0;\n useEffect(() => {\n setElapsed(0);\n if (!animateFlights || !onScreenNow || typeof requestAnimationFrame === 'undefined') return;\n const end = planes ? Infinity : drawnAfter(segments.length);\n let frame = 0;\n let started: number | null = null;\n const tick = (now: number) => {\n started ??= now;\n const time = Math.min(end, now - started);\n setElapsed(time);\n if (time < end) frame = requestAnimationFrame(tick);\n };\n frame = requestAnimationFrame(tick);\n return () => cancelAnimationFrame(frame);\n }, [animateFlights, onScreenNow, planes, segments.length]);\n\n /* Country fills: the start's country blue, the other places' countries navy. */\n const startCountry = origin?.countryCode.trim().toUpperCase() ?? null;\n const stopCountries = useMemo(\n () => new Set(stops.filter((stop) => stop.role === 'stop').map((stop) => stop.place.countryCode.trim().toUpperCase())),\n [stops],\n );\n\n useEffect(() => {\n const canvas = canvasRef.current;\n const context = canvas?.getContext('2d');\n if (!canvas || !context) return;\n const ratio = typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1;\n const scale = width / FRAME_WIDTH;\n const pixelWidth = Math.round(width * ratio);\n const pixelHeight = Math.round(FRAME_HEIGHT * scale * ratio);\n if (canvas.width !== pixelWidth) canvas.width = pixelWidth;\n if (canvas.height !== pixelHeight) canvas.height = pixelHeight;\n context.setTransform(ratio * scale, 0, 0, ratio * scale, 0, 0);\n context.clearRect(0, 0, FRAME_WIDTH, FRAME_HEIGHT);\n\n const colour = (name: string) => readColour(canvas, name);\n const path = geoPath(projectionFor(view), context);\n context.lineJoin = 'round';\n\n context.beginPath();\n path({ type: 'Sphere' });\n context.fillStyle = colour('--_sea');\n context.fill();\n context.lineWidth = 1;\n context.strokeStyle = colour('--_border');\n context.stroke();\n if (!world) return;\n\n context.beginPath();\n for (const shape of world.features) path(shape);\n context.fillStyle = colour('--_land');\n context.fill();\n context.lineWidth = 0.5;\n context.stroke();\n\n const highlight = (codes: Set<string>, fill: string) => {\n if (codes.size === 0) return;\n context.beginPath();\n for (const shape of world.features) if (typeof shape.id === 'string' && codes.has(shape.id)) path(shape);\n context.fillStyle = fill;\n context.fill();\n };\n const stopsOnly = new Set([...stopCountries].filter((code) => code !== startCountry));\n highlight(stopsOnly, colour('--_stop'));\n highlight(new Set(startCountry ? [startCountry] : []), colour('--_start'));\n }, [view, world, width, startCountry, stopCountries]);\n\n /* Overlay: routes, pins, planes and labels, projected for the current frame of the animation. */\n const projection = projectionFor(view);\n const onScreen = (point: LonLat | null) => {\n if (!point || !isFacing(point, view)) return null;\n return projection(point as [number, number]) ?? null;\n };\n const percent = ([x, y]: readonly [number, number]) =>\n ({ '--_x': `${(x / FRAME_WIDTH) * 100}%`, '--_y': `${(y / FRAME_HEIGHT) * 100}%` }) as CSSProperties;\n\n const legs = segments.flatMap((segment, index) => {\n const a = onScreen(pointOf(segment.from));\n const b = onScreen(pointOf(segment.to));\n if (!a || !b || samePlace(segment.from, segment.to)) return [];\n return [{ index, ...routeArc(a, b) }];\n });\n const pins = stops.flatMap((stop, index) => {\n const at = onScreen(points[index]);\n return at ? [{ ...stop, at }] : [];\n });\n const alone = segments.length === 0;\n\n return (\n <div ref={ref} className={cn('tm-globe-map', className)} {...props}>\n <div ref={areaRef} className=\"tm-globe-map__area\" data-settled={settled ? '' : undefined}>\n <canvas ref={canvasRef} className=\"tm-globe-map__canvas\" aria-hidden=\"true\" />\n <svg className=\"tm-globe-map__overlay\" viewBox={`0 0 ${FRAME_WIDTH} ${FRAME_HEIGHT}`} aria-hidden=\"true\" focusable=\"false\">\n {legs.map((leg) => (\n <path key={leg.index} className=\"tm-globe-map__route\" d={animateFlights ? arcPathTo(leg, legFrame(leg.index, elapsed).drawn) : leg.d} />\n ))}\n {pins.map((pin) =>\n pin.role === 'start' ? (\n <g key={pin.key}>\n {alone ? <circle className=\"tm-globe-map__pulse\" cx={pin.at[0]} cy={pin.at[1]} r={17} /> : null}\n <circle className=\"tm-globe-map__pin\" data-kind=\"start\" cx={pin.at[0]} cy={pin.at[1]} r={4} />\n </g>\n ) : (\n <circle key={pin.key} className=\"tm-globe-map__pin\" data-kind=\"stop\" cx={pin.at[0]} cy={pin.at[1]} r={3.25} />\n ),\n )}\n </svg>\n {planes\n ? legs.map((leg) => {\n // Animated: on its way along the leg; otherwise resting on the middle of it, as in Figma.\n const frame = animateFlights ? legFrame(leg.index, elapsed) : null;\n const flight = frame?.plane != null ? arcAt(leg, frame.plane) : { at: leg.mid, angle: leg.angle };\n const opacity = frame ? frame.opacity : undefined;\n return (\n <span\n key={leg.index}\n className=\"tm-globe-map__plane\"\n data-flying={frame ? '' : undefined}\n // The icon's nose points up and to the right (-45°).\n style={{ ...percent(flight.at), '--_angle': `${flight.angle + 45}deg`, opacity } as CSSProperties}\n >\n <PlaneIcon size={16} />\n </span>\n );\n })\n : null}\n {pins.map((pin) => (\n <span key={pin.key} className=\"tm-globe-map__label\" data-role={pin.role} style={percent(pin.at)}>\n {labelOf(pin.place, locale, world)}\n </span>\n ))}\n </div>\n </div>\n );\n});\n"],"mappings":"A,oTA8DA,SAAS4B,EAAY,EAAc,EAAgB,EAA6B,CAC9E,IAAMC,EAAWC,EAAO,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC,GACrDC,EAAUC,GAAO,MAAMH,EAAS,GAAGI,GACzC,GAAIF,EAAS,OAAOA,EACpB,GAAI,CACF,OAAO,IAAI,KAAK,aAAa,CAACD,EAAQ,IAAI,EAAG,CAAE,KAAM,QAAS,CAAC,CAAC,CAAC,GAAGG,CAAI,GAAKA,CAC/E,MAAQ,CACN,OAAOA,CACT,CACF,CAEA,SAASC,EAAQ,EAAmB,EAAgB,EAA6B,CAG/E,OAFIC,EAAM,MAAcA,EAAM,MAC1BA,EAAM,OAAS,WAAaA,EAAM,KAAaA,EAAM,KAClDP,EAAYO,EAAM,YAAY,KAAK,CAAC,CAAC,YAAY,EAAGL,EAAQE,CAAK,CAC1E,CAEA,IAAMI,EAAkB,GAAeC,EAAI,GAAM,EAAIA,EAAIA,EAAIA,EAAI,GAAa,GAAKA,EAAI,IAAG,EAAK,EAE/F,SAASC,EAAW,EAAkB,EAAsB,CAC1D,OAAO,iBAAiBC,CAAO,CAAC,CAAC,iBAAiBC,CAAI,CAAC,CAAC,KAAK,CAC/D,CAQA,IAAaC,GAA2B,EAAAf,EAAA,WAAA,CAA0C,SAChF,CAAE,QAAQ,KAAM,WAAW,CAAC,EAAG,SAAS,GAAO,SAAS,KAAM,WAAW,IAAK,YAAW,GAAGgB,GAC5F,EACA,CACA,GAAM,CAACV,EAAOW,IAAA,EAAY3C,EAAAA,SAAAA,CAAuB,IAAI,EAC/C,CAAC4C,EAAMC,IAAA,EAAW7C,EAAAA,SAAAA,CAAoBC,EAAAA,S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,KAAM,EAAK,CAAA,CAClB,EAPC8F,EAAI,KAOL,CAEV,CAAC,EACD,KACHL,EAAK,IAAK,IACT,EAAAlF,EAAA,IAAA,CAAC,OAAD,CAAoB,UAAU,sBAAsB,YAAWwF,EAAI,KAAM,MAAOb,EAAQa,EAAI,EAAE,EAC3F,SAAAjF,EAAQiF,EAAI,MAAOrF,EAAQE,CAAK,CAC7B,EAFKmF,EAAI,GAET,CACP,CACE,C,EACF,CAAA,CAET,CAAC,E"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import e from "../../node_modules/d3-geo/src/path/index.js";
|
|
3
|
+
import { PlaneIcon as t } from "../../icons/generated/PlaneIcon.js";
|
|
4
|
+
import { cn as n } from "../../utils/cn.js";
|
|
5
|
+
import { useOnScreen as r, usePrefersReducedMotion as i } from "../HeroColumns/heroMotion.js";
|
|
6
|
+
import { HOME_VIEW as a, arcAt as o, arcPathTo as s, drawnAfter as c, fitView as l, interpolateView as u, isFacing as ee, legFrame as d, loadWorld as te, placeKey as f, placePoint as p, projectionFor as m, routeArc as ne, samePlace as h } from "./geo.js";
|
|
7
|
+
/* empty css */
|
|
8
|
+
import { forwardRef as g, useEffect as _, useMemo as v, useRef as y, useState as b } from "react";
|
|
9
|
+
import { jsx as x, jsxs as S } from "react/jsx-runtime";
|
|
10
|
+
// src/components/GlobeMap/GlobeMap.tsx
|
|
11
|
+
function C(e, t, n) {
|
|
12
|
+
let r = t.trim().toLowerCase().split(/[-_]/)[0], i = n?.names[r]?.[e];
|
|
13
|
+
if (i) return i;
|
|
14
|
+
try {
|
|
15
|
+
return new Intl.DisplayNames([t, "en"], { type: "region" }).of(e) ?? e;
|
|
16
|
+
} catch {
|
|
17
|
+
return e;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function re(e, t, n) {
|
|
21
|
+
return e.label ? e.label : e.kind !== "country" && e.code ? e.code : C(e.countryCode.trim().toUpperCase(), t, n);
|
|
22
|
+
}
|
|
23
|
+
var ie = (e) => e < .5 ? 4 * e * e * e : 1 - (-2 * e + 2) ** 3 / 2;
|
|
24
|
+
function ae(e, t) {
|
|
25
|
+
return getComputedStyle(e).getPropertyValue(t).trim();
|
|
26
|
+
}
|
|
27
|
+
var w = /* @__PURE__ */ g(function({ start: g = null, segments: C = [], planes: w = !1, locale: oe = "en", duration: T = 900, className: se, ...E }, ce) {
|
|
28
|
+
let [D, le] = b(null), [O, k] = b(a), [A, j] = b(!0), [M, N] = b(390), P = y(null), F = y(null), I = y(O);
|
|
29
|
+
I.current = O;
|
|
30
|
+
let L = i(), R = r(P), [z, B] = b(0);
|
|
31
|
+
_(() => {
|
|
32
|
+
let e = !0;
|
|
33
|
+
return te().then((t) => e && le(t)), () => {
|
|
34
|
+
e = !1;
|
|
35
|
+
};
|
|
36
|
+
}, []), _(() => {
|
|
37
|
+
let e = P.current;
|
|
38
|
+
if (!e) return;
|
|
39
|
+
let t = () => N(e.clientWidth || 390);
|
|
40
|
+
if (t(), typeof ResizeObserver > "u") return;
|
|
41
|
+
let n = new ResizeObserver(t);
|
|
42
|
+
return n.observe(e), () => n.disconnect();
|
|
43
|
+
}, []);
|
|
44
|
+
let V = g ?? C[0]?.from ?? null, H = v(() => {
|
|
45
|
+
let e = V ? [{
|
|
46
|
+
key: f(V),
|
|
47
|
+
place: V,
|
|
48
|
+
role: "start"
|
|
49
|
+
}] : [];
|
|
50
|
+
for (let { from: t, to: n } of C) for (let r of [t, n]) e.some((e) => h(e.place, r)) || e.push({
|
|
51
|
+
key: f(r),
|
|
52
|
+
place: r,
|
|
53
|
+
role: "stop"
|
|
54
|
+
});
|
|
55
|
+
return e;
|
|
56
|
+
}, [V, C]), U = H.map((e) => p(e.place, D)), W = (e) => U[H.findIndex((t) => h(t.place, e))] ?? null, ue = U.filter((e) => e !== null), G = l(ue), de = `${G.lon.toFixed(3)},${G.lat.toFixed(3)},${G.r.toFixed(2)},${G.x.toFixed(2)},${G.y.toFixed(2)}`;
|
|
57
|
+
_(() => {
|
|
58
|
+
let e = I.current;
|
|
59
|
+
if (L || T <= 0 || typeof requestAnimationFrame > "u") {
|
|
60
|
+
k(G), j(!0);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
let t = u(e, G), n = 0, r = null;
|
|
64
|
+
j(!1);
|
|
65
|
+
let i = (e) => {
|
|
66
|
+
r ?? (r = e);
|
|
67
|
+
let a = Math.min(1, (e - r) / T);
|
|
68
|
+
k(t(ie(a))), a < 1 ? n = requestAnimationFrame(i) : j(!0);
|
|
69
|
+
};
|
|
70
|
+
return n = requestAnimationFrame(i), () => cancelAnimationFrame(n);
|
|
71
|
+
}, [
|
|
72
|
+
de,
|
|
73
|
+
L,
|
|
74
|
+
T
|
|
75
|
+
]);
|
|
76
|
+
let K = A && C.length > 0 && !L && T > 0;
|
|
77
|
+
_(() => {
|
|
78
|
+
if (B(0), !K || !R || typeof requestAnimationFrame > "u") return;
|
|
79
|
+
let e = w ? Infinity : c(C.length), t = 0, n = null, r = (i) => {
|
|
80
|
+
n ?? (n = i);
|
|
81
|
+
let a = Math.min(e, i - n);
|
|
82
|
+
B(a), a < e && (t = requestAnimationFrame(r));
|
|
83
|
+
};
|
|
84
|
+
return t = requestAnimationFrame(r), () => cancelAnimationFrame(t);
|
|
85
|
+
}, [
|
|
86
|
+
K,
|
|
87
|
+
R,
|
|
88
|
+
w,
|
|
89
|
+
C.length
|
|
90
|
+
]);
|
|
91
|
+
let q = V?.countryCode.trim().toUpperCase() ?? null, J = v(() => new Set(H.filter((e) => e.role === "stop").map((e) => e.place.countryCode.trim().toUpperCase())), [H]);
|
|
92
|
+
_(() => {
|
|
93
|
+
let t = F.current, n = t?.getContext("2d");
|
|
94
|
+
if (!t || !n) return;
|
|
95
|
+
let r = typeof window < "u" && window.devicePixelRatio || 1, i = M / 390, a = Math.round(M * r), o = Math.round(255 * i * r);
|
|
96
|
+
t.width !== a && (t.width = a), t.height !== o && (t.height = o), n.setTransform(r * i, 0, 0, r * i, 0, 0), n.clearRect(0, 0, 390, 255);
|
|
97
|
+
let s = (e) => ae(t, e), c = e(m(O), n);
|
|
98
|
+
if (n.lineJoin = "round", n.beginPath(), c({ type: "Sphere" }), n.fillStyle = s("--_sea"), n.fill(), n.lineWidth = 1, n.strokeStyle = s("--_border"), n.stroke(), !D) return;
|
|
99
|
+
n.beginPath();
|
|
100
|
+
for (let e of D.features) c(e);
|
|
101
|
+
n.fillStyle = s("--_land"), n.fill(), n.lineWidth = .5, n.stroke();
|
|
102
|
+
let l = (e, t) => {
|
|
103
|
+
if (e.size !== 0) {
|
|
104
|
+
n.beginPath();
|
|
105
|
+
for (let t of D.features) typeof t.id == "string" && e.has(t.id) && c(t);
|
|
106
|
+
n.fillStyle = t, n.fill();
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
l(new Set([...J].filter((e) => e !== q)), s("--_stop")), l(new Set(q ? [q] : []), s("--_start"));
|
|
110
|
+
}, [
|
|
111
|
+
O,
|
|
112
|
+
D,
|
|
113
|
+
M,
|
|
114
|
+
q,
|
|
115
|
+
J
|
|
116
|
+
]);
|
|
117
|
+
let Y = m(O), X = (e) => !e || !ee(e, O) ? null : Y(e) ?? null, Z = ([e, t]) => ({
|
|
118
|
+
"--_x": `${e / 390 * 100}%`,
|
|
119
|
+
"--_y": `${t / 255 * 100}%`
|
|
120
|
+
}), Q = C.flatMap((e, t) => {
|
|
121
|
+
let n = X(W(e.from)), r = X(W(e.to));
|
|
122
|
+
return !n || !r || h(e.from, e.to) ? [] : [{
|
|
123
|
+
index: t,
|
|
124
|
+
...ne(n, r)
|
|
125
|
+
}];
|
|
126
|
+
}), $ = H.flatMap((e, t) => {
|
|
127
|
+
let n = X(U[t]);
|
|
128
|
+
return n ? [{
|
|
129
|
+
...e,
|
|
130
|
+
at: n
|
|
131
|
+
}] : [];
|
|
132
|
+
}), fe = C.length === 0;
|
|
133
|
+
return /* @__PURE__ */ x("div", {
|
|
134
|
+
ref: ce,
|
|
135
|
+
className: n("tm-globe-map", se),
|
|
136
|
+
...E,
|
|
137
|
+
children: /* @__PURE__ */ S("div", {
|
|
138
|
+
ref: P,
|
|
139
|
+
className: "tm-globe-map__area",
|
|
140
|
+
"data-settled": A ? "" : void 0,
|
|
141
|
+
children: [
|
|
142
|
+
/* @__PURE__ */ x("canvas", {
|
|
143
|
+
ref: F,
|
|
144
|
+
className: "tm-globe-map__canvas",
|
|
145
|
+
"aria-hidden": "true"
|
|
146
|
+
}),
|
|
147
|
+
/* @__PURE__ */ S("svg", {
|
|
148
|
+
className: "tm-globe-map__overlay",
|
|
149
|
+
viewBox: "0 0 390 255",
|
|
150
|
+
"aria-hidden": "true",
|
|
151
|
+
focusable: "false",
|
|
152
|
+
children: [Q.map((e) => /* @__PURE__ */ x("path", {
|
|
153
|
+
className: "tm-globe-map__route",
|
|
154
|
+
d: K ? s(e, d(e.index, z).drawn) : e.d
|
|
155
|
+
}, e.index)), $.map((e) => e.role === "start" ? /* @__PURE__ */ S("g", { children: [fe ? /* @__PURE__ */ x("circle", {
|
|
156
|
+
className: "tm-globe-map__pulse",
|
|
157
|
+
cx: e.at[0],
|
|
158
|
+
cy: e.at[1],
|
|
159
|
+
r: 17
|
|
160
|
+
}) : null, /* @__PURE__ */ x("circle", {
|
|
161
|
+
className: "tm-globe-map__pin",
|
|
162
|
+
"data-kind": "start",
|
|
163
|
+
cx: e.at[0],
|
|
164
|
+
cy: e.at[1],
|
|
165
|
+
r: 4
|
|
166
|
+
})] }, e.key) : /* @__PURE__ */ x("circle", {
|
|
167
|
+
className: "tm-globe-map__pin",
|
|
168
|
+
"data-kind": "stop",
|
|
169
|
+
cx: e.at[0],
|
|
170
|
+
cy: e.at[1],
|
|
171
|
+
r: 3.25
|
|
172
|
+
}, e.key))]
|
|
173
|
+
}),
|
|
174
|
+
w ? Q.map((e) => {
|
|
175
|
+
let n = K ? d(e.index, z) : null, r = n?.plane == null ? {
|
|
176
|
+
at: e.mid,
|
|
177
|
+
angle: e.angle
|
|
178
|
+
} : o(e, n.plane), i = n ? n.opacity : void 0;
|
|
179
|
+
return /* @__PURE__ */ x("span", {
|
|
180
|
+
className: "tm-globe-map__plane",
|
|
181
|
+
"data-flying": n ? "" : void 0,
|
|
182
|
+
style: {
|
|
183
|
+
...Z(r.at),
|
|
184
|
+
"--_angle": `${r.angle + 45}deg`,
|
|
185
|
+
opacity: i
|
|
186
|
+
},
|
|
187
|
+
children: /* @__PURE__ */ x(t, { size: 16 })
|
|
188
|
+
}, e.index);
|
|
189
|
+
}) : null,
|
|
190
|
+
$.map((e) => /* @__PURE__ */ x("span", {
|
|
191
|
+
className: "tm-globe-map__label",
|
|
192
|
+
"data-role": e.role,
|
|
193
|
+
style: Z(e.at),
|
|
194
|
+
children: re(e.place, oe, D)
|
|
195
|
+
}, e.key))
|
|
196
|
+
]
|
|
197
|
+
})
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
export { w as GlobeMap };
|
|
201
|
+
|
|
202
|
+
//# sourceMappingURL=GlobeMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GlobeMap.js","names":["geoPath","path_default","countryName","language","locale","shipped","world","code","labelOf","place","easeInOutCubic","t","readColour","element","name","GlobeMap","props","setWorld","useState","view","setView","HOME_VIEW","settled","setSettled","width","setWidth","areaRef","useRef","canvasRef","viewRef","reducedMotion","usePrefersReducedMotion","onScreenNow","useOnScreen","elapsed","setElapsed","useEffect","alive","loadWorld","loaded","area","measure","observer","origin","start","segments","stops","useMemo","list","placeKey","from","to","samePlace","stop","points","placePoint","pointOf","known","point","target","fitView","targetKey","duration","step","interpolateView","frame","started","tick","now","animateFlights","end","planes","drawnAfter","time","startCountry","stopCountries","canvas","context","ratio","scale","pixelWidth","pixelHeight","colour","path","projectionFor","shape","highlight","codes","fill","projection","onScreen","isFacing","percent","x","y","legs","a","segment","b","routeArc","pins","at","index","alone","cn","className","arcPathTo","leg","legFrame","pin","flight","arcAt","opacity","PlaneIcon"],"sources":["../../../src/components/GlobeMap/GlobeMap.tsx"],"sourcesContent":["import { geoPath } from 'd3-geo';\nimport { forwardRef, useEffect, useMemo, useRef, useState, type CSSProperties, type HTMLAttributes } from 'react';\nimport { PlaneIcon } from '../../icons';\nimport { cn } from '../../utils/cn';\nimport { useOnScreen, usePrefersReducedMotion } from '../HeroColumns/heroMotion';\nimport {\n FRAME_HEIGHT,\n arcAt,\n arcPathTo,\n drawnAfter,\n legFrame,\n FRAME_WIDTH,\n HOME_VIEW,\n fitView,\n interpolateView,\n isFacing,\n loadWorld,\n placeKey,\n placePoint,\n projectionFor,\n routeArc,\n samePlace,\n type GlobePlace,\n type GlobeSegment,\n type GlobeView,\n type LonLat,\n type World,\n} from './geo';\nimport './GlobeMap.css';\n\nexport type { GlobeCountryPlace, GlobePlace, GlobePointPlace, GlobeSegment } from './geo';\n\nexport interface GlobeMapProps extends HTMLAttributes<HTMLDivElement> {\n /**\n * Where the trip starts (\"Departing from\"): its country is filled in blue, with a white pin. Alone, the globe zooms\n * in on it. Defaults to the `from` of the first segment.\n */\n start?: GlobePlace | null;\n /**\n * The legs of the trip, each drawn as a dotted arc: one leg for a one-way trip or a destination, there and back for\n * a round trip, any chain (or open jaw) for multi-city. Every place other than the start gets a navy country, a pin\n * and a label; the globe turns and zooms so that all of them are in view.\n */\n segments?: readonly GlobeSegment[];\n /**\n * A plane in a white circle on every leg, pointing the way (Figma flight maps 2745:43316 / 2745:43151). Once the globe\n * stops, each leg draws itself with its plane at the tip, one leg after another; then every plane keeps flying its\n * leg. Under `prefers-reduced-motion` the planes rest on the middle of their legs, as in Figma.\n */\n planes?: boolean;\n /** Language of the default labels (country names): `'en'`, `'hy'` or `'ru'` (shipped with the map), others via the browser. Default `'en'`. */\n locale?: string;\n /** Length of the turn-and-zoom animation in ms. Default 900. Skipped under `prefers-reduced-motion`. */\n duration?: number;\n}\n\ninterface Stop {\n key: string;\n place: GlobePlace;\n role: 'start' | 'stop';\n}\n\nfunction countryName(code: string, locale: string, world: World | null): string {\n const language = locale.trim().toLowerCase().split(/[-_]/)[0];\n const shipped = world?.names[language]?.[code];\n if (shipped) return shipped;\n try {\n return new Intl.DisplayNames([locale, 'en'], { type: 'region' }).of(code) ?? code;\n } catch {\n return code;\n }\n}\n\nfunction labelOf(place: GlobePlace, locale: string, world: World | null): string {\n if (place.label) return place.label;\n if (place.kind !== 'country' && place.code) return place.code;\n return countryName(place.countryCode.trim().toUpperCase(), locale, world);\n}\n\nconst easeInOutCubic = (t: number) => (t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2);\n\nfunction readColour(element: Element, name: string): string {\n return getComputedStyle(element).getPropertyValue(name).trim();\n}\n\n/**\n * Figma \"Map\" with \"Map / Globe\" (2966:17945 empty, 2966:18002 departure, 2745:11779 destination, 2745:43316 /\n * 2745:43151 flights): a 3D globe in a card. It starts facing Europe and the Middle East, turns and zooms to the\n * departure once it is chosen, then to fit the whole trip. Countries, cities and airports can be mixed: a country is\n * filled and pinned in its middle, a city or airport fills its country and is pinned at its coordinates.\n */\nexport const GlobeMap = /* @__PURE__ */ forwardRef<HTMLDivElement, GlobeMapProps>(function GlobeMap(\n { start = null, segments = [], planes = false, locale = 'en', duration = 900, className, ...props },\n ref,\n) {\n const [world, setWorld] = useState<World | null>(null);\n const [view, setView] = useState<GlobeView>(HOME_VIEW);\n const [settled, setSettled] = useState(true);\n const [width, setWidth] = useState(FRAME_WIDTH);\n const areaRef = useRef<HTMLDivElement>(null);\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const viewRef = useRef(view);\n viewRef.current = view;\n const reducedMotion = usePrefersReducedMotion();\n const onScreenNow = useOnScreen(areaRef);\n /** ms since the globe stopped: drives the routes drawing in and the planes flying. */\n const [elapsed, setElapsed] = useState(0);\n\n useEffect(() => {\n let alive = true;\n loadWorld().then((loaded) => alive && setWorld(loaded));\n return () => {\n alive = false;\n };\n }, []);\n\n useEffect(() => {\n const area = areaRef.current;\n if (!area) return;\n const measure = () => setWidth(area.clientWidth || FRAME_WIDTH);\n measure();\n if (typeof ResizeObserver === 'undefined') return;\n const observer = new ResizeObserver(measure);\n observer.observe(area);\n return () => observer.disconnect();\n }, []);\n\n /* The places on the map: the start, then every other place of the route once, in order. */\n const origin = start ?? segments[0]?.from ?? null;\n const stops = useMemo<Stop[]>(() => {\n const list: Stop[] = origin ? [{ key: placeKey(origin), place: origin, role: 'start' }] : [];\n for (const { from, to } of segments) {\n for (const place of [from, to]) {\n if (!list.some((stop) => samePlace(stop.place, place))) list.push({ key: placeKey(place), place, role: 'stop' });\n }\n }\n return list;\n }, [origin, segments]);\n\n const points = stops.map((stop) => placePoint(stop.place, world));\n const pointOf = (place: GlobePlace): LonLat | null => points[stops.findIndex((stop) => samePlace(stop.place, place))] ?? null;\n const known = points.filter((point): point is LonLat => point !== null);\n const target = fitView(known);\n const targetKey = `${target.lon.toFixed(3)},${target.lat.toFixed(3)},${target.r.toFixed(2)},${target.x.toFixed(2)},${target.y.toFixed(2)}`;\n\n /* Turn and zoom from wherever the globe is now to the view that fits the trip. */\n useEffect(() => {\n const from = viewRef.current;\n if (reducedMotion || duration <= 0 || typeof requestAnimationFrame === 'undefined') {\n setView(target);\n setSettled(true);\n return;\n }\n const step = interpolateView(from, target);\n let frame = 0;\n let started: number | null = null;\n setSettled(false);\n const tick = (now: number) => {\n started ??= now;\n const t = Math.min(1, (now - started) / duration);\n setView(step(easeInOutCubic(t)));\n if (t < 1) frame = requestAnimationFrame(tick);\n else setSettled(true);\n };\n frame = requestAnimationFrame(tick);\n return () => cancelAnimationFrame(frame);\n // targetKey stands for `target`, which is a new object on every render.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [targetKey, reducedMotion, duration]);\n\n /* Routes draw in and planes fly once the globe has stopped. Without planes the clock stops when every route is drawn. */\n const animateFlights = settled && segments.length > 0 && !reducedMotion && duration > 0;\n useEffect(() => {\n setElapsed(0);\n if (!animateFlights || !onScreenNow || typeof requestAnimationFrame === 'undefined') return;\n const end = planes ? Infinity : drawnAfter(segments.length);\n let frame = 0;\n let started: number | null = null;\n const tick = (now: number) => {\n started ??= now;\n const time = Math.min(end, now - started);\n setElapsed(time);\n if (time < end) frame = requestAnimationFrame(tick);\n };\n frame = requestAnimationFrame(tick);\n return () => cancelAnimationFrame(frame);\n }, [animateFlights, onScreenNow, planes, segments.length]);\n\n /* Country fills: the start's country blue, the other places' countries navy. */\n const startCountry = origin?.countryCode.trim().toUpperCase() ?? null;\n const stopCountries = useMemo(\n () => new Set(stops.filter((stop) => stop.role === 'stop').map((stop) => stop.place.countryCode.trim().toUpperCase())),\n [stops],\n );\n\n useEffect(() => {\n const canvas = canvasRef.current;\n const context = canvas?.getContext('2d');\n if (!canvas || !context) return;\n const ratio = typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1;\n const scale = width / FRAME_WIDTH;\n const pixelWidth = Math.round(width * ratio);\n const pixelHeight = Math.round(FRAME_HEIGHT * scale * ratio);\n if (canvas.width !== pixelWidth) canvas.width = pixelWidth;\n if (canvas.height !== pixelHeight) canvas.height = pixelHeight;\n context.setTransform(ratio * scale, 0, 0, ratio * scale, 0, 0);\n context.clearRect(0, 0, FRAME_WIDTH, FRAME_HEIGHT);\n\n const colour = (name: string) => readColour(canvas, name);\n const path = geoPath(projectionFor(view), context);\n context.lineJoin = 'round';\n\n context.beginPath();\n path({ type: 'Sphere' });\n context.fillStyle = colour('--_sea');\n context.fill();\n context.lineWidth = 1;\n context.strokeStyle = colour('--_border');\n context.stroke();\n if (!world) return;\n\n context.beginPath();\n for (const shape of world.features) path(shape);\n context.fillStyle = colour('--_land');\n context.fill();\n context.lineWidth = 0.5;\n context.stroke();\n\n const highlight = (codes: Set<string>, fill: string) => {\n if (codes.size === 0) return;\n context.beginPath();\n for (const shape of world.features) if (typeof shape.id === 'string' && codes.has(shape.id)) path(shape);\n context.fillStyle = fill;\n context.fill();\n };\n const stopsOnly = new Set([...stopCountries].filter((code) => code !== startCountry));\n highlight(stopsOnly, colour('--_stop'));\n highlight(new Set(startCountry ? [startCountry] : []), colour('--_start'));\n }, [view, world, width, startCountry, stopCountries]);\n\n /* Overlay: routes, pins, planes and labels, projected for the current frame of the animation. */\n const projection = projectionFor(view);\n const onScreen = (point: LonLat | null) => {\n if (!point || !isFacing(point, view)) return null;\n return projection(point as [number, number]) ?? null;\n };\n const percent = ([x, y]: readonly [number, number]) =>\n ({ '--_x': `${(x / FRAME_WIDTH) * 100}%`, '--_y': `${(y / FRAME_HEIGHT) * 100}%` }) as CSSProperties;\n\n const legs = segments.flatMap((segment, index) => {\n const a = onScreen(pointOf(segment.from));\n const b = onScreen(pointOf(segment.to));\n if (!a || !b || samePlace(segment.from, segment.to)) return [];\n return [{ index, ...routeArc(a, b) }];\n });\n const pins = stops.flatMap((stop, index) => {\n const at = onScreen(points[index]);\n return at ? [{ ...stop, at }] : [];\n });\n const alone = segments.length === 0;\n\n return (\n <div ref={ref} className={cn('tm-globe-map', className)} {...props}>\n <div ref={areaRef} className=\"tm-globe-map__area\" data-settled={settled ? '' : undefined}>\n <canvas ref={canvasRef} className=\"tm-globe-map__canvas\" aria-hidden=\"true\" />\n <svg className=\"tm-globe-map__overlay\" viewBox={`0 0 ${FRAME_WIDTH} ${FRAME_HEIGHT}`} aria-hidden=\"true\" focusable=\"false\">\n {legs.map((leg) => (\n <path key={leg.index} className=\"tm-globe-map__route\" d={animateFlights ? arcPathTo(leg, legFrame(leg.index, elapsed).drawn) : leg.d} />\n ))}\n {pins.map((pin) =>\n pin.role === 'start' ? (\n <g key={pin.key}>\n {alone ? <circle className=\"tm-globe-map__pulse\" cx={pin.at[0]} cy={pin.at[1]} r={17} /> : null}\n <circle className=\"tm-globe-map__pin\" data-kind=\"start\" cx={pin.at[0]} cy={pin.at[1]} r={4} />\n </g>\n ) : (\n <circle key={pin.key} className=\"tm-globe-map__pin\" data-kind=\"stop\" cx={pin.at[0]} cy={pin.at[1]} r={3.25} />\n ),\n )}\n </svg>\n {planes\n ? legs.map((leg) => {\n // Animated: on its way along the leg; otherwise resting on the middle of it, as in Figma.\n const frame = animateFlights ? legFrame(leg.index, elapsed) : null;\n const flight = frame?.plane != null ? arcAt(leg, frame.plane) : { at: leg.mid, angle: leg.angle };\n const opacity = frame ? frame.opacity : undefined;\n return (\n <span\n key={leg.index}\n className=\"tm-globe-map__plane\"\n data-flying={frame ? '' : undefined}\n // The icon's nose points up and to the right (-45°).\n style={{ ...percent(flight.at), '--_angle': `${flight.angle + 45}deg`, opacity } as CSSProperties}\n >\n <PlaneIcon size={16} />\n </span>\n );\n })\n : null}\n {pins.map((pin) => (\n <span key={pin.key} className=\"tm-globe-map__label\" data-role={pin.role} style={percent(pin.at)}>\n {labelOf(pin.place, locale, world)}\n </span>\n ))}\n </div>\n </div>\n );\n});\n"],"mappings":";;;;;;;;;;AA8DA,SAASE,EAAY,GAAc,GAAgB,GAA6B;CAC9E,IAAMC,IAAWC,EAAO,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC,IACrDC,IAAUC,GAAO,MAAMH,EAAS,GAAGI;CACzC,IAAIF,GAAS,OAAOA;CACpB,IAAI;EACF,OAAO,IAAI,KAAK,aAAa,CAACD,GAAQ,IAAI,GAAG,EAAE,MAAM,SAAS,CAAC,CAAC,CAAC,GAAGG,CAAI,KAAKA;CAC/E,QAAQ;EACN,OAAOA;CACT;AACF;AAEA,SAASC,GAAQ,GAAmB,GAAgB,GAA6B;CAG/E,OAFIC,EAAM,QAAcA,EAAM,QAC1BA,EAAM,SAAS,aAAaA,EAAM,OAAaA,EAAM,OAClDP,EAAYO,EAAM,YAAY,KAAK,CAAC,CAAC,YAAY,GAAGL,GAAQE,CAAK;AAC1E;AAEA,IAAMI,MAAkB,MAAeC,IAAI,KAAM,IAAIA,IAAIA,IAAIA,IAAI,KAAa,KAAKA,IAAI,MAAG,IAAK;AAE/F,SAASC,GAAW,GAAkB,GAAsB;CAC1D,OAAO,iBAAiBC,CAAO,CAAC,CAAC,iBAAiBC,CAAI,CA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IA,EAAI,GAAG;MAAI,GAAG;KAAK,CAAA,IAAI,MAC3F,kBAAC,UAAD;MAAQ,WAAU;MAAoB,aAAU;MAAQ,IAAIA,EAAI,GAAG;MAAI,IAAIA,EAAI,GAAG;MAAI,GAAG;KAAI,CAAA,CAC5F,EAAA,GAHKA,EAAI,GAGT,IAEH,kBAAC,UAAD;MAAsB,WAAU;MAAoB,aAAU;MAAO,IAAIA,EAAI,GAAG;MAAI,IAAIA,EAAI,GAAG;MAAI,GAAG;KAAO,GAAhGA,EAAI,GAA4F,CAEjH,CACG;;IACJtC,IACGwB,EAAK,KAAK,MAAQ;KAEhB,IAAM9B,IAAQI,IAAiBuC,EAASD,EAAI,OAAOzE,CAAO,IAAI,MACxD4E,IAAS7C,GAAO,SAAS,OAAiC;MAAE,IAAI0C,EAAI;MAAK,OAAOA,EAAI;KAAM,IAA1DI,EAAMJ,GAAK1C,EAAM,KAAK,GACtD+C,IAAU/C,IAAQA,EAAM,UAAU,KAAA;KACxC,OACE,kBAAC,QAAD;MAEE,WAAU;MACV,eAAaA,IAAQ,KAAK,KAAA;MAE1B,OAAO;OAAE,GAAG2B,EAAQkB,EAAO,EAAE;OAAG,YAAY,GAAGA,EAAO,QAAQ,GAAG;OAAM;MAAQ;MAE/E,UAAA,kBAACG,GAAD,EAAW,MAAM,GAAK,CAAA;KAClB,GAPCN,EAAI,KAOL;IAEV,CAAC,IACD;IACHP,EAAK,KAAK,MACT,kBAAC,QAAD;KAAoB,WAAU;KAAsB,aAAWS,EAAI;KAAM,OAAOjB,EAAQiB,EAAI,EAAE;KAC3F,UAAArG,GAAQqG,EAAI,OAAOzG,IAAQE,CAAK;IAC7B,GAFKuG,EAAI,GAET,CACP;GACE;;CACF,CAAA;AAET,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";const e=require("../../node_modules/d3-geo/src/area.cjs"),t=require("../../node_modules/d3-geo/src/centroid.cjs"),n=require("../../node_modules/d3-geo/src/distance.cjs"),r=require("../../node_modules/d3-geo/src/interpolate.cjs"),i=require("../../node_modules/d3-geo/src/projection/orthographic.cjs"),a=require("../../node_modules/topojson-client/src/feature.cjs");var o=null;function s(){return o??(o=Promise.resolve().then(()=>require("./world.json.cjs")).then(e=>c(e.default))),o}function c(n){let r=a.default(n,n.objects.countries).features,i=new Map;for(let n of r){if(typeof n.id!=`string`)continue;let r=n.geometry.type===`Polygon`?[n.geometry.coordinates]:n.geometry.coordinates;for(let a of r){let r={type:`Polygon`,coordinates:a},o=e.default(r);o>=(i.get(n.id)?.area??0)&&i.set(n.id,{area:o,anchor:t.default(r)})}}return{features:r,anchors:new Map([...i].map(([e,{anchor:t}])=>[e,t])),names:n.names??{}}}var l=6371;function u(e){let t=e.countryCode.trim().toUpperCase();return e.kind===`country`?`country:${t}`:e.code?`airport:${e.code.trim().toUpperCase()}`:e.latitude!=null&&e.longitude!=null?`point:${e.latitude.toFixed(3)},${e.longitude.toFixed(3)}`:`city:${t}:${(e.label??``).trim().toLowerCase()}`}function d(e,t){return e.kind!==`country`&&e.latitude!=null&&e.longitude!=null?[e.longitude,e.latitude]:t?.anchors.get(e.countryCode.trim().toUpperCase())??null}function f(e,t){if(u(e)===u(t))return!0;if(e.kind===`country`||t.kind===`country`||e.countryCode.trim().toUpperCase()!==t.countryCode.trim().toUpperCase())return!1;let r=d(e,null),i=d(t,null);return r&&i?n.default(r,i)*l<50:!!e.label&&!!t.label&&e.label.trim().toLowerCase()===t.label.trim().toLowerCase()}var p={lon:30,lat:38,r:117.9,x:195,y:255/2},m=1080,h=90;function g(e){if(e.length===0)return p;let n=e.length===1?e[0]:t.default({type:`MultiPoint`,coordinates:e}),[r,a]=Number.isFinite(n[0])&&Number.isFinite(n[1])?n:e[0],o=i.default().rotate([-r,-a]).scale(1).translate([0,0]),s=e.map(e=>o(e)??[0,0]),c=s.map(([e])=>e),l=s.map(([,e])=>e),[u,d,f,g]=[Math.min(...c),Math.max(...c),Math.min(...l),Math.max(...l)],_=Math.max(h,Math.min(m,230/Math.max(d-u,1e-6),155/Math.max(g-f,1e-6)));return{lon:r,lat:a,r:_,x:195-_*((u+d)/2),y:125.5-_*((f+g)/2)}}function _(e,t){let n=r.default([e.lon,e.lat],[t.lon,t.lat]);return r=>{let[i,a]=n(r);return{lon:i,lat:a,r:e.r*(t.r/e.r)**+r,x:e.x+(t.x-e.x)*r,y:e.y+(t.y-e.y)*r}}}function v(e){return i.default().rotate([-e.lon,-e.lat]).scale(e.r).translate([e.x,e.y]).clipAngle(90).clipExtent([[-2,-2],[392,257]]).precision(.4)}function y(e,t){return n.default(e,[t.lon,t.lat])<Math.PI/2-.01}var b=.12,x=e=>e.toFixed(2),S=(e,t,n)=>[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n];function C(e,t){let n=t[0]-e[0],r=t[1]-e[1],i=[(e[0]+t[0])/2-r*b*2,(e[1]+t[1])/2+n*b*2];return{d:`M${x(e[0])} ${x(e[1])}Q${x(i[0])} ${x(i[1])} ${x(t[0])} ${x(t[1])}`,p0:e,c:i,p1:t,mid:[(e[0]+t[0])/2-r*b,(e[1]+t[1])/2+n*b],angle:Math.atan2(r,n)*180/Math.PI}}function w({p0:e,c:t,p1:n},r){let i=S(e,t,r),a=S(t,n,r);return{at:S(i,a,r),angle:Math.atan2(a[1]-i[1],a[0]-i[0])*180/Math.PI}}function T(e,t){if(t>=1)return e.d;let n=S(e.p0,e.c,t),r=w(e,t).at;return`M${x(e.p0[0])} ${x(e.p0[1])}Q${x(n[0])} ${x(n[1])} ${x(r[0])} ${x(r[1])}`}var E=1100,D=1400,O=3200,k=.12,A=e=>-(Math.cos(Math.PI*e)-1)/2;function j(e,t){let n=t-e*500;if(n<=0)return{drawn:0,plane:null,opacity:0};if(n<1100){let e=A(n/E);return{drawn:e,plane:e,opacity:Math.min(1,e/k,(1-e)/k)}}let r=(n-E)%4600;if(r<1400)return{drawn:1,plane:null,opacity:0};let i=A((r-D)/O);return{drawn:1,plane:i,opacity:Math.min(1,i/k,(1-i)/k)}}var M=e=>(e-1)*500+E;exports.DRAW_MS=E,exports.FLY_MS=O,exports.HOME_VIEW=p,exports.PAUSE_MS=D,exports.PLACE_RADIUS=m,exports.arcAt=w,exports.arcPathTo=T,exports.buildWorld=c,exports.drawnAfter=M,exports.fitView=g,exports.interpolateView=_,exports.isFacing=y,exports.legFrame=j,exports.loadWorld=s,exports.placeKey=u,exports.placePoint=d,exports.projectionFor=v,exports.routeArc=C,exports.samePlace=f;
|
|
2
|
+
//# sourceMappingURL=geo.cjs.map
|