@kuraykaraaslan/kui-react 1.0.1
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/LICENSE +17 -0
- package/README.md +168 -0
- package/dist/AdvancedDataTable-F3DNXDKX.mjs +11 -0
- package/dist/DataTable-2G27T4E6.mjs +11 -0
- package/dist/DateRangePicker-AL32QB6L.mjs +11 -0
- package/dist/DropdownMenu-f5yV9dzM.d.mts +22 -0
- package/dist/DropdownMenu-f5yV9dzM.d.ts +22 -0
- package/dist/MapView-FERKPCDB.mjs +10 -0
- package/dist/ServerDataTable-RZV3K6KQ.mjs +11 -0
- package/dist/Tooltip-Bof5GvOc.d.mts +248 -0
- package/dist/Tooltip-Bof5GvOc.d.ts +248 -0
- package/dist/VideoPlayer-P3I6ESXJ.mjs +9 -0
- package/dist/app.d.mts +620 -0
- package/dist/app.d.ts +620 -0
- package/dist/app.js +7061 -0
- package/dist/app.mjs +100 -0
- package/dist/chunk-24BCQSLI.mjs +1 -0
- package/dist/chunk-45I3EDB2.mjs +90 -0
- package/dist/chunk-4IWCD7ID.mjs +1450 -0
- package/dist/chunk-5E2HXWFI.mjs +105 -0
- package/dist/chunk-C7AYI4XM.mjs +402 -0
- package/dist/chunk-J4D44TUA.mjs +1267 -0
- package/dist/chunk-KTEWZKNE.mjs +1020 -0
- package/dist/chunk-LMUQHL4Z.mjs +3829 -0
- package/dist/chunk-MD5OQ4J2.mjs +527 -0
- package/dist/chunk-MPJRPYIZ.mjs +1 -0
- package/dist/chunk-MPWUEQ7J.mjs +2422 -0
- package/dist/chunk-MTT5TKAJ.mjs +93 -0
- package/dist/chunk-RBDK7MWQ.mjs +46 -0
- package/dist/chunk-SVFQZPNZ.mjs +3648 -0
- package/dist/chunk-TZWBBMSG.mjs +1 -0
- package/dist/chunk-XA7J6PVJ.mjs +1488 -0
- package/dist/chunk-ZLYBRYWQ.mjs +726 -0
- package/dist/common.d.mts +921 -0
- package/dist/common.d.ts +921 -0
- package/dist/common.js +4991 -0
- package/dist/common.mjs +172 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +17563 -0
- package/dist/index.mjs +349 -0
- package/dist/ui.d.mts +937 -0
- package/dist/ui.d.ts +937 -0
- package/dist/ui.js +10095 -0
- package/dist/ui.mjs +163 -0
- package/package.json +114 -0
- package/styles/index.css +129 -0
|
@@ -0,0 +1,527 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Button
|
|
4
|
+
} from "./chunk-MTT5TKAJ.mjs";
|
|
5
|
+
import {
|
|
6
|
+
__objRest,
|
|
7
|
+
__spreadProps,
|
|
8
|
+
__spreadValues,
|
|
9
|
+
cn
|
|
10
|
+
} from "./chunk-RBDK7MWQ.mjs";
|
|
11
|
+
|
|
12
|
+
// modules/ui/MapView/index.tsx
|
|
13
|
+
import { useCallback as useCallback2, useState as useState5 } from "react";
|
|
14
|
+
|
|
15
|
+
// modules/ui/Card.tsx
|
|
16
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
17
|
+
function Card(_a) {
|
|
18
|
+
var _b = _a, {
|
|
19
|
+
as,
|
|
20
|
+
title,
|
|
21
|
+
subtitle,
|
|
22
|
+
headerRight,
|
|
23
|
+
footer,
|
|
24
|
+
children,
|
|
25
|
+
variant = "raised",
|
|
26
|
+
onClick,
|
|
27
|
+
hoverable,
|
|
28
|
+
loading = false,
|
|
29
|
+
className
|
|
30
|
+
} = _b, rest = __objRest(_b, [
|
|
31
|
+
"as",
|
|
32
|
+
"title",
|
|
33
|
+
"subtitle",
|
|
34
|
+
"headerRight",
|
|
35
|
+
"footer",
|
|
36
|
+
"children",
|
|
37
|
+
"variant",
|
|
38
|
+
"onClick",
|
|
39
|
+
"hoverable",
|
|
40
|
+
"loading",
|
|
41
|
+
"className"
|
|
42
|
+
]);
|
|
43
|
+
const isInteractive = !!onClick;
|
|
44
|
+
const isHoverable = hoverable || isInteractive;
|
|
45
|
+
const Tag = as != null ? as : isInteractive ? "button" : "div";
|
|
46
|
+
const isButton = Tag === "button";
|
|
47
|
+
return /* @__PURE__ */ jsx(
|
|
48
|
+
Tag,
|
|
49
|
+
__spreadProps(__spreadValues(__spreadProps(__spreadValues({}, isButton && { type: "button" }), {
|
|
50
|
+
onClick,
|
|
51
|
+
className: cn(
|
|
52
|
+
"rounded-xl border border-border overflow-hidden text-left",
|
|
53
|
+
variant === "raised" && "bg-surface-raised shadow-sm",
|
|
54
|
+
variant === "flat" && "bg-surface-base",
|
|
55
|
+
variant === "outline" && "bg-transparent",
|
|
56
|
+
isHoverable && "transition-shadow hover:shadow-md hover:border-border-focus cursor-pointer",
|
|
57
|
+
isInteractive && "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus w-full",
|
|
58
|
+
loading && "pointer-events-none",
|
|
59
|
+
className
|
|
60
|
+
)
|
|
61
|
+
}), rest), {
|
|
62
|
+
children: loading ? /* @__PURE__ */ jsxs("div", { className: "px-6 py-4 space-y-3 animate-pulse", children: [
|
|
63
|
+
/* @__PURE__ */ jsx("div", { className: "h-4 bg-surface-sunken rounded w-2/3" }),
|
|
64
|
+
/* @__PURE__ */ jsx("div", { className: "h-3 bg-surface-sunken rounded w-full" }),
|
|
65
|
+
/* @__PURE__ */ jsx("div", { className: "h-3 bg-surface-sunken rounded w-4/5" }),
|
|
66
|
+
/* @__PURE__ */ jsx("div", { className: "h-3 bg-surface-sunken rounded w-1/2" })
|
|
67
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
68
|
+
(title || headerRight) && /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-3 px-6 py-4 border-b border-border", children: [
|
|
69
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
70
|
+
title && /* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold text-text-primary", children: title }),
|
|
71
|
+
subtitle && /* @__PURE__ */ jsx("p", { className: "text-xs text-text-secondary mt-0.5", children: subtitle })
|
|
72
|
+
] }),
|
|
73
|
+
headerRight && /* @__PURE__ */ jsx("div", { className: "shrink-0", children: headerRight })
|
|
74
|
+
] }),
|
|
75
|
+
children && /* @__PURE__ */ jsx("div", { className: "px-6 py-4", children }),
|
|
76
|
+
footer && /* @__PURE__ */ jsx("div", { className: "px-6 py-3 border-t border-border bg-surface-base", children: footer })
|
|
77
|
+
] })
|
|
78
|
+
})
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// modules/ui/MapView/parts/LeafletCanvas.tsx
|
|
83
|
+
import { useEffect as useEffect3, useState as useState2 } from "react";
|
|
84
|
+
|
|
85
|
+
// modules/ui/MapView/providers/leaflet.ts
|
|
86
|
+
var LEAFLET_TILES = {
|
|
87
|
+
light: {
|
|
88
|
+
url: "https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}{r}.png",
|
|
89
|
+
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors © <a href="https://carto.com/attributions">CARTO</a>'
|
|
90
|
+
},
|
|
91
|
+
dark: {
|
|
92
|
+
url: "https://{s}.basemaps.cartocdn.com/rastertiles/dark_all/{z}/{x}/{y}{r}.png",
|
|
93
|
+
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors © <a href="https://carto.com/attributions">CARTO</a>'
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
var _cached = null;
|
|
97
|
+
function loadLeaflet() {
|
|
98
|
+
if (_cached) return _cached;
|
|
99
|
+
_cached = (async () => {
|
|
100
|
+
const [rl, leaflet] = await Promise.all([
|
|
101
|
+
import("react-leaflet"),
|
|
102
|
+
import("leaflet")
|
|
103
|
+
]);
|
|
104
|
+
return {
|
|
105
|
+
MapContainer: rl.MapContainer,
|
|
106
|
+
TileLayer: rl.TileLayer,
|
|
107
|
+
Marker: rl.Marker,
|
|
108
|
+
Tooltip: rl.Tooltip,
|
|
109
|
+
Polygon: rl.Polygon,
|
|
110
|
+
Polyline: rl.Polyline,
|
|
111
|
+
useMap: rl.useMap,
|
|
112
|
+
useMapEvents: rl.useMapEvents,
|
|
113
|
+
L: leaflet
|
|
114
|
+
};
|
|
115
|
+
})();
|
|
116
|
+
return _cached;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// modules/ui/MapView/hooks/useDarkMode.ts
|
|
120
|
+
import { useEffect, useState } from "react";
|
|
121
|
+
function useDarkMode() {
|
|
122
|
+
const [isDark, setIsDark] = useState(false);
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
if (typeof document === "undefined") return;
|
|
125
|
+
const root = document.documentElement;
|
|
126
|
+
const read = () => setIsDark(root.classList.contains("dark"));
|
|
127
|
+
read();
|
|
128
|
+
const mo = new MutationObserver(read);
|
|
129
|
+
mo.observe(root, { attributes: true, attributeFilter: ["class"] });
|
|
130
|
+
return () => mo.disconnect();
|
|
131
|
+
}, []);
|
|
132
|
+
return isDark;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// modules/ui/MapView/hooks/useFitBounds.ts
|
|
136
|
+
import { useEffect as useEffect2 } from "react";
|
|
137
|
+
function useFitBounds(map, L, markers, padding) {
|
|
138
|
+
useEffect2(() => {
|
|
139
|
+
if (!map || !L || padding === void 0) return;
|
|
140
|
+
if (!markers.length) return;
|
|
141
|
+
const bounds = L.latLngBounds(markers.map((m) => m.position));
|
|
142
|
+
if (!bounds.isValid()) return;
|
|
143
|
+
map.fitBounds(bounds, { padding: [padding, padding] });
|
|
144
|
+
}, [map, L, padding, markers.length]);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// modules/ui/MapView/parts/Popup.tsx
|
|
148
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
149
|
+
function Popup({ tooltip }) {
|
|
150
|
+
var _a, _b;
|
|
151
|
+
const hasMeta = Boolean(tooltip.description) || Boolean((_a = tooltip.fields) == null ? void 0 : _a.length);
|
|
152
|
+
return /* @__PURE__ */ jsxs2("div", { style: { minWidth: 130, maxWidth: 220 }, children: [
|
|
153
|
+
/* @__PURE__ */ jsx2("p", { style: {
|
|
154
|
+
fontWeight: 600,
|
|
155
|
+
fontSize: 13,
|
|
156
|
+
color: "#111827",
|
|
157
|
+
marginBottom: hasMeta ? 3 : 0
|
|
158
|
+
}, children: tooltip.title }),
|
|
159
|
+
tooltip.description && /* @__PURE__ */ jsx2("p", { style: {
|
|
160
|
+
fontSize: 11,
|
|
161
|
+
color: "#6b7280",
|
|
162
|
+
marginBottom: ((_b = tooltip.fields) == null ? void 0 : _b.length) ? 4 : 0,
|
|
163
|
+
lineHeight: 1.4
|
|
164
|
+
}, children: tooltip.description }),
|
|
165
|
+
tooltip.fields && tooltip.fields.length > 0 && /* @__PURE__ */ jsx2("table", { style: { width: "100%", borderCollapse: "collapse", marginTop: 2 }, children: /* @__PURE__ */ jsx2("tbody", { children: tooltip.fields.map((f, i) => /* @__PURE__ */ jsxs2("tr", { children: [
|
|
166
|
+
/* @__PURE__ */ jsx2("td", { style: { fontSize: 11, color: "#6b7280", paddingRight: 6, paddingTop: 1, whiteSpace: "nowrap" }, children: f.label }),
|
|
167
|
+
/* @__PURE__ */ jsx2("td", { style: { fontSize: 11, color: "#111827", fontWeight: 500, paddingTop: 1 }, children: f.value })
|
|
168
|
+
] }, i)) }) })
|
|
169
|
+
] });
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// modules/ui/MapView/types.ts
|
|
173
|
+
var VARIANT_HEX = {
|
|
174
|
+
primary: "#3b82f6",
|
|
175
|
+
success: "#22c55e",
|
|
176
|
+
warning: "#f59e0b",
|
|
177
|
+
error: "#ef4444",
|
|
178
|
+
info: "#06b6d4",
|
|
179
|
+
neutral: "#6b7280"
|
|
180
|
+
};
|
|
181
|
+
var VARIANT_FILL = {
|
|
182
|
+
primary: "#3b82f620",
|
|
183
|
+
success: "#22c55e20",
|
|
184
|
+
warning: "#f59e0b20",
|
|
185
|
+
error: "#ef444420",
|
|
186
|
+
info: "#06b6d420",
|
|
187
|
+
neutral: "#6b728020"
|
|
188
|
+
};
|
|
189
|
+
function markerSvg(color) {
|
|
190
|
+
return `
|
|
191
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 36" width="24" height="36" style="filter:drop-shadow(0 2px 3px rgba(0,0,0,0.35))">
|
|
192
|
+
<path d="M12 0C5.373 0 0 5.373 0 12c0 3.143 1.204 5.997 3.17 8.126L12 36l8.83-15.874A11.945 11.945 0 0 0 24 12C24 5.373 18.627 0 12 0z" fill="${color}"/>
|
|
193
|
+
<circle cx="12" cy="12" r="4.5" fill="white" opacity="0.9"/>
|
|
194
|
+
</svg>`;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// modules/ui/MapView/parts/Marker.tsx
|
|
198
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
199
|
+
function MarkerPart({ marker, L, RLMarker, RLTooltip, onMarkerClick }) {
|
|
200
|
+
var _a;
|
|
201
|
+
const variant = (_a = marker.variant) != null ? _a : "primary";
|
|
202
|
+
const color = VARIANT_HEX[variant];
|
|
203
|
+
const icon = L.divIcon({
|
|
204
|
+
html: markerSvg(color),
|
|
205
|
+
className: "",
|
|
206
|
+
iconSize: [24, 36],
|
|
207
|
+
iconAnchor: [12, 36],
|
|
208
|
+
tooltipAnchor: [0, -38]
|
|
209
|
+
});
|
|
210
|
+
return /* @__PURE__ */ jsxs3(
|
|
211
|
+
RLMarker,
|
|
212
|
+
{
|
|
213
|
+
position: marker.position,
|
|
214
|
+
icon,
|
|
215
|
+
eventHandlers: { click: () => onMarkerClick == null ? void 0 : onMarkerClick(marker.id) },
|
|
216
|
+
children: [
|
|
217
|
+
marker.tooltip && /* @__PURE__ */ jsx3(RLTooltip, { children: /* @__PURE__ */ jsx3(Popup, { tooltip: marker.tooltip }) }),
|
|
218
|
+
!marker.tooltip && marker.label && /* @__PURE__ */ jsx3(RLTooltip, { children: /* @__PURE__ */ jsx3("span", { style: { fontSize: 12, fontWeight: 600 }, children: marker.label }) })
|
|
219
|
+
]
|
|
220
|
+
}
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// modules/ui/MapView/parts/Shapes.tsx
|
|
225
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
226
|
+
function ZoneShape({ zone, Polygon, Tooltip }) {
|
|
227
|
+
var _a, _b;
|
|
228
|
+
const variant = (_a = zone.variant) != null ? _a : "primary";
|
|
229
|
+
const strokeColor = VARIANT_HEX[variant];
|
|
230
|
+
const fillColor = VARIANT_FILL[variant];
|
|
231
|
+
return /* @__PURE__ */ jsx4(
|
|
232
|
+
Polygon,
|
|
233
|
+
{
|
|
234
|
+
positions: zone.positions,
|
|
235
|
+
pathOptions: {
|
|
236
|
+
color: strokeColor,
|
|
237
|
+
fillColor,
|
|
238
|
+
fillOpacity: (_b = zone.fillOpacity) != null ? _b : 0.25,
|
|
239
|
+
weight: 2
|
|
240
|
+
},
|
|
241
|
+
children: zone.label && /* @__PURE__ */ jsx4(Tooltip, { sticky: true, children: /* @__PURE__ */ jsx4("span", { style: { fontWeight: 600, fontSize: 12, color: strokeColor }, children: zone.label }) })
|
|
242
|
+
}
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
function RouteShape({ route, Polyline, Tooltip }) {
|
|
246
|
+
var _a, _b;
|
|
247
|
+
return /* @__PURE__ */ jsx4(
|
|
248
|
+
Polyline,
|
|
249
|
+
{
|
|
250
|
+
positions: route.positions,
|
|
251
|
+
pathOptions: {
|
|
252
|
+
color: (_a = route.color) != null ? _a : VARIANT_HEX.primary,
|
|
253
|
+
weight: (_b = route.weight) != null ? _b : 3,
|
|
254
|
+
dashArray: route.dashed ? "8 6" : void 0
|
|
255
|
+
},
|
|
256
|
+
children: route.label && /* @__PURE__ */ jsx4(Tooltip, { sticky: true, children: /* @__PURE__ */ jsx4("span", { style: { fontWeight: 600, fontSize: 12 }, children: route.label }) })
|
|
257
|
+
}
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// modules/ui/MapView/parts/LeafletCanvas.tsx
|
|
262
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
263
|
+
function LeafletCanvas(props) {
|
|
264
|
+
const [bundle, setBundle] = useState2(null);
|
|
265
|
+
useEffect3(() => {
|
|
266
|
+
let alive = true;
|
|
267
|
+
loadLeaflet().then((b) => {
|
|
268
|
+
if (alive) setBundle(b);
|
|
269
|
+
});
|
|
270
|
+
return () => {
|
|
271
|
+
alive = false;
|
|
272
|
+
};
|
|
273
|
+
}, []);
|
|
274
|
+
if (!bundle) {
|
|
275
|
+
return /* @__PURE__ */ jsx5("div", { className: "w-full h-full flex items-center justify-center bg-surface-raised", children: /* @__PURE__ */ jsx5("span", { className: "text-sm text-text-secondary", children: "Harita y\xFCkleniyor\u2026" }) });
|
|
276
|
+
}
|
|
277
|
+
return /* @__PURE__ */ jsx5(InnerMap, __spreadProps(__spreadValues({}, props), { bundle }));
|
|
278
|
+
}
|
|
279
|
+
function InnerMap({
|
|
280
|
+
center,
|
|
281
|
+
zoom,
|
|
282
|
+
markers,
|
|
283
|
+
zones,
|
|
284
|
+
routes,
|
|
285
|
+
showZones,
|
|
286
|
+
showRoutes,
|
|
287
|
+
addMode,
|
|
288
|
+
fitBoundsPadding,
|
|
289
|
+
onMapClick,
|
|
290
|
+
onMarkerClick,
|
|
291
|
+
bundle
|
|
292
|
+
}) {
|
|
293
|
+
const { MapContainer, TileLayer, Marker, Tooltip, Polygon, Polyline, useMap, useMapEvents, L } = bundle;
|
|
294
|
+
const isDark = useDarkMode();
|
|
295
|
+
const tiles = isDark ? LEAFLET_TILES.dark : LEAFLET_TILES.light;
|
|
296
|
+
function ClickHandler() {
|
|
297
|
+
useMapEvents({
|
|
298
|
+
click(e) {
|
|
299
|
+
if (addMode) onMapClick(e.latlng.lat, e.latlng.lng);
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
function FitBounds() {
|
|
305
|
+
const map = useMap();
|
|
306
|
+
useFitBounds(map, L, markers, fitBoundsPadding);
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
return /* @__PURE__ */ jsxs4(
|
|
310
|
+
MapContainer,
|
|
311
|
+
{
|
|
312
|
+
center,
|
|
313
|
+
zoom,
|
|
314
|
+
style: { width: "100%", height: "100%" },
|
|
315
|
+
className: addMode ? "cursor-crosshair" : "",
|
|
316
|
+
children: [
|
|
317
|
+
/* @__PURE__ */ jsx5(TileLayer, { attribution: tiles.attribution, url: tiles.url }, isDark ? "dark" : "light"),
|
|
318
|
+
/* @__PURE__ */ jsx5(ClickHandler, {}),
|
|
319
|
+
/* @__PURE__ */ jsx5(FitBounds, {}),
|
|
320
|
+
showZones && zones.map((zone) => /* @__PURE__ */ jsx5(ZoneShape, { zone, Polygon, Tooltip }, zone.id)),
|
|
321
|
+
showRoutes && routes.map((route) => /* @__PURE__ */ jsx5(RouteShape, { route, Polyline, Tooltip }, route.id)),
|
|
322
|
+
markers.map((marker) => /* @__PURE__ */ jsx5(
|
|
323
|
+
MarkerPart,
|
|
324
|
+
{
|
|
325
|
+
marker,
|
|
326
|
+
L,
|
|
327
|
+
RLMarker: Marker,
|
|
328
|
+
RLTooltip: Tooltip,
|
|
329
|
+
onMarkerClick
|
|
330
|
+
},
|
|
331
|
+
marker.id
|
|
332
|
+
))
|
|
333
|
+
]
|
|
334
|
+
}
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// modules/ui/MapView/parts/Toolbar.tsx
|
|
339
|
+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
340
|
+
import {
|
|
341
|
+
faLocationDot,
|
|
342
|
+
faRoute,
|
|
343
|
+
faLayerGroup,
|
|
344
|
+
faPlus,
|
|
345
|
+
faXmark,
|
|
346
|
+
faEye,
|
|
347
|
+
faEyeSlash
|
|
348
|
+
} from "@fortawesome/free-solid-svg-icons";
|
|
349
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
350
|
+
function Toolbar({
|
|
351
|
+
addMode,
|
|
352
|
+
onToggleAddMode,
|
|
353
|
+
hasZones,
|
|
354
|
+
showZones,
|
|
355
|
+
onToggleZones,
|
|
356
|
+
hasRoutes,
|
|
357
|
+
showRoutes,
|
|
358
|
+
onToggleRoutes
|
|
359
|
+
}) {
|
|
360
|
+
return /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2 flex-wrap", children: [
|
|
361
|
+
/* @__PURE__ */ jsx6(
|
|
362
|
+
Button,
|
|
363
|
+
{
|
|
364
|
+
size: "xs",
|
|
365
|
+
variant: addMode ? "primary" : "outline",
|
|
366
|
+
title: addMode ? "\u0130\u015Faret\xE7i eklemeyi iptal et" : "Haritaya i\u015Faret\xE7i ekle",
|
|
367
|
+
onClick: onToggleAddMode,
|
|
368
|
+
iconLeft: /* @__PURE__ */ jsx6(FontAwesomeIcon, { icon: addMode ? faXmark : faPlus, "aria-hidden": "true" }),
|
|
369
|
+
iconRight: /* @__PURE__ */ jsx6(FontAwesomeIcon, { icon: faLocationDot, "aria-hidden": "true" }),
|
|
370
|
+
children: addMode ? "\u0130ptal" : "\u0130\u015Faret\xE7i Ekle"
|
|
371
|
+
}
|
|
372
|
+
),
|
|
373
|
+
hasZones && /* @__PURE__ */ jsx6(
|
|
374
|
+
Button,
|
|
375
|
+
{
|
|
376
|
+
size: "xs",
|
|
377
|
+
variant: showZones ? "primary" : "outline",
|
|
378
|
+
title: showZones ? "B\xF6lgeleri gizle" : "B\xF6lgeleri g\xF6ster",
|
|
379
|
+
onClick: onToggleZones,
|
|
380
|
+
iconLeft: /* @__PURE__ */ jsx6(FontAwesomeIcon, { icon: showZones ? faEye : faEyeSlash, "aria-hidden": "true" }),
|
|
381
|
+
iconRight: /* @__PURE__ */ jsx6(FontAwesomeIcon, { icon: faLayerGroup, "aria-hidden": "true" }),
|
|
382
|
+
children: "B\xF6lgeler"
|
|
383
|
+
}
|
|
384
|
+
),
|
|
385
|
+
hasRoutes && /* @__PURE__ */ jsx6(
|
|
386
|
+
Button,
|
|
387
|
+
{
|
|
388
|
+
size: "xs",
|
|
389
|
+
variant: showRoutes ? "primary" : "outline",
|
|
390
|
+
title: showRoutes ? "Rotalar\u0131 gizle" : "Rotalar\u0131 g\xF6ster",
|
|
391
|
+
onClick: onToggleRoutes,
|
|
392
|
+
iconLeft: /* @__PURE__ */ jsx6(FontAwesomeIcon, { icon: showRoutes ? faEye : faEyeSlash, "aria-hidden": "true" }),
|
|
393
|
+
iconRight: /* @__PURE__ */ jsx6(FontAwesomeIcon, { icon: faRoute, "aria-hidden": "true" }),
|
|
394
|
+
children: "Rotalar"
|
|
395
|
+
}
|
|
396
|
+
),
|
|
397
|
+
addMode && /* @__PURE__ */ jsx6("span", { className: "text-xs text-primary font-medium animate-pulse", children: "Haritaya t\u0131klayarak i\u015Faret\xE7i ekleyin" })
|
|
398
|
+
] });
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// modules/ui/MapView/hooks/useInViewport.ts
|
|
402
|
+
import { useEffect as useEffect4, useRef, useState as useState3 } from "react";
|
|
403
|
+
function useInViewport(options) {
|
|
404
|
+
const ref = useRef(null);
|
|
405
|
+
const [visible, setVisible] = useState3(false);
|
|
406
|
+
useEffect4(() => {
|
|
407
|
+
if (visible) return;
|
|
408
|
+
const el = ref.current;
|
|
409
|
+
if (!el) return;
|
|
410
|
+
if (typeof IntersectionObserver === "undefined") {
|
|
411
|
+
setVisible(true);
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
const io = new IntersectionObserver(
|
|
415
|
+
(entries) => {
|
|
416
|
+
for (const entry of entries) {
|
|
417
|
+
if (entry.isIntersecting) {
|
|
418
|
+
setVisible(true);
|
|
419
|
+
io.disconnect();
|
|
420
|
+
break;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
__spreadValues({ rootMargin: "200px", threshold: 0.01 }, options)
|
|
425
|
+
);
|
|
426
|
+
io.observe(el);
|
|
427
|
+
return () => io.disconnect();
|
|
428
|
+
}, [visible, options]);
|
|
429
|
+
return { ref, visible };
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// modules/ui/MapView/hooks/useAutoMarkers.ts
|
|
433
|
+
import { useCallback, useRef as useRef2, useState as useState4 } from "react";
|
|
434
|
+
function useAutoMarkers(onMarkerAdd) {
|
|
435
|
+
const [extras, setExtras] = useState4([]);
|
|
436
|
+
const counter = useRef2(0);
|
|
437
|
+
const handleMapClick = useCallback((lat, lng) => {
|
|
438
|
+
const pos = [lat, lng];
|
|
439
|
+
if (onMarkerAdd) {
|
|
440
|
+
onMarkerAdd(pos);
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
counter.current += 1;
|
|
444
|
+
setExtras((prev) => [
|
|
445
|
+
...prev,
|
|
446
|
+
{
|
|
447
|
+
id: `auto-${counter.current}`,
|
|
448
|
+
position: pos,
|
|
449
|
+
variant: "primary",
|
|
450
|
+
tooltip: {
|
|
451
|
+
title: `\u0130\u015Faret\xE7i ${counter.current}`,
|
|
452
|
+
fields: [
|
|
453
|
+
{ label: "Enlem", value: lat.toFixed(5) },
|
|
454
|
+
{ label: "Boylam", value: lng.toFixed(5) }
|
|
455
|
+
]
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
]);
|
|
459
|
+
}, [onMarkerAdd]);
|
|
460
|
+
return { extras, handleMapClick };
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// modules/ui/MapView/index.tsx
|
|
464
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
465
|
+
function MapView({
|
|
466
|
+
provider = "leaflet",
|
|
467
|
+
center = [39.9334, 32.8597],
|
|
468
|
+
zoom = 6,
|
|
469
|
+
markers = [],
|
|
470
|
+
zones = [],
|
|
471
|
+
routes = [],
|
|
472
|
+
fitBoundsPadding,
|
|
473
|
+
onMarkerAdd,
|
|
474
|
+
onMarkerClick,
|
|
475
|
+
height = 480,
|
|
476
|
+
className
|
|
477
|
+
}) {
|
|
478
|
+
const { ref, visible } = useInViewport();
|
|
479
|
+
const [addMode, setAddMode] = useState5(false);
|
|
480
|
+
const [showZones, setShowZones] = useState5(true);
|
|
481
|
+
const [showRoutes, setShowRoutes] = useState5(true);
|
|
482
|
+
const { extras, handleMapClick } = useAutoMarkers(onMarkerAdd);
|
|
483
|
+
const onMapClick = useCallback2((lat, lng) => {
|
|
484
|
+
handleMapClick(lat, lng);
|
|
485
|
+
setAddMode(false);
|
|
486
|
+
}, [handleMapClick]);
|
|
487
|
+
if (provider !== "leaflet") {
|
|
488
|
+
throw new Error(`MapView provider "${provider}" is not yet implemented \u2014 TODO M1+`);
|
|
489
|
+
}
|
|
490
|
+
const cssHeight = typeof height === "number" ? `${height}px` : height;
|
|
491
|
+
return /* @__PURE__ */ jsx7(Card, { variant: "raised", className: cn("overflow-hidden", className), children: /* @__PURE__ */ jsxs6("div", { className: "-mx-6 -my-4 flex flex-col", ref, children: [
|
|
492
|
+
/* @__PURE__ */ jsx7("div", { className: "px-4 py-2.5 bg-surface-raised border-b border-border", children: /* @__PURE__ */ jsx7(
|
|
493
|
+
Toolbar,
|
|
494
|
+
{
|
|
495
|
+
addMode,
|
|
496
|
+
onToggleAddMode: () => setAddMode((v) => !v),
|
|
497
|
+
hasZones: zones.length > 0,
|
|
498
|
+
showZones,
|
|
499
|
+
onToggleZones: () => setShowZones((v) => !v),
|
|
500
|
+
hasRoutes: routes.length > 0,
|
|
501
|
+
showRoutes,
|
|
502
|
+
onToggleRoutes: () => setShowRoutes((v) => !v)
|
|
503
|
+
}
|
|
504
|
+
) }),
|
|
505
|
+
/* @__PURE__ */ jsx7("div", { style: { height: cssHeight, isolation: "isolate" }, children: !visible ? /* @__PURE__ */ jsx7("div", { className: "w-full h-full flex items-center justify-center bg-surface-raised", children: /* @__PURE__ */ jsx7("span", { className: "text-sm text-text-secondary", children: "Harita y\xFCkleniyor\u2026" }) }) : /* @__PURE__ */ jsx7(
|
|
506
|
+
LeafletCanvas,
|
|
507
|
+
{
|
|
508
|
+
center,
|
|
509
|
+
zoom,
|
|
510
|
+
markers: [...markers, ...extras],
|
|
511
|
+
zones,
|
|
512
|
+
routes,
|
|
513
|
+
showZones,
|
|
514
|
+
showRoutes,
|
|
515
|
+
addMode,
|
|
516
|
+
fitBoundsPadding,
|
|
517
|
+
onMapClick,
|
|
518
|
+
onMarkerClick
|
|
519
|
+
}
|
|
520
|
+
) })
|
|
521
|
+
] }) });
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
export {
|
|
525
|
+
Card,
|
|
526
|
+
MapView
|
|
527
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";
|