agvmap-react 0.1.39 → 0.1.40-43
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/README.md +0 -37
- package/dist/LazyModalContent-DmuBEB7X.js +196 -0
- package/dist/agviewermap-react.js +4 -0
- package/dist/agviewermap-react.umd.cjs +1364 -0
- package/dist/{index-D16caLkt.js → index-D0e1C1Q0.js} +37645 -36990
- package/dist/style.css +1 -1
- package/package.json +17 -8
- package/dist/LazyModalContent-Dx3sMuo5.js +0 -197
- package/dist/agvmap-react.js +0 -4
- package/dist/agvmap-react.umd.cjs +0 -1335
package/README.md
CHANGED
|
@@ -44,45 +44,8 @@ VITE_AGV_API_PASSWORD=your_password
|
|
|
44
44
|
}}
|
|
45
45
|
|
|
46
46
|
>
|
|
47
|
-
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
> **Important**: The wrapper element must have class `agv-map-container` for scoped CSS to apply correctly. The component itself renders a `<div className="agv-map-container">` root — just place `<AgvMap>` inside your app's layout where the map should appear.
|
|
51
|
-
|
|
52
|
-
---
|
|
53
|
-
|
|
54
|
-
## Package Consumption (for host apps)
|
|
55
|
-
|
|
56
|
-
When installing `agvmap-react` in another application, follow these steps:
|
|
57
|
-
|
|
58
|
-
### 1. Peer dependencies
|
|
59
|
-
|
|
60
|
-
`react` and `react-dom` are **peer dependencies**. Your host app must provide them:
|
|
61
|
-
|
|
62
|
-
```json
|
|
63
|
-
// Your host app's package.json
|
|
64
|
-
"dependencies": {
|
|
65
|
-
"react": "^18.0.0 || ^19.0.0",
|
|
66
|
-
"react-dom": "^18.0.0 || ^19.0.0",
|
|
67
|
-
"agvmap-react": "<version>"
|
|
68
|
-
}
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### 2. Import the CSS manually
|
|
72
|
-
|
|
73
|
-
The package no longer injects CSS via a side-effect import. You must import `style.css` in your app's entry point:
|
|
74
|
-
|
|
75
|
-
```js
|
|
76
|
-
// In your app's entry file (e.g., main.jsx, App.jsx, or layout.jsx)
|
|
77
|
-
import 'agvmap-react/style.css';
|
|
78
47
|
```
|
|
79
48
|
|
|
80
|
-
### 3. All styles are scoped
|
|
81
|
-
|
|
82
|
-
All CSS selectors are scoped under `.agv-map-container`. The map component's root element already has this class, so no additional wrapper is needed — just place `<AgvMap />` in your JSX.
|
|
83
|
-
|
|
84
|
-
---
|
|
85
|
-
|
|
86
49
|
## Project Goal
|
|
87
50
|
|
|
88
51
|
Implement a map component with custom layers fetched from a REST API, to be integrated into a dashboard for visualization and analysis.
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { j as e, M as z, u as A, a as H, B as P, T as w, b as U, C as V, c as W, d as O, t as q, S as G, e as J, I as K, f as Q, g as S, h as X } from "./index-D0e1C1Q0.js";
|
|
2
|
+
import { useState as m, useContext as Y, useCallback as o, useRef as Z, useMemo as N, useEffect as $ } from "react";
|
|
3
|
+
const D = (s) => /* @__PURE__ */ e.jsxs(
|
|
4
|
+
"svg",
|
|
5
|
+
{
|
|
6
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
7
|
+
width: 20,
|
|
8
|
+
height: 20,
|
|
9
|
+
viewBox: "0 0 20 20",
|
|
10
|
+
fill: "none",
|
|
11
|
+
...s,
|
|
12
|
+
children: [
|
|
13
|
+
/* @__PURE__ */ e.jsx(
|
|
14
|
+
"path",
|
|
15
|
+
{
|
|
16
|
+
stroke: "#373737",
|
|
17
|
+
strokeLinecap: "round",
|
|
18
|
+
strokeLinejoin: "round",
|
|
19
|
+
strokeWidth: 2,
|
|
20
|
+
d: "m5.833 14.167 8.334-8.334"
|
|
21
|
+
}
|
|
22
|
+
),
|
|
23
|
+
/* @__PURE__ */ e.jsx(
|
|
24
|
+
"path",
|
|
25
|
+
{
|
|
26
|
+
stroke: "#000",
|
|
27
|
+
strokeLinecap: "round",
|
|
28
|
+
strokeLinejoin: "round",
|
|
29
|
+
strokeWidth: 2,
|
|
30
|
+
d: "M5.833 5.833h8.334v8.334"
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
), ee = ({ marker: s, markerId: f, buttonClassName: g = "" }) => {
|
|
36
|
+
const [d, i] = m(!1), { handleMarkerUpdate: t } = Y(z), c = A(), p = o(() => {
|
|
37
|
+
i((u) => !u);
|
|
38
|
+
}, []), h = (u) => t(u);
|
|
39
|
+
return /* @__PURE__ */ e.jsx(
|
|
40
|
+
H,
|
|
41
|
+
{
|
|
42
|
+
trigger: /* @__PURE__ */ e.jsx(P, { variant: "outline", size: "icon", tabIndex: -1, children: /* @__PURE__ */ e.jsx(
|
|
43
|
+
w,
|
|
44
|
+
{
|
|
45
|
+
text: c.formatMessage({
|
|
46
|
+
id: "app.agviewer_map.edit_marker",
|
|
47
|
+
defaultMessage: "Edit Marker"
|
|
48
|
+
}),
|
|
49
|
+
children: /* @__PURE__ */ e.jsx(U, { className: "w-5 h-5 action-icon" })
|
|
50
|
+
}
|
|
51
|
+
) }),
|
|
52
|
+
title: c.formatMessage({
|
|
53
|
+
id: "app.agviewer_map.edit_marker",
|
|
54
|
+
defaultMessage: "Edit Marker"
|
|
55
|
+
}),
|
|
56
|
+
open: d,
|
|
57
|
+
setOpen: i,
|
|
58
|
+
headerClassName: "m-4",
|
|
59
|
+
onClose: p,
|
|
60
|
+
children: /* @__PURE__ */ e.jsx(V, { children: /* @__PURE__ */ e.jsx(
|
|
61
|
+
W,
|
|
62
|
+
{
|
|
63
|
+
marker: s,
|
|
64
|
+
onSubmit: h,
|
|
65
|
+
onCancel: p,
|
|
66
|
+
submitButtonText: c.formatMessage({
|
|
67
|
+
id: "app.agviewer_map.save_changes",
|
|
68
|
+
defaultMessage: "Save Changes"
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
) })
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
}, se = ({ marker: s, onMarkerClick: f, onDeleteMarker: g, markersData: d, intl: i }) => /* @__PURE__ */ e.jsx("div", { className: "marker-item rounded-md hover:bg-gray-50 dark:hover:bg-gray-700 p-2 mb-2", children: /* @__PURE__ */ e.jsx("div", { className: "marker-item-info", children: /* @__PURE__ */ e.jsxs("div", { className: "flex justify-between items-center gap-2", children: [
|
|
75
|
+
/* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 flex-1 min-w-0", children: [
|
|
76
|
+
/* @__PURE__ */ e.jsx(Q, { className: "h-4 w-4 text-primary shrink-0" }),
|
|
77
|
+
/* @__PURE__ */ e.jsx("h5", { className: "text-sm font-medium text-gray-800 dark:text-gray-200 wrap-break-word leading-tight", children: s == null ? void 0 : s.title })
|
|
78
|
+
] }),
|
|
79
|
+
/* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-1 shrink-0", children: [
|
|
80
|
+
/* @__PURE__ */ e.jsx(w, { text: i.formatMessage({ id: "app.agviewer_map.focus_marker", defaultMessage: "Focus on the marker" }), children: /* @__PURE__ */ e.jsx(
|
|
81
|
+
S,
|
|
82
|
+
{
|
|
83
|
+
variant: "icon",
|
|
84
|
+
className: "rounded-full p-1 hover:bg-gray-100 dark:hover:bg-gray-600",
|
|
85
|
+
onClick: (t) => f(t, s),
|
|
86
|
+
"data-marker-id": s.id,
|
|
87
|
+
children: /* @__PURE__ */ e.jsx(D, { className: "w-4 h-4" })
|
|
88
|
+
}
|
|
89
|
+
) }),
|
|
90
|
+
/* @__PURE__ */ e.jsx(w, { text: i.formatMessage({ id: "app.agviewer_map.delete_marker", defaultMessage: "Delete Marker" }), children: /* @__PURE__ */ e.jsx(
|
|
91
|
+
S,
|
|
92
|
+
{
|
|
93
|
+
variant: "icon",
|
|
94
|
+
className: "rounded-full p-1 hover:bg-gray-100 dark:hover:bg-gray-600",
|
|
95
|
+
onClick: (t) => g(t, s),
|
|
96
|
+
"data-marker-id": s.id,
|
|
97
|
+
children: /* @__PURE__ */ e.jsx(X, { className: "w-4 h-4 text-red-500" })
|
|
98
|
+
}
|
|
99
|
+
) }),
|
|
100
|
+
/* @__PURE__ */ e.jsx(
|
|
101
|
+
ee,
|
|
102
|
+
{
|
|
103
|
+
marker: d.find((t) => t.id === s.id)
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
] })
|
|
107
|
+
] }) }) });
|
|
108
|
+
function ne({
|
|
109
|
+
markersData: s,
|
|
110
|
+
loading: f,
|
|
111
|
+
handleDeleteMarker: g,
|
|
112
|
+
onMarkerClick: d,
|
|
113
|
+
onClose: i,
|
|
114
|
+
intl: t
|
|
115
|
+
}) {
|
|
116
|
+
const [c, p] = m(""), [h, u] = m(""), [I, b] = m(!1), [l, y] = m(20), [x, k] = m(!1), L = Z(null), _ = o(
|
|
117
|
+
O((a) => {
|
|
118
|
+
u(a), b(!1);
|
|
119
|
+
}, 300),
|
|
120
|
+
[]
|
|
121
|
+
), T = o((a) => {
|
|
122
|
+
const r = a.target.value;
|
|
123
|
+
p(r), b(!0), _(r);
|
|
124
|
+
}, [_]), M = N(() => !s || s.length === 0 ? [] : s.map((a) => q(a)), [s]), n = N(() => {
|
|
125
|
+
if (!h) return M;
|
|
126
|
+
const a = h.toLowerCase();
|
|
127
|
+
return M.filter(
|
|
128
|
+
(r) => {
|
|
129
|
+
var j, v;
|
|
130
|
+
return (v = (j = r == null ? void 0 : r.title) == null ? void 0 : j.toLowerCase()) == null ? void 0 : v.includes(a);
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
}, [M, h]), B = N(() => n.slice(0, l), [n, l]);
|
|
134
|
+
$(() => {
|
|
135
|
+
y(20);
|
|
136
|
+
}, [h]);
|
|
137
|
+
const C = o(() => {
|
|
138
|
+
x || l >= n.length || (k(!0), setTimeout(() => {
|
|
139
|
+
y((a) => Math.min(a + 20, n.length)), k(!1);
|
|
140
|
+
}, 300));
|
|
141
|
+
}, [x, l, n.length]), E = o((a) => {
|
|
142
|
+
const { scrollTop: r, scrollHeight: j, clientHeight: v } = a.target;
|
|
143
|
+
r + v >= j - 100 && !x && l < n.length && C();
|
|
144
|
+
}, [C, x, l, n.length]), F = o((a, r) => {
|
|
145
|
+
d(a, r), i();
|
|
146
|
+
}, [d, i]), R = o((a, r) => {
|
|
147
|
+
g(a, r);
|
|
148
|
+
}, [g]);
|
|
149
|
+
return f ? /* @__PURE__ */ e.jsx("div", { className: "flex justify-center items-center h-40", children: /* @__PURE__ */ e.jsx(G, {}) }) : /* @__PURE__ */ e.jsxs("div", { className: "w-full", children: [
|
|
150
|
+
/* @__PURE__ */ e.jsxs("div", { className: "relative mb-4", children: [
|
|
151
|
+
/* @__PURE__ */ e.jsx(J, { className: "w-4 h-4 text-gray-500 absolute left-3 top-1/2 transform -translate-y-1/2" }),
|
|
152
|
+
/* @__PURE__ */ e.jsx(
|
|
153
|
+
K,
|
|
154
|
+
{
|
|
155
|
+
className: "pl-9 w-full text-sm h-9",
|
|
156
|
+
placeholder: t.formatMessage({ id: "app.agviewer_map.search_station", defaultMessage: "Search Station" }),
|
|
157
|
+
value: c,
|
|
158
|
+
onChange: T
|
|
159
|
+
}
|
|
160
|
+
),
|
|
161
|
+
I && /* @__PURE__ */ e.jsx("div", { className: "absolute right-3 top-1/2 transform -translate-y-1/2", children: /* @__PURE__ */ e.jsx("div", { className: "animate-spin rounded-full h-4 w-4 border-b-2 border-primary" }) })
|
|
162
|
+
] }),
|
|
163
|
+
/* @__PURE__ */ e.jsx(
|
|
164
|
+
"div",
|
|
165
|
+
{
|
|
166
|
+
ref: L,
|
|
167
|
+
className: "overflow-y-auto h-[350px]",
|
|
168
|
+
onScroll: E,
|
|
169
|
+
children: n.length === 0 ? /* @__PURE__ */ e.jsx("div", { className: "flex items-center justify-center h-20 p-4", children: /* @__PURE__ */ e.jsx("h5", { className: "text-sm text-gray-500 dark:text-gray-400", children: c ? t.formatMessage({ id: "app.agviewer_map.no_station_found", defaultMessage: "No Station Found" }) : t.formatMessage({ id: "app.agviewer_map.no_station_found", defaultMessage: "No Station Found" }) }) }) : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
170
|
+
B.map((a) => /* @__PURE__ */ e.jsx(
|
|
171
|
+
se,
|
|
172
|
+
{
|
|
173
|
+
marker: a,
|
|
174
|
+
onMarkerClick: F,
|
|
175
|
+
onDeleteMarker: R,
|
|
176
|
+
markersData: s,
|
|
177
|
+
intl: t
|
|
178
|
+
},
|
|
179
|
+
a.id
|
|
180
|
+
)),
|
|
181
|
+
x && /* @__PURE__ */ e.jsx("div", { className: "flex justify-center items-center py-4", children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
182
|
+
/* @__PURE__ */ e.jsx("div", { className: "animate-spin rounded-full h-4 w-4 border-b-2 border-primary" }),
|
|
183
|
+
/* @__PURE__ */ e.jsx("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: "Loading more..." })
|
|
184
|
+
] }) }),
|
|
185
|
+
l >= n.length && n.length > 0 && /* @__PURE__ */ e.jsx("div", { className: "flex justify-center items-center py-4", children: /* @__PURE__ */ e.jsx("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: t.formatMessage({
|
|
186
|
+
id: "app.agviewer_map.all_results_loaded",
|
|
187
|
+
defaultMessage: "All results loaded"
|
|
188
|
+
}) }) })
|
|
189
|
+
] })
|
|
190
|
+
}
|
|
191
|
+
)
|
|
192
|
+
] });
|
|
193
|
+
}
|
|
194
|
+
export {
|
|
195
|
+
ne as default
|
|
196
|
+
};
|