@object-ui/plugin-map 0.3.0

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/index.js ADDED
@@ -0,0 +1,461 @@
1
+ import ne, { useState as R, useEffect as G, useMemo as X } from "react";
2
+ import { ComponentRegistry as ae } from "@object-ui/core";
3
+ var S = { exports: {} }, N = {};
4
+ var B;
5
+ function oe() {
6
+ if (B) return N;
7
+ B = 1;
8
+ var t = /* @__PURE__ */ Symbol.for("react.transitional.element"), i = /* @__PURE__ */ Symbol.for("react.fragment");
9
+ function n(s, l, m) {
10
+ var h = null;
11
+ if (m !== void 0 && (h = "" + m), l.key !== void 0 && (h = "" + l.key), "key" in l) {
12
+ m = {};
13
+ for (var v in l)
14
+ v !== "key" && (m[v] = l[v]);
15
+ } else m = l;
16
+ return l = m.ref, {
17
+ $$typeof: t,
18
+ type: s,
19
+ key: h,
20
+ ref: l !== void 0 ? l : null,
21
+ props: m
22
+ };
23
+ }
24
+ return N.Fragment = i, N.jsx = n, N.jsxs = n, N;
25
+ }
26
+ var y = {};
27
+ var H;
28
+ function ie() {
29
+ return H || (H = 1, process.env.NODE_ENV !== "production" && (function() {
30
+ function t(e) {
31
+ if (e == null) return null;
32
+ if (typeof e == "function")
33
+ return e.$$typeof === ee ? null : e.displayName || e.name || null;
34
+ if (typeof e == "string") return e;
35
+ switch (e) {
36
+ case j:
37
+ return "Fragment";
38
+ case k:
39
+ return "Profiler";
40
+ case g:
41
+ return "StrictMode";
42
+ case M:
43
+ return "Suspense";
44
+ case C:
45
+ return "SuspenseList";
46
+ case K:
47
+ return "Activity";
48
+ }
49
+ if (typeof e == "object")
50
+ switch (typeof e.tag == "number" && console.error(
51
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
52
+ ), e.$$typeof) {
53
+ case b:
54
+ return "Portal";
55
+ case f:
56
+ return e.displayName || "Context";
57
+ case o:
58
+ return (e._context.displayName || "Context") + ".Consumer";
59
+ case x:
60
+ var r = e.render;
61
+ return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
62
+ case Z:
63
+ return r = e.displayName || null, r !== null ? r : t(e.type) || "Memo";
64
+ case L:
65
+ r = e._payload, e = e._init;
66
+ try {
67
+ return t(e(r));
68
+ } catch {
69
+ }
70
+ }
71
+ return null;
72
+ }
73
+ function i(e) {
74
+ return "" + e;
75
+ }
76
+ function n(e) {
77
+ try {
78
+ i(e);
79
+ var r = !1;
80
+ } catch {
81
+ r = !0;
82
+ }
83
+ if (r) {
84
+ r = console;
85
+ var c = r.error, u = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
86
+ return c.call(
87
+ r,
88
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
89
+ u
90
+ ), i(e);
91
+ }
92
+ }
93
+ function s(e) {
94
+ if (e === j) return "<>";
95
+ if (typeof e == "object" && e !== null && e.$$typeof === L)
96
+ return "<...>";
97
+ try {
98
+ var r = t(e);
99
+ return r ? "<" + r + ">" : "<...>";
100
+ } catch {
101
+ return "<...>";
102
+ }
103
+ }
104
+ function l() {
105
+ var e = D.A;
106
+ return e === null ? null : e.getOwner();
107
+ }
108
+ function m() {
109
+ return Error("react-stack-top-frame");
110
+ }
111
+ function h(e) {
112
+ if (W.call(e, "key")) {
113
+ var r = Object.getOwnPropertyDescriptor(e, "key").get;
114
+ if (r && r.isReactWarning) return !1;
115
+ }
116
+ return e.key !== void 0;
117
+ }
118
+ function v(e, r) {
119
+ function c() {
120
+ q || (q = !0, console.error(
121
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
122
+ r
123
+ ));
124
+ }
125
+ c.isReactWarning = !0, Object.defineProperty(e, "key", {
126
+ get: c,
127
+ configurable: !0
128
+ });
129
+ }
130
+ function T() {
131
+ var e = t(this.type);
132
+ return U[e] || (U[e] = !0, console.error(
133
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
134
+ )), e = this.props.ref, e !== void 0 ? e : null;
135
+ }
136
+ function F(e, r, c, u, A, Y) {
137
+ var d = c.ref;
138
+ return e = {
139
+ $$typeof: p,
140
+ type: e,
141
+ key: r,
142
+ props: c,
143
+ _owner: u
144
+ }, (d !== void 0 ? d : null) !== null ? Object.defineProperty(e, "ref", {
145
+ enumerable: !1,
146
+ get: T
147
+ }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
148
+ configurable: !1,
149
+ enumerable: !1,
150
+ writable: !0,
151
+ value: 0
152
+ }), Object.defineProperty(e, "_debugInfo", {
153
+ configurable: !1,
154
+ enumerable: !1,
155
+ writable: !0,
156
+ value: null
157
+ }), Object.defineProperty(e, "_debugStack", {
158
+ configurable: !1,
159
+ enumerable: !1,
160
+ writable: !0,
161
+ value: A
162
+ }), Object.defineProperty(e, "_debugTask", {
163
+ configurable: !1,
164
+ enumerable: !1,
165
+ writable: !0,
166
+ value: Y
167
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
168
+ }
169
+ function P(e, r, c, u, A, Y) {
170
+ var d = r.children;
171
+ if (d !== void 0)
172
+ if (u)
173
+ if (te(d)) {
174
+ for (u = 0; u < d.length; u++)
175
+ w(d[u]);
176
+ Object.freeze && Object.freeze(d);
177
+ } else
178
+ console.error(
179
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
180
+ );
181
+ else w(d);
182
+ if (W.call(r, "key")) {
183
+ d = t(e);
184
+ var _ = Object.keys(r).filter(function(re) {
185
+ return re !== "key";
186
+ });
187
+ u = 0 < _.length ? "{key: someKey, " + _.join(": ..., ") + ": ...}" : "{key: someKey}", J[d + u] || (_ = 0 < _.length ? "{" + _.join(": ..., ") + ": ...}" : "{}", console.error(
188
+ `A props object containing a "key" prop is being spread into JSX:
189
+ let props = %s;
190
+ <%s {...props} />
191
+ React keys must be passed directly to JSX without using spread:
192
+ let props = %s;
193
+ <%s key={someKey} {...props} />`,
194
+ u,
195
+ d,
196
+ _,
197
+ d
198
+ ), J[d + u] = !0);
199
+ }
200
+ if (d = null, c !== void 0 && (n(c), d = "" + c), h(r) && (n(r.key), d = "" + r.key), "key" in r) {
201
+ c = {};
202
+ for (var I in r)
203
+ I !== "key" && (c[I] = r[I]);
204
+ } else c = r;
205
+ return d && v(
206
+ c,
207
+ typeof e == "function" ? e.displayName || e.name || "Unknown" : e
208
+ ), F(
209
+ e,
210
+ d,
211
+ c,
212
+ l(),
213
+ A,
214
+ Y
215
+ );
216
+ }
217
+ function w(e) {
218
+ O(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === L && (e._payload.status === "fulfilled" ? O(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
219
+ }
220
+ function O(e) {
221
+ return typeof e == "object" && e !== null && e.$$typeof === p;
222
+ }
223
+ var E = ne, p = /* @__PURE__ */ Symbol.for("react.transitional.element"), b = /* @__PURE__ */ Symbol.for("react.portal"), j = /* @__PURE__ */ Symbol.for("react.fragment"), g = /* @__PURE__ */ Symbol.for("react.strict_mode"), k = /* @__PURE__ */ Symbol.for("react.profiler"), o = /* @__PURE__ */ Symbol.for("react.consumer"), f = /* @__PURE__ */ Symbol.for("react.context"), x = /* @__PURE__ */ Symbol.for("react.forward_ref"), M = /* @__PURE__ */ Symbol.for("react.suspense"), C = /* @__PURE__ */ Symbol.for("react.suspense_list"), Z = /* @__PURE__ */ Symbol.for("react.memo"), L = /* @__PURE__ */ Symbol.for("react.lazy"), K = /* @__PURE__ */ Symbol.for("react.activity"), ee = /* @__PURE__ */ Symbol.for("react.client.reference"), D = E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, W = Object.prototype.hasOwnProperty, te = Array.isArray, $ = console.createTask ? console.createTask : function() {
224
+ return null;
225
+ };
226
+ E = {
227
+ react_stack_bottom_frame: function(e) {
228
+ return e();
229
+ }
230
+ };
231
+ var q, U = {}, z = E.react_stack_bottom_frame.bind(
232
+ E,
233
+ m
234
+ )(), V = $(s(m)), J = {};
235
+ y.Fragment = j, y.jsx = function(e, r, c) {
236
+ var u = 1e4 > D.recentlyCreatedOwnerStacks++;
237
+ return P(
238
+ e,
239
+ r,
240
+ c,
241
+ !1,
242
+ u ? Error("react-stack-top-frame") : z,
243
+ u ? $(s(e)) : V
244
+ );
245
+ }, y.jsxs = function(e, r, c) {
246
+ var u = 1e4 > D.recentlyCreatedOwnerStacks++;
247
+ return P(
248
+ e,
249
+ r,
250
+ c,
251
+ !0,
252
+ u ? Error("react-stack-top-frame") : z,
253
+ u ? $(s(e)) : V
254
+ );
255
+ };
256
+ })()), y;
257
+ }
258
+ var Q;
259
+ function se() {
260
+ return Q || (Q = 1, process.env.NODE_ENV === "production" ? S.exports = oe() : S.exports = ie()), S.exports;
261
+ }
262
+ var a = se();
263
+ function le(t) {
264
+ return t.data ? t.data : t.staticData ? {
265
+ provider: "value",
266
+ items: t.staticData
267
+ } : t.objectName ? {
268
+ provider: "object",
269
+ object: t.objectName
270
+ } : null;
271
+ }
272
+ function ce(t) {
273
+ if (t) {
274
+ if (typeof t == "string") {
275
+ const i = t.split(" "), n = i[0], s = i[1]?.toLowerCase() === "desc" ? "desc" : "asc";
276
+ return { [n]: s };
277
+ }
278
+ if (Array.isArray(t))
279
+ return t.reduce((i, n) => (n.field && n.order && (i[n.field] = n.order), i), {});
280
+ }
281
+ }
282
+ function ue(t) {
283
+ return t.filter && typeof t.filter == "object" && "map" in t.filter ? t.filter.map : t.map ? t.map : {
284
+ latitudeField: "latitude",
285
+ longitudeField: "longitude",
286
+ locationField: "location",
287
+ titleField: "name",
288
+ descriptionField: "description",
289
+ zoom: 10,
290
+ center: [0, 0]
291
+ };
292
+ }
293
+ function de(t, i) {
294
+ if (i.latitudeField && i.longitudeField) {
295
+ const n = t[i.latitudeField], s = t[i.longitudeField];
296
+ if (typeof n == "number" && typeof s == "number")
297
+ return [n, s];
298
+ }
299
+ if (i.locationField) {
300
+ const n = t[i.locationField];
301
+ if (typeof n == "object" && n !== null) {
302
+ const s = n.lat || n.latitude, l = n.lng || n.lon || n.longitude;
303
+ if (typeof s == "number" && typeof l == "number")
304
+ return [s, l];
305
+ }
306
+ if (typeof n == "string") {
307
+ const s = n.split(",").map((l) => parseFloat(l.trim()));
308
+ if (s.length === 2 && !isNaN(s[0]) && !isNaN(s[1]))
309
+ return [s[0], s[1]];
310
+ }
311
+ if (Array.isArray(n) && n.length === 2) {
312
+ const s = parseFloat(n[0]), l = parseFloat(n[1]);
313
+ if (!isNaN(s) && !isNaN(l))
314
+ return [s, l];
315
+ }
316
+ }
317
+ return null;
318
+ }
319
+ const fe = ({
320
+ schema: t,
321
+ dataSource: i,
322
+ className: n,
323
+ onMarkerClick: s
324
+ }) => {
325
+ const [l, m] = R([]), [h, v] = R(!0), [T, F] = R(null), [P, w] = R(null), [O, E] = R(null), p = le(t), b = ue(t), j = p?.provider === "value";
326
+ G(() => {
327
+ (async () => {
328
+ try {
329
+ if (v(!0), j && p?.provider === "value") {
330
+ m(p.items), v(!1);
331
+ return;
332
+ }
333
+ if (!i)
334
+ throw new Error("DataSource required for object/api providers");
335
+ if (p?.provider === "object") {
336
+ const f = p.object, x = await i.find(f, {
337
+ $filter: t.filter,
338
+ $orderby: ce(t.sort)
339
+ });
340
+ m(x?.data || []);
341
+ } else p?.provider === "api" && (console.warn("API provider not yet implemented for ObjectMap"), m([]));
342
+ v(!1);
343
+ } catch (f) {
344
+ F(f), v(!1);
345
+ }
346
+ })();
347
+ }, [p, i, j, t.filter, t.sort]), G(() => {
348
+ !j && i && (async () => {
349
+ try {
350
+ if (!i) return;
351
+ const f = p?.provider === "object" ? p.object : t.objectName;
352
+ if (!f) return;
353
+ const x = await i.getObjectSchema(f);
354
+ w(x);
355
+ } catch (f) {
356
+ console.error("Failed to fetch object schema:", f);
357
+ }
358
+ })();
359
+ }, [t.objectName, i, j, p]);
360
+ const g = X(() => l.map((o, f) => {
361
+ const x = de(o, b);
362
+ if (!x) return null;
363
+ const M = b.titleField ? o[b.titleField] : "Marker", C = b.descriptionField ? o[b.descriptionField] : void 0;
364
+ return {
365
+ id: o.id || o._id || `marker-${f}`,
366
+ title: M,
367
+ description: C,
368
+ coordinates: x,
369
+ data: o
370
+ };
371
+ }).filter((o) => o !== null), [l, b]), k = X(() => {
372
+ if (!g.length)
373
+ return {
374
+ center: b.center || [0, 0],
375
+ minLat: (b.center?.[0] || 0) - 0.1,
376
+ maxLat: (b.center?.[0] || 0) + 0.1,
377
+ minLng: (b.center?.[1] || 0) - 0.1,
378
+ maxLng: (b.center?.[1] || 0) + 0.1
379
+ };
380
+ const o = g.map((x) => x.coordinates[0]), f = g.map((x) => x.coordinates[1]);
381
+ return {
382
+ center: [
383
+ (Math.min(...o) + Math.max(...o)) / 2,
384
+ (Math.min(...f) + Math.max(...f)) / 2
385
+ ],
386
+ minLat: Math.min(...o),
387
+ maxLat: Math.max(...o),
388
+ minLng: Math.min(...f),
389
+ maxLng: Math.max(...f)
390
+ };
391
+ }, [g, b.center]);
392
+ return h ? /* @__PURE__ */ a.jsx("div", { className: n, children: /* @__PURE__ */ a.jsx("div", { className: "flex items-center justify-center h-96 bg-muted rounded-lg", children: /* @__PURE__ */ a.jsx("div", { className: "text-muted-foreground", children: "Loading map..." }) }) }) : T ? /* @__PURE__ */ a.jsx("div", { className: n, children: /* @__PURE__ */ a.jsx("div", { className: "flex items-center justify-center h-96 bg-muted rounded-lg", children: /* @__PURE__ */ a.jsxs("div", { className: "text-destructive", children: [
393
+ "Error: ",
394
+ T.message
395
+ ] }) }) }) : /* @__PURE__ */ a.jsx("div", { className: n, children: /* @__PURE__ */ a.jsxs("div", { className: "relative border rounded-lg overflow-hidden bg-muted", style: { height: "600px" }, children: [
396
+ /* @__PURE__ */ a.jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-gradient-to-br from-blue-50 to-green-50 dark:from-blue-950 dark:to-green-950", children: /* @__PURE__ */ a.jsxs("div", { className: "text-center", children: [
397
+ /* @__PURE__ */ a.jsx("div", { className: "text-4xl mb-2", children: "🗺️" }),
398
+ /* @__PURE__ */ a.jsx("div", { className: "text-sm text-muted-foreground mb-4", children: "Map Visualization (Placeholder)" }),
399
+ /* @__PURE__ */ a.jsxs("div", { className: "text-xs text-muted-foreground max-w-md mx-auto", children: [
400
+ "This is a basic map placeholder. For production, integrate with Mapbox, Leaflet, or Google Maps.",
401
+ /* @__PURE__ */ a.jsx("br", {}),
402
+ /* @__PURE__ */ a.jsx("br", {}),
403
+ /* @__PURE__ */ a.jsx("strong", { children: "Map Info:" }),
404
+ /* @__PURE__ */ a.jsx("br", {}),
405
+ "Center: [",
406
+ k.center[0].toFixed(4),
407
+ ", ",
408
+ k.center[1].toFixed(4),
409
+ "]",
410
+ /* @__PURE__ */ a.jsx("br", {}),
411
+ "Markers: ",
412
+ g.length
413
+ ] })
414
+ ] }) }),
415
+ /* @__PURE__ */ a.jsxs("div", { className: "absolute top-4 right-4 w-64 bg-background border rounded-lg shadow-lg max-h-96 overflow-y-auto", children: [
416
+ /* @__PURE__ */ a.jsxs("div", { className: "p-3 border-b font-semibold bg-muted", children: [
417
+ "Locations (",
418
+ g.length,
419
+ ")"
420
+ ] }),
421
+ g.length === 0 ? /* @__PURE__ */ a.jsx("div", { className: "p-4 text-sm text-muted-foreground text-center", children: "No locations found with valid coordinates" }) : /* @__PURE__ */ a.jsx("div", { children: g.map((o) => /* @__PURE__ */ a.jsxs(
422
+ "div",
423
+ {
424
+ className: `p-3 border-b hover:bg-muted/50 cursor-pointer transition-colors ${O === o.id ? "bg-muted" : ""}`,
425
+ onClick: () => {
426
+ E(o.id), s?.(o.data);
427
+ },
428
+ children: [
429
+ /* @__PURE__ */ a.jsx("div", { className: "font-medium text-sm", children: o.title }),
430
+ o.description && /* @__PURE__ */ a.jsx("div", { className: "text-xs text-muted-foreground mt-1 line-clamp-2", children: o.description }),
431
+ /* @__PURE__ */ a.jsxs("div", { className: "text-xs text-muted-foreground mt-1", children: [
432
+ "📍 ",
433
+ o.coordinates[0].toFixed(4),
434
+ ", ",
435
+ o.coordinates[1].toFixed(4)
436
+ ] })
437
+ ]
438
+ },
439
+ o.id
440
+ )) })
441
+ ] }),
442
+ /* @__PURE__ */ a.jsxs("div", { className: "absolute bottom-4 left-4 bg-background border rounded-lg shadow-lg p-3", children: [
443
+ /* @__PURE__ */ a.jsx("div", { className: "text-xs font-semibold mb-2", children: "Legend" }),
444
+ /* @__PURE__ */ a.jsx("div", { className: "text-xs space-y-1", children: /* @__PURE__ */ a.jsxs("div", { className: "flex items-center gap-2", children: [
445
+ /* @__PURE__ */ a.jsx("div", { className: "w-3 h-3 rounded-full bg-blue-500" }),
446
+ /* @__PURE__ */ a.jsx("span", { children: "Location Marker" })
447
+ ] }) })
448
+ ] })
449
+ ] }) });
450
+ }, me = ({ schema: t }) => /* @__PURE__ */ a.jsx(fe, { schema: t, dataSource: null });
451
+ ae.register("object-map", me, {
452
+ label: "Object Map",
453
+ category: "plugin",
454
+ inputs: [
455
+ { name: "objectName", type: "string", label: "Object Name", required: !0 },
456
+ { name: "map", type: "object", label: "Map Config", description: "latitudeField, longitudeField, titleField" }
457
+ ]
458
+ });
459
+ export {
460
+ fe as ObjectMap
461
+ };
@@ -0,0 +1,6 @@
1
+ (function(h,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react"),require("@object-ui/core")):typeof define=="function"&&define.amd?define(["exports","react","@object-ui/core"],m):(h=typeof globalThis<"u"?globalThis:h||self,m(h.ObjectUIPluginMap={},h.React,h.ObjectUICore))})(this,(function(h,m,$){"use strict";var O={exports:{}},N={};var z;function K(){if(z)return N;z=1;var t=Symbol.for("react.transitional.element"),i=Symbol.for("react.fragment");function o(s,l,b){var _=null;if(b!==void 0&&(_=""+b),l.key!==void 0&&(_=""+l.key),"key"in l){b={};for(var j in l)j!=="key"&&(b[j]=l[j])}else b=l;return l=b.ref,{$$typeof:t,type:s,key:_,ref:l!==void 0?l:null,props:b}}return N.Fragment=i,N.jsx=o,N.jsxs=o,N}var T={};var V;function ee(){return V||(V=1,process.env.NODE_ENV!=="production"&&(function(){function t(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ce?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case E:return"Fragment";case A:return"Profiler";case g:return"StrictMode";case C:return"Suspense";case L:return"SuspenseList";case le:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case p:return"Portal";case f:return e.displayName||"Context";case a:return(e._context.displayName||"Context")+".Consumer";case v:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case se:return r=e.displayName||null,r!==null?r:t(e.type)||"Memo";case D:r=e._payload,e=e._init;try{return t(e(r))}catch{}}return null}function i(e){return""+e}function o(e){try{i(e);var r=!1}catch{r=!0}if(r){r=console;var c=r.error,u=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return c.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",u),i(e)}}function s(e){if(e===E)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===D)return"<...>";try{var r=t(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function l(){var e=I.A;return e===null?null:e.getOwner()}function b(){return Error("react-stack-top-frame")}function _(e){if(X.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function j(e,r){function c(){q||(q=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}c.isReactWarning=!0,Object.defineProperty(e,"key",{get:c,configurable:!0})}function w(){var e=t(this.type);return B[e]||(B[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function F(e,r,c,u,P,U){var d=c.ref;return e={$$typeof:x,type:e,key:r,props:c,_owner:u},(d!==void 0?d:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:w}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:P}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:U}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function M(e,r,c,u,P,U){var d=r.children;if(d!==void 0)if(u)if(ue(d)){for(u=0;u<d.length;u++)k(d[u]);Object.freeze&&Object.freeze(d)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else k(d);if(X.call(r,"key")){d=t(e);var y=Object.keys(r).filter(function(de){return de!=="key"});u=0<y.length?"{key: someKey, "+y.join(": ..., ")+": ...}":"{key: someKey}",Z[d+u]||(y=0<y.length?"{"+y.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
+ let props = %s;
3
+ <%s {...props} />
4
+ React keys must be passed directly to JSX without using spread:
5
+ let props = %s;
6
+ <%s key={someKey} {...props} />`,u,d,y,d),Z[d+u]=!0)}if(d=null,c!==void 0&&(o(c),d=""+c),_(r)&&(o(r.key),d=""+r.key),"key"in r){c={};for(var W in r)W!=="key"&&(c[W]=r[W])}else c=r;return d&&j(c,typeof e=="function"?e.displayName||e.name||"Unknown":e),F(e,d,c,l(),P,U)}function k(e){S(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===D&&(e._payload.status==="fulfilled"?S(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function S(e){return typeof e=="object"&&e!==null&&e.$$typeof===x}var R=m,x=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),g=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),f=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),L=Symbol.for("react.suspense_list"),se=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),le=Symbol.for("react.activity"),ce=Symbol.for("react.client.reference"),I=R.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X=Object.prototype.hasOwnProperty,ue=Array.isArray,Y=console.createTask?console.createTask:function(){return null};R={react_stack_bottom_frame:function(e){return e()}};var q,B={},H=R.react_stack_bottom_frame.bind(R,b)(),Q=Y(s(b)),Z={};T.Fragment=E,T.jsx=function(e,r,c){var u=1e4>I.recentlyCreatedOwnerStacks++;return M(e,r,c,!1,u?Error("react-stack-top-frame"):H,u?Y(s(e)):Q)},T.jsxs=function(e,r,c){var u=1e4>I.recentlyCreatedOwnerStacks++;return M(e,r,c,!0,u?Error("react-stack-top-frame"):H,u?Y(s(e)):Q)}})()),T}var J;function te(){return J||(J=1,process.env.NODE_ENV==="production"?O.exports=K():O.exports=ee()),O.exports}var n=te();function re(t){return t.data?t.data:t.staticData?{provider:"value",items:t.staticData}:t.objectName?{provider:"object",object:t.objectName}:null}function ne(t){if(t){if(typeof t=="string"){const i=t.split(" "),o=i[0],s=i[1]?.toLowerCase()==="desc"?"desc":"asc";return{[o]:s}}if(Array.isArray(t))return t.reduce((i,o)=>(o.field&&o.order&&(i[o.field]=o.order),i),{})}}function oe(t){return t.filter&&typeof t.filter=="object"&&"map"in t.filter?t.filter.map:t.map?t.map:{latitudeField:"latitude",longitudeField:"longitude",locationField:"location",titleField:"name",descriptionField:"description",zoom:10,center:[0,0]}}function ae(t,i){if(i.latitudeField&&i.longitudeField){const o=t[i.latitudeField],s=t[i.longitudeField];if(typeof o=="number"&&typeof s=="number")return[o,s]}if(i.locationField){const o=t[i.locationField];if(typeof o=="object"&&o!==null){const s=o.lat||o.latitude,l=o.lng||o.lon||o.longitude;if(typeof s=="number"&&typeof l=="number")return[s,l]}if(typeof o=="string"){const s=o.split(",").map(l=>parseFloat(l.trim()));if(s.length===2&&!isNaN(s[0])&&!isNaN(s[1]))return[s[0],s[1]]}if(Array.isArray(o)&&o.length===2){const s=parseFloat(o[0]),l=parseFloat(o[1]);if(!isNaN(s)&&!isNaN(l))return[s,l]}}return null}const G=({schema:t,dataSource:i,className:o,onMarkerClick:s})=>{const[l,b]=m.useState([]),[_,j]=m.useState(!0),[w,F]=m.useState(null),[M,k]=m.useState(null),[S,R]=m.useState(null),x=re(t),p=oe(t),E=x?.provider==="value";m.useEffect(()=>{(async()=>{try{if(j(!0),E&&x?.provider==="value"){b(x.items),j(!1);return}if(!i)throw new Error("DataSource required for object/api providers");if(x?.provider==="object"){const f=x.object,v=await i.find(f,{$filter:t.filter,$orderby:ne(t.sort)});b(v?.data||[])}else x?.provider==="api"&&(console.warn("API provider not yet implemented for ObjectMap"),b([]));j(!1)}catch(f){F(f),j(!1)}})()},[x,i,E,t.filter,t.sort]),m.useEffect(()=>{!E&&i&&(async()=>{try{if(!i)return;const f=x?.provider==="object"?x.object:t.objectName;if(!f)return;const v=await i.getObjectSchema(f);k(v)}catch(f){console.error("Failed to fetch object schema:",f)}})()},[t.objectName,i,E,x]);const g=m.useMemo(()=>l.map((a,f)=>{const v=ae(a,p);if(!v)return null;const C=p.titleField?a[p.titleField]:"Marker",L=p.descriptionField?a[p.descriptionField]:void 0;return{id:a.id||a._id||`marker-${f}`,title:C,description:L,coordinates:v,data:a}}).filter(a=>a!==null),[l,p]),A=m.useMemo(()=>{if(!g.length)return{center:p.center||[0,0],minLat:(p.center?.[0]||0)-.1,maxLat:(p.center?.[0]||0)+.1,minLng:(p.center?.[1]||0)-.1,maxLng:(p.center?.[1]||0)+.1};const a=g.map(v=>v.coordinates[0]),f=g.map(v=>v.coordinates[1]);return{center:[(Math.min(...a)+Math.max(...a))/2,(Math.min(...f)+Math.max(...f))/2],minLat:Math.min(...a),maxLat:Math.max(...a),minLng:Math.min(...f),maxLng:Math.max(...f)}},[g,p.center]);return _?n.jsx("div",{className:o,children:n.jsx("div",{className:"flex items-center justify-center h-96 bg-muted rounded-lg",children:n.jsx("div",{className:"text-muted-foreground",children:"Loading map..."})})}):w?n.jsx("div",{className:o,children:n.jsx("div",{className:"flex items-center justify-center h-96 bg-muted rounded-lg",children:n.jsxs("div",{className:"text-destructive",children:["Error: ",w.message]})})}):n.jsx("div",{className:o,children:n.jsxs("div",{className:"relative border rounded-lg overflow-hidden bg-muted",style:{height:"600px"},children:[n.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gradient-to-br from-blue-50 to-green-50 dark:from-blue-950 dark:to-green-950",children:n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"text-4xl mb-2",children:"🗺️"}),n.jsx("div",{className:"text-sm text-muted-foreground mb-4",children:"Map Visualization (Placeholder)"}),n.jsxs("div",{className:"text-xs text-muted-foreground max-w-md mx-auto",children:["This is a basic map placeholder. For production, integrate with Mapbox, Leaflet, or Google Maps.",n.jsx("br",{}),n.jsx("br",{}),n.jsx("strong",{children:"Map Info:"}),n.jsx("br",{}),"Center: [",A.center[0].toFixed(4),", ",A.center[1].toFixed(4),"]",n.jsx("br",{}),"Markers: ",g.length]})]})}),n.jsxs("div",{className:"absolute top-4 right-4 w-64 bg-background border rounded-lg shadow-lg max-h-96 overflow-y-auto",children:[n.jsxs("div",{className:"p-3 border-b font-semibold bg-muted",children:["Locations (",g.length,")"]}),g.length===0?n.jsx("div",{className:"p-4 text-sm text-muted-foreground text-center",children:"No locations found with valid coordinates"}):n.jsx("div",{children:g.map(a=>n.jsxs("div",{className:`p-3 border-b hover:bg-muted/50 cursor-pointer transition-colors ${S===a.id?"bg-muted":""}`,onClick:()=>{R(a.id),s?.(a.data)},children:[n.jsx("div",{className:"font-medium text-sm",children:a.title}),a.description&&n.jsx("div",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:a.description}),n.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["📍 ",a.coordinates[0].toFixed(4),", ",a.coordinates[1].toFixed(4)]})]},a.id))})]}),n.jsxs("div",{className:"absolute bottom-4 left-4 bg-background border rounded-lg shadow-lg p-3",children:[n.jsx("div",{className:"text-xs font-semibold mb-2",children:"Legend"}),n.jsx("div",{className:"text-xs space-y-1",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-3 h-3 rounded-full bg-blue-500"}),n.jsx("span",{children:"Location Marker"})]})})]})]})})},ie=({schema:t})=>n.jsx(G,{schema:t,dataSource:null});$.ComponentRegistry.register("object-map",ie,{label:"Object Map",category:"plugin",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"map",type:"object",label:"Map Config",description:"latitudeField, longitudeField, titleField"}]}),h.ObjectMap=G,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1,12 @@
1
+ import { default as React } from 'react';
2
+ import { ObjectGridSchema, DataSource } from '@object-ui/types';
3
+ export interface ObjectMapProps {
4
+ schema: ObjectGridSchema;
5
+ dataSource?: DataSource;
6
+ className?: string;
7
+ onMarkerClick?: (record: any) => void;
8
+ onEdit?: (record: any) => void;
9
+ onDelete?: (record: any) => void;
10
+ }
11
+ export declare const ObjectMap: React.FC<ObjectMapProps>;
12
+ //# sourceMappingURL=ObjectMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObjectMap.d.ts","sourceRoot":"","sources":["../../src/ObjectMap.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAuC,MAAM,OAAO,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAY,MAAM,kBAAkB,CAAC;AAE/E,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,gBAAgB,CAAC;IACzB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACtC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;CAClC;AAgJD,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA2N9C,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { ObjectMap, ObjectMapProps } from './ObjectMap';
2
+ export { ObjectMap };
3
+ export type { ObjectMapProps };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,CAAC;AACrB,YAAY,EAAE,cAAc,EAAE,CAAC"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@object-ui/plugin-map",
3
+ "version": "0.3.0",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "description": "Map visualization plugin for Object UI",
7
+ "homepage": "https://www.objectui.org",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/objectstack-ai/objectui.git",
11
+ "directory": "packages/plugin-map"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/objectstack-ai/objectui/issues"
15
+ },
16
+ "main": "dist/index.umd.cjs",
17
+ "module": "dist/index.js",
18
+ "types": "dist/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "import": "./dist/index.js",
23
+ "require": "./dist/index.umd.cjs"
24
+ }
25
+ },
26
+ "dependencies": {
27
+ "lucide-react": "^0.563.0",
28
+ "@object-ui/components": "0.3.0",
29
+ "@object-ui/react": "0.3.0",
30
+ "@object-ui/types": "0.3.0",
31
+ "@object-ui/core": "0.3.0"
32
+ },
33
+ "peerDependencies": {
34
+ "react": "^18.0.0 || ^19.0.0",
35
+ "react-dom": "^18.0.0 || ^19.0.0"
36
+ },
37
+ "devDependencies": {
38
+ "@types/react": "^19.2.9",
39
+ "@types/react-dom": "^19.2.3",
40
+ "@vitejs/plugin-react": "^4.2.1",
41
+ "typescript": "^5.9.3",
42
+ "vite": "^7.3.1",
43
+ "vite-plugin-dts": "^4.5.4"
44
+ },
45
+ "scripts": {
46
+ "build": "vite build",
47
+ "test": "vitest run",
48
+ "test:watch": "vitest",
49
+ "type-check": "tsc --noEmit",
50
+ "lint": "eslint ."
51
+ }
52
+ }