@constructive-io/sheets 0.13.1 → 0.15.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/README.md +231 -148
- package/dist/advanced.cjs +7220 -4030
- package/dist/advanced.cjs.map +1 -1
- package/dist/advanced.d.cts +2 -2
- package/dist/advanced.d.ts +2 -2
- package/dist/advanced.js +5 -5
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.js +3 -3
- package/dist/chunk-CJ4PRA64.js +312 -0
- package/dist/chunk-CJ4PRA64.js.map +1 -0
- package/dist/chunk-II3MSNRO.js +18 -0
- package/dist/chunk-II3MSNRO.js.map +1 -0
- package/dist/{chunk-MXVNIKES.js → chunk-J7KK4UWI.js} +6 -6
- package/dist/chunk-MBSHDF55.js +839 -0
- package/dist/chunk-MBSHDF55.js.map +1 -0
- package/dist/{chunk-ZKANUG3F.js → chunk-MOFFS5WQ.js} +20 -15
- package/dist/chunk-MOFFS5WQ.js.map +1 -0
- package/dist/chunk-VCBY2AMT.js +8920 -0
- package/dist/chunk-VCBY2AMT.js.map +1 -0
- package/dist/{chunk-H5HR5HUJ.js → chunk-ZOQDSOMO.js} +50 -312
- package/dist/chunk-ZOQDSOMO.js.map +1 -0
- package/dist/date-editor-ORCB43ZM.js +346 -0
- package/dist/date-editor-ORCB43ZM.js.map +1 -0
- package/dist/grid-cell-types-YNIVK4hN.d.cts +346 -0
- package/dist/grid-cell-types-YNIVK4hN.d.ts +346 -0
- package/dist/index.cjs +22910 -12084
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1497 -337
- package/dist/index.d.ts +1497 -337
- package/dist/index.js +12833 -6142
- package/dist/index.js.map +1 -1
- package/dist/sheets-context-Bb7ZoNBg.d.cts +436 -0
- package/dist/sheets-context-CPuf31LS.d.ts +436 -0
- package/dist/testing.cjs +1253 -638
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +80 -11
- package/dist/testing.d.ts +80 -11
- package/dist/testing.js +791 -148
- package/dist/testing.js.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-4EZ6A23C.js +0 -44
- package/dist/chunk-4EZ6A23C.js.map +0 -1
- package/dist/chunk-5QPNOKMA.js +0 -4397
- package/dist/chunk-5QPNOKMA.js.map +0 -1
- package/dist/chunk-AYMXT3ME.js +0 -540
- package/dist/chunk-AYMXT3ME.js.map +0 -1
- package/dist/chunk-H5HR5HUJ.js.map +0 -1
- package/dist/chunk-PZL2BCWF.js +0 -168
- package/dist/chunk-PZL2BCWF.js.map +0 -1
- package/dist/chunk-X7DHTSOX.js +0 -21
- package/dist/chunk-X7DHTSOX.js.map +0 -1
- package/dist/chunk-ZKANUG3F.js.map +0 -1
- package/dist/date-editor-ZFNDKYBD.js +0 -358
- package/dist/date-editor-ZFNDKYBD.js.map +0 -1
- package/dist/grid-cell-types-Pbe2m2tE.d.cts +0 -253
- package/dist/grid-cell-types-Pbe2m2tE.d.ts +0 -253
- package/dist/map-picker-ZUGGOIZS.js +0 -290
- package/dist/map-picker-ZUGGOIZS.js.map +0 -1
- package/dist/sheets-context-CY1RmDKL.d.cts +0 -244
- package/dist/sheets-context-Cu3Ec_ca.d.ts +0 -244
- /package/dist/{chunk-MXVNIKES.js.map → chunk-J7KK4UWI.js.map} +0 -0
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import { ComponentType } from 'react';
|
|
2
|
-
import { MetaQuery } from '@constructive-io/data';
|
|
3
|
-
|
|
4
|
-
interface FieldMetadata$1 {
|
|
5
|
-
name: string;
|
|
6
|
-
type?: {
|
|
7
|
-
gqlType: string;
|
|
8
|
-
pgType?: string | null;
|
|
9
|
-
pgAlias?: string | null;
|
|
10
|
-
isArray?: boolean;
|
|
11
|
-
subtype?: string | null;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
interface CellTypeResolution {
|
|
15
|
-
cellType: string;
|
|
16
|
-
canEdit: boolean;
|
|
17
|
-
canActivate: boolean;
|
|
18
|
-
activationBehavior: 'single-click' | 'double-click';
|
|
19
|
-
isReadonly: boolean;
|
|
20
|
-
}
|
|
21
|
-
declare function resolveCellType(fieldName: string, fieldMeta?: FieldMetadata$1): CellTypeResolution;
|
|
22
|
-
declare function isImageField(fieldMeta?: FieldMetadata$1, fieldName?: string): boolean;
|
|
23
|
-
|
|
24
|
-
type CellType = 'text' | 'textarea' | 'email' | 'url' | 'phone' | 'citext' | 'bpchar' | 'number' | 'integer' | 'smallint' | 'decimal' | 'currency' | 'percentage' | 'date' | 'datetime' | 'time' | 'timestamptz' | 'interval' | 'boolean' | 'toggle' | 'bit' | 'json' | 'jsonb' | 'array' | 'text-array' | 'uuid-array' | 'number-array' | 'integer-array' | 'date-array' | 'geometry' | 'geometry-point' | 'geometry-collection' | 'inet' | 'image' | 'file' | 'video' | 'audio' | 'upload' | 'uuid' | 'color' | 'rating' | 'tags' | 'tsvector' | 'origin' | 'relation' | 'unknown';
|
|
25
|
-
type CellCategory = 'text' | 'numeric' | 'date' | 'boolean' | 'structured' | 'geometric' | 'network' | 'media' | 'special' | 'other';
|
|
26
|
-
type CellValue = string | number | boolean | Date | null | undefined | Array<any> | Record<string, any>;
|
|
27
|
-
interface FieldMetadata {
|
|
28
|
-
name: string;
|
|
29
|
-
gqlType: string;
|
|
30
|
-
isArray: boolean;
|
|
31
|
-
modifier?: string | number | null;
|
|
32
|
-
pgAlias?: string | null;
|
|
33
|
-
pgType?: string | null;
|
|
34
|
-
subtype?: string | null;
|
|
35
|
-
typmod?: number | null;
|
|
36
|
-
encoding?: {
|
|
37
|
-
kind: string;
|
|
38
|
-
elementType?: string | null;
|
|
39
|
-
dimensions?: number | null;
|
|
40
|
-
geometrySubtype?: string | null;
|
|
41
|
-
srid?: number | null;
|
|
42
|
-
dotPath?: boolean | null;
|
|
43
|
-
} | null;
|
|
44
|
-
}
|
|
45
|
-
interface ColumnSchema {
|
|
46
|
-
id: string;
|
|
47
|
-
name: string;
|
|
48
|
-
type: CellType;
|
|
49
|
-
nullable: boolean;
|
|
50
|
-
metadata?: {
|
|
51
|
-
label?: string;
|
|
52
|
-
description?: string;
|
|
53
|
-
hidden?: boolean;
|
|
54
|
-
readonly?: boolean;
|
|
55
|
-
sortable?: boolean;
|
|
56
|
-
filterable?: boolean;
|
|
57
|
-
isArray?: boolean;
|
|
58
|
-
placeholder?: string;
|
|
59
|
-
maxLength?: number;
|
|
60
|
-
minLength?: number;
|
|
61
|
-
pattern?: string;
|
|
62
|
-
rows?: number;
|
|
63
|
-
required?: boolean;
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
interface TableSchema {
|
|
67
|
-
id: string;
|
|
68
|
-
name: string;
|
|
69
|
-
columns: ColumnSchema[];
|
|
70
|
-
metadata?: {
|
|
71
|
-
label?: string;
|
|
72
|
-
description?: string;
|
|
73
|
-
primaryKey?: string[];
|
|
74
|
-
indexes?: Array<{
|
|
75
|
-
columns: string[];
|
|
76
|
-
unique?: boolean;
|
|
77
|
-
}>;
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
interface RowData {
|
|
81
|
-
id: string;
|
|
82
|
-
[columnId: string]: CellValue;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* @deprecated since 0.2.0 — use CellTypeDefinition (defineCellType). This React-component model was never rendered by the canvas grid.
|
|
87
|
-
*/
|
|
88
|
-
interface BaseCellProps {
|
|
89
|
-
value: CellValue;
|
|
90
|
-
column: ColumnSchema;
|
|
91
|
-
rowId: string;
|
|
92
|
-
isEditing?: boolean;
|
|
93
|
-
onChange?: (value: CellValue) => void;
|
|
94
|
-
onStartEdit?: () => void;
|
|
95
|
-
onSave?: () => void;
|
|
96
|
-
onCancel?: () => void;
|
|
97
|
-
className?: string;
|
|
98
|
-
disabled?: boolean;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* @deprecated since 0.2.0 — use CellTypeDefinition (defineCellType). This React-component model was never rendered by the canvas grid.
|
|
102
|
-
*/
|
|
103
|
-
type CellRenderer = ComponentType<BaseCellProps>;
|
|
104
|
-
/**
|
|
105
|
-
* @deprecated since 0.2.0 — use CellTypeDefinition (defineCellType). This React-component model was never rendered by the canvas grid.
|
|
106
|
-
*/
|
|
107
|
-
interface CellRegistryEntry {
|
|
108
|
-
type: CellType;
|
|
109
|
-
component: CellRenderer;
|
|
110
|
-
editComponent?: CellRenderer;
|
|
111
|
-
validator?: (value: CellValue) => boolean;
|
|
112
|
-
formatter?: (value: CellValue) => string;
|
|
113
|
-
parser?: (input: string) => CellValue;
|
|
114
|
-
defaultValue?: () => CellValue;
|
|
115
|
-
match?: (metadata: {
|
|
116
|
-
gqlType: string;
|
|
117
|
-
isArray: boolean;
|
|
118
|
-
pgAlias?: string | null;
|
|
119
|
-
pgType?: string | null;
|
|
120
|
-
subtype?: string | null;
|
|
121
|
-
fieldName?: string;
|
|
122
|
-
value?: any;
|
|
123
|
-
}) => boolean;
|
|
124
|
-
metadata?: {
|
|
125
|
-
name: string;
|
|
126
|
-
description: string;
|
|
127
|
-
category: CellCategory;
|
|
128
|
-
supportsInlineEdit?: boolean;
|
|
129
|
-
supportsSort?: boolean;
|
|
130
|
-
supportsFilter?: boolean;
|
|
131
|
-
width?: number;
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* @deprecated since 0.2.0 — use CellTypeDefinition (defineCellType). This React-component model was never rendered by the canvas grid.
|
|
136
|
-
*/
|
|
137
|
-
interface CellPlugin {
|
|
138
|
-
name: string;
|
|
139
|
-
version: string;
|
|
140
|
-
cells: CellRegistryEntry[];
|
|
141
|
-
install?: () => void;
|
|
142
|
-
uninstall?: () => void;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Neutral render kinds. `loading` and `draft-action` originate from grid-internal
|
|
147
|
-
* state, not the `CellType` system.
|
|
148
|
-
*/
|
|
149
|
-
type SheetsCellKind = 'text' | 'number' | 'boolean' | 'badges' | 'uri' | 'image' | 'geometry' | 'relation' | 'loading' | 'draft-action' | 'custom';
|
|
150
|
-
/** Per-cell visual hint, open-ish so later phases can enrich it. */
|
|
151
|
-
interface SheetsCellStyleHint {
|
|
152
|
-
draft?: boolean;
|
|
153
|
-
faded?: boolean;
|
|
154
|
-
/** This draft cell has a field-level validation error (draftMeta.errors[colKey]). */
|
|
155
|
-
error?: boolean;
|
|
156
|
-
[extra: string]: unknown;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* The factory output + render payload. A SINGLE interface with a `kind` field
|
|
160
|
-
* (not a per-kind discriminated union): text/number/boolean share this payload
|
|
161
|
-
* and do not diverge yet.
|
|
162
|
-
*
|
|
163
|
-
* TODO(phases 2+): enrich `meta` per kind (badges/uri/image/geometry/relation)
|
|
164
|
-
* once their factories and views are ported.
|
|
165
|
-
*/
|
|
166
|
-
interface SheetsCell {
|
|
167
|
-
kind: SheetsCellKind;
|
|
168
|
-
data: unknown;
|
|
169
|
-
displayData: string;
|
|
170
|
-
readonly: boolean;
|
|
171
|
-
styleHint?: SheetsCellStyleHint;
|
|
172
|
-
meta?: {
|
|
173
|
-
cellType?: CellType;
|
|
174
|
-
[extra: string]: unknown;
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
type RelationKind = 'belongsTo' | 'hasOne' | 'hasMany' | 'manyToMany';
|
|
179
|
-
interface RelationInfo {
|
|
180
|
-
kind: RelationKind;
|
|
181
|
-
relatedTable?: string;
|
|
182
|
-
displayCandidates: string[];
|
|
183
|
-
relationField?: string;
|
|
184
|
-
foreignKeyField?: string;
|
|
185
|
-
junctionTable?: string;
|
|
186
|
-
junctionLeftKeyField?: string;
|
|
187
|
-
junctionRightKeyField?: string;
|
|
188
|
-
displayName?: string;
|
|
189
|
-
}
|
|
190
|
-
interface RelationInfoSlice {
|
|
191
|
-
relationInfoCache: Record<string, Record<string, RelationInfo>>;
|
|
192
|
-
relationInfoMapCache: Record<string, Map<string, RelationInfo>>;
|
|
193
|
-
setRelationInfoForTable: (tableName: string, info: Record<string, RelationInfo>) => void;
|
|
194
|
-
getRelationInfoForTable: (tableName: string) => Record<string, RelationInfo> | undefined;
|
|
195
|
-
getRelationInfoMapForTable: (tableName: string) => Map<string, RelationInfo> | undefined;
|
|
196
|
-
rebuildRelationInfo: (tableName: string, meta: MetaQuery | undefined) => void;
|
|
197
|
-
ensureRelationInfo: (tableName: string, meta: MetaQuery | undefined) => Record<string, RelationInfo>;
|
|
198
|
-
clearRelationInfoCache: () => void;
|
|
199
|
-
}
|
|
200
|
-
declare function buildRelationInfoFromMeta(tableName: string, meta: MetaQuery | undefined): Record<string, RelationInfo> | null;
|
|
201
|
-
|
|
202
|
-
interface EditorProps {
|
|
203
|
-
value: unknown;
|
|
204
|
-
cell: SheetsCell;
|
|
205
|
-
colKey: string;
|
|
206
|
-
rowId: string;
|
|
207
|
-
rowIndex: number;
|
|
208
|
-
tableName?: string;
|
|
209
|
-
fieldMeta?: FieldMetadata$1;
|
|
210
|
-
relationInfo?: RelationInfo;
|
|
211
|
-
/**
|
|
212
|
-
* Type-to-edit seed: when the overlay was opened by typing a printable char on the
|
|
213
|
-
* active cell, this carries that char. Value editors (text/number) initialize their
|
|
214
|
-
* input to it in OVERWRITE mode (replacing the cell value); other editors ignore it.
|
|
215
|
-
*/
|
|
216
|
-
initialText?: string;
|
|
217
|
-
/** Commit a value down the glide value-commit path (onCellEdited -> editCell). */
|
|
218
|
-
onCommit: (next: unknown) => void;
|
|
219
|
-
/**
|
|
220
|
-
* Self-committing editors (relation/image): commit a MULTI-field patch after an
|
|
221
|
-
* out-of-band server mutation, routed through the existing optimistic-update path
|
|
222
|
-
* (handleEditorSaveComplete). Value editors use {@link onCommit} instead.
|
|
223
|
-
*/
|
|
224
|
-
onCommitPatch?: (patch: Record<string, unknown>) => void;
|
|
225
|
-
/** Dismiss the overlay with no write. */
|
|
226
|
-
onCancel: () => void;
|
|
227
|
-
/** Self-committing editors: submit a client-side draft row, resolving to the server row. */
|
|
228
|
-
onSubmitDraftRow?: (draftRowId: string) => Promise<unknown>;
|
|
229
|
-
/** Self-committing editors: invalidate cached data after an out-of-band mutation. */
|
|
230
|
-
onInvalidateData?: () => void;
|
|
231
|
-
/** Geometry pre-computed by the OverlayManager (reused `computeOverlayGeometry`). */
|
|
232
|
-
overlay: {
|
|
233
|
-
maxHeight: number;
|
|
234
|
-
flipped: boolean;
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
interface RelationCellOptions {
|
|
239
|
-
relationChipLimit?: number;
|
|
240
|
-
relationLabelMaxLength?: number;
|
|
241
|
-
}
|
|
242
|
-
interface CellCreationMetadata {
|
|
243
|
-
cellType: string;
|
|
244
|
-
fieldName: string;
|
|
245
|
-
fieldMeta?: FieldMetadata$1;
|
|
246
|
-
relationInfo?: RelationInfo;
|
|
247
|
-
relationOptions?: RelationCellOptions;
|
|
248
|
-
canEdit: boolean;
|
|
249
|
-
isReadonly: boolean;
|
|
250
|
-
activationBehavior: 'single-click' | 'double-click';
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
export { type BaseCellProps as B, type CellCreationMetadata as C, type EditorProps as E, type FieldMetadata$1 as F, type RelationInfo as R, type SheetsCell as S, type TableSchema as T, type SheetsCellKind as a, type CellType as b, type CellCategory as c, type RelationInfoSlice as d, type CellRegistryEntry as e, type CellRenderer as f, type CellPlugin as g, type ColumnSchema as h, type CellValue as i, type FieldMetadata as j, type RelationKind as k, type RowData as l, buildRelationInfoFromMeta as m, isImageField as n, resolveCellType as r };
|
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use client";
|
|
3
|
-
import {
|
|
4
|
-
cn
|
|
5
|
-
} from "./chunk-YDQQA46V.js";
|
|
6
|
-
import {
|
|
7
|
-
sheetsLogger
|
|
8
|
-
} from "./chunk-X7DHTSOX.js";
|
|
9
|
-
|
|
10
|
-
// src/utils/map-picker.tsx
|
|
11
|
-
import React, { lazy, Suspense, useCallback, useEffect, useRef, useState } from "react";
|
|
12
|
-
import { MapPinIcon, SearchIcon, XIcon, Loader2 } from "lucide-react";
|
|
13
|
-
import { Button } from "@constructive-io/ui/button";
|
|
14
|
-
import { Card, CardContent } from "@constructive-io/ui/card";
|
|
15
|
-
import { InputGroup, InputGroupAddon, InputGroupInput } from "@constructive-io/ui/input-group";
|
|
16
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
17
|
-
var createMapValue = (lat, lng) => ({
|
|
18
|
-
geojson: {
|
|
19
|
-
type: "Point",
|
|
20
|
-
coordinates: [lng, lat]
|
|
21
|
-
},
|
|
22
|
-
srid: 4326,
|
|
23
|
-
x: lng,
|
|
24
|
-
y: lat
|
|
25
|
-
});
|
|
26
|
-
var extractPosition = (value) => {
|
|
27
|
-
if (!value) return null;
|
|
28
|
-
let coordinates;
|
|
29
|
-
if (value.type === "Point" && Array.isArray(value.coordinates)) {
|
|
30
|
-
coordinates = value.coordinates;
|
|
31
|
-
} else if (value.geojson?.type === "Point" && Array.isArray(value.geojson.coordinates)) {
|
|
32
|
-
coordinates = value.geojson.coordinates;
|
|
33
|
-
}
|
|
34
|
-
if (!coordinates || coordinates.length < 2) return null;
|
|
35
|
-
const [lng, lat] = coordinates;
|
|
36
|
-
if (typeof lng !== "number" || typeof lat !== "number") return null;
|
|
37
|
-
if (!isFinite(lng) || !isFinite(lat)) return null;
|
|
38
|
-
return [lat, lng];
|
|
39
|
-
};
|
|
40
|
-
var searchLocation = async (query) => {
|
|
41
|
-
if (!query.trim()) return [];
|
|
42
|
-
try {
|
|
43
|
-
const response = await fetch(
|
|
44
|
-
`https://nominatim.openstreetmap.org/search?format=json&q=${encodeURIComponent(query)}&limit=5&addressdetails=1`
|
|
45
|
-
);
|
|
46
|
-
const results = await response.json();
|
|
47
|
-
return results || [];
|
|
48
|
-
} catch (error) {
|
|
49
|
-
sheetsLogger().error("Search error:", error);
|
|
50
|
-
return [];
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
var LeafletMapInner = lazy(
|
|
54
|
-
() => Promise.all([import("react-leaflet"), import("leaflet")]).then(([reactLeaflet, L]) => {
|
|
55
|
-
const { MapContainer, TileLayer, Marker, useMapEvents, useMap } = reactLeaflet;
|
|
56
|
-
const createCustomIcon = (color = "#3b82f6") => {
|
|
57
|
-
return L.divIcon({
|
|
58
|
-
html: `
|
|
59
|
-
<div style="
|
|
60
|
-
width: 32px;
|
|
61
|
-
height: 32px;
|
|
62
|
-
display: flex;
|
|
63
|
-
align-items: center;
|
|
64
|
-
justify-content: center;
|
|
65
|
-
background: ${color};
|
|
66
|
-
border: 3px solid white;
|
|
67
|
-
border-radius: 50% 50% 50% 0;
|
|
68
|
-
transform: rotate(-45deg);
|
|
69
|
-
box-shadow: 0 2px 8px rgba(0,0,0,0.3);
|
|
70
|
-
">
|
|
71
|
-
<svg width="16" height="16" viewBox="0 0 24 24" fill="white" style="transform: rotate(45deg);">
|
|
72
|
-
<path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"/>
|
|
73
|
-
</svg>
|
|
74
|
-
</div>
|
|
75
|
-
`,
|
|
76
|
-
className: "custom-marker",
|
|
77
|
-
iconSize: [32, 32],
|
|
78
|
-
iconAnchor: [16, 32],
|
|
79
|
-
popupAnchor: [0, -32]
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
function MapEventHandler({
|
|
83
|
-
onMapClick,
|
|
84
|
-
position
|
|
85
|
-
}) {
|
|
86
|
-
const map = useMap();
|
|
87
|
-
useMapEvents({
|
|
88
|
-
click(e) {
|
|
89
|
-
onMapClick(e.latlng.lat, e.latlng.lng);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
React.useEffect(() => {
|
|
93
|
-
if (position && map) {
|
|
94
|
-
map.setView(position, 15);
|
|
95
|
-
}
|
|
96
|
-
}, [position, map]);
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
function LeafletMap({
|
|
100
|
-
position,
|
|
101
|
-
onMapClick,
|
|
102
|
-
disabled,
|
|
103
|
-
height,
|
|
104
|
-
markerColor
|
|
105
|
-
}) {
|
|
106
|
-
const defaultCenter = [40.7128, -74.006];
|
|
107
|
-
return /* @__PURE__ */ jsxs("div", { style: { height: `${height}px` }, className: "relative", children: [
|
|
108
|
-
/* @__PURE__ */ jsxs(
|
|
109
|
-
MapContainer,
|
|
110
|
-
{
|
|
111
|
-
center: position || defaultCenter,
|
|
112
|
-
zoom: position ? 15 : 10,
|
|
113
|
-
style: { height: "100%", width: "100%" },
|
|
114
|
-
className: cn("z-0", disabled && "pointer-events-none opacity-64"),
|
|
115
|
-
children: [
|
|
116
|
-
/* @__PURE__ */ jsx(
|
|
117
|
-
TileLayer,
|
|
118
|
-
{
|
|
119
|
-
attribution: '\xA9 <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
|
120
|
-
url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
|
121
|
-
}
|
|
122
|
-
),
|
|
123
|
-
position && /* @__PURE__ */ jsx(Marker, { position, icon: createCustomIcon(markerColor) }),
|
|
124
|
-
/* @__PURE__ */ jsx(MapEventHandler, { onMapClick, position })
|
|
125
|
-
]
|
|
126
|
-
}
|
|
127
|
-
),
|
|
128
|
-
disabled && /* @__PURE__ */ jsx("div", { className: "bg-background/50 absolute inset-0 z-10" })
|
|
129
|
-
] });
|
|
130
|
-
}
|
|
131
|
-
return { default: LeafletMap };
|
|
132
|
-
})
|
|
133
|
-
);
|
|
134
|
-
function MapLoading({ height }) {
|
|
135
|
-
return /* @__PURE__ */ jsx("div", { style: { height: `${height}px` }, className: "bg-muted flex items-center justify-center rounded-lg border", children: /* @__PURE__ */ jsx(Loader2, { className: "h-6 w-6 animate-spin text-muted-foreground" }) });
|
|
136
|
-
}
|
|
137
|
-
function MapPicker({
|
|
138
|
-
value,
|
|
139
|
-
onChange,
|
|
140
|
-
className,
|
|
141
|
-
placeholder = "Search for a location...",
|
|
142
|
-
disabled = false,
|
|
143
|
-
height = 300,
|
|
144
|
-
markerColor = "#3b82f6"
|
|
145
|
-
}) {
|
|
146
|
-
const [searchQuery, setSearchQuery] = useState("");
|
|
147
|
-
const [searchResults, setSearchResults] = useState([]);
|
|
148
|
-
const [isSearching, setIsSearching] = useState(false);
|
|
149
|
-
const [showResults, setShowResults] = useState(false);
|
|
150
|
-
const searchTimeoutRef = useRef(null);
|
|
151
|
-
const position = extractPosition(value);
|
|
152
|
-
const handleMapClick = useCallback(
|
|
153
|
-
(lat, lng) => {
|
|
154
|
-
if (disabled) return;
|
|
155
|
-
const newValue = createMapValue(lat, lng);
|
|
156
|
-
onChange?.(newValue);
|
|
157
|
-
setSearchQuery("");
|
|
158
|
-
setShowResults(false);
|
|
159
|
-
},
|
|
160
|
-
[disabled, onChange]
|
|
161
|
-
);
|
|
162
|
-
const handleSearchChange = useCallback((e) => {
|
|
163
|
-
const query = e.target.value;
|
|
164
|
-
setSearchQuery(query);
|
|
165
|
-
if (searchTimeoutRef.current) {
|
|
166
|
-
clearTimeout(searchTimeoutRef.current);
|
|
167
|
-
}
|
|
168
|
-
searchTimeoutRef.current = setTimeout(async () => {
|
|
169
|
-
if (query.trim()) {
|
|
170
|
-
setIsSearching(true);
|
|
171
|
-
setShowResults(true);
|
|
172
|
-
const results = await searchLocation(query);
|
|
173
|
-
setSearchResults(results);
|
|
174
|
-
setIsSearching(false);
|
|
175
|
-
} else {
|
|
176
|
-
setShowResults(false);
|
|
177
|
-
setSearchResults([]);
|
|
178
|
-
}
|
|
179
|
-
}, 300);
|
|
180
|
-
}, []);
|
|
181
|
-
const handleResultSelect = useCallback(
|
|
182
|
-
(result) => {
|
|
183
|
-
if (disabled) return;
|
|
184
|
-
const lat = parseFloat(result.lat);
|
|
185
|
-
const lng = parseFloat(result.lon);
|
|
186
|
-
const newValue = createMapValue(lat, lng);
|
|
187
|
-
onChange?.(newValue);
|
|
188
|
-
setSearchQuery(result.display_name);
|
|
189
|
-
setShowResults(false);
|
|
190
|
-
},
|
|
191
|
-
[disabled, onChange]
|
|
192
|
-
);
|
|
193
|
-
const clearSearch = useCallback(() => {
|
|
194
|
-
setSearchQuery("");
|
|
195
|
-
setShowResults(false);
|
|
196
|
-
setSearchResults([]);
|
|
197
|
-
}, []);
|
|
198
|
-
const clearLocation = useCallback(() => {
|
|
199
|
-
if (disabled) return;
|
|
200
|
-
onChange?.(void 0);
|
|
201
|
-
setSearchQuery("");
|
|
202
|
-
}, [disabled, onChange]);
|
|
203
|
-
useEffect(() => {
|
|
204
|
-
return () => {
|
|
205
|
-
if (searchTimeoutRef.current) {
|
|
206
|
-
clearTimeout(searchTimeoutRef.current);
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
}, []);
|
|
210
|
-
return /* @__PURE__ */ jsxs("div", { className: cn("relative w-full", className), children: [
|
|
211
|
-
/* @__PURE__ */ jsxs("div", { className: "relative mb-2", children: [
|
|
212
|
-
/* @__PURE__ */ jsxs(InputGroup, { children: [
|
|
213
|
-
/* @__PURE__ */ jsx(InputGroupAddon, { children: /* @__PURE__ */ jsx(SearchIcon, {}) }),
|
|
214
|
-
/* @__PURE__ */ jsx(
|
|
215
|
-
InputGroupInput,
|
|
216
|
-
{
|
|
217
|
-
type: "text",
|
|
218
|
-
placeholder,
|
|
219
|
-
value: searchQuery,
|
|
220
|
-
onChange: handleSearchChange,
|
|
221
|
-
disabled
|
|
222
|
-
}
|
|
223
|
-
),
|
|
224
|
-
/* @__PURE__ */ jsxs(InputGroupAddon, { align: "inline-end", children: [
|
|
225
|
-
searchQuery && /* @__PURE__ */ jsx(
|
|
226
|
-
Button,
|
|
227
|
-
{
|
|
228
|
-
type: "button",
|
|
229
|
-
variant: "ghost",
|
|
230
|
-
size: "sm",
|
|
231
|
-
onClick: clearSearch,
|
|
232
|
-
disabled,
|
|
233
|
-
className: "h-7 w-7 p-0",
|
|
234
|
-
children: /* @__PURE__ */ jsx(XIcon, { className: "h-3 w-3" })
|
|
235
|
-
}
|
|
236
|
-
),
|
|
237
|
-
position && /* @__PURE__ */ jsx(
|
|
238
|
-
Button,
|
|
239
|
-
{
|
|
240
|
-
type: "button",
|
|
241
|
-
variant: "ghost",
|
|
242
|
-
size: "sm",
|
|
243
|
-
onClick: clearLocation,
|
|
244
|
-
disabled,
|
|
245
|
-
className: "h-7 w-7 p-0",
|
|
246
|
-
children: /* @__PURE__ */ jsx(MapPinIcon, { className: "h-3 w-3" })
|
|
247
|
-
}
|
|
248
|
-
)
|
|
249
|
-
] })
|
|
250
|
-
] }),
|
|
251
|
-
showResults && /* @__PURE__ */ jsx(Card, { className: "absolute top-full right-0 left-0 z-50 mt-1 max-h-60 overflow-y-auto", children: /* @__PURE__ */ jsxs(CardContent, { className: "p-0", children: [
|
|
252
|
-
isSearching && /* @__PURE__ */ jsx("div", { className: "text-muted-foreground px-3 py-2 text-sm", children: "Searching..." }),
|
|
253
|
-
!isSearching && searchResults.length === 0 && searchQuery && /* @__PURE__ */ jsx("div", { className: "text-muted-foreground px-3 py-2 text-sm", children: "No results found" }),
|
|
254
|
-
!isSearching && searchResults.map((result) => /* @__PURE__ */ jsx(
|
|
255
|
-
"button",
|
|
256
|
-
{
|
|
257
|
-
onClick: () => handleResultSelect(result),
|
|
258
|
-
disabled,
|
|
259
|
-
className: "hover:bg-accent hover:text-accent-foreground w-full px-3 py-2 text-left text-sm\n disabled:cursor-not-allowed disabled:opacity-64",
|
|
260
|
-
children: result.display_name
|
|
261
|
-
},
|
|
262
|
-
result.place_id
|
|
263
|
-
))
|
|
264
|
-
] }) })
|
|
265
|
-
] }),
|
|
266
|
-
/* @__PURE__ */ jsx(Card, { className: "overflow-hidden", children: /* @__PURE__ */ jsx(CardContent, { className: "p-0", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(MapLoading, { height }), children: /* @__PURE__ */ jsx(
|
|
267
|
-
LeafletMapInner,
|
|
268
|
-
{
|
|
269
|
-
position,
|
|
270
|
-
onMapClick: handleMapClick,
|
|
271
|
-
disabled,
|
|
272
|
-
height,
|
|
273
|
-
markerColor
|
|
274
|
-
}
|
|
275
|
-
) }) }) }),
|
|
276
|
-
position && /* @__PURE__ */ jsx("div", { className: "text-muted-foreground mt-2 text-xs", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
277
|
-
/* @__PURE__ */ jsx(MapPinIcon, { className: "h-3 w-3" }),
|
|
278
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
279
|
-
"Latitude: ",
|
|
280
|
-
position[0].toFixed(6),
|
|
281
|
-
", Longitude: ",
|
|
282
|
-
position[1].toFixed(6)
|
|
283
|
-
] })
|
|
284
|
-
] }) })
|
|
285
|
-
] });
|
|
286
|
-
}
|
|
287
|
-
export {
|
|
288
|
-
MapPicker
|
|
289
|
-
};
|
|
290
|
-
//# sourceMappingURL=map-picker-ZUGGOIZS.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/map-picker.tsx"],"sourcesContent":["'use client';\n\nimport React, { lazy, Suspense, useCallback, useEffect, useRef, useState } from 'react';\nimport type { LeafletMouseEvent } from 'leaflet';\nimport { MapPinIcon, SearchIcon, XIcon, Loader2 } from 'lucide-react';\n\nimport { cn } from './cn';\nimport { sheetsLogger } from './sheets-logger';\nimport { Button } from '@constructive-io/ui/button';\nimport { Card, CardContent } from '@constructive-io/ui/card';\nimport { InputGroup, InputGroupAddon, InputGroupInput } from '@constructive-io/ui/input-group';\n\n// TypeScript interfaces\ninterface GeoJSONPoint {\n\ttype: 'Point';\n\tcoordinates: [number, number]; // [longitude, latitude]\n}\n\ninterface MapPickerValue {\n\tgeojson: GeoJSONPoint;\n\tsrid: number;\n\tx: number;\n\ty: number;\n}\n\ninterface MapPickerProps {\n\tvalue?: MapPickerValue | GeoJSONPoint | any;\n\tonChange?: (value: MapPickerValue | undefined) => void;\n\tclassName?: string;\n\tplaceholder?: string;\n\tdisabled?: boolean;\n\theight?: number;\n\tmarkerColor?: string;\n}\n\ninterface SearchResult {\n\tdisplay_name: string;\n\tlat: string;\n\tlon: string;\n\tplace_id: string;\n}\n\n// Utility functions\nconst createMapValue = (lat: number, lng: number): MapPickerValue => ({\n\tgeojson: {\n\t\ttype: 'Point',\n\t\tcoordinates: [lng, lat],\n\t},\n\tsrid: 4326,\n\tx: lng,\n\ty: lat,\n});\n\nconst extractPosition = (value: any): [number, number] | null => {\n\tif (!value) return null;\n\n\tlet coordinates: [number, number] | undefined;\n\n\tif (value.type === 'Point' && Array.isArray(value.coordinates)) {\n\t\tcoordinates = value.coordinates;\n\t} else if (value.geojson?.type === 'Point' && Array.isArray(value.geojson.coordinates)) {\n\t\tcoordinates = value.geojson.coordinates;\n\t}\n\n\tif (!coordinates || coordinates.length < 2) return null;\n\n\tconst [lng, lat] = coordinates;\n\n\tif (typeof lng !== 'number' || typeof lat !== 'number') return null;\n\tif (!isFinite(lng) || !isFinite(lat)) return null;\n\n\treturn [lat, lng];\n};\n\nconst searchLocation = async (query: string): Promise<SearchResult[]> => {\n\tif (!query.trim()) return [];\n\n\ttry {\n\t\tconst response = await fetch(\n\t\t\t`https://nominatim.openstreetmap.org/search?format=json&q=${encodeURIComponent(query)}&limit=5&addressdetails=1`,\n\t\t);\n\t\tconst results = await response.json();\n\t\treturn results || [];\n\t} catch (error) {\n\t\tsheetsLogger().error('Search error:', error);\n\t\treturn [];\n\t}\n};\n\n/**\n * Inner map component that uses react-leaflet.\n * Lazy-loaded to avoid bundling ~270KB Leaflet in main chunk.\n */\nconst LeafletMapInner = lazy(() =>\n\tPromise.all([import('react-leaflet'), import('leaflet')]).then(([reactLeaflet, L]) => {\n\t\tconst { MapContainer, TileLayer, Marker, useMapEvents, useMap } = reactLeaflet;\n\n\t\tconst createCustomIcon = (color: string = '#3b82f6') => {\n\t\t\treturn L.divIcon({\n\t\t\t\thtml: `\n\t\t\t\t\t<div style=\"\n\t\t\t\t\t\twidth: 32px;\n\t\t\t\t\t\theight: 32px;\n\t\t\t\t\t\tdisplay: flex;\n\t\t\t\t\t\talign-items: center;\n\t\t\t\t\t\tjustify-content: center;\n\t\t\t\t\t\tbackground: ${color};\n\t\t\t\t\t\tborder: 3px solid white;\n\t\t\t\t\t\tborder-radius: 50% 50% 50% 0;\n\t\t\t\t\t\ttransform: rotate(-45deg);\n\t\t\t\t\t\tbox-shadow: 0 2px 8px rgba(0,0,0,0.3);\n\t\t\t\t\t\">\n\t\t\t\t\t\t<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"white\" style=\"transform: rotate(45deg);\">\n\t\t\t\t\t\t\t<path d=\"M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z\"/>\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t</div>\n\t\t\t\t`,\n\t\t\t\tclassName: 'custom-marker',\n\t\t\t\ticonSize: [32, 32],\n\t\t\t\ticonAnchor: [16, 32],\n\t\t\t\tpopupAnchor: [0, -32],\n\t\t\t});\n\t\t};\n\n\t\tfunction MapEventHandler({\n\t\t\tonMapClick,\n\t\t\tposition,\n\t\t}: {\n\t\t\tonMapClick: (lat: number, lng: number) => void;\n\t\t\tposition: [number, number] | null;\n\t\t}): React.ReactElement | null {\n\t\t\tconst map = useMap();\n\n\t\t\tuseMapEvents({\n\t\t\t\tclick(e: LeafletMouseEvent) {\n\t\t\t\t\tonMapClick(e.latlng.lat, e.latlng.lng);\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tReact.useEffect(() => {\n\t\t\t\tif (position && map) {\n\t\t\t\t\tmap.setView(position, 15);\n\t\t\t\t}\n\t\t\t}, [position, map]);\n\n\t\t\treturn null;\n\t\t}\n\n\t\tfunction LeafletMap({\n\t\t\tposition,\n\t\t\tonMapClick,\n\t\t\tdisabled,\n\t\t\theight,\n\t\t\tmarkerColor,\n\t\t}: {\n\t\t\tposition: [number, number] | null;\n\t\t\tonMapClick: (lat: number, lng: number) => void;\n\t\t\tdisabled: boolean;\n\t\t\theight: number;\n\t\t\tmarkerColor: string;\n\t\t}) {\n\t\t\tconst defaultCenter: [number, number] = [40.7128, -74.006];\n\n\t\t\treturn (\n\t\t\t\t<div style={{ height: `${height}px` }} className='relative'>\n\t\t\t\t\t<MapContainer\n\t\t\t\t\t\tcenter={position || defaultCenter}\n\t\t\t\t\t\tzoom={position ? 15 : 10}\n\t\t\t\t\t\tstyle={{ height: '100%', width: '100%' }}\n\t\t\t\t\t\tclassName={cn('z-0', disabled && 'pointer-events-none opacity-64')}\n\t\t\t\t\t>\n\t\t\t\t\t\t<TileLayer\n\t\t\t\t\t\t\tattribution='© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors'\n\t\t\t\t\t\t\turl='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'\n\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t{position && <Marker position={position} icon={createCustomIcon(markerColor)} />}\n\n\t\t\t\t\t\t<MapEventHandler onMapClick={onMapClick} position={position} />\n\t\t\t\t\t</MapContainer>\n\n\t\t\t\t\t{disabled && <div className='bg-background/50 absolute inset-0 z-10' />}\n\t\t\t\t</div>\n\t\t\t);\n\t\t}\n\n\t\treturn { default: LeafletMap };\n\t})\n);\n\nfunction MapLoading({ height }: { height: number }) {\n\treturn (\n\t\t<div style={{ height: `${height}px` }} className='bg-muted flex items-center justify-center rounded-lg border'>\n\t\t\t<Loader2 className='h-6 w-6 animate-spin text-muted-foreground' />\n\t\t</div>\n\t);\n}\n\nexport function MapPicker({\n\tvalue,\n\tonChange,\n\tclassName,\n\tplaceholder = 'Search for a location...',\n\tdisabled = false,\n\theight = 300,\n\tmarkerColor = '#3b82f6',\n}: MapPickerProps) {\n\tconst [searchQuery, setSearchQuery] = useState('');\n\tconst [searchResults, setSearchResults] = useState<SearchResult[]>([]);\n\tconst [isSearching, setIsSearching] = useState(false);\n\tconst [showResults, setShowResults] = useState(false);\n\tconst searchTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n\tconst position = extractPosition(value);\n\n\tconst handleMapClick = useCallback(\n\t\t(lat: number, lng: number) => {\n\t\t\tif (disabled) return;\n\t\t\tconst newValue = createMapValue(lat, lng);\n\t\t\tonChange?.(newValue);\n\t\t\tsetSearchQuery('');\n\t\t\tsetShowResults(false);\n\t\t},\n\t\t[disabled, onChange],\n\t);\n\n\tconst handleSearchChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\n\t\tconst query = e.target.value;\n\t\tsetSearchQuery(query);\n\n\t\tif (searchTimeoutRef.current) {\n\t\t\tclearTimeout(searchTimeoutRef.current);\n\t\t}\n\n\t\tsearchTimeoutRef.current = setTimeout(async () => {\n\t\t\tif (query.trim()) {\n\t\t\t\tsetIsSearching(true);\n\t\t\t\tsetShowResults(true);\n\t\t\t\tconst results = await searchLocation(query);\n\t\t\t\tsetSearchResults(results);\n\t\t\t\tsetIsSearching(false);\n\t\t\t} else {\n\t\t\t\tsetShowResults(false);\n\t\t\t\tsetSearchResults([]);\n\t\t\t}\n\t\t}, 300);\n\t}, []);\n\n\tconst handleResultSelect = useCallback(\n\t\t(result: SearchResult) => {\n\t\t\tif (disabled) return;\n\t\t\tconst lat = parseFloat(result.lat);\n\t\t\tconst lng = parseFloat(result.lon);\n\t\t\tconst newValue = createMapValue(lat, lng);\n\t\t\tonChange?.(newValue);\n\t\t\tsetSearchQuery(result.display_name);\n\t\t\tsetShowResults(false);\n\t\t},\n\t\t[disabled, onChange],\n\t);\n\n\tconst clearSearch = useCallback(() => {\n\t\tsetSearchQuery('');\n\t\tsetShowResults(false);\n\t\tsetSearchResults([]);\n\t}, []);\n\n\tconst clearLocation = useCallback(() => {\n\t\tif (disabled) return;\n\t\tonChange?.(undefined);\n\t\tsetSearchQuery('');\n\t}, [disabled, onChange]);\n\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tif (searchTimeoutRef.current) {\n\t\t\t\tclearTimeout(searchTimeoutRef.current);\n\t\t\t}\n\t\t};\n\t}, []);\n\n\treturn (\n\t\t<div className={cn('relative w-full', className)}>\n\t\t\t{/* Search Input */}\n\t\t\t<div className='relative mb-2'>\n\t\t\t\t<InputGroup>\n\t\t\t\t\t<InputGroupAddon>\n\t\t\t\t\t\t<SearchIcon />\n\t\t\t\t\t</InputGroupAddon>\n\t\t\t\t\t<InputGroupInput\n\t\t\t\t\t\ttype='text'\n\t\t\t\t\t\tplaceholder={placeholder}\n\t\t\t\t\t\tvalue={searchQuery}\n\t\t\t\t\t\tonChange={handleSearchChange}\n\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t/>\n\t\t\t\t\t<InputGroupAddon align='inline-end'>\n\t\t\t\t\t\t{searchQuery && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\ttype='button'\n\t\t\t\t\t\t\t\tvariant='ghost'\n\t\t\t\t\t\t\t\tsize='sm'\n\t\t\t\t\t\t\t\tonClick={clearSearch}\n\t\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\t\tclassName='h-7 w-7 p-0'\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<XIcon className='h-3 w-3' />\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{position && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\ttype='button'\n\t\t\t\t\t\t\t\tvariant='ghost'\n\t\t\t\t\t\t\t\tsize='sm'\n\t\t\t\t\t\t\t\tonClick={clearLocation}\n\t\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\t\tclassName='h-7 w-7 p-0'\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<MapPinIcon className='h-3 w-3' />\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</InputGroupAddon>\n\t\t\t\t</InputGroup>\n\n\t\t\t\t{/* Search Results */}\n\t\t\t\t{showResults && (\n\t\t\t\t\t<Card className='absolute top-full right-0 left-0 z-50 mt-1 max-h-60 overflow-y-auto'>\n\t\t\t\t\t\t<CardContent className='p-0'>\n\t\t\t\t\t\t\t{isSearching && <div className='text-muted-foreground px-3 py-2 text-sm'>Searching...</div>}\n\t\t\t\t\t\t\t{!isSearching && searchResults.length === 0 && searchQuery && (\n\t\t\t\t\t\t\t\t<div className='text-muted-foreground px-3 py-2 text-sm'>No results found</div>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t{!isSearching &&\n\t\t\t\t\t\t\t\tsearchResults.map((result) => (\n\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\tkey={result.place_id}\n\t\t\t\t\t\t\t\t\t\tonClick={() => handleResultSelect(result)}\n\t\t\t\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\t\t\t\tclassName='hover:bg-accent hover:text-accent-foreground w-full px-3 py-2 text-left text-sm\n\t\t\t\t\t\t\t\t\t\t\tdisabled:cursor-not-allowed disabled:opacity-64'\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{result.display_name}\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</CardContent>\n\t\t\t\t\t</Card>\n\t\t\t\t)}\n\t\t\t</div>\n\n\t\t\t{/* Map Container */}\n\t\t\t<Card className='overflow-hidden'>\n\t\t\t\t<CardContent className='p-0'>\n\t\t\t\t\t<Suspense fallback={<MapLoading height={height} />}>\n\t\t\t\t\t\t<LeafletMapInner\n\t\t\t\t\t\t\tposition={position}\n\t\t\t\t\t\t\tonMapClick={handleMapClick}\n\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\theight={height}\n\t\t\t\t\t\t\tmarkerColor={markerColor}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Suspense>\n\t\t\t\t</CardContent>\n\t\t\t</Card>\n\n\t\t\t{/* Current Location Info */}\n\t\t\t{position && (\n\t\t\t\t<div className='text-muted-foreground mt-2 text-xs'>\n\t\t\t\t\t<div className='flex items-center gap-1'>\n\t\t\t\t\t\t<MapPinIcon className='h-3 w-3' />\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\tLatitude: {position[0].toFixed(6)}, Longitude: {position[1].toFixed(6)}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;;;AAEA,OAAO,SAAS,MAAM,UAAU,aAAa,WAAW,QAAQ,gBAAgB;AAEhF,SAAS,YAAY,YAAY,OAAO,eAAe;AAIvD,SAAS,cAAc;AACvB,SAAS,MAAM,mBAAmB;AAClC,SAAS,YAAY,iBAAiB,uBAAuB;AA2JxD,SAMC,KAND;AA1HL,IAAM,iBAAiB,CAAC,KAAa,SAAiC;AAAA,EACrE,SAAS;AAAA,IACR,MAAM;AAAA,IACN,aAAa,CAAC,KAAK,GAAG;AAAA,EACvB;AAAA,EACA,MAAM;AAAA,EACN,GAAG;AAAA,EACH,GAAG;AACJ;AAEA,IAAM,kBAAkB,CAAC,UAAwC;AAChE,MAAI,CAAC,MAAO,QAAO;AAEnB,MAAI;AAEJ,MAAI,MAAM,SAAS,WAAW,MAAM,QAAQ,MAAM,WAAW,GAAG;AAC/D,kBAAc,MAAM;AAAA,EACrB,WAAW,MAAM,SAAS,SAAS,WAAW,MAAM,QAAQ,MAAM,QAAQ,WAAW,GAAG;AACvF,kBAAc,MAAM,QAAQ;AAAA,EAC7B;AAEA,MAAI,CAAC,eAAe,YAAY,SAAS,EAAG,QAAO;AAEnD,QAAM,CAAC,KAAK,GAAG,IAAI;AAEnB,MAAI,OAAO,QAAQ,YAAY,OAAO,QAAQ,SAAU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