@constructive-io/sheets 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/LICENSE +21 -0
- package/README.md +188 -0
- package/dist/advanced.cjs +5477 -0
- package/dist/advanced.cjs.map +1 -0
- package/dist/advanced.d.cts +83 -0
- package/dist/advanced.d.ts +83 -0
- package/dist/advanced.js +34 -0
- package/dist/advanced.js.map +1 -0
- package/dist/auth.cjs +1396 -0
- package/dist/auth.cjs.map +1 -0
- package/dist/auth.d.cts +60 -0
- package/dist/auth.d.ts +60 -0
- package/dist/auth.js +19 -0
- package/dist/auth.js.map +1 -0
- package/dist/chunk-4PGPVMZB.js +670 -0
- package/dist/chunk-4PGPVMZB.js.map +1 -0
- package/dist/chunk-FNVHSOQQ.js +1314 -0
- package/dist/chunk-FNVHSOQQ.js.map +1 -0
- package/dist/chunk-GGECS2BP.js +17 -0
- package/dist/chunk-GGECS2BP.js.map +1 -0
- package/dist/chunk-GLVZSPV2.js +43 -0
- package/dist/chunk-GLVZSPV2.js.map +1 -0
- package/dist/chunk-H4JJTMP5.js +160 -0
- package/dist/chunk-H4JJTMP5.js.map +1 -0
- package/dist/chunk-ODUBS2NL.js +100 -0
- package/dist/chunk-ODUBS2NL.js.map +1 -0
- package/dist/chunk-PZL2BCWF.js +168 -0
- package/dist/chunk-PZL2BCWF.js.map +1 -0
- package/dist/chunk-TU7ATZ4X.js +4494 -0
- package/dist/chunk-TU7ATZ4X.js.map +1 -0
- package/dist/chunk-X7DHTSOX.js +21 -0
- package/dist/chunk-X7DHTSOX.js.map +1 -0
- package/dist/chunk-YDQQA46V.js +13 -0
- package/dist/chunk-YDQQA46V.js.map +1 -0
- package/dist/date-editor-CXKKGNL6.js +361 -0
- package/dist/date-editor-CXKKGNL6.js.map +1 -0
- package/dist/editor-props-M6Dh0P9f.d.cts +245 -0
- package/dist/editor-props-M6Dh0P9f.d.ts +245 -0
- package/dist/index.cjs +15861 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1650 -0
- package/dist/index.d.ts +1650 -0
- package/dist/index.js +8470 -0
- package/dist/index.js.map +1 -0
- package/dist/map-picker-VTKDS6CM.js +290 -0
- package/dist/map-picker-VTKDS6CM.js.map +1 -0
- package/dist/sheets-context-CojEFlaY.d.cts +214 -0
- package/dist/sheets-context-Da55TTR9.d.ts +214 -0
- package/dist/testing.cjs +1113 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +45 -0
- package/dist/testing.d.ts +45 -0
- package/dist/testing.js +269 -0
- package/dist/testing.js.map +1 -0
- package/package.json +144 -0
|
@@ -0,0 +1,290 @@
|
|
|
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-50"),
|
|
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-50",
|
|
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-VTKDS6CM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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}) {\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-50')}\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-50'\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,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S,CAAC,EAAE,QAAQ,CAAC;AAAA,QAAE;AAAA,QAAc,SAAS,CAAC,EAAE,QAAQ,CAAC;AAAA,SACtE;AAAA,OACD,GACD;AAAA,KAEF;AAEF;","names":[]}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
3
|
+
import { DocumentNode } from 'graphql';
|
|
4
|
+
import { TypedDocumentString, MetaQuery, CleanTable, FieldSelection, MutationOptions } from '@constructive-io/data';
|
|
5
|
+
import { S as SheetsCell, b as CellType, c as CellCategory, C as CellCreationMetadata, E as EditorProps } from './editor-props-M6Dh0P9f.cjs';
|
|
6
|
+
|
|
7
|
+
type ExecutableDocument = TypedDocumentString<any, any> | DocumentNode | string | unknown;
|
|
8
|
+
type SheetsExecuteFn = <T = unknown>(document: ExecutableDocument, variables?: Record<string, unknown>) => Promise<T>;
|
|
9
|
+
/**
|
|
10
|
+
* Result of an upload through the seam. `url` is the only guaranteed field;
|
|
11
|
+
* the REST upload endpoint also returns `{ filename, mime, size }` (and may
|
|
12
|
+
* return server-internal extras). Keeping it open-ended lets callers read the
|
|
13
|
+
* richer metadata while a bare `{ url }` (e.g. the mock) still satisfies it.
|
|
14
|
+
*/
|
|
15
|
+
type SheetsUploadResult = {
|
|
16
|
+
url: string;
|
|
17
|
+
} & Record<string, unknown>;
|
|
18
|
+
/**
|
|
19
|
+
* Optional upload metadata carried through the seam (third arg). Lets an
|
|
20
|
+
* injected `executeUpload` see the destination field/row and report progress.
|
|
21
|
+
* All fields optional, so existing `(file, path?)` callers stay valid.
|
|
22
|
+
*/
|
|
23
|
+
interface SheetsUploadOptions {
|
|
24
|
+
tableName?: string;
|
|
25
|
+
fieldName?: string;
|
|
26
|
+
recordId?: string | number;
|
|
27
|
+
onProgress?: (progress: {
|
|
28
|
+
loaded: number;
|
|
29
|
+
total: number;
|
|
30
|
+
percentage: number;
|
|
31
|
+
}) => void;
|
|
32
|
+
}
|
|
33
|
+
type SheetsUploadFn = (file: File, path?: string, options?: SheetsUploadOptions) => Promise<SheetsUploadResult>;
|
|
34
|
+
declare function createSheetsExecute(config: SheetsConfig, getToken: () => string | null): SheetsExecuteFn;
|
|
35
|
+
declare function createSheetsUpload(config: SheetsConfig, getToken: () => string | null): SheetsUploadFn;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Injectable logger seam for @constructive-io/sheets.
|
|
39
|
+
*
|
|
40
|
+
* The host app may provide a custom logger via SheetsConfig.logger. The provider
|
|
41
|
+
* installs it into this module singleton (see sheets-provider.tsx), so any module
|
|
42
|
+
* or hook can log without threading the logger through props/context.
|
|
43
|
+
*
|
|
44
|
+
* Default behaviour matches the prior console.* calls. `debug` is omitted from the
|
|
45
|
+
* default logger (no-op) so verbose diagnostics stay silent unless a host opts in.
|
|
46
|
+
*/
|
|
47
|
+
interface SheetsLogger {
|
|
48
|
+
debug?(msg: string, ctx?: unknown): void;
|
|
49
|
+
warn(msg: string, ctx?: unknown): void;
|
|
50
|
+
error(msg: string, ctx?: unknown): void;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Smallest render-column descriptor a cell view needs now. Overridable. */
|
|
54
|
+
interface CellColumnDescriptor {
|
|
55
|
+
key: string;
|
|
56
|
+
name: string;
|
|
57
|
+
cellType: CellType;
|
|
58
|
+
}
|
|
59
|
+
/** Props every native cell view receives. Minimal and overridable. */
|
|
60
|
+
interface CellProps {
|
|
61
|
+
cell: SheetsCell;
|
|
62
|
+
value: unknown;
|
|
63
|
+
colKey: string;
|
|
64
|
+
rowId: string;
|
|
65
|
+
rowIndex: number;
|
|
66
|
+
column: CellColumnDescriptor;
|
|
67
|
+
isEditing: boolean;
|
|
68
|
+
onStartEdit: () => void;
|
|
69
|
+
disabled: boolean;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Schema-only inputs used to DETECT a cell type. Never the runtime value. */
|
|
73
|
+
interface CellTypeMatchInput {
|
|
74
|
+
gqlType: string;
|
|
75
|
+
isArray: boolean;
|
|
76
|
+
pgAlias?: string | null;
|
|
77
|
+
pgType?: string | null;
|
|
78
|
+
subtype?: string | null;
|
|
79
|
+
fieldName?: string;
|
|
80
|
+
}
|
|
81
|
+
/** Context handed to `toSheetsCell` so a definition can build the neutral cell.
|
|
82
|
+
* Geometry uses the built-in fallback, so no `createGeometry` callback is needed. */
|
|
83
|
+
interface SheetsCellRenderContext {
|
|
84
|
+
metadata: CellCreationMetadata;
|
|
85
|
+
}
|
|
86
|
+
interface CellTypeDefinition<TValue = unknown> {
|
|
87
|
+
/** Stable key. A def whose typeKey equals a built-in (e.g. 'relation') overrides it. */
|
|
88
|
+
typeKey: string;
|
|
89
|
+
category?: CellCategory;
|
|
90
|
+
/** Toolbar / type-picker icon. */
|
|
91
|
+
icon?: React.ComponentType<{
|
|
92
|
+
size?: number;
|
|
93
|
+
}>;
|
|
94
|
+
defaultWidth?: number;
|
|
95
|
+
supportsInlineEdit?: boolean;
|
|
96
|
+
/** DETECTION (schema-only). Highest-priority match wins; omit for typeKey-only. */
|
|
97
|
+
match?: (meta: CellTypeMatchInput) => boolean;
|
|
98
|
+
/** Native DISPLAY. Build the neutral SheetsCell. Omit to keep the built-in renderer. */
|
|
99
|
+
toSheetsCell?: (value: TValue, ctx: SheetsCellRenderContext) => SheetsCell;
|
|
100
|
+
/** Native cell COMPONENT override (the slot target). Omit to keep the built-in view. */
|
|
101
|
+
cell?: React.ComponentType<CellProps>;
|
|
102
|
+
/** Native EDITOR override (DOM portal overlay). Omit to keep the built-in native editor. */
|
|
103
|
+
editorComponent?: React.ComponentType<EditorProps>;
|
|
104
|
+
/** Value -> display/copy/export string. */
|
|
105
|
+
format?: (value: TValue) => string;
|
|
106
|
+
defaultValue?: () => TValue;
|
|
107
|
+
}
|
|
108
|
+
/** Identity helper that pins the generic — `defineCellType<number>({ ... })`. */
|
|
109
|
+
declare function defineCellType<T = unknown>(def: CellTypeDefinition<T>): CellTypeDefinition<T>;
|
|
110
|
+
/** A named bundle of cell types, registered via `SheetsConfig.plugins`. */
|
|
111
|
+
interface CellTypePlugin {
|
|
112
|
+
name: string;
|
|
113
|
+
cellTypes: CellTypeDefinition<any>[];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** The table being operated on, plus all tables (needed for relation-aware AST building). */
|
|
117
|
+
interface AdapterTableContext {
|
|
118
|
+
table: CleanTable;
|
|
119
|
+
allTables: CleanTable[];
|
|
120
|
+
tableName: string;
|
|
121
|
+
}
|
|
122
|
+
/** A normalized list query. `relationFieldMap` is resolved by the hook (it is cache-bound). */
|
|
123
|
+
interface AdapterListQuery {
|
|
124
|
+
where?: unknown;
|
|
125
|
+
orderBy?: Array<{
|
|
126
|
+
field: string;
|
|
127
|
+
direction: 'asc' | 'desc';
|
|
128
|
+
}>;
|
|
129
|
+
limit?: number;
|
|
130
|
+
offset?: number;
|
|
131
|
+
/** Relay cursor for forward pagination (infinite/cursor mode). */
|
|
132
|
+
after?: string;
|
|
133
|
+
fieldSelection?: FieldSelection;
|
|
134
|
+
/** Resolved relation field name map, threaded from the hook's cached resolution. */
|
|
135
|
+
relationFieldMap?: Record<string, string>;
|
|
136
|
+
}
|
|
137
|
+
interface AdapterPageInfo {
|
|
138
|
+
endCursor?: string | null;
|
|
139
|
+
startCursor?: string | null;
|
|
140
|
+
hasNextPage?: boolean;
|
|
141
|
+
hasPreviousPage?: boolean;
|
|
142
|
+
}
|
|
143
|
+
interface AdapterListResult<T = Record<string, unknown>> {
|
|
144
|
+
rows: T[];
|
|
145
|
+
totalCount: number;
|
|
146
|
+
pageInfo?: AdapterPageInfo;
|
|
147
|
+
}
|
|
148
|
+
interface SheetsBackendAdapter {
|
|
149
|
+
/** Introspect the schema. Default adapter runs the v5 `_meta` query. */
|
|
150
|
+
fetchMeta(execute: SheetsExecuteFn): Promise<MetaQuery>;
|
|
151
|
+
/** Read a page of rows, flattening relation connections into arrays. */
|
|
152
|
+
listRows<T = Record<string, unknown>>(ctx: AdapterTableContext, query: AdapterListQuery, execute: SheetsExecuteFn): Promise<AdapterListResult<T>>;
|
|
153
|
+
/** Create a row; resolves to the created row (or null). */
|
|
154
|
+
createRow<T = Record<string, unknown>>(ctx: AdapterTableContext, data: Record<string, unknown>, execute: SheetsExecuteFn, options?: MutationOptions): Promise<T | null>;
|
|
155
|
+
/** Update a row by id (or composite PK object); resolves to the updated row (or null). */
|
|
156
|
+
updateRow<T = Record<string, unknown>>(ctx: AdapterTableContext, id: string | number | Record<string, unknown>, patch: Record<string, unknown>, execute: SheetsExecuteFn, options?: MutationOptions): Promise<T | null>;
|
|
157
|
+
/** Delete a row by id (or composite PK object). */
|
|
158
|
+
deleteRow(ctx: AdapterTableContext, id: string | number | Record<string, unknown>, execute: SheetsExecuteFn, options?: MutationOptions): Promise<void>;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
interface SheetsAuthEmbedded {
|
|
162
|
+
mode: 'embedded';
|
|
163
|
+
getToken: () => string | null;
|
|
164
|
+
}
|
|
165
|
+
interface SheetsAuthStandalone {
|
|
166
|
+
mode: 'standalone';
|
|
167
|
+
}
|
|
168
|
+
interface SheetsConfig {
|
|
169
|
+
/** Data endpoint (app-public GraphQL) */
|
|
170
|
+
endpoint: string;
|
|
171
|
+
/** Auth endpoint (auth GraphQL) — required for standalone mode */
|
|
172
|
+
authEndpoint?: string;
|
|
173
|
+
/** Database ID for multi-tenant scoping */
|
|
174
|
+
databaseId?: string;
|
|
175
|
+
/** Auth mode */
|
|
176
|
+
auth: SheetsAuthEmbedded | SheetsAuthStandalone;
|
|
177
|
+
/** Field type overrides (replaces schema-builder smart tags) */
|
|
178
|
+
fieldTypeOverrides?: Record<string, string>;
|
|
179
|
+
/** Optional: BCP-47 locale for locale-aware date/number formatting (default 'en-US'). */
|
|
180
|
+
locale?: string;
|
|
181
|
+
/** Optional: inject custom execute function */
|
|
182
|
+
execute?: SheetsExecuteFn;
|
|
183
|
+
/** Optional: inject custom upload function */
|
|
184
|
+
executeUpload?: SheetsUploadFn;
|
|
185
|
+
/** Optional: inject existing QueryClient */
|
|
186
|
+
queryClient?: QueryClient;
|
|
187
|
+
/** Optional: inject a custom backend adapter. Defaults to the PostGraphile adapter. */
|
|
188
|
+
adapter?: SheetsBackendAdapter;
|
|
189
|
+
/** Optional: provider-level cell-type plugins (consumer override layer). */
|
|
190
|
+
plugins?: CellTypePlugin[];
|
|
191
|
+
/** Called on 401/UNAUTHENTICATED before the error is thrown. Host app handles token cleanup. */
|
|
192
|
+
onAuthError?: () => void;
|
|
193
|
+
/** Optional: inject a custom logger. Installed into the module logger singleton by the provider. */
|
|
194
|
+
logger?: SheetsLogger;
|
|
195
|
+
/** Optional: called when a grid/editor/mutation/upload error surfaces. Host app handles reporting. */
|
|
196
|
+
onError?: (error: unknown, ctx?: {
|
|
197
|
+
source?: 'grid' | 'editor' | 'mutation' | 'upload';
|
|
198
|
+
tableName?: string;
|
|
199
|
+
}) => void;
|
|
200
|
+
}
|
|
201
|
+
interface SheetsContextValue {
|
|
202
|
+
config: SheetsConfig;
|
|
203
|
+
execute: SheetsExecuteFn;
|
|
204
|
+
executeUpload: SheetsUploadFn;
|
|
205
|
+
scopeKey: SheetsScopeKey;
|
|
206
|
+
}
|
|
207
|
+
interface SheetsScopeKey {
|
|
208
|
+
databaseId: string | null;
|
|
209
|
+
endpoint: string;
|
|
210
|
+
}
|
|
211
|
+
declare const SheetsContext: React$1.Context<SheetsContextValue | null>;
|
|
212
|
+
declare function useSheetsContext(): SheetsContextValue;
|
|
213
|
+
|
|
214
|
+
export { type AdapterTableContext as A, type CellProps as C, type SheetsExecuteFn as S, type SheetsUploadFn as a, type SheetsConfig as b, type CellTypeDefinition as c, type CellTypeMatchInput as d, type SheetsCellRenderContext as e, type SheetsScopeKey as f, type SheetsBackendAdapter as g, SheetsContext as h, type SheetsContextValue as i, type SheetsAuthEmbedded as j, type SheetsAuthStandalone as k, createSheetsExecute as l, createSheetsUpload as m, type AdapterListQuery as n, type AdapterListResult as o, type AdapterPageInfo as p, defineCellType as q, type CellTypePlugin as r, type CellColumnDescriptor as s, type SheetsLogger as t, useSheetsContext as u };
|