@dxos/react-ui-geo 0.8.3 → 0.8.4-main.05e74ebcff

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.
Files changed (101) hide show
  1. package/LICENSE +102 -5
  2. package/data/airports.ts +1 -1
  3. package/data/cities.ts +1 -1
  4. package/data/countries-110m.ts +1 -1
  5. package/data/countries-dots-3.ts +1 -1
  6. package/data/countries-dots-4.ts +1 -1
  7. package/dist/lib/browser/{countries-110m-WI4PCLDF.mjs → countries-110m-RE5RNRQG.mjs} +2 -2
  8. package/dist/lib/browser/countries-110m-RE5RNRQG.mjs.map +7 -0
  9. package/dist/lib/browser/data.mjs +4 -3
  10. package/dist/lib/browser/data.mjs.map +4 -4
  11. package/dist/lib/browser/index.mjs +396 -466
  12. package/dist/lib/browser/index.mjs.map +3 -3
  13. package/dist/lib/browser/meta.json +1 -1
  14. package/dist/lib/browser/translations.mjs +19 -0
  15. package/dist/lib/browser/translations.mjs.map +7 -0
  16. package/dist/lib/node-esm/{countries-110m-DQ4XRC4B.mjs → countries-110m-4EDBXSFJ.mjs} +2 -2
  17. package/dist/lib/node-esm/countries-110m-4EDBXSFJ.mjs.map +7 -0
  18. package/dist/lib/node-esm/data.mjs +5 -3
  19. package/dist/lib/node-esm/data.mjs.map +4 -4
  20. package/dist/lib/node-esm/index.mjs +396 -465
  21. package/dist/lib/node-esm/index.mjs.map +3 -3
  22. package/dist/lib/node-esm/meta.json +1 -1
  23. package/dist/lib/node-esm/translations.mjs +21 -0
  24. package/dist/lib/node-esm/translations.mjs.map +7 -0
  25. package/dist/types/data/airports.d.ts +4 -4
  26. package/dist/types/data/airports.d.ts.map +1 -1
  27. package/dist/types/data/cities.d.ts.map +1 -1
  28. package/dist/types/data/countries-110m.d.ts.map +1 -1
  29. package/dist/types/data/countries-dots-3.d.ts.map +1 -1
  30. package/dist/types/data/countries-dots-4.d.ts.map +1 -1
  31. package/dist/types/src/components/Globe/Globe.d.ts +6 -4
  32. package/dist/types/src/components/Globe/Globe.d.ts.map +1 -1
  33. package/dist/types/src/components/Globe/Globe.stories.d.ts +27 -9
  34. package/dist/types/src/components/Globe/Globe.stories.d.ts.map +1 -1
  35. package/dist/types/src/components/Map/Map.d.ts +42 -18
  36. package/dist/types/src/components/Map/Map.d.ts.map +1 -1
  37. package/dist/types/src/components/Map/Map.stories.d.ts +14 -8
  38. package/dist/types/src/components/Map/Map.stories.d.ts.map +1 -1
  39. package/dist/types/src/components/Toolbar/Controls.d.ts.map +1 -1
  40. package/dist/types/src/components/index.d.ts +0 -1
  41. package/dist/types/src/components/index.d.ts.map +1 -1
  42. package/dist/types/src/hooks/context.d.ts +6 -8
  43. package/dist/types/src/hooks/context.d.ts.map +1 -1
  44. package/dist/types/src/hooks/useDrag.d.ts.map +1 -1
  45. package/dist/types/src/hooks/useGlobeZoomHandler.d.ts +2 -2
  46. package/dist/types/src/hooks/useGlobeZoomHandler.d.ts.map +1 -1
  47. package/dist/types/src/hooks/useMapZoomHandler.d.ts +2 -2
  48. package/dist/types/src/hooks/useMapZoomHandler.d.ts.map +1 -1
  49. package/dist/types/src/hooks/useSpinner.d.ts +1 -1
  50. package/dist/types/src/hooks/useSpinner.d.ts.map +1 -1
  51. package/dist/types/src/hooks/useTour.d.ts +4 -3
  52. package/dist/types/src/hooks/useTour.d.ts.map +1 -1
  53. package/dist/types/src/index.d.ts +1 -2
  54. package/dist/types/src/index.d.ts.map +1 -1
  55. package/dist/types/src/translations.d.ts +12 -0
  56. package/dist/types/src/translations.d.ts.map +1 -0
  57. package/dist/types/src/types.d.ts +2 -1
  58. package/dist/types/src/types.d.ts.map +1 -1
  59. package/dist/types/src/util/debug.d.ts.map +1 -1
  60. package/dist/types/src/util/inertia.d.ts.map +1 -1
  61. package/dist/types/src/util/path.d.ts +5 -8
  62. package/dist/types/src/util/path.d.ts.map +1 -1
  63. package/dist/types/src/util/render.d.ts +4 -4
  64. package/dist/types/src/util/render.d.ts.map +1 -1
  65. package/dist/types/tsconfig.tsbuildinfo +1 -1
  66. package/package.json +44 -35
  67. package/src/components/Globe/Globe.stories.tsx +85 -38
  68. package/src/components/Globe/Globe.tsx +124 -81
  69. package/src/components/Map/Map.stories.tsx +27 -15
  70. package/src/components/Map/Map.tsx +220 -94
  71. package/src/components/Toolbar/Controls.tsx +14 -20
  72. package/src/components/index.ts +0 -2
  73. package/src/hooks/context.tsx +11 -34
  74. package/src/hooks/useGlobeZoomHandler.ts +9 -3
  75. package/src/hooks/useMapZoomHandler.ts +1 -1
  76. package/src/hooks/useSpinner.ts +1 -1
  77. package/src/hooks/useTour.ts +10 -8
  78. package/src/index.ts +1 -2
  79. package/src/translations.ts +20 -0
  80. package/src/types.ts +3 -1
  81. package/src/util/inertia.ts +1 -1
  82. package/src/util/path.ts +5 -6
  83. package/src/util/render.ts +4 -3
  84. package/dist/lib/browser/chunk-ENCWOTYX.mjs +0 -9
  85. package/dist/lib/browser/chunk-ENCWOTYX.mjs.map +0 -7
  86. package/dist/lib/browser/countries-110m-WI4PCLDF.mjs.map +0 -7
  87. package/dist/lib/node/chunk-LAICG6L2.cjs +0 -40
  88. package/dist/lib/node/chunk-LAICG6L2.cjs.map +0 -7
  89. package/dist/lib/node/countries-110m-KQ5WAB2O.cjs +0 -37877
  90. package/dist/lib/node/countries-110m-KQ5WAB2O.cjs.map +0 -7
  91. package/dist/lib/node/data.cjs +0 -28
  92. package/dist/lib/node/data.cjs.map +0 -7
  93. package/dist/lib/node/index.cjs +0 -1187
  94. package/dist/lib/node/index.cjs.map +0 -7
  95. package/dist/lib/node/meta.json +0 -1
  96. package/dist/lib/node-esm/chunk-PIIEDZEU.mjs +0 -11
  97. package/dist/lib/node-esm/chunk-PIIEDZEU.mjs.map +0 -7
  98. package/dist/lib/node-esm/countries-110m-DQ4XRC4B.mjs.map +0 -7
  99. package/dist/types/src/components/types.d.ts +0 -15
  100. package/dist/types/src/components/types.d.ts.map +0 -1
  101. package/src/components/types.ts +0 -19
package/package.json CHANGED
@@ -1,84 +1,93 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-geo",
3
- "version": "0.8.3",
3
+ "version": "0.8.4-main.05e74ebcff",
4
4
  "description": "Geo components.",
5
5
  "homepage": "https://github.com/dxos",
6
6
  "bugs": "https://github.com/dxos/issues",
7
- "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dxos/dxos"
10
+ },
11
+ "license": "FSL-1.1-Apache-2.0",
8
12
  "author": "DXOS.org",
9
13
  "sideEffects": true,
10
14
  "type": "module",
15
+ "imports": {
16
+ "#translations": "./src/translations.ts"
17
+ },
11
18
  "exports": {
19
+ ".": {
20
+ "source": "./src/index.ts",
21
+ "types": "./dist/types/src/index.d.ts",
22
+ "browser": "./dist/lib/browser/index.mjs",
23
+ "node": "./dist/lib/node-esm/index.mjs"
24
+ },
12
25
  "./data": {
26
+ "source": "./src/data.ts",
13
27
  "types": "./dist/types/src/data.d.ts",
14
28
  "browser": "./dist/lib/browser/data.mjs",
15
29
  "node": "./dist/lib/node-esm/data.mjs"
16
30
  },
17
- ".": {
18
- "types": "./dist/types/src/index.d.ts",
19
- "browser": "./dist/lib/browser/index.mjs",
20
- "node": "./dist/lib/node-esm/index.mjs"
31
+ "./translations": {
32
+ "source": "./src/translations.ts",
33
+ "types": "./dist/types/src/translations.d.ts",
34
+ "browser": "./dist/lib/browser/translations.mjs",
35
+ "node": "./dist/lib/node-esm/translations.mjs"
21
36
  }
22
37
  },
23
38
  "types": "dist/types/src/index.d.ts",
24
- "typesVersions": {
25
- "*": {
26
- "data": [
27
- "dist/types/src/data.d.ts"
28
- ]
29
- }
30
- },
31
39
  "files": [
32
40
  "data",
33
41
  "dist",
34
42
  "src"
35
43
  ],
36
44
  "dependencies": {
37
- "@preact-signals/safe-react": "^0.9.0",
45
+ "@radix-ui/react-compose-refs": "1.1.1",
46
+ "@radix-ui/react-context": "1.1.1",
38
47
  "d3": "^7.9.0",
39
48
  "d3-geo-projection": "^4.0.0",
40
49
  "d3-hexbin": "^0.2.2",
41
50
  "geojson": "^0.5.0",
42
51
  "leaflet": "^1.9.4",
43
52
  "lodash.defaultsdeep": "^4.6.1",
44
- "react-leaflet": "^4.2.1",
53
+ "react-leaflet": "^5.0.0",
45
54
  "react-resize-detector": "^11.0.1",
46
55
  "topojson-client": "^3.1.0",
47
56
  "topojson-simplify": "^3.0.3",
48
57
  "versor": "^0.2.0",
49
- "@dxos/async": "0.8.3",
50
- "@dxos/log": "0.8.3",
51
- "@dxos/debug": "0.8.3",
52
- "@dxos/util": "0.8.3",
53
- "@dxos/node-std": "0.8.3"
58
+ "@dxos/debug": "0.8.4-main.05e74ebcff",
59
+ "@dxos/async": "0.8.4-main.05e74ebcff",
60
+ "@dxos/log": "0.8.4-main.05e74ebcff",
61
+ "@dxos/node-std": "0.8.4-main.05e74ebcff",
62
+ "@dxos/util": "0.8.4-main.05e74ebcff"
54
63
  },
55
64
  "devDependencies": {
56
- "@react-three/drei": "^9.99.0",
57
- "@react-three/fiber": "^8.15.0",
65
+ "@react-three/drei": "^10.7.7",
66
+ "@react-three/fiber": "^9.5.0",
58
67
  "@types/d3": "^7.4.3",
59
68
  "@types/geojson": "^7946.0.14",
60
69
  "@types/leaflet": "^1.9.16",
61
- "@types/react": "~18.2.0",
62
- "@types/react-dom": "~18.2.0",
70
+ "@types/react": "~19.2.7",
71
+ "@types/react-dom": "~19.2.3",
63
72
  "@types/three": "0.165.0",
64
73
  "@types/topojson-client": "^3.1.4",
65
74
  "@types/topojson-simplify": "^3.0.3",
66
75
  "@types/topojson-specification": "^1.0.5",
67
76
  "JSONStream": "^1.3.5",
68
77
  "geojson2h3": "^1.2.0",
69
- "leva": "^0.9.35",
70
- "react": "~18.2.0",
71
- "react-dom": "~18.2.0",
72
- "three": "0.165.0",
73
- "@dxos/react-ui": "0.8.3",
74
- "@dxos/react-ui-theme": "0.8.3",
75
- "@dxos/storybook-utils": "0.8.3"
78
+ "leva": "^0.10.1",
79
+ "react": "~19.2.3",
80
+ "react-dom": "~19.2.3",
81
+ "three": "^0.178.0",
82
+ "@dxos/storybook-utils": "0.8.4-main.05e74ebcff",
83
+ "@dxos/ui-theme": "0.8.4-main.05e74ebcff",
84
+ "@dxos/react-ui": "0.8.4-main.05e74ebcff"
76
85
  },
77
86
  "peerDependencies": {
78
- "react": "~18.2.0",
79
- "react-dom": "~18.2.0",
80
- "@dxos/react-ui": "0.8.3",
81
- "@dxos/react-ui-theme": "0.8.3"
87
+ "react": "~19.2.3",
88
+ "react-dom": "~19.2.3",
89
+ "@dxos/ui-theme": "0.8.4-main.05e74ebcff",
90
+ "@dxos/react-ui": "0.8.4-main.05e74ebcff"
82
91
  },
83
92
  "publishConfig": {
84
93
  "access": "public"
@@ -2,21 +2,20 @@
2
2
  // Copyright 2018 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
- import { type Meta } from '@storybook/react';
5
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
8
6
  import { type FeatureCollection, type Geometry, type Position } from 'geojson';
9
7
  import { Leva } from 'leva';
10
8
  import React, { useMemo, useRef, useState } from 'react';
11
9
  import { type Topology } from 'topojson-specification';
12
10
 
13
11
  import { useAsyncState } from '@dxos/react-ui';
14
- import { withTheme, withLayout } from '@dxos/storybook-utils';
12
+ import { withLayout, withTheme } from '@dxos/react-ui/testing';
15
13
 
16
- import { Globe, type GlobeCanvasProps, type GlobeController, type GlobeRootProps } from './Globe';
17
- import { useDrag, useGlobeZoomHandler, useSpinner, useTour, type Vector } from '../../hooks';
18
- import { closestPoint, type LatLng, type StyleSet } from '../../util';
14
+ import { type Vector, useDrag, useGlobeZoomHandler, useSpinner, useTour } from '../../hooks';
15
+ import { type LatLngLiteral } from '../../types';
16
+ import { type StyleSet, closestPoint } from '../../util';
19
17
  import { type ControlProps } from '../Toolbar';
18
+ import { Globe, type GlobeCanvasProps, type GlobeController, type GlobeRootProps } from './Globe';
20
19
 
21
20
  // TODO(burdon): Load from JSON at runtime?
22
21
  const useTopology = () => {
@@ -95,8 +94,11 @@ const createTrip = (
95
94
  routes: Record<string, string[]>,
96
95
  points: Position[] = [],
97
96
  ) => {
98
- let previousHub: LatLng;
99
- return Object.entries(routes).reduce<{ points: LatLng[]; lines: { source: LatLng; target: LatLng }[] }>(
97
+ let previousHub: LatLngLiteral;
98
+ return Object.entries(routes).reduce<{
99
+ points: LatLngLiteral[];
100
+ lines: { source: LatLngLiteral; target: LatLngLiteral }[];
101
+ }>(
100
102
  (features, [hub, regional]) => {
101
103
  const hubAirport = airports.features.find(({ properties }) => properties.iata === hub);
102
104
  if (hubAirport) {
@@ -125,7 +127,7 @@ const createTrip = (
125
127
  );
126
128
  };
127
129
 
128
- type StoryProps = Pick<GlobeRootProps, 'scale' | 'translation' | 'rotation'> &
130
+ type DefaultStoryProps = Pick<GlobeRootProps, 'zoom' | 'translation' | 'rotation'> &
129
131
  Pick<GlobeCanvasProps, 'projection' | 'styles'> & {
130
132
  drag?: boolean;
131
133
  spin?: boolean;
@@ -133,17 +135,17 @@ type StoryProps = Pick<GlobeRootProps, 'scale' | 'translation' | 'rotation'> &
133
135
  xAxis?: boolean;
134
136
  };
135
137
 
136
- const Story = ({
137
- scale: _scale = 1,
138
+ const DefaultStory = ({
139
+ zoom: zoomProp = 1,
138
140
  translation,
139
141
  rotation = [0, 0, 0],
140
142
  projection,
141
- styles,
143
+ styles = defaultStyles,
142
144
  drag = false,
143
145
  spin = false,
144
146
  tour = false,
145
147
  xAxis = false,
146
- }: StoryProps) => {
148
+ }: DefaultStoryProps) => {
147
149
  const controller = useRef<GlobeController>(null);
148
150
  const [dots] = useAsyncState(async () => {
149
151
  const points = (await import('../../../data/countries-dots-3.ts')).default;
@@ -154,6 +156,7 @@ const Story = ({
154
156
  });
155
157
  const [topology] = useTopology();
156
158
  const [airports] = useAsyncState(async () => (await import('../../../data/airports.ts')).default);
159
+
157
160
  const features = useMemo(() => {
158
161
  return airports ? createTrip(airports, routes, (dots?.objects.dots as any)?.geometries[0].coordinates) : undefined;
159
162
  }, [airports, routes, dots]);
@@ -188,24 +191,24 @@ const Story = ({
188
191
  break;
189
192
  }
190
193
  case 'zoom-in': {
191
- controller.current.setScale((scale) => scale * 1.1);
194
+ controller.current.setZoom((scale) => scale * 1.1);
192
195
  break;
193
196
  }
194
197
  case 'zoom-out': {
195
- controller.current.setScale((scale) => scale * 0.9);
198
+ controller.current.setZoom((scale) => scale * 0.9);
196
199
  break;
197
200
  }
198
201
  }
199
202
  };
200
203
 
201
204
  return (
202
- <Globe.Root classNames='absolute inset-0' scale={_scale} translation={translation} rotation={rotation}>
205
+ <Globe.Root zoom={zoomProp} translation={translation} rotation={rotation}>
203
206
  <Globe.Canvas
204
- ref={controller}
205
207
  topology={styles?.dots ? dots : topology}
206
208
  projection={projection}
207
209
  styles={styles}
208
210
  features={tour ? { points: features?.points ?? [] } : features}
211
+ ref={controller}
209
212
  />
210
213
  <Globe.Zoom onAction={handleAction} />
211
214
  <Globe.Action onAction={handleAction} />
@@ -219,11 +222,15 @@ const Story = ({
219
222
 
220
223
  const initialRotation: Vector = [0, -40, 0];
221
224
 
222
- const meta: Meta = {
225
+ const meta = {
223
226
  title: 'ui/react-ui-geo/Globe',
224
227
  component: Globe.Root,
225
- decorators: [withTheme, withLayout({ fullscreen: true, classNames: 'bg-[#000]' })],
226
- };
228
+ render: DefaultStory,
229
+ decorators: [withTheme(), withLayout({ layout: 'fullscreen' })],
230
+ parameters: {
231
+ layout: 'fullscreen',
232
+ },
233
+ } satisfies Meta;
227
234
 
228
235
  export default meta;
229
236
 
@@ -234,8 +241,8 @@ export const Earth1 = () => {
234
241
  useDrag(controller);
235
242
 
236
243
  return (
237
- <Globe.Root scale={1.2} rotation={[Math.random() * 360, 0, 0]}>
238
- <Globe.Canvas ref={setController} topology={topology} />
244
+ <Globe.Root zoom={1.2} rotation={[Math.random() * 360, 0, 0]}>
245
+ <Globe.Canvas ref={setController} topology={topology} styles={defaultStyles} />
239
246
  <Globe.Zoom onAction={handleAction} />
240
247
  </Globe.Root>
241
248
  );
@@ -249,8 +256,8 @@ export const Earth2 = () => {
249
256
 
250
257
  return (
251
258
  <div className='absolute bottom-0 left-0 right-0 '>
252
- <Globe.Root classNames='h-[400px]' scale={2.8} translation={{ x: 0, y: 400 }}>
253
- <Globe.Canvas ref={setController} topology={topology} />
259
+ <Globe.Root classNames='h-[400px]' zoom={2.8} translation={{ x: 0, y: 400 }}>
260
+ <Globe.Canvas ref={setController} topology={topology} styles={defaultStyles} />
254
261
  <Globe.Zoom onAction={handleAction} />
255
262
  </Globe.Root>
256
263
  </div>
@@ -283,33 +290,73 @@ export const Mercator = () => {
283
290
  useDrag(controller);
284
291
 
285
292
  return (
286
- <Globe.Root classNames='flex grow overflow-hidden' scale={0.7} rotation={initialRotation}>
293
+ <Globe.Root classNames='flex grow overflow-hidden' zoom={0.7} rotation={initialRotation}>
287
294
  <Globe.Canvas ref={setController} topology={topology} projection='mercator' styles={monochrome} />
288
295
  <Globe.Zoom onAction={handleAction} />
289
296
  </Globe.Root>
290
297
  );
291
298
  };
292
299
 
293
- export const Globe1 = () => {
294
- return <Story drag projection='mercator' scale={0.8} rotation={initialRotation} />;
300
+ type Story = StoryObj<typeof DefaultStory>;
301
+
302
+ export const Globe1: Story = {
303
+ args: {
304
+ drag: true,
305
+ projection: 'mercator',
306
+ zoom: 0.8,
307
+ rotation: initialRotation,
308
+ styles: defaultStyles,
309
+ },
295
310
  };
296
311
 
297
- export const Globe2 = () => {
298
- return <Story drag projection='transverse-mercator' scale={0.8} rotation={initialRotation} styles={defaultStyles} />;
312
+ export const Globe2: Story = {
313
+ args: {
314
+ drag: true,
315
+ projection: 'transverse-mercator',
316
+ zoom: 0.8,
317
+ rotation: initialRotation,
318
+ styles: defaultStyles,
319
+ },
299
320
  };
300
321
 
301
- export const Globe3 = () => {
302
- return <Story drag spin scale={1.5} rotation={initialRotation} styles={defaultStyles} />;
322
+ export const Globe3: Story = {
323
+ args: {
324
+ drag: true,
325
+ spin: true,
326
+ zoom: 1.5,
327
+ rotation: initialRotation,
328
+ styles: defaultStyles,
329
+ },
303
330
  };
304
331
 
305
- export const Globe4 = () => {
306
- return <Story drag tour scale={2} rotation={initialRotation} styles={defaultStyles} />;
332
+ export const Globe4: Story = {
333
+ args: {
334
+ drag: true,
335
+ tour: true,
336
+ zoom: 2,
337
+ rotation: initialRotation,
338
+ styles: defaultStyles,
339
+ },
307
340
  };
308
341
 
309
- export const Globe5 = () => {
310
- return <Story drag tour scale={0.9} rotation={initialRotation} styles={dotStyles} />;
342
+ export const Globe5: Story = {
343
+ args: {
344
+ drag: true,
345
+ tour: true,
346
+ zoom: 0.9,
347
+ rotation: initialRotation,
348
+ styles: dotStyles,
349
+ },
311
350
  };
312
351
 
313
- export const Globe6 = () => {
314
- return <Story drag xAxis tour scale={2} translation={{ x: 0, y: 600 }} rotation={[0, -20, 0]} styles={dotStyles} />;
352
+ export const Globe6: Story = {
353
+ args: {
354
+ drag: true,
355
+ xAxis: true,
356
+ tour: true,
357
+ zoom: 2,
358
+ translation: { x: 0, y: 600 },
359
+ rotation: [0, -20, 0],
360
+ styles: dotStyles,
361
+ },
315
362
  };