@dxos/react-ui-geo 0.8.4-main.dedc0f3 → 0.8.4-main.dfabb4ec29
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/dist/lib/browser/{countries-110m-ZM3ZIEFS.mjs → countries-110m-RE5RNRQG.mjs} +1 -1
- package/dist/lib/browser/data.mjs +4 -3
- package/dist/lib/browser/data.mjs.map +4 -4
- package/dist/lib/browser/index.mjs +364 -462
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +19 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/node-esm/{countries-110m-3SFASWVD.mjs → countries-110m-4EDBXSFJ.mjs} +1 -1
- package/dist/lib/node-esm/data.mjs +5 -3
- package/dist/lib/node-esm/data.mjs.map +4 -4
- package/dist/lib/node-esm/index.mjs +364 -461
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/translations.mjs +21 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/types/data/airports.d.ts +4 -4
- package/dist/types/data/airports.d.ts.map +1 -1
- package/dist/types/data/cities.d.ts.map +1 -1
- package/dist/types/data/countries-110m.d.ts.map +1 -1
- package/dist/types/data/countries-dots-3.d.ts.map +1 -1
- package/dist/types/data/countries-dots-4.d.ts.map +1 -1
- package/dist/types/src/components/Globe/Globe.d.ts +5 -3
- package/dist/types/src/components/Globe/Globe.d.ts.map +1 -1
- package/dist/types/src/components/Globe/Globe.stories.d.ts +9 -5
- package/dist/types/src/components/Globe/Globe.stories.d.ts.map +1 -1
- package/dist/types/src/components/Map/Map.d.ts +22 -11
- package/dist/types/src/components/Map/Map.d.ts.map +1 -1
- package/dist/types/src/components/Map/Map.stories.d.ts +3 -1
- package/dist/types/src/components/Map/Map.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Controls.d.ts.map +1 -1
- package/dist/types/src/hooks/context.d.ts +1 -3
- package/dist/types/src/hooks/context.d.ts.map +1 -1
- package/dist/types/src/hooks/useDrag.d.ts.map +1 -1
- package/dist/types/src/hooks/useGlobeZoomHandler.d.ts +1 -1
- package/dist/types/src/hooks/useGlobeZoomHandler.d.ts.map +1 -1
- package/dist/types/src/hooks/useMapZoomHandler.d.ts +1 -1
- package/dist/types/src/hooks/useMapZoomHandler.d.ts.map +1 -1
- package/dist/types/src/hooks/useSpinner.d.ts.map +1 -1
- package/dist/types/src/hooks/useTour.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +12 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/src/util/debug.d.ts.map +1 -1
- package/dist/types/src/util/inertia.d.ts.map +1 -1
- package/dist/types/src/util/path.d.ts.map +1 -1
- package/dist/types/src/util/render.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +42 -36
- package/src/components/Globe/Globe.stories.tsx +10 -10
- package/src/components/Globe/Globe.tsx +55 -28
- package/src/components/Map/Map.stories.tsx +12 -10
- package/src/components/Map/Map.tsx +82 -71
- package/src/components/Toolbar/Controls.tsx +12 -14
- package/src/hooks/context.tsx +6 -29
- package/src/hooks/useGlobeZoomHandler.ts +8 -2
- package/src/hooks/useSpinner.ts +0 -1
- package/src/hooks/useTour.ts +1 -0
- package/src/index.ts +0 -1
- package/src/translations.ts +20 -0
- package/src/util/render.ts +0 -1
- package/dist/lib/browser/chunk-GMWLKTLN.mjs +0 -9
- package/dist/lib/browser/chunk-GMWLKTLN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JODBF4CC.mjs +0 -11
- package/dist/lib/node-esm/chunk-JODBF4CC.mjs.map +0 -7
- /package/dist/lib/browser/{countries-110m-ZM3ZIEFS.mjs.map → countries-110m-RE5RNRQG.mjs.map} +0 -0
- /package/dist/lib/node-esm/{countries-110m-3SFASWVD.mjs.map → countries-110m-4EDBXSFJ.mjs.map} +0 -0
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
import { type ControlPosition } from 'leaflet';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import { IconButton, type ThemedClassName, Toolbar } from '@dxos/react-ui';
|
|
8
|
+
import { IconButton, type ThemedClassName, Toolbar, useTranslation } from '@dxos/react-ui';
|
|
9
|
+
|
|
10
|
+
import { translationKey } from '#translations';
|
|
9
11
|
|
|
10
12
|
export type ControlAction = 'toggle' | 'start' | 'zoom-in' | 'zoom-out';
|
|
11
13
|
|
|
@@ -21,22 +23,20 @@ export const controlPositions: Record<ControlPosition, string> = {
|
|
|
21
23
|
};
|
|
22
24
|
|
|
23
25
|
export const ZoomControls = ({ classNames, onAction }: ControlProps) => {
|
|
26
|
+
const { t } = useTranslation(translationKey);
|
|
27
|
+
|
|
24
28
|
return (
|
|
25
29
|
<Toolbar.Root classNames={['gap-2', classNames]}>
|
|
26
30
|
<IconButton
|
|
27
31
|
icon='ph--plus--regular'
|
|
28
|
-
label='zoom in'
|
|
29
32
|
iconOnly
|
|
30
|
-
|
|
31
|
-
classNames='px-0 aspect-square'
|
|
33
|
+
label={t('zoom-in-icon.button')}
|
|
32
34
|
onClick={() => onAction?.('zoom-in')}
|
|
33
35
|
/>
|
|
34
36
|
<IconButton
|
|
35
37
|
icon='ph--minus--regular'
|
|
36
|
-
label='zoom out'
|
|
37
38
|
iconOnly
|
|
38
|
-
|
|
39
|
-
classNames='px-0 aspect-square'
|
|
39
|
+
label={t('zoom-out-icon.button')}
|
|
40
40
|
onClick={() => onAction?.('zoom-out')}
|
|
41
41
|
/>
|
|
42
42
|
</Toolbar.Root>
|
|
@@ -44,22 +44,20 @@ export const ZoomControls = ({ classNames, onAction }: ControlProps) => {
|
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
export const ActionControls = ({ classNames, onAction }: ControlProps) => {
|
|
47
|
+
const { t } = useTranslation(translationKey);
|
|
48
|
+
|
|
47
49
|
return (
|
|
48
50
|
<Toolbar.Root classNames={['gap-2', classNames]}>
|
|
49
51
|
<IconButton
|
|
50
|
-
icon='ph--
|
|
51
|
-
label='start'
|
|
52
|
+
icon='ph--path--regular'
|
|
52
53
|
iconOnly
|
|
53
|
-
|
|
54
|
-
classNames='px-0 aspect-square'
|
|
54
|
+
label={t('start-icon.button')}
|
|
55
55
|
onClick={() => onAction?.('start')}
|
|
56
56
|
/>
|
|
57
57
|
<IconButton
|
|
58
58
|
icon='ph--globe-hemisphere-west--regular'
|
|
59
|
-
label='toggle'
|
|
60
59
|
iconOnly
|
|
61
|
-
|
|
62
|
-
classNames='px-0 aspect-square'
|
|
60
|
+
label={t('toggle-icon.button')}
|
|
63
61
|
onClick={() => onAction?.('toggle')}
|
|
64
62
|
/>
|
|
65
63
|
</Toolbar.Root>
|
package/src/hooks/context.tsx
CHANGED
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import { type Dispatch, type SetStateAction, createContext, useContext } from 'react';
|
|
6
6
|
|
|
7
7
|
import { raise } from '@dxos/debug';
|
|
8
|
-
import { useControlledState } from '@dxos/react-ui';
|
|
9
8
|
|
|
10
9
|
import { type LatLngLiteral } from '../types';
|
|
11
10
|
|
|
12
11
|
// TODO(burdon): Factor out common geometry types.
|
|
13
12
|
export type Size = { width: number; height: number };
|
|
13
|
+
|
|
14
14
|
export type Point = { x: number; y: number };
|
|
15
|
+
|
|
15
16
|
export type Vector = [number, number, number];
|
|
16
17
|
|
|
17
18
|
export type GlobeContextType = {
|
|
@@ -26,33 +27,9 @@ export type GlobeContextType = {
|
|
|
26
27
|
setRotation: Dispatch<SetStateAction<Vector>>;
|
|
27
28
|
};
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export
|
|
32
|
-
Partial<Pick<GlobeContextType, 'size' | 'center' | 'zoom' | 'translation' | 'rotation'>>
|
|
33
|
-
>;
|
|
34
|
-
|
|
35
|
-
export const GlobeContextProvider = ({
|
|
36
|
-
children,
|
|
37
|
-
size,
|
|
38
|
-
center: _center,
|
|
39
|
-
zoom: _zoom,
|
|
40
|
-
translation: _translation,
|
|
41
|
-
rotation: _rotation,
|
|
42
|
-
}: GlobeContextProviderProps) => {
|
|
43
|
-
const [center, setCenter] = useControlledState(_center);
|
|
44
|
-
const [zoom, setZoom] = useControlledState(_zoom);
|
|
45
|
-
const [translation, setTranslation] = useControlledState<Point>(_translation);
|
|
46
|
-
const [rotation, setRotation] = useControlledState<Vector>(_rotation);
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<GlobeContext.Provider
|
|
50
|
-
value={{ size, center, zoom, translation, rotation, setCenter, setZoom, setTranslation, setRotation }}
|
|
51
|
-
>
|
|
52
|
-
{children}
|
|
53
|
-
</GlobeContext.Provider>
|
|
54
|
-
);
|
|
55
|
-
};
|
|
30
|
+
/** @internal */
|
|
31
|
+
// TODO(burdon): Replace with radix.
|
|
32
|
+
export const GlobeContext = createContext<GlobeContextType>(undefined);
|
|
56
33
|
|
|
57
34
|
export const useGlobeContext = () => {
|
|
58
35
|
return useContext(GlobeContext) ?? raise(new Error('Missing GlobeContext'));
|
|
@@ -6,6 +6,8 @@ import { useCallback } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { type ControlProps, type GlobeController } from '../components';
|
|
8
8
|
|
|
9
|
+
const ZOOM_FACTOR = 0.1;
|
|
10
|
+
|
|
9
11
|
export const useGlobeZoomHandler = (controller: GlobeController | null | undefined): ControlProps['onAction'] => {
|
|
10
12
|
return useCallback<ControlProps['onAction']>(
|
|
11
13
|
(event) => {
|
|
@@ -15,11 +17,15 @@ export const useGlobeZoomHandler = (controller: GlobeController | null | undefin
|
|
|
15
17
|
|
|
16
18
|
switch (event) {
|
|
17
19
|
case 'zoom-in': {
|
|
18
|
-
controller.setZoom((zoom) =>
|
|
20
|
+
controller.setZoom((zoom) => {
|
|
21
|
+
return zoom * (1 + ZOOM_FACTOR);
|
|
22
|
+
});
|
|
19
23
|
break;
|
|
20
24
|
}
|
|
21
25
|
case 'zoom-out': {
|
|
22
|
-
controller.setZoom((zoom) =>
|
|
26
|
+
controller.setZoom((zoom) => {
|
|
27
|
+
return zoom * (1 - ZOOM_FACTOR);
|
|
28
|
+
});
|
|
23
29
|
break;
|
|
24
30
|
}
|
|
25
31
|
}
|
package/src/hooks/useSpinner.ts
CHANGED
package/src/hooks/useTour.ts
CHANGED
|
@@ -34,6 +34,7 @@ export const useTour = (
|
|
|
34
34
|
options: TourOptions = {},
|
|
35
35
|
): [boolean, Dispatch<SetStateAction<boolean>>] => {
|
|
36
36
|
const selection = useMemo(() => d3Selection(), []);
|
|
37
|
+
// TODO(burdon): Redo controlled state.
|
|
37
38
|
const [running, setRunning] = useState(options.running ?? false);
|
|
38
39
|
useEffect(() => {
|
|
39
40
|
if (!running) {
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Resource } from '@dxos/react-ui';
|
|
6
|
+
|
|
7
|
+
export const translationKey = '@dxos/react-ui-geo';
|
|
8
|
+
|
|
9
|
+
export const translations = [
|
|
10
|
+
{
|
|
11
|
+
'en-US': {
|
|
12
|
+
[translationKey]: {
|
|
13
|
+
'zoom-in-icon.button': 'Zoom in',
|
|
14
|
+
'zoom-out-icon.button': 'Zoom out',
|
|
15
|
+
'start-icon.button': 'Start',
|
|
16
|
+
'toggle-icon.button': 'Toggle',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
] as const satisfies Resource[];
|
package/src/util/render.ts
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/data.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { type Topology } from 'topojson-specification';\n\nexport const loadTopology = async (): Promise<Topology> => {\n return (await import('../data/countries-110m.ts')).default;\n};\n"],
|
|
5
|
-
"mappings": ";AAMO,IAAMA,eAAe,YAAA;AAC1B,UAAQ,MAAM,OAAO,+BAAA,GAA8BC;AACrD;",
|
|
6
|
-
"names": ["loadTopology", "default"]
|
|
7
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
|
|
3
|
-
// src/data.ts
|
|
4
|
-
var loadTopology = async () => {
|
|
5
|
-
return (await import("./countries-110m-3SFASWVD.mjs")).default;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
loadTopology
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=chunk-JODBF4CC.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/data.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { type Topology } from 'topojson-specification';\n\nexport const loadTopology = async (): Promise<Topology> => {\n return (await import('../data/countries-110m.ts')).default;\n};\n"],
|
|
5
|
-
"mappings": ";;;AAMO,IAAMA,eAAe,YAAA;AAC1B,UAAQ,MAAM,OAAO,+BAAA,GAA8BC;AACrD;",
|
|
6
|
-
"names": ["loadTopology", "default"]
|
|
7
|
-
}
|
/package/dist/lib/browser/{countries-110m-ZM3ZIEFS.mjs.map → countries-110m-RE5RNRQG.mjs.map}
RENAMED
|
File without changes
|
/package/dist/lib/node-esm/{countries-110m-3SFASWVD.mjs.map → countries-110m-4EDBXSFJ.mjs.map}
RENAMED
|
File without changes
|