@constructive-io/sheets 0.14.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 -157
- package/dist/advanced.cjs +7192 -3840
- 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-BYAYBXVB.js → chunk-J7KK4UWI.js} +6 -6
- package/dist/chunk-MBSHDF55.js +839 -0
- package/dist/chunk-MBSHDF55.js.map +1 -0
- package/dist/chunk-MOFFS5WQ.js +128 -0
- 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-YJZFHL2D.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-C2-ocDS7.d.cts → grid-cell-types-YNIVK4hN.d.cts} +71 -18
- package/dist/{grid-cell-types-C2-ocDS7.d.ts → grid-cell-types-YNIVK4hN.d.ts} +71 -18
- package/dist/index.cjs +22733 -12052
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1432 -266
- package/dist/index.d.ts +1432 -266
- package/dist/index.js +12688 -6097
- 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 +1170 -589
- 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 +778 -147
- package/dist/testing.js.map +1 -1
- package/package.json +4 -5
- package/dist/chunk-4EZ6A23C.js +0 -44
- package/dist/chunk-4EZ6A23C.js.map +0 -1
- package/dist/chunk-6Y7CZ5VS.js +0 -168
- package/dist/chunk-6Y7CZ5VS.js.map +0 -1
- package/dist/chunk-BGL6EBTE.js +0 -446
- package/dist/chunk-BGL6EBTE.js.map +0 -1
- package/dist/chunk-ER3FIDK7.js +0 -4383
- package/dist/chunk-ER3FIDK7.js.map +0 -1
- package/dist/chunk-GZM2CSTR.js +0 -279
- package/dist/chunk-GZM2CSTR.js.map +0 -1
- package/dist/chunk-X7DHTSOX.js +0 -21
- package/dist/chunk-X7DHTSOX.js.map +0 -1
- package/dist/chunk-YJZFHL2D.js.map +0 -1
- package/dist/date-editor-G26WKILO.js +0 -358
- package/dist/date-editor-G26WKILO.js.map +0 -1
- package/dist/map-picker-ZUGGOIZS.js +0 -290
- package/dist/map-picker-ZUGGOIZS.js.map +0 -1
- package/dist/sheets-context-CHUVJCff.d.ts +0 -245
- package/dist/sheets-context-C_MkTxXm.d.cts +0 -245
- /package/dist/{chunk-BYAYBXVB.js.map → chunk-J7KK4UWI.js.map} +0 -0
|
@@ -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,QAAO;AAC/D,MAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,GAAG,EAAG,QAAO;AAE7C,SAAO,CAAC,KAAK,GAAG;AACjB;AAEA,IAAM,iBAAiB,OAAO,UAA2C;AACxE,MAAI,CAAC,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AOb,CACA;AAAA,SACH,GACD;AAAA,OAEF;AAAA,IAGA,oBAAC,QAAK,WAAU,mBACf,8BAAC,eAAY,WAAU,OACtB,8BAAC,YAAS,UAAU,oBAAC,cAAW,QAAgB,GAC/C;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA,YAAY;AAAA,QACZ;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD,GACD,GACD,GACD;AAAA,IAGC,YACA,oBAAC,SAAI,WAAU,sCACd,+BAAC,SAAI,WAAU,2BACd;AAAA,0BAAC,cAAW,WAAU,WAAU;AAAA,MAChC,qBAAC,UAAK;AAAA;AAAA,QACM,SAAS,CAAC,EAAE,QAAQ,CAAC;AAAA,QAAE;AAAA,QAAc,SAAS,CAAC,EAAE,QAAQ,CAAC;AAAA,SACtE;AAAA,OACD,GACD;AAAA,KAEF;AAEF;","names":[]}
|
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
import { QueryClient } from '@tanstack/react-query';
|
|
3
|
-
import { DocumentNode } from 'graphql';
|
|
4
|
-
import { TypedDocumentString, FieldSelection, CleanTable, MetaQuery, MutationOptions } from '@constructive-io/data';
|
|
5
|
-
import { b as CellType, S as SheetsCell, C as CellCreationMetadata, c as CellCategory, E as EditorProps } from './grid-cell-types-C2-ocDS7.js';
|
|
6
|
-
|
|
7
|
-
type ExecutableDocument = TypedDocumentString<any, any> | DocumentNode | string | unknown;
|
|
8
|
-
type SheetsExecuteFn = <T = unknown>(document: ExecutableDocument, variables?: Record<string, unknown>) => Promise<T>;
|
|
9
|
-
/** Durable file metadata for image and upload columns. */
|
|
10
|
-
interface SheetsFileValue {
|
|
11
|
-
id: string;
|
|
12
|
-
key: string;
|
|
13
|
-
bucket_id: string;
|
|
14
|
-
mime: string;
|
|
15
|
-
size: number;
|
|
16
|
-
filename: string;
|
|
17
|
-
/** Public URL supplied by storage, when available. */
|
|
18
|
-
url?: string;
|
|
19
|
-
}
|
|
20
|
-
interface SheetsUploadResult {
|
|
21
|
-
file: SheetsFileValue;
|
|
22
|
-
/** Optional download URL for immediate use. It can expire. */
|
|
23
|
-
url?: string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Optional upload metadata carried through the seam (third arg). Lets an
|
|
27
|
-
* injected `executeUpload` see the destination field/row and report progress.
|
|
28
|
-
* All fields optional, so existing `(file, path?)` callers stay valid.
|
|
29
|
-
*/
|
|
30
|
-
interface SheetsUploadOptions {
|
|
31
|
-
tableName?: string;
|
|
32
|
-
fieldName?: string;
|
|
33
|
-
recordId?: string | number;
|
|
34
|
-
onProgress?: (progress: {
|
|
35
|
-
loaded: number;
|
|
36
|
-
total: number;
|
|
37
|
-
percentage: number;
|
|
38
|
-
}) => void;
|
|
39
|
-
}
|
|
40
|
-
type SheetsUploadFn = (file: File, path?: string, options?: SheetsUploadOptions) => Promise<SheetsUploadResult>;
|
|
41
|
-
declare function createSheetsExecute(config: SheetsConfig, getToken: () => string | null): SheetsExecuteFn;
|
|
42
|
-
/** Creates an uploader for storage. Direct callers may use the supplied endpoint as storage. */
|
|
43
|
-
declare function createSheetsUpload(config: SheetsConfig, getToken: () => string | null): SheetsUploadFn;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Injectable logger seam for @constructive-io/sheets.
|
|
47
|
-
*
|
|
48
|
-
* The host app may provide a custom logger via SheetsConfig.logger. The provider
|
|
49
|
-
* installs it into this module singleton (see sheets-provider.tsx), so any module
|
|
50
|
-
* or hook can log without threading the logger through props/context.
|
|
51
|
-
*
|
|
52
|
-
* Default behaviour matches the prior console.* calls. `debug` is omitted from the
|
|
53
|
-
* default logger (no-op) so verbose diagnostics stay silent unless a host opts in.
|
|
54
|
-
*/
|
|
55
|
-
interface SheetsLogger {
|
|
56
|
-
debug?(msg: string, ctx?: unknown): void;
|
|
57
|
-
warn(msg: string, ctx?: unknown): void;
|
|
58
|
-
error(msg: string, ctx?: unknown): void;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** Smallest render-column descriptor a cell view needs now. Overridable. */
|
|
62
|
-
interface CellColumnDescriptor {
|
|
63
|
-
key: string;
|
|
64
|
-
name: string;
|
|
65
|
-
cellType: CellType;
|
|
66
|
-
}
|
|
67
|
-
/** Props every native cell view receives. Minimal and overridable. */
|
|
68
|
-
interface CellProps {
|
|
69
|
-
cell: SheetsCell;
|
|
70
|
-
value: unknown;
|
|
71
|
-
colKey: string;
|
|
72
|
-
rowId: string;
|
|
73
|
-
rowIndex: number;
|
|
74
|
-
column: CellColumnDescriptor;
|
|
75
|
-
isEditing: boolean;
|
|
76
|
-
onStartEdit: () => void;
|
|
77
|
-
disabled: boolean;
|
|
78
|
-
readOnlyReason?: string;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/** Schema-only inputs used to DETECT a cell type. Never the runtime value. */
|
|
82
|
-
interface CellTypeMatchInput {
|
|
83
|
-
gqlType: string;
|
|
84
|
-
isArray: boolean;
|
|
85
|
-
pgAlias?: string | null;
|
|
86
|
-
pgType?: string | null;
|
|
87
|
-
subtype?: string | null;
|
|
88
|
-
fieldName?: string;
|
|
89
|
-
}
|
|
90
|
-
/** Context handed to `toSheetsCell` so a definition can build the neutral cell.
|
|
91
|
-
* Geometry uses the built-in fallback, so no `createGeometry` callback is needed. */
|
|
92
|
-
interface SheetsCellRenderContext {
|
|
93
|
-
metadata: CellCreationMetadata;
|
|
94
|
-
}
|
|
95
|
-
interface CellTypeDefinition<TValue = unknown> {
|
|
96
|
-
/** Stable key. A def whose typeKey equals a built-in (e.g. 'relation') overrides it. */
|
|
97
|
-
typeKey: string;
|
|
98
|
-
category?: CellCategory;
|
|
99
|
-
/** Toolbar / type-picker icon. */
|
|
100
|
-
icon?: React.ComponentType<{
|
|
101
|
-
size?: number;
|
|
102
|
-
}>;
|
|
103
|
-
defaultWidth?: number;
|
|
104
|
-
supportsInlineEdit?: boolean;
|
|
105
|
-
/** DETECTION (schema-only). Highest-priority match wins; omit for typeKey-only. */
|
|
106
|
-
match?: (meta: CellTypeMatchInput) => boolean;
|
|
107
|
-
/** Native DISPLAY. Build the neutral SheetsCell. Omit to keep the built-in renderer. */
|
|
108
|
-
toSheetsCell?: (value: TValue, ctx: SheetsCellRenderContext) => SheetsCell;
|
|
109
|
-
/** Native cell COMPONENT override (the slot target). Omit to keep the built-in view. */
|
|
110
|
-
cell?: React.ComponentType<CellProps>;
|
|
111
|
-
/** Native EDITOR override (DOM portal overlay). Omit to keep the built-in native editor. */
|
|
112
|
-
editorComponent?: React.ComponentType<EditorProps>;
|
|
113
|
-
/** Value -> display/copy/export string. */
|
|
114
|
-
format?: (value: TValue) => string;
|
|
115
|
-
defaultValue?: () => TValue;
|
|
116
|
-
}
|
|
117
|
-
/** Identity helper that pins the generic — `defineCellType<number>({ ... })`. */
|
|
118
|
-
declare function defineCellType<T = unknown>(def: CellTypeDefinition<T>): CellTypeDefinition<T>;
|
|
119
|
-
/** A named bundle of cell types, registered via `SheetsConfig.plugins`. */
|
|
120
|
-
interface CellTypePlugin {
|
|
121
|
-
name: string;
|
|
122
|
-
cellTypes: CellTypeDefinition<any>[];
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/** The table being operated on, plus all tables (needed for relation-aware AST building). */
|
|
126
|
-
interface AdapterTableContext {
|
|
127
|
-
table: CleanTable;
|
|
128
|
-
allTables: CleanTable[];
|
|
129
|
-
tableName: string;
|
|
130
|
-
}
|
|
131
|
-
/** A normalized list query. `relationFieldMap` is resolved by the hook (it is cache-bound). */
|
|
132
|
-
interface AdapterListQuery {
|
|
133
|
-
where?: unknown;
|
|
134
|
-
orderBy?: Array<{
|
|
135
|
-
field: string;
|
|
136
|
-
direction: 'asc' | 'desc';
|
|
137
|
-
}>;
|
|
138
|
-
limit?: number;
|
|
139
|
-
offset?: number;
|
|
140
|
-
/** Relay cursor for forward pagination (infinite/cursor mode). */
|
|
141
|
-
after?: string;
|
|
142
|
-
fieldSelection?: FieldSelection;
|
|
143
|
-
/** Resolved relation field name map, threaded from the hook's cached resolution. */
|
|
144
|
-
relationFieldMap?: Record<string, string>;
|
|
145
|
-
}
|
|
146
|
-
interface AdapterPageInfo {
|
|
147
|
-
endCursor?: string | null;
|
|
148
|
-
startCursor?: string | null;
|
|
149
|
-
hasNextPage?: boolean;
|
|
150
|
-
hasPreviousPage?: boolean;
|
|
151
|
-
}
|
|
152
|
-
interface AdapterListResult<T = Record<string, unknown>> {
|
|
153
|
-
rows: T[];
|
|
154
|
-
totalCount: number;
|
|
155
|
-
pageInfo?: AdapterPageInfo;
|
|
156
|
-
}
|
|
157
|
-
interface SheetsBackendAdapter {
|
|
158
|
-
/** Introspect the schema. Default adapter validates and runs the July 2026 `_meta` contract. */
|
|
159
|
-
fetchMeta(execute: SheetsExecuteFn): Promise<MetaQuery>;
|
|
160
|
-
/** Read a page of rows, flattening relation connections into arrays. */
|
|
161
|
-
listRows<T = Record<string, unknown>>(ctx: AdapterTableContext, query: AdapterListQuery, execute: SheetsExecuteFn): Promise<AdapterListResult<T>>;
|
|
162
|
-
/** Create a row; resolves to the created row (or null). */
|
|
163
|
-
createRow<T = Record<string, unknown>>(ctx: AdapterTableContext, data: Record<string, unknown>, execute: SheetsExecuteFn, options?: MutationOptions): Promise<T | null>;
|
|
164
|
-
/** Update a row by id (or composite PK object); resolves to the updated row (or null). */
|
|
165
|
-
updateRow<T = Record<string, unknown>>(ctx: AdapterTableContext, id: string | number | Record<string, unknown>, patch: Record<string, unknown>, execute: SheetsExecuteFn, options?: MutationOptions): Promise<T | null>;
|
|
166
|
-
/** Delete a row by id (or composite PK object). */
|
|
167
|
-
deleteRow(ctx: AdapterTableContext, id: string | number | Record<string, unknown>, execute: SheetsExecuteFn, options?: MutationOptions): Promise<void>;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
interface SheetsAuthEmbedded {
|
|
171
|
-
mode: 'embedded';
|
|
172
|
-
getToken: () => string | null;
|
|
173
|
-
/**
|
|
174
|
-
* Stable, non-secret identity used to isolate cached data between users.
|
|
175
|
-
* Hosts should return the authenticated user/session id, never the token.
|
|
176
|
-
* When omitted, the provider uses an opaque key that changes with the token.
|
|
177
|
-
*/
|
|
178
|
-
getIdentityKey?: () => string | null;
|
|
179
|
-
}
|
|
180
|
-
interface SheetsAuthStandalone {
|
|
181
|
-
mode: 'standalone';
|
|
182
|
-
}
|
|
183
|
-
interface SheetsStorageTransport {
|
|
184
|
-
endpoint: string;
|
|
185
|
-
execute: SheetsExecuteFn;
|
|
186
|
-
}
|
|
187
|
-
interface SheetsConfig {
|
|
188
|
-
/** Data endpoint (app-public GraphQL) */
|
|
189
|
-
endpoint: string;
|
|
190
|
-
/** Auth endpoint (auth GraphQL) — required for standalone mode */
|
|
191
|
-
authEndpoint?: string;
|
|
192
|
-
/** Database ID for multi-tenant scoping */
|
|
193
|
-
databaseId?: string;
|
|
194
|
-
/** Auth mode */
|
|
195
|
-
auth: SheetsAuthEmbedded | SheetsAuthStandalone;
|
|
196
|
-
/** Field type overrides (replaces schema-builder smart tags) */
|
|
197
|
-
fieldTypeOverrides?: Record<string, string>;
|
|
198
|
-
/** Optional: BCP-47 locale for locale-aware date/number formatting (default 'en-US'). */
|
|
199
|
-
locale?: string;
|
|
200
|
-
/** Optional: inject custom execute function */
|
|
201
|
-
execute?: SheetsExecuteFn;
|
|
202
|
-
/** Optional: inject custom upload function */
|
|
203
|
-
executeUpload?: SheetsUploadFn;
|
|
204
|
-
/** Storage endpoint for media uploads and download URL lookups. */
|
|
205
|
-
storage?: {
|
|
206
|
-
endpoint: string;
|
|
207
|
-
execute?: SheetsExecuteFn;
|
|
208
|
-
};
|
|
209
|
-
/** Explicit bucket override. Omit to use the tenant's public default. */
|
|
210
|
-
upload?: {
|
|
211
|
-
bucketKey?: string;
|
|
212
|
-
};
|
|
213
|
-
/** Optional: inject existing QueryClient */
|
|
214
|
-
queryClient?: QueryClient;
|
|
215
|
-
/** Optional: inject a custom backend adapter. Defaults to the PostGraphile adapter. */
|
|
216
|
-
adapter?: SheetsBackendAdapter;
|
|
217
|
-
/** Optional: provider-level cell-type plugins (consumer override layer). */
|
|
218
|
-
plugins?: CellTypePlugin[];
|
|
219
|
-
/** Called on 401/UNAUTHENTICATED before the error is thrown. Host app handles token cleanup. */
|
|
220
|
-
onAuthError?: () => void;
|
|
221
|
-
/** Optional: inject a custom logger. Installed into the module logger singleton by the provider. */
|
|
222
|
-
logger?: SheetsLogger;
|
|
223
|
-
/** Optional: called when a grid/editor/mutation/upload error surfaces. Host app handles reporting. */
|
|
224
|
-
onError?: (error: unknown, ctx?: {
|
|
225
|
-
source?: 'grid' | 'editor' | 'mutation' | 'upload';
|
|
226
|
-
tableName?: string;
|
|
227
|
-
}) => void;
|
|
228
|
-
}
|
|
229
|
-
interface SheetsContextValue {
|
|
230
|
-
config: SheetsConfig;
|
|
231
|
-
execute: SheetsExecuteFn;
|
|
232
|
-
executeUpload: SheetsUploadFn;
|
|
233
|
-
storage?: SheetsStorageTransport;
|
|
234
|
-
canUpload: boolean;
|
|
235
|
-
scopeKey: SheetsScopeKey;
|
|
236
|
-
}
|
|
237
|
-
interface SheetsScopeKey {
|
|
238
|
-
databaseId: string | null;
|
|
239
|
-
endpoint: string;
|
|
240
|
-
identityKey: string | null;
|
|
241
|
-
}
|
|
242
|
-
declare const SheetsContext: react.Context<SheetsContextValue | null>;
|
|
243
|
-
declare function useSheetsContext(): SheetsContextValue;
|
|
244
|
-
|
|
245
|
-
export { type AdapterListQuery as A, type CellProps as C, type SheetsExecuteFn as S, type SheetsUploadFn as a, type SheetsConfig as b, type CellTypeDefinition as c, type SheetsCellRenderContext as d, type CellTypeMatchInput as e, type SheetsScopeKey as f, type SheetsFileValue as g, type SheetsBackendAdapter as h, type AdapterListResult as i, type AdapterPageInfo as j, type AdapterTableContext as k, type CellColumnDescriptor as l, type CellTypePlugin as m, type SheetsAuthEmbedded as n, type SheetsAuthStandalone as o, SheetsContext as p, type SheetsContextValue as q, type SheetsLogger as r, type SheetsUploadResult as s, createSheetsExecute as t, createSheetsUpload as u, defineCellType as v, useSheetsContext as w };
|