@dxos/react-ui-geo 0.7.5-labs.ff2ff30 → 0.7.5-main.b19bfc8

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 (38) hide show
  1. package/dist/lib/browser/index.mjs +146 -81
  2. package/dist/lib/browser/index.mjs.map +3 -3
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +123 -58
  5. package/dist/lib/node/index.cjs.map +3 -3
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/lib/node-esm/index.mjs +146 -81
  8. package/dist/lib/node-esm/index.mjs.map +3 -3
  9. package/dist/lib/node-esm/meta.json +1 -1
  10. package/dist/types/src/components/Globe/Globe.d.ts +5 -5
  11. package/dist/types/src/components/Globe/Globe.d.ts.map +1 -1
  12. package/dist/types/src/components/Globe/Globe.stories.d.ts +9 -10
  13. package/dist/types/src/components/Globe/Globe.stories.d.ts.map +1 -1
  14. package/dist/types/src/components/Map/Map.d.ts +9 -10
  15. package/dist/types/src/components/Map/Map.d.ts.map +1 -1
  16. package/dist/types/src/components/Map/Map.stories.d.ts +6 -2
  17. package/dist/types/src/components/Map/Map.stories.d.ts.map +1 -1
  18. package/dist/types/src/components/Toolbar/Controls.d.ts +2 -3
  19. package/dist/types/src/components/Toolbar/Controls.d.ts.map +1 -1
  20. package/dist/types/src/components/types.d.ts +2 -1
  21. package/dist/types/src/components/types.d.ts.map +1 -1
  22. package/dist/types/src/hooks/context.d.ts +2 -2
  23. package/dist/types/src/hooks/context.d.ts.map +1 -1
  24. package/dist/types/src/hooks/useTour.d.ts +8 -3
  25. package/dist/types/src/hooks/useTour.d.ts.map +1 -1
  26. package/dist/types/src/util/debug.d.ts.map +1 -1
  27. package/dist/types/src/util/render.d.ts +2 -2
  28. package/dist/types/src/util/render.d.ts.map +1 -1
  29. package/package.json +12 -10
  30. package/src/components/Globe/Globe.stories.tsx +8 -11
  31. package/src/components/Globe/Globe.tsx +56 -32
  32. package/src/components/Map/Map.stories.tsx +28 -6
  33. package/src/components/Map/Map.tsx +93 -82
  34. package/src/components/types.ts +2 -1
  35. package/src/hooks/useDrag.ts +1 -1
  36. package/src/hooks/useTour.ts +31 -19
  37. package/src/util/debug.ts +1 -0
  38. package/src/util/render.ts +18 -4
@@ -1 +1 @@
1
- {"version":3,"file":"Map.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Map/Map.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAqB5D,QAAA,MAAM,IAAI,EAAE,IAKX,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC;AAEtB,eAAO,MAAM,OAAO,EAAE,KAAU,CAAC"}
1
+ {"version":3,"file":"Map.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Map/Map.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAS5D,QAAA,MAAM,MAAM;;6CAWX,CAAC;AAEF,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,MAAM,CAI7B,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,MAAM,CAAC,CAAC;AAErC,eAAO,MAAM,OAAO,EAAE,KAAU,CAAC;AAEjC,eAAO,MAAM,WAAW,EAAE,KAoBzB,CAAC"}
@@ -1,11 +1,10 @@
1
1
  import { type ControlPosition } from 'leaflet';
2
- import React from 'react';
3
2
  import { type ThemedClassName } from '@dxos/react-ui';
4
3
  export type ControlAction = 'toggle' | 'start' | 'zoom-in' | 'zoom-out';
5
4
  export type ControlProps = ThemedClassName<{
6
5
  onAction?: (action: ControlAction) => void;
7
6
  }>;
8
7
  export declare const controlPositions: Record<ControlPosition, string>;
9
- export declare const ZoomControls: ({ classNames, onAction }: ControlProps) => React.JSX.Element;
10
- export declare const ActionControls: ({ classNames, onAction }: ControlProps) => React.JSX.Element;
8
+ export declare const ZoomControls: ({ classNames, onAction }: ControlProps) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const ActionControls: ({ classNames, onAction }: ControlProps) => import("react/jsx-runtime").JSX.Element;
11
10
  //# sourceMappingURL=Controls.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Controls.d.ts","sourceRoot":"","sources":["../../../../../src/components/Toolbar/Controls.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAc,KAAK,eAAe,EAAW,MAAM,gBAAgB,CAAC;AAE3E,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,CAAC;AAExE,MAAM,MAAM,YAAY,GAAG,eAAe,CAAC;IACzC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;CAC5C,CAAC,CAAC;AAEH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,eAAe,EAAE,MAAM,CAK5D,CAAC;AAEF,eAAO,MAAM,YAAY,6BAA8B,YAAY,sBAuBlE,CAAC;AAEF,eAAO,MAAM,cAAc,6BAA8B,YAAY,sBAuBpE,CAAC"}
1
+ {"version":3,"file":"Controls.d.ts","sourceRoot":"","sources":["../../../../../src/components/Toolbar/Controls.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/C,OAAO,EAAc,KAAK,eAAe,EAAW,MAAM,gBAAgB,CAAC;AAE3E,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,CAAC;AAExE,MAAM,MAAM,YAAY,GAAG,eAAe,CAAC;IACzC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;CAC5C,CAAC,CAAC;AAEH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,eAAe,EAAE,MAAM,CAK5D,CAAC;AAEF,eAAO,MAAM,YAAY,6BAA8B,YAAY,4CAuBlE,CAAC;AAEF,eAAO,MAAM,cAAc,6BAA8B,YAAY,4CAuBpE,CAAC"}
@@ -1,9 +1,10 @@
1
1
  import { type LatLngLiteral } from 'leaflet';
2
2
  import { type ThemedClassName } from '@dxos/react-ui';
3
3
  import { type MapMarker } from '../types';
4
- export type { LatLngLiteral };
4
+ export { type LatLngLiteral };
5
5
  export type MapCanvasProps = ThemedClassName<{
6
6
  markers?: MapMarker[];
7
+ selected?: string[];
7
8
  zoom?: number;
8
9
  center?: LatLngLiteral;
9
10
  onChange?: (ev: {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,YAAY,EAAE,aAAa,EAAE,CAAC;AAE9B,MAAM,MAAM,cAAc,GAAG,eAAe,CAAC;IAC3C,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE;QAAE,MAAM,EAAE,aAAa,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CAClE,CAAC,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/types.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,OAAO,EAAE,KAAK,aAAa,EAAE,CAAC;AAE9B,MAAM,MAAM,cAAc,GAAG,eAAe,CAAC;IAC3C,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE;QAAE,MAAM,EAAE,aAAa,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CAClE,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import React, { type Dispatch, type PropsWithChildren, type SetStateAction } from 'react';
1
+ import { type Dispatch, type PropsWithChildren, type SetStateAction } from 'react';
2
2
  import { type LatLng } from '../util';
3
3
  export type Size = {
4
4
  width: number;
@@ -21,6 +21,6 @@ export type GlobeContextType = {
21
21
  setRotation: Dispatch<SetStateAction<Vector>>;
22
22
  };
23
23
  export type GlobeContextProviderProps = PropsWithChildren<Partial<Pick<GlobeContextType, 'size' | 'center' | 'scale' | 'translation' | 'rotation'>>>;
24
- export declare const GlobeContextProvider: ({ children, size, center: _center, scale: _scale, translation: _translation, rotation: _rotation, }: GlobeContextProviderProps) => React.JSX.Element;
24
+ export declare const GlobeContextProvider: ({ children, size, center: _center, scale: _scale, translation: _translation, rotation: _rotation, }: GlobeContextProviderProps) => import("react/jsx-runtime").JSX.Element;
25
25
  export declare const useGlobeContext: () => GlobeContextType;
26
26
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/hooks/context.tsx"],"names":[],"m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, type SetStateAction } from 'react';
1
2
  import type { GlobeController } from '../components';
2
- import { type Features, type StyleSet } from '../util';
3
+ import { type LatLng, type StyleSet } from '../util';
3
4
  export type TourOptions = {
5
+ running?: boolean;
4
6
  disabled?: boolean;
5
- styles?: StyleSet;
6
7
  duration?: number;
8
+ loop?: boolean;
9
+ tilt?: number;
10
+ autoRotate?: boolean;
11
+ styles?: StyleSet;
7
12
  };
8
13
  /**
9
14
  * Iterates between points.
10
15
  * Inspired by: https://observablehq.com/@mbostock/top-100-cities
11
16
  */
12
- export declare const useTour: (controller?: GlobeController | null, features?: Features, options?: TourOptions) => (() => void)[];
17
+ export declare const useTour: (controller?: GlobeController | null, points?: LatLng[], options?: TourOptions) => [boolean, Dispatch<SetStateAction<boolean>>];
13
18
  //# sourceMappingURL=useTour.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useTour.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTour.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,KAAK,QAAQ,EAAkD,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAMvG,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,OAAO,gBAAiB,eAAe,GAAG,IAAI,aAAa,QAAQ,YAAW,WAAW,mBAwFrG,CAAC"}
1
+ {"version":3,"file":"useTour.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTour.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAuB,MAAM,OAAO,CAAC;AAKhF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAiB,KAAK,MAAM,EAAsB,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAMxF,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,QAAQ,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,OAAO,gBACL,eAAe,GAAG,IAAI,WAC1B,MAAM,EAAE,YACR,WAAW,KACnB,CAAC,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CA0F7C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../../../src/util/debug.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,KAAK,GAAI,CAAC,aAAa,MAAM,CAAC,KAAG,CAS7C,CAAC"}
1
+ {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../../../src/util/debug.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,KAAK,GAAI,CAAC,aAAa,MAAM,CAAC,KAAG,CAU7C,CAAC"}
@@ -2,7 +2,7 @@ import { type GeoPath, type GeoPermissibleObjects } from 'd3';
2
2
  import { type Topology } from 'topojson-specification';
3
3
  import { type LatLng } from './path';
4
4
  export type Styles = Record<string, any>;
5
- export type Style = 'water' | 'graticule' | 'land' | 'border' | 'dots' | 'point' | 'line' | 'cursor' | 'arc';
5
+ export type Style = 'background' | 'water' | 'graticule' | 'land' | 'border' | 'dots' | 'point' | 'line' | 'cursor' | 'arc';
6
6
  export type StyleSet = Partial<Record<Style, Styles>>;
7
7
  export type Features = {
8
8
  points?: LatLng[];
@@ -22,5 +22,5 @@ export declare const createLayers: (topology: Topology, features: Features, styl
22
22
  /**
23
23
  * Render layers created above.
24
24
  */
25
- export declare const renderLayers: (generator: GeoPath, layers: Layer[], scale: number) => CanvasRenderingContext2D;
25
+ export declare const renderLayers: (generator: GeoPath, layers: Layer[], scale: number, styles: StyleSet) => CanvasRenderingContext2D;
26
26
  //# sourceMappingURL=render.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../../src/util/render.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,IAAI,CAAC;AAE9D,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,KAAK,MAAM,EAAqB,MAAM,QAAQ,CAAC;AAExD,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAEzC,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE7G,MAAM,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AAEtD,MAAM,MAAM,QAAQ,GAAG;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,qBAAqB,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,aAAc,QAAQ,YAAY,QAAQ,UAAU,QAAQ,KAAG,KAAK,EA2E5F,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,cAAe,OAAO,UAAU,KAAK,EAAE,SAAc,MAAM,6BAsCnF,CAAC"}
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../../src/util/render.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,IAAI,CAAC;AAE9D,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,KAAK,MAAM,EAAqB,MAAM,QAAQ,CAAC;AAExD,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAEzC,MAAM,MAAM,KAAK,GACb,YAAY,GACZ,OAAO,GACP,WAAW,GACX,MAAM,GACN,QAAQ,GACR,MAAM,GACN,OAAO,GACP,MAAM,GACN,QAAQ,GACR,KAAK,CAAC;AAEV,MAAM,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AAEtD,MAAM,MAAM,QAAQ,GAAG;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,qBAAqB,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,aAAc,QAAQ,YAAY,QAAQ,UAAU,QAAQ,KAAG,KAAK,EA2E5F,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,cAAe,OAAO,UAAU,KAAK,EAAE,SAAc,MAAM,UAAU,QAAQ,6BA0CrG,CAAC"}
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-geo",
3
- "version": "0.7.5-labs.ff2ff30",
3
+ "version": "0.7.5-main.b19bfc8",
4
4
  "description": "Geo components.",
5
5
  "homepage": "https://github.com/dxos",
6
6
  "bugs": "https://github.com/dxos/issues",
7
7
  "license": "MIT",
8
8
  "author": "DXOS.org",
9
9
  "sideEffects": true,
10
+ "type": "module",
10
11
  "exports": {
11
12
  "./data": {
12
13
  "types": "./dist/types/src/data.d.ts",
@@ -44,10 +45,11 @@
44
45
  "topojson-client": "^3.1.0",
45
46
  "topojson-simplify": "^3.0.3",
46
47
  "versor": "^0.2.0",
47
- "@dxos/async": "0.7.5-labs.ff2ff30",
48
- "@dxos/debug": "0.7.5-labs.ff2ff30",
49
- "@dxos/node-std": "0.7.5-labs.ff2ff30",
50
- "@dxos/util": "0.7.5-labs.ff2ff30"
48
+ "@dxos/async": "0.7.5-main.b19bfc8",
49
+ "@dxos/debug": "0.7.5-main.b19bfc8",
50
+ "@dxos/node-std": "0.7.5-main.b19bfc8",
51
+ "@dxos/util": "0.7.5-main.b19bfc8",
52
+ "@dxos/log": "0.7.5-main.b19bfc8"
51
53
  },
52
54
  "devDependencies": {
53
55
  "@react-three/drei": "^9.99.0",
@@ -67,15 +69,15 @@
67
69
  "react": "~18.2.0",
68
70
  "react-dom": "~18.2.0",
69
71
  "three": "0.165.0",
70
- "@dxos/react-ui": "0.7.5-labs.ff2ff30",
71
- "@dxos/react-ui-theme": "0.7.5-labs.ff2ff30",
72
- "@dxos/storybook-utils": "0.7.5-labs.ff2ff30"
72
+ "@dxos/react-ui-theme": "0.7.5-main.b19bfc8",
73
+ "@dxos/storybook-utils": "0.7.5-main.b19bfc8",
74
+ "@dxos/react-ui": "0.7.5-main.b19bfc8"
73
75
  },
74
76
  "peerDependencies": {
75
77
  "react": "~18.2.0",
76
78
  "react-dom": "~18.2.0",
77
- "@dxos/react-ui": "0.7.5-labs.ff2ff30",
78
- "@dxos/react-ui-theme": "0.7.5-labs.ff2ff30"
79
+ "@dxos/react-ui": "0.7.5-main.b19bfc8",
80
+ "@dxos/react-ui-theme": "0.7.5-main.b19bfc8"
79
81
  },
80
82
  "publishConfig": {
81
83
  "access": "public"
@@ -138,7 +138,7 @@ const Story = ({
138
138
  translation,
139
139
  rotation = [0, 0, 0],
140
140
  projection,
141
- styles = defaultStyles,
141
+ styles,
142
142
  drag = false,
143
143
  spin = false,
144
144
  tour = false,
@@ -160,10 +160,7 @@ const Story = ({
160
160
 
161
161
  // Control hooks.
162
162
  const [startSpinner, stopSpinner] = useSpinner(controller.current, { disabled: !spin });
163
- const [startTour, stopTour] = useTour(controller.current, features, {
164
- disabled: !tour,
165
- styles,
166
- });
163
+ const [_running, setRunning] = useTour(controller.current, features?.points, { disabled: !tour, styles });
167
164
  useDrag(controller.current, {
168
165
  xAxis,
169
166
  disabled: !drag,
@@ -171,7 +168,7 @@ const Story = ({
171
168
  switch (event.type) {
172
169
  case 'start': {
173
170
  stopSpinner();
174
- stopTour();
171
+ setRunning(false);
175
172
  break;
176
173
  }
177
174
  }
@@ -186,7 +183,7 @@ const Story = ({
186
183
  startSpinner();
187
184
  }
188
185
  if (tour) {
189
- startTour();
186
+ setRunning(true);
190
187
  }
191
188
  break;
192
189
  }
@@ -205,7 +202,7 @@ const Story = ({
205
202
  <Globe.Root classNames='absolute inset-0' scale={_scale} translation={translation} rotation={rotation}>
206
203
  <Globe.Canvas
207
204
  ref={controller}
208
- topology={styles.dots ? dots : topology}
205
+ topology={styles?.dots ? dots : topology}
209
206
  projection={projection}
210
207
  styles={styles}
211
208
  features={tour ? { points: features?.points ?? [] } : features}
@@ -298,15 +295,15 @@ export const Globe1 = () => {
298
295
  };
299
296
 
300
297
  export const Globe2 = () => {
301
- return <Story drag projection='transverse-mercator' scale={0.8} rotation={initialRotation} />;
298
+ return <Story drag projection='transverse-mercator' scale={0.8} rotation={initialRotation} styles={defaultStyles} />;
302
299
  };
303
300
 
304
301
  export const Globe3 = () => {
305
- return <Story drag spin scale={1.5} rotation={initialRotation} />;
302
+ return <Story drag spin scale={1.5} rotation={initialRotation} styles={defaultStyles} />;
306
303
  };
307
304
 
308
305
  export const Globe4 = () => {
309
- return <Story drag tour scale={2} rotation={initialRotation} />;
306
+ return <Story drag tour scale={2} rotation={initialRotation} styles={defaultStyles} />;
310
307
  };
311
308
 
312
309
  export const Globe5 = () => {
@@ -17,7 +17,7 @@ import React, {
17
17
  import { useResizeDetector } from 'react-resize-detector';
18
18
  import { type Topology } from 'topojson-specification';
19
19
 
20
- import { type ThemedClassName, useDynamicRef } from '@dxos/react-ui';
20
+ import { type ThemedClassName, type ThemeMode, useDynamicRef, useThemeContext } from '@dxos/react-ui';
21
21
  import { mx } from '@dxos/react-ui-theme';
22
22
 
23
23
  import {
@@ -28,7 +28,6 @@ import {
28
28
  } from '../../hooks';
29
29
  import {
30
30
  type Features,
31
- type Styles,
32
31
  type StyleSet,
33
32
  createLayers,
34
33
  geoToPosition,
@@ -38,35 +37,57 @@ import {
38
37
  } from '../../util';
39
38
  import { ZoomControls, ActionControls, type ControlProps, controlPositions } from '../Toolbar';
40
39
 
41
- // https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute
42
- const defaultStyles: Styles = {
43
- background: {
44
- fillStyle: '#111111',
45
- },
46
-
47
- water: {
48
- fillStyle: '#123E6A',
49
- },
50
-
51
- hex: {
52
- strokeStyle: 'green',
53
- fillStyle: 'gray',
54
- pointRadius: 1,
55
- },
56
-
57
- land: {
58
- fillStyle: '#032153',
59
- },
60
-
61
- line: {
62
- strokeStyle: '#111111',
40
+ /**
41
+ * https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute
42
+ */
43
+ const defaultStyles: Record<ThemeMode, StyleSet> = {
44
+ light: {
45
+ background: {
46
+ fillStyle: '#EEE',
47
+ },
48
+
49
+ water: {
50
+ fillStyle: '#555',
51
+ },
52
+
53
+ land: {
54
+ fillStyle: '#999',
55
+ },
56
+
57
+ line: {
58
+ strokeStyle: 'darkred',
59
+ },
60
+
61
+ point: {
62
+ fillStyle: '#111111',
63
+ strokeStyle: '#111111',
64
+ strokeWidth: 1,
65
+ pointRadius: 0.5,
66
+ },
63
67
  },
64
-
65
- point: {
66
- fillStyle: '#111111',
67
- strokeStyle: '#111111',
68
- strokeWidth: 1,
69
- pointRadius: 0.5,
68
+ dark: {
69
+ background: {
70
+ fillStyle: '#111111',
71
+ },
72
+
73
+ water: {
74
+ fillStyle: '#123E6A',
75
+ },
76
+
77
+ land: {
78
+ fillStyle: '#032153',
79
+ },
80
+
81
+ line: {
82
+ strokeStyle: '#111111',
83
+ },
84
+
85
+ point: {
86
+ fillStyle: '#111111',
87
+ strokeStyle: '#111111',
88
+ strokeWidth: 1,
89
+ pointRadius: 0.5,
90
+ },
70
91
  },
71
92
  };
72
93
 
@@ -125,7 +146,10 @@ type GlobeCanvasProps = {
125
146
  * https://github.com/topojson/world-atlas
126
147
  */
127
148
  const GlobeCanvas = forwardRef<GlobeController, GlobeCanvasProps>(
128
- ({ projection: _projection, topology, features, styles = defaultStyles }, forwardRef) => {
149
+ ({ projection: _projection, topology, features, styles: _styles }, forwardRef) => {
150
+ const { themeMode } = useThemeContext();
151
+ const styles = useMemo(() => _styles ?? defaultStyles[themeMode], [_styles, themeMode]);
152
+
129
153
  // Canvas.
130
154
  const [canvas, setCanvas] = useState<HTMLCanvasElement>(null);
131
155
  const canvasRef = (canvas: HTMLCanvasElement) => setCanvas(canvas);
@@ -207,7 +231,7 @@ const GlobeCanvas = forwardRef<GlobeController, GlobeCanvasProps>(
207
231
  .translate([size.width / 2 + (translation?.x ?? 0), size.height / 2 + (translation?.y ?? 0)])
208
232
  .rotate(rotation ?? [0, 0, 0]);
209
233
 
210
- renderLayers(generator, layers, scale);
234
+ renderLayers(generator, layers, scale, styles);
211
235
  });
212
236
  }
213
237
  }, [generator, size, scale, translation, rotation, layers]);
@@ -11,29 +11,51 @@ import { withLayout, withTheme } from '@dxos/storybook-utils';
11
11
 
12
12
  import { Map, type MapController } from './Map';
13
13
  import { useMapZoomHandler } from '../../hooks';
14
+ import { type MapMarker } from '../../types';
14
15
 
15
- const Render = () => {
16
+ const Render = ({ markers }) => {
16
17
  const [controller, setController] = useState<MapController>();
17
18
  const handleZoomAction = useMapZoomHandler(controller);
18
19
 
19
20
  return (
20
21
  <Map.Root>
21
- <Map.Canvas ref={setController} />
22
+ <Map.Canvas ref={setController} markers={markers} />
22
23
  <Map.Zoom position='bottomleft' onAction={handleZoomAction} />
23
24
  <Map.Action position='bottomright' />
24
25
  </Map.Root>
25
26
  );
26
27
  };
27
28
 
28
- const meta: Meta = {
29
+ const meta: Meta<typeof Render> = {
29
30
  title: 'ui/react-ui-geo/Map',
30
- component: Map.Root,
31
- render: Render,
31
+ component: Render,
32
32
  decorators: [withTheme, withLayout({ fullscreen: true, tooltips: true })],
33
33
  };
34
34
 
35
35
  export default meta;
36
36
 
37
- type Story = StoryObj;
37
+ type Story = StoryObj<typeof Render>;
38
38
 
39
39
  export const Default: Story = {};
40
+
41
+ export const WithMarkers: Story = {
42
+ args: {
43
+ markers: [
44
+ { id: 'tokyo', title: 'Tokyo', location: { lat: 35.6762, lng: 139.6503 } },
45
+ { id: 'sydney', title: 'Sydney', location: { lat: -33.8688, lng: 151.2093 } },
46
+ { id: 'auckland', title: 'Auckland', location: { lat: -36.8509, lng: 174.7645 } },
47
+ { id: 'new-delhi', title: 'New Delhi', location: { lat: 28.6139, lng: 77.209 } },
48
+ { id: 'manila', title: 'Manila', location: { lat: 14.5995, lng: 120.9842 } },
49
+ { id: 'beijing', title: 'Beijing', location: { lat: 39.9042, lng: 116.4074 } },
50
+ { id: 'seoul', title: 'Seoul', location: { lat: 37.5665, lng: 126.978 } },
51
+ { id: 'bangkok', title: 'Bangkok', location: { lat: 13.7563, lng: 100.5018 } },
52
+ { id: 'singapore', title: 'Singapore', location: { lat: 1.3521, lng: 103.8198 } },
53
+ { id: 'kuala-lumpur', title: 'Kuala Lumpur', location: { lat: 3.139, lng: 101.6869 } },
54
+ { id: 'jakarta', title: 'Jakarta', location: { lat: -6.2088, lng: 106.8456 } },
55
+ { id: 'hanoi', title: 'Hanoi', location: { lat: 21.0285, lng: 105.8542 } },
56
+ { id: 'phnom-penh', title: 'Phnom Penh', location: { lat: 11.5564, lng: 104.9282 } },
57
+ { id: 'vientiane', title: 'Vientiane', location: { lat: 17.9757, lng: 102.6331 } },
58
+ { id: 'yangon', title: 'Yangon', location: { lat: 16.8661, lng: 96.1951 } },
59
+ ] as MapMarker[],
60
+ },
61
+ };
@@ -5,16 +5,15 @@
5
5
  // eslint-disable-next-line no-restricted-imports
6
6
  import 'leaflet/dist/leaflet.css';
7
7
 
8
- import type L from 'leaflet';
9
- import { type ControlPosition, Control, DomEvent, DomUtil, type LatLngExpression, latLngBounds } from 'leaflet';
10
- import React, { forwardRef, type PropsWithChildren, useEffect, useImperativeHandle } from 'react';
8
+ import L, { Control, DomEvent, DomUtil, latLngBounds, type ControlPosition, type LatLngExpression } from 'leaflet';
9
+ import { forwardRef, useEffect, useImperativeHandle, type PropsWithChildren } from 'react';
11
10
  import { createRoot } from 'react-dom/client';
11
+ import type { MapContainerProps } from 'react-leaflet';
12
12
  import { MapContainer, Marker, Popup, TileLayer, useMap } from 'react-leaflet';
13
- import { type MapContainerProps } from 'react-leaflet/lib/MapContainer';
14
13
  import { useResizeDetector } from 'react-resize-detector';
15
14
 
16
15
  import { debounce } from '@dxos/async';
17
- import { Tooltip, ThemeProvider, type ThemedClassName } from '@dxos/react-ui';
16
+ import { ThemeProvider, Tooltip, type ThemedClassName } from '@dxos/react-ui';
18
17
  import { defaultTx, mx } from '@dxos/react-ui-theme';
19
18
 
20
19
  import { ActionControls, controlPositions, ZoomControls, type ControlProps } from '../Toolbar';
@@ -61,84 +60,96 @@ type MapController = {
61
60
  setZoom: (cb: (zoom: number) => number) => void;
62
61
  };
63
62
 
64
- const MapCanvas = forwardRef<MapController, MapCanvasProps>(
65
- ({ markers = [], center, zoom, onChange }, forwardedRef) => {
66
- const { ref, width, height } = useResizeDetector({ refreshRate: 200 });
67
- const map = useMap();
68
-
69
- useImperativeHandle(
70
- forwardedRef,
71
- () => ({
72
- setCenter: (center: LatLngExpression, zoom?: number) => {
73
- map.setView(center, zoom);
74
- },
75
- setZoom: (cb) => {
76
- map.setZoom(cb(map.getZoom()));
77
- },
78
- }),
79
- [map],
80
- );
81
-
82
- // Resize.
83
- useEffect(() => {
84
- if (width && height) {
85
- map.invalidateSize();
86
- }
87
- }, [width, height]);
88
-
89
- // Position.
90
- useEffect(() => {
91
- if (center) {
63
+ const MapCanvas = forwardRef<MapController, MapCanvasProps>(({ markers, center, zoom, onChange }, forwardedRef) => {
64
+ const { ref, width, height } = useResizeDetector({ refreshRate: 200 });
65
+ const map = useMap();
66
+
67
+ useImperativeHandle(
68
+ forwardedRef,
69
+ () => ({
70
+ setCenter: (center: LatLngExpression, zoom?: number) => {
92
71
  map.setView(center, zoom);
93
- } else if (zoom !== undefined) {
94
- map.setZoom(zoom);
95
- }
96
- }, [center, zoom]);
97
-
98
- // Events.
99
- useEffect(() => {
100
- const handler = debounce(() => {
101
- onChange?.({ center: map.getCenter(), zoom: map.getZoom() });
102
- }, 100);
103
- map.on('move', handler);
104
- map.on('zoom', handler);
105
- return () => {
106
- map.off('move', handler);
107
- map.off('zoom', handler);
108
- };
109
- }, [map, onChange]);
110
-
111
- // Set the viewport around the markers, or show the whole world map if `markers` is empty.
112
- useEffect(() => {
113
- if (markers.length > 0) {
114
- const bounds = latLngBounds(markers.map((marker) => marker.location));
115
- map.fitBounds(bounds);
116
- } else {
117
- map.setView(defaults.center, defaults.zoom);
118
- }
119
- }, [markers]);
120
-
121
- return (
122
- <div ref={ref} className='flex w-full h-full overflow-hidden bg-baseSurface'>
123
- {/* Map tiles. */}
124
- <TileLayer
125
- className='dark:filter dark:grayscale dark:invert'
126
- url='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
127
- />
128
-
129
- {/* Markers. */}
130
- {/* TODO(burdon): Marker icon doesn't load on mobile? */}
131
- {markers.map(({ id, title, location: { lat, lng } }) => {
132
- return (
133
- <Marker key={id} position={{ lat, lng }}>
134
- {title && <Popup>{title}</Popup>}
135
- </Marker>
136
- );
137
- })}
138
- </div>
139
- );
140
- },
141
- );
72
+ },
73
+ setZoom: (cb) => {
74
+ map.setZoom(cb(map.getZoom()));
75
+ },
76
+ }),
77
+ [map],
78
+ );
79
+
80
+ // Resize.
81
+ useEffect(() => {
82
+ if (width && height) {
83
+ map.invalidateSize();
84
+ }
85
+ }, [width, height]);
86
+
87
+ // Position.
88
+ useEffect(() => {
89
+ if (center) {
90
+ map.setView(center, zoom);
91
+ } else if (zoom !== undefined) {
92
+ map.setZoom(zoom);
93
+ }
94
+ }, [center, zoom]);
95
+
96
+ // Events.
97
+ useEffect(() => {
98
+ const handler = debounce(() => {
99
+ onChange?.({ center: map.getCenter(), zoom: map.getZoom() });
100
+ }, 100);
101
+ map.on('move', handler);
102
+ map.on('zoom', handler);
103
+ return () => {
104
+ map.off('move', handler);
105
+ map.off('zoom', handler);
106
+ };
107
+ }, [map, onChange]);
108
+
109
+ // Set the viewport around the markers, or show the whole world map if `markers` is empty.
110
+ useEffect(() => {
111
+ if (markers.length > 0) {
112
+ const bounds = latLngBounds(markers.map((marker) => marker.location));
113
+ map.fitBounds(bounds);
114
+ } else {
115
+ map.setView(defaults.center, defaults.zoom);
116
+ }
117
+ }, [markers]);
118
+
119
+ return (
120
+ <div ref={ref} className='flex w-full h-full overflow-hidden bg-baseSurface'>
121
+ {/* Map tiles. */}
122
+ <TileLayer
123
+ className='dark:filter dark:grayscale dark:invert'
124
+ url='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
125
+ />
126
+
127
+ {/* Markers. */}
128
+ {markers?.map(({ id, title, location: { lat, lng } }) => {
129
+ return (
130
+ <Marker
131
+ key={id}
132
+ position={{ lat, lng }}
133
+ icon={
134
+ // TODO(burdon): Create custom icon from bundled assets.
135
+ new L.Icon({
136
+ iconUrl: 'https://dxos.network/marker-icon.png',
137
+ iconRetinaUrl: 'https://dxos.network/marker-icon-2x.png',
138
+ shadowUrl: 'https://dxos.network/marker-shadow.png',
139
+ iconSize: [25, 41],
140
+ iconAnchor: [12, 41],
141
+ popupAnchor: [1, -34],
142
+ shadowSize: [41, 41],
143
+ })
144
+ }
145
+ >
146
+ {title && <Popup>{title}</Popup>}
147
+ </Marker>
148
+ );
149
+ })}
150
+ </div>
151
+ );
152
+ });
142
153
 
143
154
  //
144
155
  // Controls
@@ -8,10 +8,11 @@ import { type ThemedClassName } from '@dxos/react-ui';
8
8
 
9
9
  import { type MapMarker } from '../types';
10
10
 
11
- export type { LatLngLiteral };
11
+ export { type LatLngLiteral };
12
12
 
13
13
  export type MapCanvasProps = ThemedClassName<{
14
14
  markers?: MapMarker[];
15
+ selected?: string[];
15
16
  zoom?: number;
16
17
  center?: LatLngLiteral;
17
18
  onChange?: (ev: { center: LatLngLiteral; zoom: number }) => void;
@@ -49,7 +49,7 @@ export const useDrag = (controller?: GlobeController | null, options: DragOption
49
49
  return () => {
50
50
  cancelDrag(d3.select(canvas));
51
51
  };
52
- }, [controller, options]);
52
+ }, [controller, JSON.stringify(options)]);
53
53
  };
54
54
 
55
55
  const cancelDrag = (node) => node.on('.drag', null);