@dxos/react-ui-geo 0.7.5-labs.e27f9b9 → 0.7.5-labs.f400bbc

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 (39) hide show
  1. package/dist/lib/browser/index.mjs +118 -53
  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 +115 -50
  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 +118 -53
  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 +7 -7
  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 +15 -32
  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/context.tsx +5 -5
  36. package/src/hooks/useDrag.ts +1 -1
  37. package/src/hooks/useTour.ts +31 -19
  38. package/src/util/debug.ts +1 -0
  39. 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":["../../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13 +1,18 @@
1
+ import { type Dispatch, 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.e27f9b9",
3
+ "version": "0.7.5-labs.f400bbc",
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.e27f9b9",
48
- "@dxos/node-std": "0.7.5-labs.e27f9b9",
49
- "@dxos/debug": "0.7.5-labs.e27f9b9",
50
- "@dxos/util": "0.7.5-labs.e27f9b9"
48
+ "@dxos/async": "0.7.5-labs.f400bbc",
49
+ "@dxos/debug": "0.7.5-labs.f400bbc",
50
+ "@dxos/log": "0.7.5-labs.f400bbc",
51
+ "@dxos/node-std": "0.7.5-labs.f400bbc",
52
+ "@dxos/util": "0.7.5-labs.f400bbc"
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.e27f9b9",
71
- "@dxos/react-ui-theme": "0.7.5-labs.e27f9b9",
72
- "@dxos/storybook-utils": "0.7.5-labs.e27f9b9"
72
+ "@dxos/react-ui": "0.7.5-labs.f400bbc",
73
+ "@dxos/react-ui-theme": "0.7.5-labs.f400bbc",
74
+ "@dxos/storybook-utils": "0.7.5-labs.f400bbc"
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.e27f9b9",
78
- "@dxos/react-ui-theme": "0.7.5-labs.e27f9b9"
79
+ "@dxos/react-ui": "0.7.5-labs.f400bbc",
80
+ "@dxos/react-ui-theme": "0.7.5-labs.f400bbc"
79
81
  },
80
82
  "publishConfig": {
81
83
  "access": "public"
@@ -18,19 +18,9 @@ import { useDrag, useGlobeZoomHandler, useSpinner, useTour, type Vector } from '
18
18
  import { closestPoint, type LatLng, type StyleSet } from '../../util';
19
19
  import { type ControlProps } from '../Toolbar';
20
20
 
21
- // TODO(burdon): Local script (e.g., plot on chart) vs. remote functions.
22
- // TODO(burdon): Add charts to sheet.
23
- // TODO(burdon): Able to script (e.g., list of cities from named range).
24
- // TODO(burdon): Search flight information. Calendar (itinerary).
25
- // TODO(burdon): Show MANY packets flowing across the network.
26
-
27
- const useImportJson = (filename: string) => {
28
- return useAsyncState(
29
- // TODO(burdon): Configure vite plugins for experimental syntax.
30
- // @babel/plugin-syntax-import-assertions
31
- // @babel/plugin-syntax-import-attributes
32
- async () => await import(filename), // { assert: { type: 'json' } }),
33
- );
21
+ // TODO(burdon): Load from JSON at runtime?
22
+ const useTopology = () => {
23
+ return useAsyncState(async () => (await import('../../../data/countries-110m.ts')).default);
34
24
  };
35
25
 
36
26
  const defaultStyles: StyleSet = {
@@ -148,7 +138,7 @@ const Story = ({
148
138
  translation,
149
139
  rotation = [0, 0, 0],
150
140
  projection,
151
- styles = defaultStyles,
141
+ styles,
152
142
  drag = false,
153
143
  spin = false,
154
144
  tour = false,
@@ -162,8 +152,7 @@ const Story = ({
162
152
  objects: { dots: points },
163
153
  } as any as Topology;
164
154
  });
165
- // const [topology] = useImportJson('../../../data/raw/countries-110m.json');
166
- const [topology] = useAsyncState(async () => (await import('../../../data/countries-110m.ts')).default);
155
+ const [topology] = useTopology();
167
156
  const [airports] = useAsyncState(async () => (await import('../../../data/airports.ts')).default);
168
157
  const features = useMemo(() => {
169
158
  return airports ? createTrip(airports, routes, (dots?.objects.dots as any)?.geometries[0].coordinates) : undefined;
@@ -171,10 +160,7 @@ const Story = ({
171
160
 
172
161
  // Control hooks.
173
162
  const [startSpinner, stopSpinner] = useSpinner(controller.current, { disabled: !spin });
174
- const [startTour, stopTour] = useTour(controller.current, features, {
175
- disabled: !tour,
176
- styles,
177
- });
163
+ const [_running, setRunning] = useTour(controller.current, features?.points, { disabled: !tour, styles });
178
164
  useDrag(controller.current, {
179
165
  xAxis,
180
166
  disabled: !drag,
@@ -182,7 +168,7 @@ const Story = ({
182
168
  switch (event.type) {
183
169
  case 'start': {
184
170
  stopSpinner();
185
- stopTour();
171
+ setRunning(false);
186
172
  break;
187
173
  }
188
174
  }
@@ -197,7 +183,7 @@ const Story = ({
197
183
  startSpinner();
198
184
  }
199
185
  if (tour) {
200
- startTour();
186
+ setRunning(true);
201
187
  }
202
188
  break;
203
189
  }
@@ -216,7 +202,7 @@ const Story = ({
216
202
  <Globe.Root classNames='absolute inset-0' scale={_scale} translation={translation} rotation={rotation}>
217
203
  <Globe.Canvas
218
204
  ref={controller}
219
- topology={styles.dots ? dots : topology}
205
+ topology={styles?.dots ? dots : topology}
220
206
  projection={projection}
221
207
  styles={styles}
222
208
  features={tour ? { points: features?.points ?? [] } : features}
@@ -242,8 +228,7 @@ const meta: Meta = {
242
228
  export default meta;
243
229
 
244
230
  export const Earth1 = () => {
245
- // const [topology] = useImportJson('../../../data/raw/countries-110m.json');
246
- const [topology] = useAsyncState(async () => (await import('../../../data/countries-110m.ts')).default);
231
+ const [topology] = useTopology();
247
232
  const [controller, setController] = useState<GlobeController | null>();
248
233
  const handleAction = useGlobeZoomHandler(controller);
249
234
  useDrag(controller);
@@ -257,8 +242,7 @@ export const Earth1 = () => {
257
242
  };
258
243
 
259
244
  export const Earth2 = () => {
260
- // const [topology] = useImportJson('../../../data/raw/countries-110m.json');
261
- const [topology] = useAsyncState(async () => (await import('../../../data/countries-110m.ts')).default);
245
+ const [topology] = useTopology();
262
246
  const [controller, setController] = useState<GlobeController | null>();
263
247
  const handleAction = useGlobeZoomHandler(controller);
264
248
  useDrag(controller);
@@ -293,8 +277,7 @@ const monochrome: StyleSet = {
293
277
  };
294
278
 
295
279
  export const Mercator = () => {
296
- // const [topology] = useImportJson('../../../data/raw/countries-110m.json');
297
- const [topology] = useAsyncState(async () => (await import('../../../data/countries-110m.ts')).default);
280
+ const [topology] = useTopology();
298
281
  const [controller, setController] = useState<GlobeController | null>();
299
282
  const handleAction = useGlobeZoomHandler(controller);
300
283
  useDrag(controller);
@@ -312,15 +295,15 @@ export const Globe1 = () => {
312
295
  };
313
296
 
314
297
  export const Globe2 = () => {
315
- 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} />;
316
299
  };
317
300
 
318
301
  export const Globe3 = () => {
319
- return <Story drag spin scale={1.5} rotation={initialRotation} />;
302
+ return <Story drag spin scale={1.5} rotation={initialRotation} styles={defaultStyles} />;
320
303
  };
321
304
 
322
305
  export const Globe4 = () => {
323
- return <Story drag tour scale={2} rotation={initialRotation} />;
306
+ return <Story drag tour scale={2} rotation={initialRotation} styles={defaultStyles} />;
324
307
  };
325
308
 
326
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
+ };