@ztwoint/z-ui 0.1.122 → 0.1.124
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/components/assets/icons/index.d.ts +2 -0
- package/dist/components/assets/icons/left-square-bracket.d.ts +6 -0
- package/dist/components/assets/icons/left-square-bracket.js +23 -0
- package/dist/components/assets/icons/right-square-bracket.d.ts +6 -0
- package/dist/components/assets/icons/right-square-bracket.js +23 -0
- package/dist/components/table/components/cell/avatar-cell.js +13 -6
- package/dist/components/table/table-provider.js +7 -0
- package/dist/components/table-card/table-card.js +52 -45
- package/dist/components/z2map/components/index.d.ts +5 -0
- package/dist/components/z2map/components/map-controls.d.ts +12 -0
- package/dist/components/z2map/components/map-controls.js +29 -0
- package/dist/components/z2map/components/map-empty-state.d.ts +2 -0
- package/dist/components/z2map/components/map-empty-state.js +10 -0
- package/dist/components/z2map/components/map-loading-state.d.ts +8 -0
- package/dist/components/z2map/components/map-loading-state.js +45 -0
- package/dist/components/z2map/components/map-pin-content.d.ts +8 -0
- package/dist/components/z2map/components/map-pin-content.js +27 -0
- package/dist/components/z2map/components/map-pin.d.ts +19 -0
- package/dist/components/z2map/components/map-pin.js +116 -0
- package/dist/components/z2map/components/map-style-control.d.ts +8 -0
- package/dist/components/z2map/components/map-style-control.js +45 -0
- package/dist/components/z2map/components/map-zoom-control.d.ts +8 -0
- package/dist/components/z2map/components/map-zoom-control.js +49 -0
- package/dist/components/z2map/index.d.ts +9 -0
- package/dist/components/z2map/map.constants.d.ts +47 -0
- package/dist/components/z2map/map.constants.js +40 -0
- package/dist/components/z2map/map.d.ts +4 -0
- package/dist/components/z2map/map.hook.d.ts +33 -0
- package/dist/components/z2map/map.hook.js +99 -0
- package/dist/components/z2map/map.js +161 -0
- package/dist/components/z2map/map.type.d.ts +45 -0
- package/dist/components/z2map/map.utils.d.ts +10 -0
- package/dist/components/z2map/map.utils.js +37 -0
- package/dist/css/node_modules/mapbox-gl/dist/mapbox-gl.css +1 -0
- package/dist/css/styles/tailwind.css +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +221 -201
- package/dist/node_modules/@vis.gl/react-mapbox/dist/components/attribution-control.js +12 -0
- package/dist/node_modules/@vis.gl/react-mapbox/dist/components/fullscreen-control.js +12 -0
- package/dist/node_modules/@vis.gl/react-mapbox/dist/components/geolocate-control.js +30 -0
- package/dist/node_modules/@vis.gl/react-mapbox/dist/components/map.js +54 -0
- package/dist/node_modules/@vis.gl/react-mapbox/dist/components/marker.js +56 -0
- package/dist/node_modules/@vis.gl/react-mapbox/dist/components/navigation-control.js +12 -0
- package/dist/node_modules/@vis.gl/react-mapbox/dist/components/popup.js +35 -0
- package/dist/node_modules/@vis.gl/react-mapbox/dist/components/scale-control.js +14 -0
- package/dist/node_modules/@vis.gl/react-mapbox/dist/components/use-control.js +14 -0
- package/dist/node_modules/@vis.gl/react-mapbox/dist/components/use-map.js +6 -0
- package/dist/node_modules/@vis.gl/react-mapbox/dist/mapbox/create-ref.js +77 -0
- package/dist/node_modules/@vis.gl/react-mapbox/dist/mapbox/mapbox.js +315 -0
- package/dist/node_modules/@vis.gl/react-mapbox/dist/mapbox/proxy-transform.js +35 -0
- package/dist/node_modules/@vis.gl/react-mapbox/dist/utils/apply-react-style.js +13 -0
- package/dist/node_modules/@vis.gl/react-mapbox/dist/utils/compare-class-names.js +16 -0
- package/dist/node_modules/@vis.gl/react-mapbox/dist/utils/deep-equal.js +33 -0
- package/dist/node_modules/@vis.gl/react-mapbox/dist/utils/set-globals.js +18 -0
- package/dist/node_modules/@vis.gl/react-mapbox/dist/utils/style-utils.js +25 -0
- package/dist/node_modules/@vis.gl/react-mapbox/dist/utils/transform.js +40 -0
- package/dist/node_modules/@vis.gl/react-mapbox/dist/utils/use-isomorphic-layout-effect.js +5 -0
- package/dist/routes/map.d.ts +2 -0
- package/dist/types/components/assets/icons/index.d.ts +2 -0
- package/dist/types/components/assets/icons/left-square-bracket.d.ts +6 -0
- package/dist/types/components/assets/icons/right-square-bracket.d.ts +6 -0
- package/dist/types/components/z2map/components/index.d.ts +5 -0
- package/dist/types/components/z2map/components/map-controls.d.ts +12 -0
- package/dist/types/components/z2map/components/map-empty-state.d.ts +2 -0
- package/dist/types/components/z2map/components/map-loading-state.d.ts +8 -0
- package/dist/types/components/z2map/components/map-pin-content.d.ts +8 -0
- package/dist/types/components/z2map/components/map-pin.d.ts +19 -0
- package/dist/types/components/z2map/components/map-style-control.d.ts +8 -0
- package/dist/types/components/z2map/components/map-zoom-control.d.ts +8 -0
- package/dist/types/components/z2map/index.d.ts +9 -0
- package/dist/types/components/z2map/map.constants.d.ts +47 -0
- package/dist/types/components/z2map/map.d.ts +5 -0
- package/dist/types/components/z2map/map.hook.d.ts +33 -0
- package/dist/types/components/z2map/map.type.d.ts +45 -0
- package/dist/types/components/z2map/map.utils.d.ts +10 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/routes/map.d.ts +2 -0
- package/package.json +5 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as e, jsxs as o } from "react/jsx-runtime";
|
|
2
|
+
import { Layers as d, Map as p, Satellite as m, Mountain as c, Moon as M, Sun as b } from "lucide-react";
|
|
3
|
+
import { Button as h } from "../../button/button.js";
|
|
4
|
+
import { Z2DropdownMenu as D, Z2DropdownMenuTrigger as w, Z2DropdownMenuContent as T, Z2DropdownMenuLabel as v, Z2DropdownMenuRadioGroup as S, Z2DropdownMenuRadioItem as g } from "../../dropdown-menu/z2-dropdown-menu.js";
|
|
5
|
+
import { cn as R } from "../../../lib/utils.js";
|
|
6
|
+
import { MAP_VARIANTS as n } from "../map.constants.js";
|
|
7
|
+
const i = [
|
|
8
|
+
{ value: n.STREETS, label: "Streets", icon: /* @__PURE__ */ e(p, { size: 14 }) },
|
|
9
|
+
{ value: n.SATELLITE, label: "Satellite", icon: /* @__PURE__ */ e(m, { size: 14 }) },
|
|
10
|
+
{ value: n.TERRAIN, label: "Terrain", icon: /* @__PURE__ */ e(c, { size: 14 }) },
|
|
11
|
+
{ value: n.DARK, label: "Dark", icon: /* @__PURE__ */ e(M, { size: 14 }) },
|
|
12
|
+
{ value: n.LIGHT, label: "Light", icon: /* @__PURE__ */ e(b, { size: 14 }) }
|
|
13
|
+
], f = ({
|
|
14
|
+
activeStyle: r,
|
|
15
|
+
onStyleChange: s,
|
|
16
|
+
className: u
|
|
17
|
+
}) => {
|
|
18
|
+
const l = i.find((a) => a.value === r), t = (a) => {
|
|
19
|
+
s(a);
|
|
20
|
+
};
|
|
21
|
+
return /* @__PURE__ */ e("div", { className: R("relative", u), children: /* @__PURE__ */ o(D, { children: [
|
|
22
|
+
/* @__PURE__ */ e(w, { asChild: !0, children: /* @__PURE__ */ e(
|
|
23
|
+
h,
|
|
24
|
+
{
|
|
25
|
+
variant: "stroke",
|
|
26
|
+
shade: "neutral",
|
|
27
|
+
leftIcon: /* @__PURE__ */ e(d, { size: 16 }),
|
|
28
|
+
label: l == null ? void 0 : l.label,
|
|
29
|
+
"aria-label": "Open map style menu",
|
|
30
|
+
size: "large"
|
|
31
|
+
}
|
|
32
|
+
) }),
|
|
33
|
+
/* @__PURE__ */ o(T, { size: "xsmall", className: "bg-white/95 backdrop-blur-sm", children: [
|
|
34
|
+
/* @__PURE__ */ e(v, {}),
|
|
35
|
+
/* @__PURE__ */ e(S, { value: r, onValueChange: t, children: i.map((a) => /* @__PURE__ */ o(g, { value: a.value, children: [
|
|
36
|
+
/* @__PURE__ */ e("span", { className: "mr-2", children: a.icon }),
|
|
37
|
+
a.label
|
|
38
|
+
] }, a.value)) })
|
|
39
|
+
] })
|
|
40
|
+
] }) });
|
|
41
|
+
};
|
|
42
|
+
f.displayName = "MapStyleControl";
|
|
43
|
+
export {
|
|
44
|
+
f as MapStyleControl
|
|
45
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsxs as t, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { Plus as i, Minus as n } from "lucide-react";
|
|
3
|
+
import { Button as e } from "../../button/button.js";
|
|
4
|
+
import { cn as d } from "../../../lib/utils.js";
|
|
5
|
+
const m = ({
|
|
6
|
+
onZoomIn: l,
|
|
7
|
+
onZoomOut: a,
|
|
8
|
+
className: s,
|
|
9
|
+
disabled: r = !1
|
|
10
|
+
}) => /* @__PURE__ */ t(
|
|
11
|
+
"div",
|
|
12
|
+
{
|
|
13
|
+
className: d(
|
|
14
|
+
"flex flex-col gap-0 bg-white/95 backdrop-blur-sm rounded-xl shadow-[0_4px_20px_rgba(0,0,0,0.12)] border border-stroke-solid-light overflow-hidden",
|
|
15
|
+
s
|
|
16
|
+
),
|
|
17
|
+
children: [
|
|
18
|
+
/* @__PURE__ */ o(
|
|
19
|
+
e,
|
|
20
|
+
{
|
|
21
|
+
onClick: l,
|
|
22
|
+
disabled: r,
|
|
23
|
+
"aria-label": "Zoom in",
|
|
24
|
+
variant: "ghost",
|
|
25
|
+
shade: "neutral",
|
|
26
|
+
leftIcon: /* @__PURE__ */ o(i, { size: 18, strokeWidth: 2.5 }),
|
|
27
|
+
className: "w-10 h-10 rounded-none"
|
|
28
|
+
}
|
|
29
|
+
),
|
|
30
|
+
/* @__PURE__ */ o("div", { className: "w-full h-px bg-stroke-solid-light" }),
|
|
31
|
+
/* @__PURE__ */ o(
|
|
32
|
+
e,
|
|
33
|
+
{
|
|
34
|
+
onClick: a,
|
|
35
|
+
disabled: r,
|
|
36
|
+
"aria-label": "Zoom out",
|
|
37
|
+
variant: "ghost",
|
|
38
|
+
shade: "neutral",
|
|
39
|
+
leftIcon: /* @__PURE__ */ o(n, { size: 18, strokeWidth: 2.5 }),
|
|
40
|
+
className: "w-10 h-10 rounded-none"
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
m.displayName = "MapZoomControl";
|
|
47
|
+
export {
|
|
48
|
+
m as MapZoomControl
|
|
49
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as Z2Map } from './map';
|
|
2
|
+
export type { Location, MapProps, PinVariant, PinSize, Coordinate } from './map.type';
|
|
3
|
+
export { MAP_VARIANTS, DEFAULT_MAP_CONFIG, PIN_SIZES } from './map.constants';
|
|
4
|
+
export type { MapVariant } from './map.constants';
|
|
5
|
+
export { MapPinComponent } from './components/map-pin';
|
|
6
|
+
export { MapPinContent } from './components/map-pin-content';
|
|
7
|
+
export { MapControls } from './components/map-controls';
|
|
8
|
+
export { MapZoomControl } from './components/map-zoom-control';
|
|
9
|
+
export { MapStyleControl } from './components/map-style-control';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export declare const MAP_VARIANTS: {
|
|
2
|
+
readonly STREETS: "streets";
|
|
3
|
+
readonly SATELLITE: "satellite";
|
|
4
|
+
readonly TERRAIN: "terrain";
|
|
5
|
+
readonly DARK: "dark";
|
|
6
|
+
readonly LIGHT: "light";
|
|
7
|
+
};
|
|
8
|
+
export type MapVariant = (typeof MAP_VARIANTS)[keyof typeof MAP_VARIANTS];
|
|
9
|
+
export declare const MAPBOX_STYLE_MAP: Record<MapVariant, string>;
|
|
10
|
+
export declare const DEFAULT_MAP_CONFIG: {
|
|
11
|
+
center: {
|
|
12
|
+
lat: number;
|
|
13
|
+
lng: number;
|
|
14
|
+
};
|
|
15
|
+
zoom: number;
|
|
16
|
+
minZoom: number;
|
|
17
|
+
maxZoom: number;
|
|
18
|
+
variant: MapVariant;
|
|
19
|
+
width: string;
|
|
20
|
+
height: number;
|
|
21
|
+
interactive: boolean;
|
|
22
|
+
draggable: boolean;
|
|
23
|
+
scrollZoom: boolean;
|
|
24
|
+
showZoomControls: boolean;
|
|
25
|
+
showStyleSwitcher: boolean;
|
|
26
|
+
fitBoundsToLocations: boolean;
|
|
27
|
+
popoverDisabled: boolean;
|
|
28
|
+
pinVariant: "brand";
|
|
29
|
+
pinSize: "md";
|
|
30
|
+
};
|
|
31
|
+
export declare const PIN_SIZES: {
|
|
32
|
+
readonly sm: {
|
|
33
|
+
readonly width: 22;
|
|
34
|
+
readonly height: 22;
|
|
35
|
+
readonly iconSize: 12;
|
|
36
|
+
};
|
|
37
|
+
readonly md: {
|
|
38
|
+
readonly width: 32;
|
|
39
|
+
readonly height: 32;
|
|
40
|
+
readonly iconSize: 16;
|
|
41
|
+
};
|
|
42
|
+
readonly lg: {
|
|
43
|
+
readonly width: 40;
|
|
44
|
+
readonly height: 40;
|
|
45
|
+
readonly iconSize: 20;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const t = {
|
|
2
|
+
STREETS: "streets",
|
|
3
|
+
SATELLITE: "satellite",
|
|
4
|
+
TERRAIN: "terrain",
|
|
5
|
+
DARK: "dark",
|
|
6
|
+
LIGHT: "light"
|
|
7
|
+
}, o = {
|
|
8
|
+
[t.STREETS]: "mapbox://styles/mapbox/streets-v12",
|
|
9
|
+
[t.SATELLITE]: "mapbox://styles/mapbox/satellite-streets-v12",
|
|
10
|
+
[t.TERRAIN]: "mapbox://styles/mapbox/outdoors-v12",
|
|
11
|
+
[t.DARK]: "mapbox://styles/mapbox/dark-v11",
|
|
12
|
+
[t.LIGHT]: "mapbox://styles/mapbox/light-v11"
|
|
13
|
+
}, e = {
|
|
14
|
+
center: { lat: 37.8, lng: -122.4 },
|
|
15
|
+
zoom: 10,
|
|
16
|
+
minZoom: 1,
|
|
17
|
+
maxZoom: 20,
|
|
18
|
+
variant: t.STREETS,
|
|
19
|
+
width: "100%",
|
|
20
|
+
height: 450,
|
|
21
|
+
interactive: !0,
|
|
22
|
+
draggable: !0,
|
|
23
|
+
scrollZoom: !0,
|
|
24
|
+
showZoomControls: !0,
|
|
25
|
+
showStyleSwitcher: !1,
|
|
26
|
+
fitBoundsToLocations: !0,
|
|
27
|
+
popoverDisabled: !1,
|
|
28
|
+
pinVariant: "brand",
|
|
29
|
+
pinSize: "md"
|
|
30
|
+
}, s = {
|
|
31
|
+
sm: { width: 22, height: 22, iconSize: 12 },
|
|
32
|
+
md: { width: 32, height: 32, iconSize: 16 },
|
|
33
|
+
lg: { width: 40, height: 40, iconSize: 20 }
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
e as DEFAULT_MAP_CONFIG,
|
|
37
|
+
o as MAPBOX_STYLE_MAP,
|
|
38
|
+
t as MAP_VARIANTS,
|
|
39
|
+
s as PIN_SIZES
|
|
40
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { MapRef } from 'react-map-gl/mapbox';
|
|
2
|
+
import { MapProps, Location } from './map.type';
|
|
3
|
+
import { MapVariant } from './map.constants';
|
|
4
|
+
export declare const useMap: (props: MapProps) => {
|
|
5
|
+
mapRef: import('react').RefObject<MapRef | null>;
|
|
6
|
+
initialViewState: {
|
|
7
|
+
latitude: number;
|
|
8
|
+
longitude: number;
|
|
9
|
+
zoom: number;
|
|
10
|
+
};
|
|
11
|
+
currentVariant: MapVariant;
|
|
12
|
+
activeLocation: Location | null;
|
|
13
|
+
openPopoverId: string | null;
|
|
14
|
+
setOpenPopoverId: import('react').Dispatch<import('react').SetStateAction<string | null>>;
|
|
15
|
+
mapStyle: string;
|
|
16
|
+
containerStyle: {
|
|
17
|
+
width: string;
|
|
18
|
+
height: string;
|
|
19
|
+
};
|
|
20
|
+
handleZoomIn: () => void;
|
|
21
|
+
handleZoomOut: () => void;
|
|
22
|
+
handleStyleChange: (newStyle: MapVariant) => void;
|
|
23
|
+
handlePinHover: (location: Location | null) => void;
|
|
24
|
+
handlePinClick: (location: Location) => void;
|
|
25
|
+
handlePinClickWrapper: (location: Location) => void;
|
|
26
|
+
handleMove: (evt: {
|
|
27
|
+
viewState: {
|
|
28
|
+
latitude: number;
|
|
29
|
+
longitude: number;
|
|
30
|
+
zoom: number;
|
|
31
|
+
};
|
|
32
|
+
}) => void;
|
|
33
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { useRef as F, useState as w, useMemo as R, useCallback as i } from "react";
|
|
2
|
+
import { WebMercatorViewport as G } from "@math.gl/web-mercator";
|
|
3
|
+
import { DEFAULT_MAP_CONFIG as r, MAPBOX_STYLE_MAP as H } from "./map.constants.js";
|
|
4
|
+
import { calculateBounds as N, formatDimension as L } from "./map.utils.js";
|
|
5
|
+
const q = (P) => {
|
|
6
|
+
const {
|
|
7
|
+
locations: e,
|
|
8
|
+
center: m,
|
|
9
|
+
zoom: a,
|
|
10
|
+
variant: T = r.variant,
|
|
11
|
+
fitBoundsToLocations: v = r.fitBoundsToLocations,
|
|
12
|
+
width: u = r.width,
|
|
13
|
+
height: s = r.height,
|
|
14
|
+
popoverDisabled: S = r.popoverDisabled,
|
|
15
|
+
onMapMove: c,
|
|
16
|
+
onPinHover: d,
|
|
17
|
+
onPinClick: l
|
|
18
|
+
} = P, o = F(null), [z, y] = w(T), [A, B] = w(null), [C, b] = w(null), M = R(() => {
|
|
19
|
+
const t = a ?? r.zoom, p = (n, f) => ({
|
|
20
|
+
latitude: n.lat,
|
|
21
|
+
longitude: n.lng,
|
|
22
|
+
zoom: f
|
|
23
|
+
});
|
|
24
|
+
if (m && a !== void 0)
|
|
25
|
+
return p(m, a);
|
|
26
|
+
if (v && (e == null ? void 0 : e.length) > 0) {
|
|
27
|
+
const n = N(e.map((E) => E.coordinate)), f = typeof u == "number" ? u : 800, k = typeof s == "number" ? s : 450, g = new G({
|
|
28
|
+
width: f,
|
|
29
|
+
height: k
|
|
30
|
+
}).fitBounds(
|
|
31
|
+
[
|
|
32
|
+
[n.west, n.south],
|
|
33
|
+
[n.east, n.north]
|
|
34
|
+
],
|
|
35
|
+
{
|
|
36
|
+
padding: 40
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
return {
|
|
40
|
+
latitude: g.latitude,
|
|
41
|
+
longitude: g.longitude,
|
|
42
|
+
zoom: g.zoom
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return (e == null ? void 0 : e.length) > 0 ? p(e[0].coordinate, t) : p(r.center, t);
|
|
46
|
+
}, [e, m, a, v, u, s]), V = i(() => {
|
|
47
|
+
o.current && o.current.zoomTo(o.current.getZoom() + 1, { duration: 300 });
|
|
48
|
+
}, []), Z = i(() => {
|
|
49
|
+
o.current && o.current.zoomTo(o.current.getZoom() - 1, { duration: 300 });
|
|
50
|
+
}, []), D = i((t) => {
|
|
51
|
+
y(t);
|
|
52
|
+
}, []), I = i(
|
|
53
|
+
(t) => {
|
|
54
|
+
d == null || d(t);
|
|
55
|
+
},
|
|
56
|
+
[d]
|
|
57
|
+
), h = i(
|
|
58
|
+
(t) => {
|
|
59
|
+
B(t), l == null || l(t);
|
|
60
|
+
},
|
|
61
|
+
[l]
|
|
62
|
+
), O = i(
|
|
63
|
+
(t) => {
|
|
64
|
+
c == null || c(
|
|
65
|
+
{ lat: t.viewState.latitude, lng: t.viewState.longitude },
|
|
66
|
+
t.viewState.zoom
|
|
67
|
+
);
|
|
68
|
+
},
|
|
69
|
+
[c]
|
|
70
|
+
), _ = i(
|
|
71
|
+
(t) => {
|
|
72
|
+
h(t), S || b(t.id);
|
|
73
|
+
},
|
|
74
|
+
[h, S]
|
|
75
|
+
), x = H[z], W = {
|
|
76
|
+
width: L(u),
|
|
77
|
+
height: L(s)
|
|
78
|
+
};
|
|
79
|
+
return {
|
|
80
|
+
mapRef: o,
|
|
81
|
+
initialViewState: M,
|
|
82
|
+
currentVariant: z,
|
|
83
|
+
activeLocation: A,
|
|
84
|
+
openPopoverId: C,
|
|
85
|
+
setOpenPopoverId: b,
|
|
86
|
+
mapStyle: x,
|
|
87
|
+
containerStyle: W,
|
|
88
|
+
handleZoomIn: V,
|
|
89
|
+
handleZoomOut: Z,
|
|
90
|
+
handleStyleChange: D,
|
|
91
|
+
handlePinHover: I,
|
|
92
|
+
handlePinClick: h,
|
|
93
|
+
handlePinClickWrapper: _,
|
|
94
|
+
handleMove: O
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
export {
|
|
98
|
+
q as useMap
|
|
99
|
+
};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { jsx as o, jsxs as g, Fragment as V } from "react/jsx-runtime";
|
|
2
|
+
import { Map as G } from "../../node_modules/@vis.gl/react-mapbox/dist/components/map.js";
|
|
3
|
+
import { Marker as H } from "../../node_modules/@vis.gl/react-mapbox/dist/components/marker.js";
|
|
4
|
+
import "../../node_modules/@vis.gl/react-mapbox/dist/components/popup.js";
|
|
5
|
+
import "../../node_modules/@vis.gl/react-mapbox/dist/components/attribution-control.js";
|
|
6
|
+
import "../../node_modules/@vis.gl/react-mapbox/dist/components/fullscreen-control.js";
|
|
7
|
+
import "../../node_modules/@vis.gl/react-mapbox/dist/components/geolocate-control.js";
|
|
8
|
+
import "../../node_modules/@vis.gl/react-mapbox/dist/components/navigation-control.js";
|
|
9
|
+
import "../../node_modules/@vis.gl/react-mapbox/dist/components/scale-control.js";
|
|
10
|
+
import "react";
|
|
11
|
+
import "../../node_modules/@vis.gl/react-mapbox/dist/components/use-map.js";
|
|
12
|
+
import { Popover as R, PopoverTrigger as U, PopoverContent as W } from "../popover/popover.js";
|
|
13
|
+
import { useMap as $ } from "./map.hook.js";
|
|
14
|
+
import { MapPinComponent as v } from "./components/map-pin.js";
|
|
15
|
+
import { MapPinContent as q } from "./components/map-pin-content.js";
|
|
16
|
+
import { MapControls as B } from "./components/map-controls.js";
|
|
17
|
+
import { MapLoadingState as J } from "./components/map-loading-state.js";
|
|
18
|
+
import { MapEmptyState as K } from "./components/map-empty-state.js";
|
|
19
|
+
import { DEFAULT_MAP_CONFIG as r } from "./map.constants.js";
|
|
20
|
+
import { cn as Q } from "../../lib/utils.js";
|
|
21
|
+
/* empty css */
|
|
22
|
+
const X = ({
|
|
23
|
+
locations: n = [],
|
|
24
|
+
mapboxToken: M,
|
|
25
|
+
width: a = r.width,
|
|
26
|
+
height: d = r.height,
|
|
27
|
+
className: s,
|
|
28
|
+
pinVariant: l = r.pinVariant,
|
|
29
|
+
pinSize: h = r.pinSize,
|
|
30
|
+
renderPin: t,
|
|
31
|
+
renderPopover: m,
|
|
32
|
+
popoverDisabled: C = r.popoverDisabled,
|
|
33
|
+
interactive: w = r.interactive,
|
|
34
|
+
draggable: u = r.draggable,
|
|
35
|
+
scrollZoom: x = r.scrollZoom,
|
|
36
|
+
showZoomControls: b = r.showZoomControls,
|
|
37
|
+
showStyleSwitcher: y = r.showStyleSwitcher,
|
|
38
|
+
minZoom: S = r.minZoom,
|
|
39
|
+
maxZoom: k = r.maxZoom,
|
|
40
|
+
loading: Z = !1,
|
|
41
|
+
..._
|
|
42
|
+
}) => {
|
|
43
|
+
const {
|
|
44
|
+
mapRef: O,
|
|
45
|
+
initialViewState: I,
|
|
46
|
+
currentVariant: A,
|
|
47
|
+
activeLocation: p,
|
|
48
|
+
openPopoverId: E,
|
|
49
|
+
setOpenPopoverId: P,
|
|
50
|
+
mapStyle: j,
|
|
51
|
+
containerStyle: F,
|
|
52
|
+
handleZoomIn: L,
|
|
53
|
+
handleZoomOut: N,
|
|
54
|
+
handleStyleChange: T,
|
|
55
|
+
handlePinHover: i,
|
|
56
|
+
handlePinClickWrapper: c,
|
|
57
|
+
handleMove: z
|
|
58
|
+
} = $({ locations: n, width: a, height: d, ..._ });
|
|
59
|
+
return Z ? /* @__PURE__ */ o(J, { width: a, height: d, className: s }) : /* @__PURE__ */ g(
|
|
60
|
+
"div",
|
|
61
|
+
{
|
|
62
|
+
style: F,
|
|
63
|
+
className: Q(
|
|
64
|
+
"relative rounded-xl overflow-hidden shadow-[0_2px_16px_rgba(0,0,0,0.08)] border border-stroke-solid-light",
|
|
65
|
+
s
|
|
66
|
+
),
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ o(
|
|
69
|
+
G,
|
|
70
|
+
{
|
|
71
|
+
ref: O,
|
|
72
|
+
mapboxAccessToken: M,
|
|
73
|
+
initialViewState: I,
|
|
74
|
+
style: { width: "100%", height: "100%" },
|
|
75
|
+
mapStyle: j,
|
|
76
|
+
interactive: w,
|
|
77
|
+
dragPan: u,
|
|
78
|
+
scrollZoom: x,
|
|
79
|
+
minZoom: S,
|
|
80
|
+
maxZoom: k,
|
|
81
|
+
onMove: z,
|
|
82
|
+
projection: { name: "mercator" },
|
|
83
|
+
cursor: u ? void 0 : "default",
|
|
84
|
+
children: n.map((e) => {
|
|
85
|
+
const f = (p == null ? void 0 : p.id) === e.id;
|
|
86
|
+
return /* @__PURE__ */ o(
|
|
87
|
+
H,
|
|
88
|
+
{
|
|
89
|
+
latitude: e.coordinate.lat,
|
|
90
|
+
longitude: e.coordinate.lng,
|
|
91
|
+
anchor: "center",
|
|
92
|
+
children: C ? /* @__PURE__ */ o(V, { children: t ? t(e) : /* @__PURE__ */ o(
|
|
93
|
+
v,
|
|
94
|
+
{
|
|
95
|
+
variant: l,
|
|
96
|
+
size: h,
|
|
97
|
+
icon: e.icon,
|
|
98
|
+
active: f,
|
|
99
|
+
onClick: () => c(e),
|
|
100
|
+
onMouseEnter: () => i(e),
|
|
101
|
+
onMouseLeave: () => i(null)
|
|
102
|
+
}
|
|
103
|
+
) }) : /* @__PURE__ */ g(
|
|
104
|
+
R,
|
|
105
|
+
{
|
|
106
|
+
open: E === e.id,
|
|
107
|
+
onOpenChange: (D) => {
|
|
108
|
+
P(D ? e.id : null);
|
|
109
|
+
},
|
|
110
|
+
children: [
|
|
111
|
+
/* @__PURE__ */ o(U, { asChild: !0, children: /* @__PURE__ */ o("div", { children: t ? t(e) : /* @__PURE__ */ o(
|
|
112
|
+
v,
|
|
113
|
+
{
|
|
114
|
+
variant: l,
|
|
115
|
+
size: h,
|
|
116
|
+
icon: e.icon,
|
|
117
|
+
active: f,
|
|
118
|
+
onClick: () => c(e),
|
|
119
|
+
onMouseEnter: () => i(e),
|
|
120
|
+
onMouseLeave: () => i(null)
|
|
121
|
+
}
|
|
122
|
+
) }) }),
|
|
123
|
+
/* @__PURE__ */ o(
|
|
124
|
+
W,
|
|
125
|
+
{
|
|
126
|
+
side: "top",
|
|
127
|
+
align: "center",
|
|
128
|
+
className: "w-auto max-w-sm p-3 bg-white/98 backdrop-blur-md shadow-[0_8px_32px_rgba(0,0,0,0.12)] border-stroke-solid-light",
|
|
129
|
+
sideOffset: 8,
|
|
130
|
+
children: /* @__PURE__ */ o(q, { location: e, customContent: m == null ? void 0 : m(e) })
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
},
|
|
137
|
+
e.id
|
|
138
|
+
);
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
),
|
|
142
|
+
/* @__PURE__ */ o(
|
|
143
|
+
B,
|
|
144
|
+
{
|
|
145
|
+
showZoomControls: b,
|
|
146
|
+
onZoomIn: L,
|
|
147
|
+
onZoomOut: N,
|
|
148
|
+
showStyleSwitcher: y,
|
|
149
|
+
activeStyle: A,
|
|
150
|
+
onStyleChange: T
|
|
151
|
+
}
|
|
152
|
+
),
|
|
153
|
+
n.length === 0 && /* @__PURE__ */ o(K, {})
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
};
|
|
158
|
+
X.displayName = "Map";
|
|
159
|
+
export {
|
|
160
|
+
X as default
|
|
161
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { MapVariant } from './map.constants';
|
|
3
|
+
export interface Coordinate {
|
|
4
|
+
lat: number;
|
|
5
|
+
lng: number;
|
|
6
|
+
}
|
|
7
|
+
export interface Location {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
coordinate: Coordinate;
|
|
11
|
+
title: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
specs?: string[];
|
|
14
|
+
icon?: ReactNode;
|
|
15
|
+
metadata?: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
export type PinVariant = 'brand' | 'neutral' | 'danger' | 'success' | 'warning';
|
|
18
|
+
export type PinSize = 'sm' | 'md' | 'lg';
|
|
19
|
+
export interface MapProps {
|
|
20
|
+
locations: Location[];
|
|
21
|
+
mapboxToken?: string;
|
|
22
|
+
onPinClick?: (location: Location) => void;
|
|
23
|
+
onPinHover?: (location: Location | null) => void;
|
|
24
|
+
onMapMove?: (center: Coordinate, zoom: number) => void;
|
|
25
|
+
center?: Coordinate;
|
|
26
|
+
zoom?: number;
|
|
27
|
+
minZoom?: number;
|
|
28
|
+
maxZoom?: number;
|
|
29
|
+
variant?: MapVariant;
|
|
30
|
+
width?: string | number;
|
|
31
|
+
height?: string | number;
|
|
32
|
+
className?: string;
|
|
33
|
+
pinVariant?: PinVariant;
|
|
34
|
+
pinSize?: PinSize;
|
|
35
|
+
renderPin?: (location: Location) => ReactNode;
|
|
36
|
+
interactive?: boolean;
|
|
37
|
+
draggable?: boolean;
|
|
38
|
+
scrollZoom?: boolean;
|
|
39
|
+
showZoomControls?: boolean;
|
|
40
|
+
showStyleSwitcher?: boolean;
|
|
41
|
+
renderPopover?: (location: Location) => ReactNode;
|
|
42
|
+
popoverDisabled?: boolean;
|
|
43
|
+
fitBoundsToLocations?: boolean;
|
|
44
|
+
loading?: boolean;
|
|
45
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Coordinate } from './map.type';
|
|
2
|
+
export declare const calculateCenter: (coordinates: Coordinate[]) => Coordinate;
|
|
3
|
+
export declare const calculateBounds: (coordinates: Coordinate[]) => {
|
|
4
|
+
north: number;
|
|
5
|
+
south: number;
|
|
6
|
+
east: number;
|
|
7
|
+
west: number;
|
|
8
|
+
center: Coordinate;
|
|
9
|
+
};
|
|
10
|
+
export declare const formatDimension: (value: string | number) => string;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const a = (t) => {
|
|
2
|
+
if (t.length === 0)
|
|
3
|
+
return { lat: 0, lng: 0 };
|
|
4
|
+
if (t.length === 1)
|
|
5
|
+
return t[0];
|
|
6
|
+
let l = 0, n = 0;
|
|
7
|
+
return t.forEach((e) => {
|
|
8
|
+
l += e.lat, n += e.lng;
|
|
9
|
+
}), {
|
|
10
|
+
lat: l / t.length,
|
|
11
|
+
lng: n / t.length
|
|
12
|
+
};
|
|
13
|
+
}, u = (t) => {
|
|
14
|
+
if (t.length === 0)
|
|
15
|
+
return {
|
|
16
|
+
north: 0,
|
|
17
|
+
south: 0,
|
|
18
|
+
east: 0,
|
|
19
|
+
west: 0,
|
|
20
|
+
center: { lat: 0, lng: 0 }
|
|
21
|
+
};
|
|
22
|
+
let l = t[0].lat, n = t[0].lat, e = t[0].lng, g = t[0].lng;
|
|
23
|
+
return t.forEach((h) => {
|
|
24
|
+
l = Math.max(l, h.lat), n = Math.min(n, h.lat), e = Math.max(e, h.lng), g = Math.min(g, h.lng);
|
|
25
|
+
}), {
|
|
26
|
+
north: l,
|
|
27
|
+
south: n,
|
|
28
|
+
east: e,
|
|
29
|
+
west: g,
|
|
30
|
+
center: a(t)
|
|
31
|
+
};
|
|
32
|
+
}, r = (t) => typeof t == "number" ? `${t}px` : t;
|
|
33
|
+
export {
|
|
34
|
+
u as calculateBounds,
|
|
35
|
+
a as calculateCenter,
|
|
36
|
+
r as formatDimension
|
|
37
|
+
};
|