@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
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
cn
|
|
4
|
+
} from "./chunk-YDQQA46V.js";
|
|
5
|
+
import {
|
|
6
|
+
sheetsLocale
|
|
7
|
+
} from "./chunk-GGECS2BP.js";
|
|
8
|
+
|
|
9
|
+
// src/cell-types/cell-type-groups.ts
|
|
10
|
+
var DATE_TIME_TYPES = /* @__PURE__ */ new Set(["date", "datetime", "timestamptz", "time"]);
|
|
11
|
+
var GEOMETRY_TYPES = /* @__PURE__ */ new Set(["geometry", "geometry-point", "geometry-collection"]);
|
|
12
|
+
var NUMBER_TYPES = /* @__PURE__ */ new Set([
|
|
13
|
+
"number",
|
|
14
|
+
"integer",
|
|
15
|
+
"bigint",
|
|
16
|
+
"decimal",
|
|
17
|
+
"currency",
|
|
18
|
+
"smallint",
|
|
19
|
+
"percentage",
|
|
20
|
+
"rating"
|
|
21
|
+
]);
|
|
22
|
+
var BOOLEAN_TYPES = /* @__PURE__ */ new Set(["boolean", "toggle"]);
|
|
23
|
+
var TABULAR_TEXT_TYPES = /* @__PURE__ */ new Set([
|
|
24
|
+
"date",
|
|
25
|
+
"datetime",
|
|
26
|
+
"timestamptz",
|
|
27
|
+
"time",
|
|
28
|
+
"interval",
|
|
29
|
+
"range",
|
|
30
|
+
"point",
|
|
31
|
+
"vector",
|
|
32
|
+
"bitstring",
|
|
33
|
+
"binary"
|
|
34
|
+
]);
|
|
35
|
+
var CHOICE_TYPES = /* @__PURE__ */ new Set(["select", "multi-select"]);
|
|
36
|
+
var TYPED_ARRAY_TYPES = /* @__PURE__ */ new Set([
|
|
37
|
+
"array",
|
|
38
|
+
"text-array",
|
|
39
|
+
"uuid-array",
|
|
40
|
+
"number-array",
|
|
41
|
+
"integer-array",
|
|
42
|
+
"date-array",
|
|
43
|
+
"tags"
|
|
44
|
+
]);
|
|
45
|
+
function isArrayCellType(cellType) {
|
|
46
|
+
return TYPED_ARRAY_TYPES.has(cellType) || cellType.endsWith("-array");
|
|
47
|
+
}
|
|
48
|
+
var STRUCTURED_DATA_TYPES = /* @__PURE__ */ new Set([
|
|
49
|
+
"json",
|
|
50
|
+
"jsonb",
|
|
51
|
+
"array",
|
|
52
|
+
"text-array",
|
|
53
|
+
"uuid-array",
|
|
54
|
+
"number-array",
|
|
55
|
+
"integer-array",
|
|
56
|
+
"date-array",
|
|
57
|
+
"interval",
|
|
58
|
+
"range",
|
|
59
|
+
"composite",
|
|
60
|
+
"point"
|
|
61
|
+
]);
|
|
62
|
+
var MEDIA_TYPES = /* @__PURE__ */ new Set(["image", "file", "video", "audio", "upload", "attachment"]);
|
|
63
|
+
var ENHANCED_TYPES = /* @__PURE__ */ new Set([
|
|
64
|
+
"email",
|
|
65
|
+
"url",
|
|
66
|
+
"phone",
|
|
67
|
+
"currency",
|
|
68
|
+
"percentage",
|
|
69
|
+
"color",
|
|
70
|
+
"rating",
|
|
71
|
+
"tags"
|
|
72
|
+
]);
|
|
73
|
+
var BUILTIN_EDITOR_TYPES = /* @__PURE__ */ new Set(["text", "varchar"]);
|
|
74
|
+
var NON_EDITABLE_TYPES = /* @__PURE__ */ new Set(["tsvector", "binary", "vector", "unknown"]);
|
|
75
|
+
var VIEWER_ONLY_TYPES = /* @__PURE__ */ new Set(["tsvector", "binary", "vector", "unknown"]);
|
|
76
|
+
|
|
77
|
+
// src/cell-types/date-time-format.ts
|
|
78
|
+
var DATE_RE = /^\d{4,}-\d{2}-\d{2}$/;
|
|
79
|
+
var TIME_RE = /^(\d{1,2}):(\d{2})(?::(\d{2})(\.\d+)?)?(Z|[+-]\d{2}(?::?\d{2})?)?$/;
|
|
80
|
+
var DATE_TIME_RE = /^(\d{4,}-\d{2}-\d{2})[T ](\d{1,2}):(\d{2})(?::(\d{2})(\.\d+)?)?(Z|[+-]\d{2}(?::?\d{2})?)?$/;
|
|
81
|
+
function dateTimeKindOf(cellType) {
|
|
82
|
+
if (cellType === "date") return "date";
|
|
83
|
+
if (cellType === "time") return "time";
|
|
84
|
+
if (cellType === "datetime" || cellType === "timestamptz") return "datetime";
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
function pad2(value) {
|
|
88
|
+
return String(value).padStart(2, "0");
|
|
89
|
+
}
|
|
90
|
+
function shownFraction(fraction) {
|
|
91
|
+
const digits = fraction ? fraction.slice(1).replace(/0+$/, "") : "";
|
|
92
|
+
return digits ? `.${digits}` : "";
|
|
93
|
+
}
|
|
94
|
+
function viewerZoneName(instant, locale = sheetsLocale()) {
|
|
95
|
+
try {
|
|
96
|
+
const part = new Intl.DateTimeFormat(locale, { timeZoneName: "short" }).formatToParts(instant).find((entry) => entry.type === "timeZoneName");
|
|
97
|
+
return part?.value ?? "local time";
|
|
98
|
+
} catch {
|
|
99
|
+
return "local time";
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function instantOf(isoLike) {
|
|
103
|
+
const instant = new Date(isoLike.replace(" ", "T").replace(/(\.\d{3})\d+/, "$1"));
|
|
104
|
+
return Number.isNaN(instant.getTime()) ? null : instant;
|
|
105
|
+
}
|
|
106
|
+
function localDate(instant) {
|
|
107
|
+
return `${String(instant.getFullYear()).padStart(4, "0")}-${pad2(instant.getMonth() + 1)}-${pad2(instant.getDate())}`;
|
|
108
|
+
}
|
|
109
|
+
function localTime(instant) {
|
|
110
|
+
return `${pad2(instant.getHours())}:${pad2(instant.getMinutes())}:${pad2(instant.getSeconds())}`;
|
|
111
|
+
}
|
|
112
|
+
function displayTime(text, locale) {
|
|
113
|
+
const match = TIME_RE.exec(text);
|
|
114
|
+
if (!match) return null;
|
|
115
|
+
const [, hours, minutes, seconds = "00", fraction, zone] = match;
|
|
116
|
+
const tail = shownFraction(fraction);
|
|
117
|
+
if (!zone) return { text: `${pad2(hours)}:${minutes}:${seconds}${tail}`, zone: null };
|
|
118
|
+
const today = /* @__PURE__ */ new Date();
|
|
119
|
+
const day = `${today.getUTCFullYear()}-${pad2(today.getUTCMonth() + 1)}-${pad2(today.getUTCDate())}`;
|
|
120
|
+
const instant = instantOf(`${day}T${pad2(hours)}:${minutes}:${seconds}${zone}`);
|
|
121
|
+
if (!instant) return null;
|
|
122
|
+
return { text: `${localTime(instant)}${tail}`, zone: viewerZoneName(instant, locale) };
|
|
123
|
+
}
|
|
124
|
+
function displayDateTime(text, locale) {
|
|
125
|
+
const match = DATE_TIME_RE.exec(text);
|
|
126
|
+
if (!match) return null;
|
|
127
|
+
const [, date, hours, minutes, seconds = "00", fraction, zone] = match;
|
|
128
|
+
const tail = shownFraction(fraction);
|
|
129
|
+
if (!zone) return { text: `${date} ${pad2(hours)}:${minutes}:${seconds}${tail}`, zone: null };
|
|
130
|
+
const instant = instantOf(text);
|
|
131
|
+
if (!instant) return null;
|
|
132
|
+
return { text: `${localDate(instant)} ${localTime(instant)}${tail}`, zone: viewerZoneName(instant, locale) };
|
|
133
|
+
}
|
|
134
|
+
function formatDateTimeText(text, kind, locale = sheetsLocale()) {
|
|
135
|
+
try {
|
|
136
|
+
const shown = kind === "date" ? DATE_RE.test(text) ? { text, zone: null } : null : kind === "time" ? displayTime(text, locale) : displayDateTime(text, locale);
|
|
137
|
+
return shown ?? { text, zone: null };
|
|
138
|
+
} catch {
|
|
139
|
+
return { text, zone: null };
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function dateTimeTitle(exact, zone) {
|
|
143
|
+
return zone ? `${exact} \xB7 shown in ${zone}` : exact;
|
|
144
|
+
}
|
|
145
|
+
function isTimestampText(text) {
|
|
146
|
+
return DATE_TIME_RE.test(text);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// src/grid/editors/editor-focus-trap.tsx
|
|
150
|
+
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
151
|
+
import { jsx } from "react/jsx-runtime";
|
|
152
|
+
var FOCUSABLE_SELECTOR = [
|
|
153
|
+
"button:not([disabled])",
|
|
154
|
+
"input:not([disabled])",
|
|
155
|
+
"textarea:not([disabled])",
|
|
156
|
+
"select:not([disabled])",
|
|
157
|
+
"a[href]",
|
|
158
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
159
|
+
].join(", ");
|
|
160
|
+
function getVisibleFocusable(container) {
|
|
161
|
+
return Array.from(container.querySelectorAll(FOCUSABLE_SELECTOR)).filter(
|
|
162
|
+
(el) => el.offsetParent !== null
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
function EditorFocusTrap({ children, onEscape, onKeyDown, className, style }) {
|
|
166
|
+
const containerRef = useRef(null);
|
|
167
|
+
const [previousActiveElement] = useState(() => typeof document === "undefined" ? null : document.activeElement);
|
|
168
|
+
useLayoutEffect(() => {
|
|
169
|
+
if (!containerRef.current) return;
|
|
170
|
+
const visibleElements = getVisibleFocusable(containerRef.current);
|
|
171
|
+
if (visibleElements.length > 0) {
|
|
172
|
+
visibleElements[0].focus();
|
|
173
|
+
} else {
|
|
174
|
+
containerRef.current.focus();
|
|
175
|
+
}
|
|
176
|
+
}, []);
|
|
177
|
+
useEffect(() => {
|
|
178
|
+
return () => {
|
|
179
|
+
if (previousActiveElement instanceof HTMLElement && previousActiveElement.isConnected) {
|
|
180
|
+
previousActiveElement.focus();
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
}, [previousActiveElement]);
|
|
184
|
+
const handleKeyDown = useCallback(
|
|
185
|
+
(e) => {
|
|
186
|
+
onKeyDown?.(e);
|
|
187
|
+
if (e.key === "Escape") {
|
|
188
|
+
e.preventDefault();
|
|
189
|
+
e.stopPropagation();
|
|
190
|
+
onEscape?.();
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (e.key !== "Tab") return;
|
|
194
|
+
const container = containerRef.current;
|
|
195
|
+
if (!container) return;
|
|
196
|
+
const focusableElements = getVisibleFocusable(container);
|
|
197
|
+
if (focusableElements.length === 0) return;
|
|
198
|
+
const firstElement = focusableElements[0];
|
|
199
|
+
const lastElement = focusableElements[focusableElements.length - 1];
|
|
200
|
+
const activeElement = document.activeElement;
|
|
201
|
+
if (e.shiftKey) {
|
|
202
|
+
if (activeElement === firstElement) {
|
|
203
|
+
e.preventDefault();
|
|
204
|
+
lastElement.focus();
|
|
205
|
+
}
|
|
206
|
+
} else {
|
|
207
|
+
if (activeElement === lastElement) {
|
|
208
|
+
e.preventDefault();
|
|
209
|
+
firstElement.focus();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
[onEscape, onKeyDown]
|
|
214
|
+
);
|
|
215
|
+
return /* @__PURE__ */ jsx(
|
|
216
|
+
"div",
|
|
217
|
+
{
|
|
218
|
+
ref: containerRef,
|
|
219
|
+
className,
|
|
220
|
+
style,
|
|
221
|
+
onKeyDown: handleKeyDown,
|
|
222
|
+
tabIndex: -1,
|
|
223
|
+
role: "dialog",
|
|
224
|
+
"aria-modal": "true",
|
|
225
|
+
children
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// src/grid/editors/editor-frame.tsx
|
|
231
|
+
import { Button } from "@constructive-io/ui/button";
|
|
232
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
233
|
+
var MAC_UA_RE = /Mac|iPod|iPhone|iPad/;
|
|
234
|
+
function modifierKeyLabel() {
|
|
235
|
+
return typeof navigator !== "undefined" && MAC_UA_RE.test(navigator.userAgent) ? "\u2318" : "Ctrl";
|
|
236
|
+
}
|
|
237
|
+
var VALUE_REQUIRED_REASON = "This field cannot be empty.";
|
|
238
|
+
function editorClear(nullable, onClear) {
|
|
239
|
+
return nullable ? { onClear } : { reason: VALUE_REQUIRED_REASON };
|
|
240
|
+
}
|
|
241
|
+
function EditorHeader({ title, titleHint, chip, children, className }) {
|
|
242
|
+
return /* @__PURE__ */ jsxs("div", { "data-slot": "editor-header", className: cn("flex items-center justify-between gap-2", className), children: [
|
|
243
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-h-7 min-w-0 items-center gap-2", children: [
|
|
244
|
+
/* @__PURE__ */ jsx2("h3", { className: "truncate text-sm font-medium", title: titleHint, children: title }),
|
|
245
|
+
chip ? /* @__PURE__ */ jsx2("span", { className: "bg-muted text-muted-foreground shrink-0 rounded-md px-2 py-0.5 text-xs font-medium", children: chip }) : null
|
|
246
|
+
] }),
|
|
247
|
+
children
|
|
248
|
+
] });
|
|
249
|
+
}
|
|
250
|
+
function EditorFooter({ onSave, saveShortcut, saveBlockedReason, clear, status, className }) {
|
|
251
|
+
const blocked = Boolean(saveBlockedReason);
|
|
252
|
+
return /* @__PURE__ */ jsxs("div", { "data-slot": "editor-footer", className: cn("flex items-center justify-end gap-2 border-t pt-2", className), children: [
|
|
253
|
+
status ? /* @__PURE__ */ jsx2("div", { className: "me-auto min-w-0 truncate text-xs", children: status }) : null,
|
|
254
|
+
clear ? "onClear" in clear ? /* @__PURE__ */ jsx2(Button, { size: "xs", variant: "ghost", onClick: clear.onClear, title: "Remove the value", children: "Clear" }) : /* @__PURE__ */ jsx2(Button, { size: "xs", variant: "ghost", disabled: true, focusableWhenDisabled: true, title: clear.reason, children: "Clear" }) : null,
|
|
255
|
+
/* @__PURE__ */ jsx2(
|
|
256
|
+
Button,
|
|
257
|
+
{
|
|
258
|
+
size: "xs",
|
|
259
|
+
onClick: onSave,
|
|
260
|
+
disabled: blocked,
|
|
261
|
+
focusableWhenDisabled: blocked,
|
|
262
|
+
title: blocked ? saveBlockedReason ?? void 0 : saveShortcut ? `Save (${saveShortcut})` : void 0,
|
|
263
|
+
children: "Save"
|
|
264
|
+
}
|
|
265
|
+
)
|
|
266
|
+
] });
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// src/grid/editors/overlay-presets.ts
|
|
270
|
+
var OVERLAY_SM = "min-w-[320px] max-w-[480px]";
|
|
271
|
+
var OVERLAY_MD = "min-w-[400px] max-w-[560px]";
|
|
272
|
+
var OVERLAY_LG = "min-w-[480px] max-w-[720px]";
|
|
273
|
+
var OVERLAY_XL = "min-w-[600px] max-w-4xl";
|
|
274
|
+
var OVERLAY = {
|
|
275
|
+
sm: OVERLAY_SM,
|
|
276
|
+
md: OVERLAY_MD,
|
|
277
|
+
lg: OVERLAY_LG,
|
|
278
|
+
xl: OVERLAY_XL
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
export {
|
|
282
|
+
DATE_TIME_TYPES,
|
|
283
|
+
GEOMETRY_TYPES,
|
|
284
|
+
NUMBER_TYPES,
|
|
285
|
+
BOOLEAN_TYPES,
|
|
286
|
+
TABULAR_TEXT_TYPES,
|
|
287
|
+
CHOICE_TYPES,
|
|
288
|
+
TYPED_ARRAY_TYPES,
|
|
289
|
+
isArrayCellType,
|
|
290
|
+
STRUCTURED_DATA_TYPES,
|
|
291
|
+
MEDIA_TYPES,
|
|
292
|
+
ENHANCED_TYPES,
|
|
293
|
+
BUILTIN_EDITOR_TYPES,
|
|
294
|
+
NON_EDITABLE_TYPES,
|
|
295
|
+
VIEWER_ONLY_TYPES,
|
|
296
|
+
dateTimeKindOf,
|
|
297
|
+
formatDateTimeText,
|
|
298
|
+
dateTimeTitle,
|
|
299
|
+
isTimestampText,
|
|
300
|
+
EditorFocusTrap,
|
|
301
|
+
modifierKeyLabel,
|
|
302
|
+
VALUE_REQUIRED_REASON,
|
|
303
|
+
editorClear,
|
|
304
|
+
EditorHeader,
|
|
305
|
+
EditorFooter,
|
|
306
|
+
OVERLAY_SM,
|
|
307
|
+
OVERLAY_MD,
|
|
308
|
+
OVERLAY_LG,
|
|
309
|
+
OVERLAY_XL,
|
|
310
|
+
OVERLAY
|
|
311
|
+
};
|
|
312
|
+
//# sourceMappingURL=chunk-CJ4PRA64.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cell-types/cell-type-groups.ts","../src/cell-types/date-time-format.ts","../src/grid/editors/editor-focus-trap.tsx","../src/grid/editors/editor-frame.tsx","../src/grid/editors/overlay-presets.ts"],"sourcesContent":["/**\n * Canonical cell-type group constants.\n *\n * Every file that needs to check \"is this cell type a date?\" or \"is this a\n * geometry?\" should import from here instead of maintaining inline arrays.\n *\n * All Sets are typed as `Set<string>` so `.has(cellType)` works without casts.\n */\n\n// ─── Date / Time ────────────────────────────────────────────────────────────\nexport const DATE_TIME_TYPES: Set<string> = new Set(['date', 'datetime', 'timestamptz', 'time']);\n\n// ─── Geometry ───────────────────────────────────────────────────────────────\nexport const GEOMETRY_TYPES: Set<string> = new Set(['geometry', 'geometry-point', 'geometry-collection']);\n\n// ─── Numeric ────────────────────────────────────────────────────────────────\nexport const NUMBER_TYPES: Set<string> = new Set([\n\t'number',\n\t'integer',\n\t'bigint',\n\t'decimal',\n\t'currency',\n\t'smallint',\n\t'percentage',\n\t'rating',\n]);\n\n// ─── Boolean ────────────────────────────────────────────────────────────────\n// A bit string (`bit`, `bitstring`) is text of 0 and 1, never a checkbox.\nexport const BOOLEAN_TYPES: Set<string> = new Set(['boolean', 'toggle']);\n\n// ─── Exact decimal strings ──────────────────────────────────────────────────\n/** Numbers carried as exact decimal strings end to end; never parsed into a JS number. */\nexport const DECIMAL_STRING_TYPES: Set<string> = new Set(['bigint', 'decimal']);\n\n// ─── Tabular figures ────────────────────────────────────────────────────────\n/**\n * Text cell types whose values are mostly digits read down a column (dates, times,\n * durations, ranges, points, vectors, bit strings): they use tabular figures so the\n * digits line up. Number cells always do.\n */\nexport const TABULAR_TEXT_TYPES: Set<string> = new Set([\n\t'date',\n\t'datetime',\n\t'timestamptz',\n\t'time',\n\t'interval',\n\t'range',\n\t'point',\n\t'vector',\n\t'bitstring',\n\t'binary',\n]);\n\n// ─── Choices ────────────────────────────────────────────────────────────────\n/** A fixed list of values: an enum, or text with an allowed-values list. */\nexport const CHOICE_TYPES: Set<string> = new Set(['select', 'multi-select']);\n\n// ─── Array / Collection ─────────────────────────────────────────────────────\nexport const TYPED_ARRAY_TYPES: Set<string> = new Set([\n\t'array',\n\t'text-array',\n\t'uuid-array',\n\t'number-array',\n\t'integer-array',\n\t'date-array',\n\t'tags',\n]);\n\n/** Check for any array-like cell type (typed arrays + generic `-array` suffix) */\nexport function isArrayCellType(cellType: string): boolean {\n\treturn TYPED_ARRAY_TYPES.has(cellType) || cellType.endsWith('-array');\n}\n\n// ─── Structured data (JSON, arrays, interval) ──────────────────────────────\nexport const STRUCTURED_DATA_TYPES: Set<string> = new Set([\n\t'json',\n\t'jsonb',\n\t'array',\n\t'text-array',\n\t'uuid-array',\n\t'number-array',\n\t'integer-array',\n\t'date-array',\n\t'interval',\n\t'range',\n\t'composite',\n\t'point',\n]);\n\n// ─── Media ──────────────────────────────────────────────────────────────────\nexport const MEDIA_TYPES: Set<string> = new Set(['image', 'file', 'video', 'audio', 'upload', 'attachment']);\n\n// ─── Enhanced scalar types ──────────────────────────────────────────────────\nexport const ENHANCED_TYPES: Set<string> = new Set([\n\t'email',\n\t'url',\n\t'phone',\n\t'currency',\n\t'percentage',\n\t'color',\n\t'rating',\n\t'tags',\n]);\n\n// ─── Editor behaviour ───────────────────────────────────────────────────────\n\n/** Cell types that use Glide's built-in text editor (no custom overlay). */\nexport const BUILTIN_EDITOR_TYPES: Set<string> = new Set(['text', 'varchar']);\n\n/** Cell types that are never editable (always read-only). */\nexport const NON_EDITABLE_TYPES: Set<string> = new Set(['tsvector', 'binary', 'vector', 'unknown']);\n\n/** Cell types that open a read-only viewer (show and copy the value) instead of an editor. */\nexport const VIEWER_ONLY_TYPES: Set<string> = new Set(['tsvector', 'binary', 'vector', 'unknown']);\n","// How dates and times read in cells, range cells, the record panel and the date editor's\n// value line. One rule (team decision):\n//\n// - A date stays as stored, \"YYYY-MM-DD\": readable and exact.\n// - A time or a date and time reads \"HH:mm:ss\" / \"YYYY-MM-DD HH:mm:ss\": no \"T\", the\n// fraction of a second only when it is not zero (all its non-zero digits), no offset.\n// - A value with a zone (timestamp with zone, time with zone) is shown in the viewer's\n// zone, the same zone the date editor edits in; the element's title carries the exact\n// stored text and that zone (\"… · shown in GMT+7\").\n// - A value without a zone shows its stored wall time, unconverted.\n//\n// Only the display changes: copy, export, paste and writes keep the exact stored text.\n\nimport { sheetsLocale } from '../utils/sheets-i18n';\n\nconst DATE_RE = /^\\d{4,}-\\d{2}-\\d{2}$/;\nconst TIME_RE = /^(\\d{1,2}):(\\d{2})(?::(\\d{2})(\\.\\d+)?)?(Z|[+-]\\d{2}(?::?\\d{2})?)?$/;\nconst DATE_TIME_RE = /^(\\d{4,}-\\d{2}-\\d{2})[T ](\\d{1,2}):(\\d{2})(?::(\\d{2})(\\.\\d+)?)?(Z|[+-]\\d{2}(?::?\\d{2})?)?$/;\n\n/** The kinds of date and time text, by cell type. */\nexport type DateTimeKind = 'date' | 'time' | 'datetime';\n\nexport function dateTimeKindOf(cellType: string | undefined): DateTimeKind | null {\n\tif (cellType === 'date') return 'date';\n\tif (cellType === 'time') return 'time';\n\tif (cellType === 'datetime' || cellType === 'timestamptz') return 'datetime';\n\treturn null;\n}\n\nexport interface DateTimeDisplay {\n\t/** What the element shows. */\n\ttext: string;\n\t/** The viewer's zone the text is shown in (\"GMT+7\"), for a zoned value; else null. */\n\tzone: string | null;\n}\n\nfunction pad2(value: number | string): string {\n\treturn String(value).padStart(2, '0');\n}\n\n/** \".123400\" -> \".1234\"; \".000000\" -> \"\". */\nfunction shownFraction(fraction: string | undefined): string {\n\tconst digits = fraction ? fraction.slice(1).replace(/0+$/, '') : '';\n\treturn digits ? `.${digits}` : '';\n}\n\n/** The viewer's zone at an instant, as the locale names it briefly (\"GMT+7\", \"PST\"). */\nexport function viewerZoneName(instant: Date, locale: string = sheetsLocale()): string {\n\ttry {\n\t\tconst part = new Intl.DateTimeFormat(locale, { timeZoneName: 'short' })\n\t\t\t.formatToParts(instant)\n\t\t\t.find((entry) => entry.type === 'timeZoneName');\n\t\treturn part?.value ?? 'local time';\n\t} catch {\n\t\treturn 'local time';\n\t}\n}\n\n/** A Date for stored text with an offset; microseconds are cut to what Date holds (the shown fraction comes from the text). */\nfunction instantOf(isoLike: string): Date | null {\n\tconst instant = new Date(isoLike.replace(' ', 'T').replace(/(\\.\\d{3})\\d+/, '$1'));\n\treturn Number.isNaN(instant.getTime()) ? null : instant;\n}\n\nfunction localDate(instant: Date): string {\n\treturn `${String(instant.getFullYear()).padStart(4, '0')}-${pad2(instant.getMonth() + 1)}-${pad2(instant.getDate())}`;\n}\n\nfunction localTime(instant: Date): string {\n\treturn `${pad2(instant.getHours())}:${pad2(instant.getMinutes())}:${pad2(instant.getSeconds())}`;\n}\n\nfunction displayTime(text: string, locale: string): DateTimeDisplay | null {\n\tconst match = TIME_RE.exec(text);\n\tif (!match) return null;\n\tconst [, hours, minutes, seconds = '00', fraction, zone] = match;\n\tconst tail = shownFraction(fraction);\n\tif (!zone) return { text: `${pad2(hours!)}:${minutes}:${seconds}${tail}`, zone: null };\n\t// A time of day has no date; today's date gives the viewer's offset in effect now.\n\tconst today = new Date();\n\tconst day = `${today.getUTCFullYear()}-${pad2(today.getUTCMonth() + 1)}-${pad2(today.getUTCDate())}`;\n\tconst instant = instantOf(`${day}T${pad2(hours!)}:${minutes}:${seconds}${zone}`);\n\tif (!instant) return null;\n\treturn { text: `${localTime(instant)}${tail}`, zone: viewerZoneName(instant, locale) };\n}\n\nfunction displayDateTime(text: string, locale: string): DateTimeDisplay | null {\n\tconst match = DATE_TIME_RE.exec(text);\n\tif (!match) return null;\n\tconst [, date, hours, minutes, seconds = '00', fraction, zone] = match;\n\tconst tail = shownFraction(fraction);\n\tif (!zone) return { text: `${date} ${pad2(hours!)}:${minutes}:${seconds}${tail}`, zone: null };\n\t// Offsets are whole minutes, so the seconds and their fraction are the same in every zone.\n\tconst instant = instantOf(text);\n\tif (!instant) return null;\n\treturn { text: `${localDate(instant)} ${localTime(instant)}${tail}`, zone: viewerZoneName(instant, locale) };\n}\n\n/** Date or time text as it is shown. Text that does not match its kind is shown as it is. */\nexport function formatDateTimeText(text: string, kind: DateTimeKind, locale: string = sheetsLocale()): DateTimeDisplay {\n\ttry {\n\t\tconst shown = kind === 'date' ? (DATE_RE.test(text) ? { text, zone: null } : null) : kind === 'time' ? displayTime(text, locale) : displayDateTime(text, locale);\n\t\treturn shown ?? { text, zone: null };\n\t} catch {\n\t\treturn { text, zone: null };\n\t}\n}\n\n/** The title for a shown date or time: the exact stored text, and the zone it is shown in. */\nexport function dateTimeTitle(exact: string, zone: string | null): string {\n\treturn zone ? `${exact} · shown in ${zone}` : exact;\n}\n\n/** True for date-and-time text (\"2024-01-01T00:00:00+00:00\"); false for a date alone or other text. */\nexport function isTimestampText(text: string): boolean {\n\treturn DATE_TIME_RE.test(text);\n}\n","import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';\n\ninterface EditorFocusTrapProps {\n\tchildren: React.ReactNode;\n\tonEscape?: () => void;\n\tonKeyDown?: (e: React.KeyboardEvent) => void;\n\tclassName?: string;\n\tstyle?: React.CSSProperties;\n}\n\nconst FOCUSABLE_SELECTOR = [\n\t'button:not([disabled])',\n\t'input:not([disabled])',\n\t'textarea:not([disabled])',\n\t'select:not([disabled])',\n\t'a[href]',\n\t'[tabindex]:not([tabindex=\"-1\"])',\n].join(', ');\n\n/** Filter to only truly visible focusable elements */\nfunction getVisibleFocusable(container: HTMLElement): HTMLElement[] {\n\treturn Array.from(container.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)).filter(\n\t\t(el) => el.offsetParent !== null,\n\t);\n}\n\nexport function EditorFocusTrap({ children, onEscape, onKeyDown, className, style }: EditorFocusTrapProps) {\n\tconst containerRef = useRef<HTMLDivElement>(null);\n\t// The element to give focus back to on close (the grid, or the button that opened the\n\t// editor). Read on the first render, before any child mounts: an `autoFocus` input inside\n\t// the editor takes focus during the commit, before this component's own effects run.\n\tconst [previousActiveElement] = useState<Element | null>(() => (typeof document === 'undefined' ? null : document.activeElement));\n\n\t// Focus the first visible focusable element synchronously before paint, so the\n\t// editor input is focused instantly on open (no setTimeout settle, no focus-jump\n\t// off an input the user already started typing in). Runs once on mount.\n\tuseLayoutEffect(() => {\n\t\tif (!containerRef.current) return;\n\n\t\tconst visibleElements = getVisibleFocusable(containerRef.current);\n\t\tif (visibleElements.length > 0) {\n\t\t\tvisibleElements[0].focus();\n\t\t} else {\n\t\t\t// If no visible focusable elements, focus the container itself\n\t\t\tcontainerRef.current.focus();\n\t\t}\n\t}, []);\n\n\t// Restore focus to the previously active element when unmounting (only if still\n\t// in DOM).\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tif (previousActiveElement instanceof HTMLElement && previousActiveElement.isConnected) {\n\t\t\t\tpreviousActiveElement.focus();\n\t\t\t}\n\t\t};\n\t}, [previousActiveElement]);\n\n\t// Handle keyboard events — forward all keys to parent, then handle Escape/Tab\n\tconst handleKeyDown = useCallback(\n\t\t(e: React.KeyboardEvent) => {\n\t\t\t// Forward all key events to parent before handling\n\t\t\tonKeyDown?.(e);\n\n\t\t\tif (e.key === 'Escape') {\n\t\t\t\te.preventDefault();\n\t\t\t\te.stopPropagation();\n\t\t\t\tonEscape?.();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (e.key !== 'Tab') return;\n\n\t\t\tconst container = containerRef.current;\n\t\t\tif (!container) return;\n\n\t\t\tconst focusableElements = getVisibleFocusable(container);\n\t\t\tif (focusableElements.length === 0) return;\n\n\t\t\tconst firstElement = focusableElements[0];\n\t\t\tconst lastElement = focusableElements[focusableElements.length - 1];\n\t\t\tconst activeElement = document.activeElement;\n\n\t\t\tif (e.shiftKey) {\n\t\t\t\t// Shift+Tab: going backwards\n\t\t\t\tif (activeElement === firstElement) {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tlastElement.focus();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Tab: going forwards\n\t\t\t\tif (activeElement === lastElement) {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tfirstElement.focus();\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[onEscape, onKeyDown],\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tref={containerRef}\n\t\t\tclassName={className}\n\t\t\tstyle={style}\n\t\t\tonKeyDown={handleKeyDown}\n\t\t\ttabIndex={-1}\n\t\t\trole=\"dialog\"\n\t\t\taria-modal=\"true\"\n\t\t>\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n","'use client';\n\n// The parts every value editor shares, so their frames read the same: a title row (the\n// field's readable name, an optional chip for the kind of value, optional controls on\n// the right) and a footer with Clear and Save. Keyboard shortcuts are in the buttons'\n// titles, not printed in the popover.\n\nimport type { ReactNode } from 'react';\n\nimport { Button } from '@constructive-io/ui/button';\n\nimport { cn } from '../../utils/cn';\n\nconst MAC_UA_RE = /Mac|iPod|iPhone|iPad/;\n\n/** The platform's name for the modifier key in a shortcut (\"⌘\" or \"Ctrl\"). */\nexport function modifierKeyLabel(): string {\n\treturn typeof navigator !== 'undefined' && MAC_UA_RE.test(navigator.userAgent) ? '⌘' : 'Ctrl';\n}\n\n/** Why Clear is not offered: the column requires a value. */\nexport const VALUE_REQUIRED_REASON = 'This field cannot be empty.';\n\n/** Clear for a nullable column, or the reason it cannot be cleared. */\nexport type EditorClear = { onClear: () => void } | { reason: string };\n\nexport function editorClear(nullable: boolean | undefined, onClear: () => void): EditorClear {\n\treturn nullable ? { onClear } : { reason: VALUE_REQUIRED_REASON };\n}\n\ninterface EditorHeaderProps {\n\ttitle: string;\n\t/** Extra detail on hover (the field's API name, for example). */\n\ttitleHint?: string;\n\t/** The kind of value, when it helps (a shape kind, for example). */\n\tchip?: string | null;\n\t/** Controls on the right (a mode switch). */\n\tchildren?: ReactNode;\n\tclassName?: string;\n}\n\nexport function EditorHeader({ title, titleHint, chip, children, className }: EditorHeaderProps) {\n\treturn (\n\t\t<div data-slot='editor-header' className={cn('flex items-center justify-between gap-2', className)}>\n\t\t\t{/* As tall as a small switch, so a header is the same height with or without one. */}\n\t\t\t<div className='flex min-h-7 min-w-0 items-center gap-2'>\n\t\t\t\t<h3 className='truncate text-sm font-medium' title={titleHint}>\n\t\t\t\t\t{title}\n\t\t\t\t</h3>\n\t\t\t\t{chip ? (\n\t\t\t\t\t<span className='bg-muted text-muted-foreground shrink-0 rounded-md px-2 py-0.5 text-xs font-medium'>{chip}</span>\n\t\t\t\t) : null}\n\t\t\t</div>\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n\ninterface EditorFooterProps {\n\tonSave: () => void;\n\t/** The keys that save, for the Save button's title (\"Enter\", or \"⌘ Enter\"). */\n\tsaveShortcut?: string;\n\t/** Why Save is not available (an invalid value), shown as its title. */\n\tsaveBlockedReason?: string | null;\n\t/** Clear, or why the value cannot be cleared; omitted when clearing does not apply. */\n\tclear?: EditorClear | null;\n\t/** A short status on the left, such as why the value is not valid. */\n\tstatus?: ReactNode;\n\tclassName?: string;\n}\n\nexport function EditorFooter({ onSave, saveShortcut, saveBlockedReason, clear, status, className }: EditorFooterProps) {\n\tconst blocked = Boolean(saveBlockedReason);\n\treturn (\n\t\t<div data-slot='editor-footer' className={cn('flex items-center justify-end gap-2 border-t pt-2', className)}>\n\t\t\t{status ? <div className='me-auto min-w-0 truncate text-xs'>{status}</div> : null}\n\t\t\t{clear ? (\n\t\t\t\t'onClear' in clear ? (\n\t\t\t\t\t<Button size='xs' variant='ghost' onClick={clear.onClear} title='Remove the value'>\n\t\t\t\t\t\tClear\n\t\t\t\t\t</Button>\n\t\t\t\t) : (\n\t\t\t\t\t<Button size='xs' variant='ghost' disabled focusableWhenDisabled title={clear.reason}>\n\t\t\t\t\t\tClear\n\t\t\t\t\t</Button>\n\t\t\t\t)\n\t\t\t) : null}\n\t\t\t<Button\n\t\t\t\tsize='xs'\n\t\t\t\tonClick={onSave}\n\t\t\t\tdisabled={blocked}\n\t\t\t\tfocusableWhenDisabled={blocked}\n\t\t\t\ttitle={blocked ? saveBlockedReason ?? undefined : saveShortcut ? `Save (${saveShortcut})` : undefined}\n\t\t\t>\n\t\t\t\tSave\n\t\t\t</Button>\n\t\t</div>\n\t);\n}\n","/**\n * Standardised overlay width presets for cell editors.\n *\n * Each preset defines `min-w` / `max-w` Tailwind classes so every overlay\n * feels consistent while still fitting its content naturally.\n *\n * Usage:\n * import { OVERLAY } from './overlay-presets';\n * <EditorFocusTrap className={cn(OVERLAY.sm, 'bg-popover …')} />\n */\n\n/** Single-input editors — inet, date, interval, time */\nexport const OVERLAY_SM = 'min-w-[320px] max-w-[480px]';\n\n/** Tag chips / expandable lists — array, url, relation, upload, tsvector */\nexport const OVERLAY_MD = 'min-w-[400px] max-w-[560px]';\n\n/** Rich editors — JSON, image */\nexport const OVERLAY_LG = 'min-w-[480px] max-w-[720px]';\n\n/** Full-width editors — geometry / map */\nexport const OVERLAY_XL = 'min-w-[600px] max-w-4xl';\n\nexport const OVERLAY = {\n\tsm: OVERLAY_SM,\n\tmd: OVERLAY_MD,\n\tlg: OVERLAY_LG,\n\txl: OVERLAY_XL,\n} as const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AAM,aAAa;AAGnB,IAAM,aAAa;AAEnB,IAAM,UAAU;AAAA,EACtB,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACL;","names":["jsx"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/context/sheets-context.ts
|
|
4
|
+
import { createContext, useContext } from "react";
|
|
5
|
+
var SheetsContext = createContext(null);
|
|
6
|
+
function useSheetsContext() {
|
|
7
|
+
const ctx = useContext(SheetsContext);
|
|
8
|
+
if (!ctx) {
|
|
9
|
+
throw new Error("useSheetsContext must be used within a <SheetsProvider>");
|
|
10
|
+
}
|
|
11
|
+
return ctx;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
SheetsContext,
|
|
16
|
+
useSheetsContext
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=chunk-II3MSNRO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/context/sheets-context.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport type { QueryClient } from '@tanstack/react-query';\n\nimport type { DisplayFieldOverrides } from '@constructive-io/data';\n\nimport type { SheetsExecuteFn, SheetsUploadFn } from './sheets-execute';\nimport type { SheetsLogger } from '../utils/sheets-logger';\nimport type { CellTypePlugin } from '../cell-types/define-cell-type';\nimport type { SheetsBackendAdapter } from '../adapter/sheets-adapter';\nimport type { SheetsUploadConfig } from '../uploads/upload-config';\nimport type { SheetsViewStorage } from '../grid/views/view-storage';\nimport type { SheetsMapConfig } from '../utils/map-settings';\n\nexport interface SheetsAuthEmbedded {\n\tmode: 'embedded';\n\tgetToken: () => string | null;\n\t/**\n\t * Stable, non-secret identity used to isolate cached data between users.\n\t * Hosts should return the authenticated user/session id, never the token.\n\t * When omitted, the provider uses an opaque key that changes with the token.\n\t */\n\tgetIdentityKey?: () => string | null;\n}\n\nexport interface SheetsAuthStandalone {\n\tmode: 'standalone';\n}\n\nexport interface SheetsStorageTransport {\n\tendpoint: string;\n\texecute: SheetsExecuteFn;\n}\n\nexport interface SheetsConfig {\n\t/** Data endpoint (app-public GraphQL) */\n\tendpoint: string;\n\t/** Auth endpoint (auth GraphQL) — required for standalone mode */\n\tauthEndpoint?: string;\n\t/** Database ID for multi-tenant scoping */\n\tdatabaseId?: string;\n\t/** Auth mode */\n\tauth: SheetsAuthEmbedded | SheetsAuthStandalone;\n\t/** Field type overrides (replaces schema-builder smart tags) */\n\tfieldTypeOverrides?: Record<string, string>;\n\t/**\n\t * Fields that label a record of a table (relation chips, pickers, record\n\t * titles), keyed by `TableModel.key` or table name, in priority order.\n\t * Tables without an entry use the built-in display rule.\n\t */\n\tdisplayFields?: DisplayFieldOverrides;\n\t/** Optional: BCP-47 locale for locale-aware date/number formatting (default 'en-US'). */\n\tlocale?: string;\n\t/**\n\t * The geometry editor's map: tile URL and attribution, and the place search endpoint.\n\t * Default: OpenStreetMap tiles and Nominatim search. `tiles: 'off'` edits shapes as\n\t * GeoJSON text; `placeSearch: 'off'` removes the search box. With a\n\t * Content-Security-Policy, allow the tile host in `img-src` and the search endpoint in\n\t * `connect-src`.\n\t */\n\tmap?: SheetsMapConfig;\n\t/** Optional: inject custom execute function */\n\texecute?: SheetsExecuteFn;\n\t/** Optional: inject custom upload function */\n\texecuteUpload?: SheetsUploadFn;\n\t/** Storage endpoint for media uploads and download URL lookups. */\n\tstorage?: { endpoint: string; execute?: SheetsExecuteFn };\n\t/** Upload choices (bucket, owner, files table, per-column overrides); every field is optional. */\n\tupload?: SheetsUploadConfig;\n\t/**\n\t * Where saved views are kept. Default: this browser's local storage, keyed by endpoint,\n\t * database, identity and table. A host can supply server storage.\n\t */\n\tviews?: SheetsViewStorage;\n\t/** Optional: inject existing QueryClient */\n\tqueryClient?: QueryClient;\n\t/** Optional: inject a custom backend adapter. Defaults to the PostGraphile adapter. */\n\tadapter?: SheetsBackendAdapter;\n\t/** Optional: provider-level cell-type plugins (consumer override layer). */\n\tplugins?: CellTypePlugin[];\n\t/** Called on 401/UNAUTHENTICATED before the error is thrown. Host app handles token cleanup. */\n\tonAuthError?: () => void;\n\t/** Optional: inject a custom logger. Installed into the module logger singleton by the provider. */\n\tlogger?: SheetsLogger;\n\t/** Optional: called when a grid/editor/mutation/upload error surfaces. Host app handles reporting. */\n\tonError?: (\n\t\terror: unknown,\n\t\tctx?: { source?: 'grid' | 'editor' | 'mutation' | 'upload'; tableName?: string },\n\t) => void;\n}\n\nexport interface SheetsContextValue {\n\tconfig: SheetsConfig;\n\texecute: SheetsExecuteFn;\n\texecuteUpload: SheetsUploadFn;\n\tstorage?: SheetsStorageTransport;\n\tcanUpload: boolean;\n\tscopeKey: SheetsScopeKey;\n}\n\nexport interface SheetsScopeKey {\n\tdatabaseId: string | null;\n\tendpoint: string;\n\tidentityKey: string | null;\n}\n\nexport const SheetsContext = createContext<SheetsContextValue | null>(null);\n\nexport function useSheetsContext(): SheetsContextValue {\n\tconst ctx = useContext(SheetsContext);\n\tif (!ctx) {\n\t\tthrow new Error('useSheetsContext must be used within a <SheetsProvider>');\n\t}\n\treturn ctx;\n}\n"],"mappings":";;;AAAA,SAAS,eAAe,kBAAkB;AAyGnC,IAAM,gBAAgB,cAAyC,IAAI;AAEnE,SAAS,mBAAuC;AACtD,QAAM,MAAM,WAAW,aAAa;AACpC,MAAI,CAAC,KAAK;AACT,UAAM,IAAI,MAAM,yDAAyD;AAAA,EAC1E;AACA,SAAO;AACR;","names":[]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
-
setStoredToken
|
|
4
|
-
} from "./chunk-4EZ6A23C.js";
|
|
5
|
-
import {
|
|
6
|
-
useSheetsContext,
|
|
3
|
+
setStoredToken,
|
|
7
4
|
useSheetsStore,
|
|
8
5
|
useSheetsStoreApi
|
|
9
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ZOQDSOMO.js";
|
|
7
|
+
import {
|
|
8
|
+
useSheetsContext
|
|
9
|
+
} from "./chunk-II3MSNRO.js";
|
|
10
10
|
import {
|
|
11
11
|
cn
|
|
12
12
|
} from "./chunk-YDQQA46V.js";
|
|
@@ -1285,4 +1285,4 @@ export {
|
|
|
1285
1285
|
useSheetsResetPassword,
|
|
1286
1286
|
SheetsAuthGate
|
|
1287
1287
|
};
|
|
1288
|
-
//# sourceMappingURL=chunk-
|
|
1288
|
+
//# sourceMappingURL=chunk-J7KK4UWI.js.map
|