agviewermap-react 0.1.20 → 0.1.22

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,196 @@
1
+ import { j as e, M as z, u as A, a as H, B as P, T as b, 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-B74DbHYT.js";
2
+ import { useState as g, 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: u = "" }) => {
36
+ const [d, i] = g(!1), { handleMarkerUpdate: t } = Y(z), c = A(), p = o(() => {
37
+ i((m) => !m);
38
+ }, []), h = (m) => (console.log("data after editing", m), console.log("data before editing", s), t(m));
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
+ b,
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: u, 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 flex-shrink-0" }),
77
+ /* @__PURE__ */ e.jsx("h5", { className: "text-sm font-medium text-gray-800 dark:text-gray-200 break-words leading-tight", children: s == null ? void 0 : s.title })
78
+ ] }),
79
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-1 flex-shrink-0", children: [
80
+ /* @__PURE__ */ e.jsx(b, { 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(b, { 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) => u(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: u,
112
+ onMarkerClick: d,
113
+ onClose: i,
114
+ intl: t
115
+ }) {
116
+ const [c, p] = g(""), [h, m] = g(""), [I, w] = g(!1), [l, y] = g(20), [x, k] = g(!1), L = Z(null), _ = o(
117
+ O((a) => {
118
+ m(a), w(!1);
119
+ }, 300),
120
+ []
121
+ ), T = o((a) => {
122
+ const r = a.target.value;
123
+ p(r), w(!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
+ u(a, r);
148
+ }, [u]);
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
+ };
@@ -1,4 +1,4 @@
1
- import { A as p } from "./index-DctakHpv.js";
1
+ import { A as p } from "./index-B74DbHYT.js";
2
2
  export {
3
3
  p as AgvMap
4
4
  };