agvmap-react 0.3.1 → 0.3.4

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.
@@ -0,0 +1,241 @@
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 y, h as X } from "./index-PA3gIYcW.js";
2
+ import { useState as h, useContext as Y, useCallback as l, 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: "currentColor",
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: "currentColor",
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: g, buttonClassName: u = "" }) => {
36
+ const [d, o] = h(!1), { handleMarkerUpdate: a } = Y(z), c = A(), p = l(() => {
37
+ o((f) => !f);
38
+ }, []), m = (f) => a(f);
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: o,
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: m,
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 = ({
75
+ marker: s,
76
+ onMarkerClick: g,
77
+ onDeleteMarker: u,
78
+ markersData: d,
79
+ intl: o
80
+ }) => /* @__PURE__ */ e.jsx("div", { className: "marker-item rounded-md hover:bg-accent 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: [
81
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 flex-1 min-w-0", children: [
82
+ /* @__PURE__ */ e.jsx(Q, { className: "h-4 w-4 text-primary flex-shrink-0" }),
83
+ /* @__PURE__ */ e.jsx("h5", { className: "text-sm font-medium text-mute-foreground break-words leading-tight", children: s == null ? void 0 : s.title })
84
+ ] }),
85
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-1 flex-shrink-0", children: [
86
+ /* @__PURE__ */ e.jsx(
87
+ w,
88
+ {
89
+ text: o.formatMessage({
90
+ id: "app.agviewer_map.focus_marker",
91
+ defaultMessage: "Focus on the marker"
92
+ }),
93
+ children: /* @__PURE__ */ e.jsx(
94
+ y,
95
+ {
96
+ variant: "icon",
97
+ className: "rounded-full p-1 text-muted-foreground dark:text-gray-300 hover:bg-accent hover:text-foreground",
98
+ onClick: (a) => g(a, s),
99
+ "data-marker-id": s.id,
100
+ children: /* @__PURE__ */ e.jsx(D, { className: "w-5 h-5" })
101
+ }
102
+ )
103
+ }
104
+ ),
105
+ /* @__PURE__ */ e.jsx(
106
+ w,
107
+ {
108
+ text: o.formatMessage({
109
+ id: "app.agviewer_map.delete_marker",
110
+ defaultMessage: "Delete Marker"
111
+ }),
112
+ children: /* @__PURE__ */ e.jsx(
113
+ y,
114
+ {
115
+ variant: "icon",
116
+ className: "rounded-full p-1 text-foreground hover:bg-accent hover:text-accent-foreground",
117
+ onClick: (a) => u(a, s),
118
+ "data-marker-id": s.id,
119
+ children: /* @__PURE__ */ e.jsx(X, { className: "w-4 h-4 text-red-500" })
120
+ }
121
+ )
122
+ }
123
+ ),
124
+ /* @__PURE__ */ e.jsx(
125
+ ee,
126
+ {
127
+ marker: d.find((a) => a.id === s.id)
128
+ }
129
+ )
130
+ ] })
131
+ ] }) }) });
132
+ function ne({
133
+ markersData: s,
134
+ loading: g,
135
+ handleDeleteMarker: u,
136
+ onMarkerClick: d,
137
+ onClose: o,
138
+ intl: a
139
+ }) {
140
+ const [c, p] = h(""), [m, f] = h(""), [I, b] = h(!1), [i, k] = h(20), [x, _] = h(!1), L = Z(null), C = l(
141
+ O((t) => {
142
+ f(t), b(!1);
143
+ }, 300),
144
+ []
145
+ ), T = l(
146
+ (t) => {
147
+ const r = t.target.value;
148
+ p(r), b(!0), C(r);
149
+ },
150
+ [C]
151
+ ), M = N(() => !s || s.length === 0 ? [] : s.map((t) => q(t)), [s]), n = N(() => {
152
+ if (!m) return M;
153
+ const t = m.toLowerCase();
154
+ return M.filter(
155
+ (r) => {
156
+ var j, v;
157
+ return (v = (j = r == null ? void 0 : r.title) == null ? void 0 : j.toLowerCase()) == null ? void 0 : v.includes(t);
158
+ }
159
+ );
160
+ }, [M, m]), B = N(() => n.slice(0, i), [n, i]);
161
+ $(() => {
162
+ k(20);
163
+ }, [m]);
164
+ const S = l(() => {
165
+ x || i >= n.length || (_(!0), setTimeout(() => {
166
+ k((t) => Math.min(t + 20, n.length)), _(!1);
167
+ }, 300));
168
+ }, [x, i, n.length]), E = l(
169
+ (t) => {
170
+ const { scrollTop: r, scrollHeight: j, clientHeight: v } = t.target;
171
+ r + v >= j - 100 && !x && i < n.length && S();
172
+ },
173
+ [S, x, i, n.length]
174
+ ), F = l(
175
+ (t, r) => {
176
+ d(t, r), o();
177
+ },
178
+ [d, o]
179
+ ), R = l(
180
+ (t, r) => {
181
+ u(t, r);
182
+ },
183
+ [u]
184
+ );
185
+ return g ? /* @__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: [
186
+ /* @__PURE__ */ e.jsxs("div", { className: "relative mb-4", children: [
187
+ /* @__PURE__ */ e.jsx(J, { className: "w-4 h-4 text-muted-foreground absolute left-3 top-1/2 transform -translate-y-1/2" }),
188
+ /* @__PURE__ */ e.jsx(
189
+ K,
190
+ {
191
+ className: "pl-9 w-full h-9",
192
+ placeholder: a.formatMessage({
193
+ id: "app.agviewer_map.search_station",
194
+ defaultMessage: "Search Station"
195
+ }),
196
+ value: c,
197
+ onChange: T
198
+ }
199
+ ),
200
+ 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" }) })
201
+ ] }),
202
+ /* @__PURE__ */ e.jsx(
203
+ "div",
204
+ {
205
+ ref: L,
206
+ className: "overflow-y-auto h-[350px]",
207
+ onScroll: E,
208
+ 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-muted-foreground", children: c ? a.formatMessage({
209
+ id: "app.agviewer_map.no_station_found",
210
+ defaultMessage: "No Station Found"
211
+ }) : a.formatMessage({
212
+ id: "app.agviewer_map.no_station_found",
213
+ defaultMessage: "No Station Found"
214
+ }) }) }) : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
215
+ B.map((t) => /* @__PURE__ */ e.jsx(
216
+ se,
217
+ {
218
+ marker: t,
219
+ onMarkerClick: F,
220
+ onDeleteMarker: R,
221
+ markersData: s,
222
+ intl: a
223
+ },
224
+ t.id
225
+ )),
226
+ 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: [
227
+ /* @__PURE__ */ e.jsx("div", { className: "animate-spin rounded-full h-4 w-4 border-b-2 border-primary" }),
228
+ /* @__PURE__ */ e.jsx("span", { className: "text-sm text-muted-foreground", children: "Loading more..." })
229
+ ] }) }),
230
+ i >= 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-muted-foreground", children: a.formatMessage({
231
+ id: "app.agviewer_map.all_results_loaded",
232
+ defaultMessage: "All results loaded"
233
+ }) }) })
234
+ ] })
235
+ }
236
+ )
237
+ ] });
238
+ }
239
+ export {
240
+ ne as default
241
+ };
@@ -0,0 +1,4 @@
1
+ import { A as p } from "./index-PA3gIYcW.js";
2
+ export {
3
+ p as AgvMap
4
+ };