@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.
Files changed (60) hide show
  1. package/README.md +231 -157
  2. package/dist/advanced.cjs +7192 -3840
  3. package/dist/advanced.cjs.map +1 -1
  4. package/dist/advanced.d.cts +2 -2
  5. package/dist/advanced.d.ts +2 -2
  6. package/dist/advanced.js +5 -5
  7. package/dist/auth.cjs.map +1 -1
  8. package/dist/auth.js +3 -3
  9. package/dist/chunk-CJ4PRA64.js +312 -0
  10. package/dist/chunk-CJ4PRA64.js.map +1 -0
  11. package/dist/chunk-II3MSNRO.js +18 -0
  12. package/dist/chunk-II3MSNRO.js.map +1 -0
  13. package/dist/{chunk-BYAYBXVB.js → chunk-J7KK4UWI.js} +6 -6
  14. package/dist/chunk-MBSHDF55.js +839 -0
  15. package/dist/chunk-MBSHDF55.js.map +1 -0
  16. package/dist/chunk-MOFFS5WQ.js +128 -0
  17. package/dist/chunk-MOFFS5WQ.js.map +1 -0
  18. package/dist/chunk-VCBY2AMT.js +8920 -0
  19. package/dist/chunk-VCBY2AMT.js.map +1 -0
  20. package/dist/{chunk-YJZFHL2D.js → chunk-ZOQDSOMO.js} +50 -312
  21. package/dist/chunk-ZOQDSOMO.js.map +1 -0
  22. package/dist/date-editor-ORCB43ZM.js +346 -0
  23. package/dist/date-editor-ORCB43ZM.js.map +1 -0
  24. package/dist/{grid-cell-types-C2-ocDS7.d.cts → grid-cell-types-YNIVK4hN.d.cts} +71 -18
  25. package/dist/{grid-cell-types-C2-ocDS7.d.ts → grid-cell-types-YNIVK4hN.d.ts} +71 -18
  26. package/dist/index.cjs +22733 -12052
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +1432 -266
  29. package/dist/index.d.ts +1432 -266
  30. package/dist/index.js +12688 -6097
  31. package/dist/index.js.map +1 -1
  32. package/dist/sheets-context-Bb7ZoNBg.d.cts +436 -0
  33. package/dist/sheets-context-CPuf31LS.d.ts +436 -0
  34. package/dist/testing.cjs +1170 -589
  35. package/dist/testing.cjs.map +1 -1
  36. package/dist/testing.d.cts +80 -11
  37. package/dist/testing.d.ts +80 -11
  38. package/dist/testing.js +778 -147
  39. package/dist/testing.js.map +1 -1
  40. package/package.json +4 -5
  41. package/dist/chunk-4EZ6A23C.js +0 -44
  42. package/dist/chunk-4EZ6A23C.js.map +0 -1
  43. package/dist/chunk-6Y7CZ5VS.js +0 -168
  44. package/dist/chunk-6Y7CZ5VS.js.map +0 -1
  45. package/dist/chunk-BGL6EBTE.js +0 -446
  46. package/dist/chunk-BGL6EBTE.js.map +0 -1
  47. package/dist/chunk-ER3FIDK7.js +0 -4383
  48. package/dist/chunk-ER3FIDK7.js.map +0 -1
  49. package/dist/chunk-GZM2CSTR.js +0 -279
  50. package/dist/chunk-GZM2CSTR.js.map +0 -1
  51. package/dist/chunk-X7DHTSOX.js +0 -21
  52. package/dist/chunk-X7DHTSOX.js.map +0 -1
  53. package/dist/chunk-YJZFHL2D.js.map +0 -1
  54. package/dist/date-editor-G26WKILO.js +0 -358
  55. package/dist/date-editor-G26WKILO.js.map +0 -1
  56. package/dist/map-picker-ZUGGOIZS.js +0 -290
  57. package/dist/map-picker-ZUGGOIZS.js.map +0 -1
  58. package/dist/sheets-context-CHUVJCff.d.ts +0 -245
  59. package/dist/sheets-context-C_MkTxXm.d.cts +0 -245
  60. /package/dist/{chunk-BYAYBXVB.js.map → chunk-J7KK4UWI.js.map} +0 -0
@@ -0,0 +1,346 @@
1
+ "use client";
2
+ import {
3
+ DATE_TIME_TYPES,
4
+ EditorFocusTrap,
5
+ EditorFooter,
6
+ EditorHeader,
7
+ OVERLAY,
8
+ dateTimeTitle,
9
+ editorClear,
10
+ formatDateTimeText,
11
+ modifierKeyLabel
12
+ } from "./chunk-CJ4PRA64.js";
13
+ import "./chunk-YDQQA46V.js";
14
+ import "./chunk-GGECS2BP.js";
15
+
16
+ // src/grid/editors/date-editor.tsx
17
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
18
+ import { getLocalTimeZone, parseDate as parseAriaDate, today } from "@internationalized/date";
19
+ import { Calendar } from "@constructive-io/ui/calendar-rac";
20
+
21
+ // src/grid/editors/date-value-parts.ts
22
+ var DATE_RE = /^(\d{4,})-(\d{2})-(\d{2})$/;
23
+ var TIME_RE = /^(\d{1,2}):(\d{2})(?::(\d{2})(\.\d+)?)?(Z|[+-]\d{2}(?::?\d{2})?)?$/;
24
+ var DATE_TIME_RE = /^(\d{4,}-\d{2}-\d{2})[T ](\d{1,2}):(\d{2})(?::(\d{2})(\.\d+)?)?(Z|[+-]\d{2}(?::?\d{2})?)?$/;
25
+ function pad2(value) {
26
+ return String(value).padStart(2, "0");
27
+ }
28
+ function localDate(instant) {
29
+ return `${String(instant.getFullYear()).padStart(4, "0")}-${pad2(instant.getMonth() + 1)}-${pad2(instant.getDate())}`;
30
+ }
31
+ function localTime(instant) {
32
+ return `${pad2(instant.getHours())}:${pad2(instant.getMinutes())}:${pad2(instant.getSeconds())}`;
33
+ }
34
+ function readDateValueParts(text, type) {
35
+ const value = text.trim();
36
+ if (!value) return null;
37
+ if (type === "date") {
38
+ const match2 = DATE_RE.exec(value) ?? DATE_RE.exec(value.slice(0, 10));
39
+ return match2 ? { date: value.slice(0, 10), time: "", fraction: "", timeZone: "", instant: false } : null;
40
+ }
41
+ if (type === "time") {
42
+ const match2 = TIME_RE.exec(value);
43
+ if (!match2) return null;
44
+ const [, hours2, minutes2, seconds2 = "00", fraction2 = "", zone2 = ""] = match2;
45
+ return { date: "", time: `${pad2(hours2)}:${minutes2}:${seconds2}`, fraction: fraction2, timeZone: zone2, instant: false };
46
+ }
47
+ const match = DATE_TIME_RE.exec(value);
48
+ if (!match) return null;
49
+ const [, date, hours, minutes, seconds = "00", fraction = "", zone] = match;
50
+ if (!zone) return { date, time: `${pad2(hours)}:${minutes}:${seconds}`, fraction, timeZone: "", instant: false };
51
+ const instant = new Date(value.replace(" ", "T").replace(/(\.\d{3})\d+/, "$1"));
52
+ if (Number.isNaN(instant.getTime())) return null;
53
+ return { date: localDate(instant), time: localTime(instant), fraction, timeZone: "", instant: true };
54
+ }
55
+ function localOffset(date, time) {
56
+ const instant = /* @__PURE__ */ new Date(`${date}T${time}`);
57
+ const minutes = Number.isNaN(instant.getTime()) ? -(/* @__PURE__ */ new Date()).getTimezoneOffset() : -instant.getTimezoneOffset();
58
+ const sign = minutes >= 0 ? "+" : "-";
59
+ const absolute = Math.abs(minutes);
60
+ return `${sign}${pad2(Math.floor(absolute / 60))}:${pad2(absolute % 60)}`;
61
+ }
62
+ function writeDateValueParts(parts, type) {
63
+ if (type === "date") return parts.date;
64
+ if (type === "time") return `${parts.time}${parts.fraction}${parts.timeZone}`;
65
+ const time = parts.time || "00:00:00";
66
+ const base = `${parts.date}T${time}${parts.fraction}`;
67
+ return parts.instant ? `${base}${localOffset(parts.date, time)}` : base;
68
+ }
69
+ function emptyDateValueParts(type) {
70
+ return { date: "", time: type === "date" ? "" : "00:00:00", fraction: "", timeZone: "", instant: type === "timestamptz" };
71
+ }
72
+ function normalizeTimeInput(value) {
73
+ const match = /^(\d{1,2}):(\d{2})(?::(\d{2}))?/.exec(value.trim());
74
+ if (!match) return null;
75
+ const [, hours, minutes, seconds = "00"] = match;
76
+ if (Number(hours) > 23 || Number(minutes) > 59 || Number(seconds) > 59) return null;
77
+ return `${pad2(hours)}:${minutes}:${seconds}`;
78
+ }
79
+
80
+ // src/grid/editors/date-text.ts
81
+ var YEAR_FIRST = /^(\d{4})[-/.](\d{1,2})[-/.](\d{1,2})$/;
82
+ var YEAR_LAST = /^(\d{1,2})[-/.](\d{1,2})[-/.](\d{4})$/;
83
+ function dayMonthOrder(locale) {
84
+ const parts = new Intl.DateTimeFormat(locale, { year: "numeric", month: "numeric", day: "numeric" }).formatToParts(new Date(Date.UTC(2024, 0, 31, 12))).map((part) => part.type).filter((type) => type === "day" || type === "month" || type === "year");
85
+ return parts.indexOf("day") < parts.indexOf("month") ? "day-month" : "month-day";
86
+ }
87
+ var pad = (value, width = 2) => String(value).padStart(width, "0");
88
+ function isoDate(year, month, day) {
89
+ const probe = new Date(Date.UTC(year, month - 1, day));
90
+ probe.setUTCFullYear(year);
91
+ if (probe.getUTCFullYear() !== year || probe.getUTCMonth() !== month - 1 || probe.getUTCDate() !== day) return null;
92
+ return `${pad(year, 4)}-${pad(month)}-${pad(day)}`;
93
+ }
94
+ function parseTypedDate(text, locale) {
95
+ const trimmed = text.trim();
96
+ const yearFirst = YEAR_FIRST.exec(trimmed);
97
+ if (yearFirst) return isoDate(Number(yearFirst[1]), Number(yearFirst[2]), Number(yearFirst[3]));
98
+ const yearLast = YEAR_LAST.exec(trimmed);
99
+ if (!yearLast) return null;
100
+ const [first, second, year] = [Number(yearLast[1]), Number(yearLast[2]), Number(yearLast[3])];
101
+ return dayMonthOrder(locale) === "day-month" ? isoDate(year, second, first) : isoDate(year, first, second);
102
+ }
103
+ function typedDateExample(locale) {
104
+ return dayMonthOrder(locale) === "day-month" ? "2024-01-31 or 31/01/2024" : "2024-01-31 or 01/31/2024";
105
+ }
106
+
107
+ // src/grid/editors/date-editor.tsx
108
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
109
+ function resolveDateType(value, explicitType) {
110
+ if (explicitType && DATE_TIME_TYPES.has(explicitType)) return explicitType;
111
+ if (typeof value === "string") {
112
+ if (value.includes("T") || value.includes(" ")) return /[+-]\d{2}(:?\d{2})?$|Z$/.test(value) ? "timestamptz" : "datetime";
113
+ if (value.includes(":") && !value.includes("-")) return "time";
114
+ }
115
+ return "date";
116
+ }
117
+ function displayKind(type) {
118
+ return type === "date" ? "date" : type === "time" ? "time" : "datetime";
119
+ }
120
+ var TIME_INPUT = "bg-muted/40 border-border/40 text-foreground w-full rounded-md border px-2.5 py-1.5 text-sm tabular-nums outline-none focus-visible:border-ring/60 focus-visible:ring-[3px] focus-visible:ring-ring/35";
121
+ var CALENDAR_FILL = [
122
+ "w-full",
123
+ "[&_table]:w-full [&_table]:table-fixed",
124
+ "[&_td>[role=button]]:mx-auto [&_th]:w-auto",
125
+ "[&_header_button:focus-visible]:ring-2 [&_header_button:focus-visible]:ring-inset"
126
+ ].join(" ");
127
+ function calendarDate(iso) {
128
+ if (!iso) return null;
129
+ try {
130
+ return parseAriaDate(iso);
131
+ } catch {
132
+ return null;
133
+ }
134
+ }
135
+ var DateEditor = ({
136
+ value,
137
+ onFinishedEditing,
138
+ dateType: forcedDateType,
139
+ canClear = false,
140
+ title = "Date",
141
+ initialText
142
+ }) => {
143
+ const stored = typeof value === "string" ? value : "";
144
+ const dateType = resolveDateType(stored, forcedDateType);
145
+ const isTimeOnly = dateType === "time";
146
+ const isDateTimeType = dateType === "datetime" || dateType === "timestamptz";
147
+ const [parts, setParts] = useState(() => readDateValueParts(stored, dateType));
148
+ const [dirty, setDirty] = useState(false);
149
+ const keyContainerRef = useRef(null);
150
+ const selectedDate = useMemo(() => calendarDate(parts?.date), [parts?.date]);
151
+ const [dateText, setDateText] = useState(() => initialText ?? parts?.date ?? "");
152
+ const [dateError, setDateError] = useState(null);
153
+ const [focusedDate, setFocusedDate] = useState(() => selectedDate ?? today(getLocalTimeZone()));
154
+ const dateInputRef = useRef(null);
155
+ useEffect(() => {
156
+ const input = dateInputRef.current;
157
+ if (!input) return;
158
+ if (initialText == null) input.select();
159
+ else input.setSelectionRange(input.value.length, input.value.length);
160
+ }, []);
161
+ const setDay = useCallback(
162
+ (date) => {
163
+ setParts((current) => ({ ...current ?? emptyDateValueParts(dateType), date }));
164
+ setDirty(true);
165
+ },
166
+ [dateType]
167
+ );
168
+ const handleDateText = useCallback(
169
+ (text) => {
170
+ setDateText(text);
171
+ setDateError(null);
172
+ const date = parseTypedDate(text);
173
+ if (!date) return;
174
+ setDay(date);
175
+ const shown2 = calendarDate(date);
176
+ if (shown2) setFocusedDate(shown2);
177
+ },
178
+ [setDay]
179
+ );
180
+ useEffect(() => {
181
+ if (initialText != null) handleDateText(initialText);
182
+ }, []);
183
+ const handleDateSelect = useCallback(
184
+ (picked) => {
185
+ if (!picked || Array.isArray(picked)) return;
186
+ const day = picked;
187
+ const date = `${String(day.year).padStart(4, "0")}-${String(day.month).padStart(2, "0")}-${String(day.day).padStart(2, "0")}`;
188
+ setDay(date);
189
+ setDateText(date);
190
+ setDateError(null);
191
+ },
192
+ [setDay]
193
+ );
194
+ const handleTimeChange = useCallback(
195
+ (input) => {
196
+ const time = normalizeTimeInput(input);
197
+ if (!time) return;
198
+ setParts((current) => ({ ...current ?? emptyDateValueParts(dateType), time }));
199
+ setDirty(true);
200
+ },
201
+ [dateType]
202
+ );
203
+ const written = parts && dirty && (isTimeOnly || parts.date) ? writeDateValueParts(parts, dateType) : null;
204
+ const handleSave = useCallback(() => {
205
+ if (!isTimeOnly) {
206
+ const text = dateText.trim();
207
+ if (text === "" && stored) {
208
+ if (canClear) onFinishedEditing(null);
209
+ else setDateError("This field needs a value.");
210
+ return;
211
+ }
212
+ if (text !== "" && !parseTypedDate(text)) {
213
+ setDateError(`Enter a date like ${typedDateExample()}.`);
214
+ dateInputRef.current?.focus();
215
+ return;
216
+ }
217
+ }
218
+ if (!written) {
219
+ onFinishedEditing();
220
+ return;
221
+ }
222
+ onFinishedEditing(written);
223
+ }, [isTimeOnly, dateText, stored, canClear, written, onFinishedEditing]);
224
+ const handleCancel = useCallback(() => {
225
+ onFinishedEditing();
226
+ }, [onFinishedEditing]);
227
+ const actionsRef = useRef({ handleSave, handleCancel });
228
+ actionsRef.current = { handleSave, handleCancel };
229
+ useEffect(() => {
230
+ const el = keyContainerRef.current;
231
+ if (!el) return;
232
+ const handler = (e) => {
233
+ const { handleSave: handleSave2, handleCancel: handleCancel2 } = actionsRef.current;
234
+ if (e.key === "Escape") {
235
+ e.preventDefault();
236
+ e.stopPropagation();
237
+ handleCancel2();
238
+ return;
239
+ }
240
+ if (e.key === "Enter" && (e.metaKey || e.ctrlKey) || e.key === "s" && (e.metaKey || e.ctrlKey)) {
241
+ e.preventDefault();
242
+ e.stopPropagation();
243
+ handleSave2();
244
+ return;
245
+ }
246
+ if (e.key === "Tab") {
247
+ e.stopPropagation();
248
+ }
249
+ };
250
+ el.addEventListener("keydown", handler);
251
+ return () => el.removeEventListener("keydown", handler);
252
+ }, []);
253
+ const shownText = written ?? stored;
254
+ const shown = shownText ? formatDateTimeText(shownText, displayKind(dateType)) : null;
255
+ return /* @__PURE__ */ jsx(
256
+ EditorFocusTrap,
257
+ {
258
+ onEscape: handleCancel,
259
+ className: `bg-popover rounded-lg border p-2.5 shadow-lg ${isTimeOnly ? OVERLAY.sm : "w-[min(20rem,calc(100vw-1.5rem))]"}`,
260
+ children: /* @__PURE__ */ jsxs("div", { ref: keyContainerRef, className: "flex flex-col gap-2", children: [
261
+ /* @__PURE__ */ jsx(EditorHeader, { title }),
262
+ /* @__PURE__ */ jsx(
263
+ "p",
264
+ {
265
+ "data-slot": "date-editor-value",
266
+ className: "text-muted-foreground -mt-1 text-xs tabular-nums",
267
+ title: shown && shownText ? dateTimeTitle(shownText, shown.zone) : void 0,
268
+ children: shown?.text || "No value"
269
+ }
270
+ ),
271
+ isTimeOnly ? /* @__PURE__ */ jsx(
272
+ "input",
273
+ {
274
+ type: "time",
275
+ step: "1",
276
+ "aria-label": `${title} time`,
277
+ value: parts?.time ?? "",
278
+ onChange: (e) => handleTimeChange(e.target.value),
279
+ className: TIME_INPUT,
280
+ autoFocus: true
281
+ }
282
+ ) : /* @__PURE__ */ jsxs(Fragment, { children: [
283
+ /* @__PURE__ */ jsx(
284
+ "input",
285
+ {
286
+ ref: dateInputRef,
287
+ type: "text",
288
+ autoComplete: "off",
289
+ spellCheck: false,
290
+ "aria-label": `${title} date`,
291
+ "aria-invalid": dateError ? true : void 0,
292
+ "aria-describedby": dateError ? "sheets-date-editor-error" : void 0,
293
+ placeholder: typedDateExample(),
294
+ value: dateText,
295
+ onChange: (e) => handleDateText(e.target.value),
296
+ onKeyDown: (e) => {
297
+ if (e.key !== "Enter" || e.metaKey || e.ctrlKey || e.altKey || e.shiftKey) return;
298
+ e.preventDefault();
299
+ e.stopPropagation();
300
+ handleSave();
301
+ },
302
+ className: TIME_INPUT,
303
+ autoFocus: true
304
+ }
305
+ ),
306
+ dateError ? /* @__PURE__ */ jsx("p", { id: "sheets-date-editor-error", role: "alert", className: "text-destructive -mt-1 text-xs", children: dateError }) : null,
307
+ /* @__PURE__ */ jsx(
308
+ Calendar,
309
+ {
310
+ value: selectedDate,
311
+ onChange: handleDateSelect,
312
+ focusedValue: focusedDate,
313
+ onFocusChange: setFocusedDate,
314
+ "aria-label": "Select date",
315
+ className: CALENDAR_FILL
316
+ }
317
+ ),
318
+ isDateTimeType ? /* @__PURE__ */ jsx(
319
+ "input",
320
+ {
321
+ type: "time",
322
+ step: "1",
323
+ "aria-label": `${title} time`,
324
+ value: parts?.time ?? "",
325
+ onChange: (e) => handleTimeChange(e.target.value),
326
+ className: TIME_INPUT
327
+ }
328
+ ) : null
329
+ ] }),
330
+ /* @__PURE__ */ jsx(
331
+ EditorFooter,
332
+ {
333
+ onSave: handleSave,
334
+ saveShortcut: `${modifierKeyLabel()} Enter`,
335
+ clear: editorClear(canClear, () => onFinishedEditing(null))
336
+ }
337
+ )
338
+ ] })
339
+ }
340
+ );
341
+ };
342
+ export {
343
+ DateEditor,
344
+ resolveDateType
345
+ };
346
+ //# sourceMappingURL=date-editor-ORCB43ZM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/grid/editors/date-editor.tsx","../src/grid/editors/date-value-parts.ts","../src/grid/editors/date-text.ts"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { getLocalTimeZone, parseDate as parseAriaDate, today } from '@internationalized/date';\nimport type { DateValue as DateValueType } from 'react-aria-components';\n\nimport { Calendar } from '@constructive-io/ui/calendar-rac';\n\nimport { DATE_TIME_TYPES } from '../../cell-types/cell-type-groups';\nimport { dateTimeTitle, formatDateTimeText, type DateTimeKind } from '../../cell-types/date-time-format';\n\nimport {\n\temptyDateValueParts,\n\tnormalizeTimeInput,\n\treadDateValueParts,\n\twriteDateValueParts,\n\ttype DateEditorType,\n\ttype DateValueParts,\n} from './date-value-parts';\nimport { parseTypedDate, typedDateExample } from './date-text';\nimport { EditorFocusTrap } from './editor-focus-trap';\nimport { EditorFooter, EditorHeader, editorClear, modifierKeyLabel } from './editor-frame';\nimport { OVERLAY } from './overlay-presets';\n\nexport type { DateEditorType } from './date-value-parts';\n\n/** The editor's type from the cell type, else guessed from the stored text. */\nexport function resolveDateType(value: unknown, explicitType?: string): DateEditorType {\n\tif (explicitType && DATE_TIME_TYPES.has(explicitType)) return explicitType as DateEditorType;\n\tif (typeof value === 'string') {\n\t\tif (value.includes('T') || value.includes(' ')) return /[+-]\\d{2}(:?\\d{2})?$|Z$/.test(value) ? 'timestamptz' : 'datetime';\n\t\tif (value.includes(':') && !value.includes('-')) return 'time';\n\t}\n\treturn 'date';\n}\n\nfunction displayKind(type: DateEditorType): DateTimeKind {\n\treturn type === 'date' ? 'date' : type === 'time' ? 'time' : 'datetime';\n}\n\nconst TIME_INPUT =\n\t'bg-muted/40 border-border/40 text-foreground w-full rounded-md border px-2.5 py-1.5 text-sm tabular-nums outline-none focus-visible:border-ring/60 focus-visible:ring-[3px] focus-visible:ring-ring/35';\n\n// The calendar fills the editor's content box: seven equal day columns and a header whose\n// arrows sit at its two ends. The arrows' focus ring is drawn inside them, so it is no\n// larger than the button.\nconst CALENDAR_FILL = [\n\t'w-full',\n\t'[&_table]:w-full [&_table]:table-fixed',\n\t'[&_td>[role=button]]:mx-auto [&_th]:w-auto',\n\t'[&_header_button:focus-visible]:ring-2 [&_header_button:focus-visible]:ring-inset',\n].join(' ');\n\ninterface DateEditorProps {\n\tvalue: unknown;\n\tonFinishedEditing: (next?: unknown) => void;\n\tdateType?: DateEditorType;\n\t/** Offer a Clear action that commits null (the column accepts no value). */\n\tcanClear?: boolean;\n\t/** The field's readable name, shown as the title. */\n\ttitle?: string;\n\t/** Text typed on the cell to open the editor; it starts the date field. */\n\tinitialText?: string;\n}\n\n/** A date for the calendar, or null when the text is not one. */\nfunction calendarDate(iso: string | null | undefined): DateValueType | null {\n\tif (!iso) return null;\n\ttry {\n\t\treturn parseAriaDate(iso);\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport const DateEditor: React.FC<DateEditorProps> = ({\n\tvalue,\n\tonFinishedEditing,\n\tdateType: forcedDateType,\n\tcanClear = false,\n\ttitle = 'Date',\n\tinitialText,\n}) => {\n\tconst stored = typeof value === 'string' ? value : '';\n\tconst dateType = resolveDateType(stored, forcedDateType);\n\tconst isTimeOnly = dateType === 'time';\n\tconst isDateTimeType = dateType === 'datetime' || dateType === 'timestamptz';\n\n\t// The parts of the stored text; nothing changes until the user picks a day or a time.\n\tconst [parts, setParts] = useState<DateValueParts | null>(() => readDateValueParts(stored, dateType));\n\tconst [dirty, setDirty] = useState(false);\n\tconst keyContainerRef = useRef<HTMLDivElement>(null);\n\n\tconst selectedDate = useMemo(() => calendarDate(parts?.date), [parts?.date]);\n\n\t// The date can also be typed. The field starts with what was typed on the cell, else the\n\t// stored day; a whole date moves the calendar there, and Save refuses text that is not one.\n\tconst [dateText, setDateText] = useState(() => initialText ?? parts?.date ?? '');\n\tconst [dateError, setDateError] = useState<string | null>(null);\n\tconst [focusedDate, setFocusedDate] = useState<DateValueType>(() => selectedDate ?? today(getLocalTimeZone()));\n\tconst dateInputRef = useRef<HTMLInputElement>(null);\n\tuseEffect(() => {\n\t\tconst input = dateInputRef.current;\n\t\tif (!input) return;\n\t\t// Typing replaces the stored day; text typed on the cell goes on where it ended.\n\t\tif (initialText == null) input.select();\n\t\telse input.setSelectionRange(input.value.length, input.value.length);\n\t\t// Only on open.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, []);\n\n\tconst setDay = useCallback(\n\t\t(date: string) => {\n\t\t\t// Only the day changes: the time, its fraction and its zone stay as they are.\n\t\t\tsetParts((current) => ({ ...(current ?? emptyDateValueParts(dateType)), date }));\n\t\t\tsetDirty(true);\n\t\t},\n\t\t[dateType],\n\t);\n\n\tconst handleDateText = useCallback(\n\t\t(text: string) => {\n\t\t\tsetDateText(text);\n\t\t\tsetDateError(null);\n\t\t\tconst date = parseTypedDate(text);\n\t\t\tif (!date) return;\n\t\t\tsetDay(date);\n\t\t\tconst shown = calendarDate(date);\n\t\t\tif (shown) setFocusedDate(shown);\n\t\t},\n\t\t[setDay],\n\t);\n\n\tuseEffect(() => {\n\t\t// Text typed on the cell that is already a whole date counts at once.\n\t\tif (initialText != null) handleDateText(initialText);\n\t\t// Only on open.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, []);\n\n\tconst handleDateSelect = useCallback(\n\t\t(picked: DateValueType | readonly DateValueType[] | null) => {\n\t\t\t// The shared Calendar also supports multi-select; this editor picks one day.\n\t\t\tif (!picked || Array.isArray(picked)) return;\n\t\t\tconst day = picked as DateValueType;\n\t\t\tconst date = `${String(day.year).padStart(4, '0')}-${String(day.month).padStart(2, '0')}-${String(day.day).padStart(2, '0')}`;\n\t\t\tsetDay(date);\n\t\t\tsetDateText(date);\n\t\t\tsetDateError(null);\n\t\t},\n\t\t[setDay],\n\t);\n\n\tconst handleTimeChange = useCallback(\n\t\t(input: string) => {\n\t\t\tconst time = normalizeTimeInput(input);\n\t\t\tif (!time) return;\n\t\t\t// The field edits whole seconds; the stored fraction of a second is kept.\n\t\t\tsetParts((current) => ({ ...(current ?? emptyDateValueParts(dateType)), time }));\n\t\t\tsetDirty(true);\n\t\t},\n\t\t[dateType],\n\t);\n\n\tconst written = parts && dirty && (isTimeOnly || parts.date) ? writeDateValueParts(parts, dateType) : null;\n\n\tconst handleSave = useCallback(() => {\n\t\tif (!isTimeOnly) {\n\t\t\tconst text = dateText.trim();\n\t\t\t// An emptied date field clears the value where the column allows no value.\n\t\t\tif (text === '' && stored) {\n\t\t\t\tif (canClear) onFinishedEditing(null);\n\t\t\t\telse setDateError('This field needs a value.');\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (text !== '' && !parseTypedDate(text)) {\n\t\t\t\tsetDateError(`Enter a date like ${typedDateExample()}.`);\n\t\t\t\tdateInputRef.current?.focus();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t// Nothing changed: close without writing, so the stored text stays exactly as it is.\n\t\tif (!written) {\n\t\t\tonFinishedEditing();\n\t\t\treturn;\n\t\t}\n\t\tonFinishedEditing(written);\n\t}, [isTimeOnly, dateText, stored, canClear, written, onFinishedEditing]);\n\n\tconst handleCancel = useCallback(() => {\n\t\tonFinishedEditing();\n\t}, [onFinishedEditing]);\n\n\t// Refs for native key handler\n\tconst actionsRef = useRef({ handleSave, handleCancel });\n\tactionsRef.current = { handleSave, handleCancel };\n\n\t// Native DOM keydown listener — prevents Glide from intercepting keys in portal context\n\tuseEffect(() => {\n\t\tconst el = keyContainerRef.current;\n\t\tif (!el) return;\n\t\tconst handler = (e: KeyboardEvent) => {\n\t\t\tconst { handleSave, handleCancel } = actionsRef.current;\n\n\t\t\tif (e.key === 'Escape') {\n\t\t\t\te.preventDefault();\n\t\t\t\te.stopPropagation();\n\t\t\t\thandleCancel();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ((e.key === 'Enter' && (e.metaKey || e.ctrlKey)) || (e.key === 's' && (e.metaKey || e.ctrlKey))) {\n\t\t\t\te.preventDefault();\n\t\t\t\te.stopPropagation();\n\t\t\t\thandleSave();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Stop Tab from reaching Glide\n\t\t\tif (e.key === 'Tab') {\n\t\t\t\te.stopPropagation();\n\t\t\t}\n\t\t};\n\t\tel.addEventListener('keydown', handler);\n\t\treturn () => el.removeEventListener('keydown', handler);\n\t}, []);\n\n\t// The value as the cells show it, in the same zone; the title has the exact text.\n\tconst shownText = written ?? stored;\n\tconst shown = shownText ? formatDateTimeText(shownText, displayKind(dateType)) : null;\n\n\treturn (\n\t\t<EditorFocusTrap\n\t\t\tonEscape={handleCancel}\n\t\t\t// A calendar is as wide as its seven 36px days; the editor takes that width so the\n\t\t\t// month sits with equal space on both sides. A time alone keeps the small editor width.\n\t\t\tclassName={`bg-popover rounded-lg border p-2.5 shadow-lg ${isTimeOnly ? OVERLAY.sm : 'w-[min(20rem,calc(100vw-1.5rem))]'}`}\n\t\t>\n\t\t\t<div ref={keyContainerRef} className='flex flex-col gap-2'>\n\t\t\t\t<EditorHeader title={title} />\n\t\t\t\t{/* The value so far, as the cell shows it, on the calendar's left edge. */}\n\t\t\t\t<p\n\t\t\t\t\tdata-slot='date-editor-value'\n\t\t\t\t\tclassName='text-muted-foreground -mt-1 text-xs tabular-nums'\n\t\t\t\t\ttitle={shown && shownText ? dateTimeTitle(shownText, shown.zone) : undefined}\n\t\t\t\t>\n\t\t\t\t\t{shown?.text || 'No value'}\n\t\t\t\t</p>\n\t\t\t\t{isTimeOnly ? (\n\t\t\t\t\t<input\n\t\t\t\t\t\ttype='time'\n\t\t\t\t\t\tstep='1'\n\t\t\t\t\t\taria-label={`${title} time`}\n\t\t\t\t\t\tvalue={parts?.time ?? ''}\n\t\t\t\t\t\tonChange={(e) => handleTimeChange(e.target.value)}\n\t\t\t\t\t\tclassName={TIME_INPUT}\n\t\t\t\t\t\tautoFocus\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tref={dateInputRef}\n\t\t\t\t\t\t\ttype='text'\n\t\t\t\t\t\t\tautoComplete='off'\n\t\t\t\t\t\t\tspellCheck={false}\n\t\t\t\t\t\t\taria-label={`${title} date`}\n\t\t\t\t\t\t\taria-invalid={dateError ? true : undefined}\n\t\t\t\t\t\t\taria-describedby={dateError ? 'sheets-date-editor-error' : undefined}\n\t\t\t\t\t\t\tplaceholder={typedDateExample()}\n\t\t\t\t\t\t\tvalue={dateText}\n\t\t\t\t\t\t\tonChange={(e) => handleDateText(e.target.value)}\n\t\t\t\t\t\t\tonKeyDown={(e) => {\n\t\t\t\t\t\t\t\t// Enter saves what was typed, as in a cell.\n\t\t\t\t\t\t\t\tif (e.key !== 'Enter' || e.metaKey || e.ctrlKey || e.altKey || e.shiftKey) return;\n\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t\te.stopPropagation();\n\t\t\t\t\t\t\t\thandleSave();\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tclassName={TIME_INPUT}\n\t\t\t\t\t\t\tautoFocus\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{dateError ? (\n\t\t\t\t\t\t\t<p id='sheets-date-editor-error' role='alert' className='text-destructive -mt-1 text-xs'>\n\t\t\t\t\t\t\t\t{dateError}\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t<Calendar\n\t\t\t\t\t\t\tvalue={selectedDate}\n\t\t\t\t\t\t\tonChange={handleDateSelect}\n\t\t\t\t\t\t\tfocusedValue={focusedDate}\n\t\t\t\t\t\t\tonFocusChange={setFocusedDate}\n\t\t\t\t\t\t\taria-label='Select date'\n\t\t\t\t\t\t\tclassName={CALENDAR_FILL}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{isDateTimeType ? (\n\t\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t\ttype='time'\n\t\t\t\t\t\t\t\tstep='1'\n\t\t\t\t\t\t\t\taria-label={`${title} time`}\n\t\t\t\t\t\t\t\tvalue={parts?.time ?? ''}\n\t\t\t\t\t\t\t\tonChange={(e) => handleTimeChange(e.target.value)}\n\t\t\t\t\t\t\t\tclassName={TIME_INPUT}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t\t<EditorFooter\n\t\t\t\t\tonSave={handleSave}\n\t\t\t\t\tsaveShortcut={`${modifierKeyLabel()} Enter`}\n\t\t\t\t\tclear={editorClear(canClear, () => onFinishedEditing(null))}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</EditorFocusTrap>\n\t);\n};\n","// The date editor works on the parts of the stored text, never on a JS Date, so\n// nothing the user did not change is lost: microseconds (\"13:45:30.123456\"), a time's\n// own zone (\"+00:00\") and a wall time without a zone all survive a save. A date and\n// time with a zone is an instant: the editor shows and edits it in the viewer's zone,\n// as the cells do, and writes it back with the viewer's offset for that moment.\n\nexport type DateEditorType = 'date' | 'datetime' | 'timestamptz' | 'time';\n\nexport interface DateValueParts {\n\t/** Calendar day, \"YYYY-MM-DD\" (in the viewer's zone for an instant); '' for a time. */\n\tdate: string;\n\t/** Time of day, \"HH:mm:ss\" (in the viewer's zone for an instant); '' for a date. */\n\ttime: string;\n\t/** Fraction of a second as stored (\".123456\"), or ''. Kept when the time changes. */\n\tfraction: string;\n\t/** A time-of-day value's own zone (\"+00:00\"), kept as stored; '' when it has none. */\n\ttimeZone: string;\n\t/** A date and time with a zone: an instant, written with the viewer's offset. */\n\tinstant: boolean;\n}\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\nfunction pad2(value: number | string): string {\n\treturn String(value).padStart(2, '0');\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\n/** The parts of stored text, or null for no value or text that is not of this type. */\nexport function readDateValueParts(text: string, type: DateEditorType): DateValueParts | null {\n\tconst value = text.trim();\n\tif (!value) return null;\n\tif (type === 'date') {\n\t\tconst match = DATE_RE.exec(value) ?? DATE_RE.exec(value.slice(0, 10));\n\t\treturn match ? { date: value.slice(0, 10), time: '', fraction: '', timeZone: '', instant: false } : null;\n\t}\n\tif (type === 'time') {\n\t\tconst match = TIME_RE.exec(value);\n\t\tif (!match) return null;\n\t\tconst [, hours, minutes, seconds = '00', fraction = '', zone = ''] = match;\n\t\treturn { date: '', time: `${pad2(hours!)}:${minutes}:${seconds}`, fraction, timeZone: zone, instant: false };\n\t}\n\tconst match = DATE_TIME_RE.exec(value);\n\tif (!match) return null;\n\tconst [, date, hours, minutes, seconds = '00', fraction = '', zone] = match;\n\tif (!zone) return { date: date!, time: `${pad2(hours!)}:${minutes}:${seconds}`, fraction, timeZone: '', instant: false };\n\t// An instant: read in the viewer's zone. Offsets are whole minutes, so the seconds and\n\t// their fraction do not change.\n\tconst instant = new Date(value.replace(' ', 'T').replace(/(\\.\\d{3})\\d+/, '$1'));\n\tif (Number.isNaN(instant.getTime())) return null;\n\treturn { date: localDate(instant), time: localTime(instant), fraction, timeZone: '', instant: true };\n}\n\n/** The viewer's offset at this local wall time (\"+07:00\"). */\nfunction localOffset(date: string, time: string): string {\n\tconst instant = new Date(`${date}T${time}`);\n\tconst minutes = Number.isNaN(instant.getTime()) ? -new Date().getTimezoneOffset() : -instant.getTimezoneOffset();\n\tconst sign = minutes >= 0 ? '+' : '-';\n\tconst absolute = Math.abs(minutes);\n\treturn `${sign}${pad2(Math.floor(absolute / 60))}:${pad2(absolute % 60)}`;\n}\n\n/** Stored text for these parts. */\nexport function writeDateValueParts(parts: DateValueParts, type: DateEditorType): string {\n\tif (type === 'date') return parts.date;\n\tif (type === 'time') return `${parts.time}${parts.fraction}${parts.timeZone}`;\n\tconst time = parts.time || '00:00:00';\n\tconst base = `${parts.date}T${time}${parts.fraction}`;\n\treturn parts.instant ? `${base}${localOffset(parts.date, time)}` : base;\n}\n\n/** Parts for a value the user starts from nothing. A zoned type is an instant. */\nexport function emptyDateValueParts(type: DateEditorType): DateValueParts {\n\treturn { date: '', time: type === 'date' ? '' : '00:00:00', fraction: '', timeZone: '', instant: type === 'timestamptz' };\n}\n\n/** A time field's value (\"HH:mm\" or \"HH:mm:ss\") as \"HH:mm:ss\", or null when it is not a time. */\nexport function normalizeTimeInput(value: string): string | null {\n\tconst match = /^(\\d{1,2}):(\\d{2})(?::(\\d{2}))?/.exec(value.trim());\n\tif (!match) return null;\n\tconst [, hours, minutes, seconds = '00'] = match;\n\tif (Number(hours) > 23 || Number(minutes) > 59 || Number(seconds) > 59) return null;\n\treturn `${pad2(hours!)}:${minutes}:${seconds}`;\n}\n","// A date typed as text. Year first (2024-01-31, 2024/1/31) is read as year, month, day; a date\n// that ends with the year (31/01/2024, 1.31.2024) is read in the order the locale writes its\n// dates, so 03/04/2024 is 3 April where the day comes first and March 4 where the month does.\n// A two-digit year is not guessed.\n\ntype Part = 'day' | 'month' | 'year';\n\nconst YEAR_FIRST = /^(\\d{4})[-/.](\\d{1,2})[-/.](\\d{1,2})$/;\nconst YEAR_LAST = /^(\\d{1,2})[-/.](\\d{1,2})[-/.](\\d{4})$/;\n\n/** The order of day and month in the locale's numeric dates. */\nexport function dayMonthOrder(locale?: string): 'day-month' | 'month-day' {\n\tconst parts = new Intl.DateTimeFormat(locale, { year: 'numeric', month: 'numeric', day: 'numeric' })\n\t\t.formatToParts(new Date(Date.UTC(2024, 0, 31, 12)))\n\t\t.map((part) => part.type)\n\t\t.filter((type): type is Part => type === 'day' || type === 'month' || type === 'year');\n\treturn parts.indexOf('day') < parts.indexOf('month') ? 'day-month' : 'month-day';\n}\n\nconst pad = (value: number, width = 2) => String(value).padStart(width, '0');\n\nfunction isoDate(year: number, month: number, day: number): string | null {\n\tconst probe = new Date(Date.UTC(year, month - 1, day));\n\tprobe.setUTCFullYear(year);\n\tif (probe.getUTCFullYear() !== year || probe.getUTCMonth() !== month - 1 || probe.getUTCDate() !== day) return null;\n\treturn `${pad(year, 4)}-${pad(month)}-${pad(day)}`;\n}\n\n/** The date `text` names, as YYYY-MM-DD, or null when it is not a whole, real date. */\nexport function parseTypedDate(text: string, locale?: string): string | null {\n\tconst trimmed = text.trim();\n\tconst yearFirst = YEAR_FIRST.exec(trimmed);\n\tif (yearFirst) return isoDate(Number(yearFirst[1]), Number(yearFirst[2]), Number(yearFirst[3]));\n\tconst yearLast = YEAR_LAST.exec(trimmed);\n\tif (!yearLast) return null;\n\tconst [first, second, year] = [Number(yearLast[1]), Number(yearLast[2]), Number(yearLast[3])];\n\treturn dayMonthOrder(locale) === 'day-month' ? isoDate(year, second, first) : isoDate(year, first, second);\n}\n\n/** What to type, for the hint: \"2024-01-31 or 31/01/2024\" in the locale's order. */\nexport function typedDateExample(locale?: string): string {\n\treturn dayMonthOrder(locale) === 'day-month' ? '2024-01-31 or 31/01/2024' : '2024-01-31 or 01/31/2024';\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAgB,aAAa,WAAW,SAAS,QAAQ,gBAAgB;AACzE,SAAS,kBAAkB,aAAa,eAAe,aAAa;AAGpE,SAAS,gBAAgB;;;ACiBzB,IAAM,UAAU;AAChB,IAAM,UAAU;AAChB,IAAM,eAAe;AAErB,SAAS,KAAK,OAAgC;AAC7C,SAAO,OAAO,KAAK,EAAE,SAAS,GAAG,GAAG;AACrC;AAEA,SAAS,UAAU,SAAuB;AACzC,SAAO,GAAG,OAAO,QAAQ,YAAY,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC,IAAI,KAAK,QAAQ,SAAS,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,QAAQ,CAAC,CAAC;AACpH;AAEA,SAAS,UAAU,SAAuB;AACzC,SAAO,GAAG,KAAK,QAAQ,SAAS,CAAC,CAAC,IAAI,KAAK,QAAQ,WAAW,CAAC,CAAC,IAAI,KAAK,QAAQ,WAAW,CAAC,CAAC;AAC/F;AAGO,SAAS,mBAAmB,MAAc,MAA6C;AAC7F,QAAM,QAAQ,KAAK,KAAK;AACxB,MAAI,CAAC,MAAO,QAAO;AACnB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cACL,cAAa;AAAA,cACb,YAAY;AAAA,cACZ,cAAY,GAAG,KAAK;AAAA,cACpB,gBAAc,YAAY,OAAO;AAAA,cACjC,oBAAkB,YAAY,6BAA6B;AAAA,cAC3D,aAAa,iBAAiB;AAAA,cAC9B,OAAO;AAAA,cACP,UAAU,CAAC,MAAM,eAAe,EAAE,OAAO,KAAK;AAAA,cAC9C,WAAW,CAAC,MAAM;AAEjB,oBAAI,EAAE,QAAQ,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,SAAU;AAC3E,kBAAE,eAAe;AACjB,kBAAE,gBAAgB;AAClB,2BAAW;AAAA,cACZ;AAAA,cACA,WAAW;AAAA,cACX,WAAS;AAAA;AAAA,UACV;AAAA,UACC,YACA,oBAAC,OAAE,IAAG,4BAA2B,MAAK,SAAQ,WAAU,kCACtD,qBACF,IACG;AAAA,UACJ;AAAA,YAAC;AAAA;AAAA,cACA,OAAO;AAAA,cACP,UAAU;AAAA,cACV,cAAc;AAAA,cACd,eAAe;AAAA,cACf,cAAW;AAAA,cACX,WAAW;AAAA;AAAA,UACZ;AAAA,UACC,iBACA;AAAA,YAAC;AAAA;AAAA,cACA,MAAK;AAAA,cACL,MAAK;AAAA,cACL,cAAY,GAAG,KAAK;AAAA,cACpB,OAAO,OAAO,QAAQ;AAAA,cACtB,UAAU,CAAC,MAAM,iBAAiB,EAAE,OAAO,KAAK;AAAA,cAChD,WAAW;AAAA;AAAA,UACZ,IACG;AAAA,WACL;AAAA,QAED;AAAA,UAAC;AAAA;AAAA,YACA,QAAQ;AAAA,YACR,cAAc,GAAG,iBAAiB,CAAC;AAAA,YACnC,OAAO,YAAY,UAAU,MAAM,kBAAkB,IAAI,CAAC;AAAA;AAAA,QAC3D;AAAA,SACD;AAAA;AAAA,EACD;AAEF;","names":["match","hours","minutes","seconds","fraction","zone","shown","handleSave","handleCancel"]}
@@ -1,5 +1,5 @@
1
+ import { RelationModel, TableModel, RowIdentityValue, TableWriteCapability, MetaTable, RowKey, ColumnModel } from '@constructive-io/data';
1
2
  import { ComponentType } from 'react';
2
- import { MetaQuery, RowIdentityValue, TableWriteCapability, MetaTable } from '@constructive-io/data';
3
3
 
4
4
  interface FieldMetadata$1 {
5
5
  name: string;
@@ -18,10 +18,23 @@ interface CellTypeResolution {
18
18
  activationBehavior: 'single-click' | 'double-click';
19
19
  isReadonly: boolean;
20
20
  }
21
+ /**
22
+ * Resolve a cell type from raw `_meta` field metadata.
23
+ *
24
+ * @deprecated The grid routes table-model columns with `cellTypeForColumn` and takes
25
+ * read-only state from the model's write flags. This resolver never marks a field
26
+ * read-only by its name; it only says whether the cell type itself is editable.
27
+ */
21
28
  declare function resolveCellType(fieldName: string, fieldMeta?: FieldMetadata$1): CellTypeResolution;
29
+ /**
30
+ * Whether raw field metadata describes an image column. Decided by the type only
31
+ * (a registered matcher or the image type), never by the field's name.
32
+ *
33
+ * @deprecated Read `ColumnModel.value.file?.kind === 'image'` from the table model.
34
+ */
22
35
  declare function isImageField(fieldMeta?: FieldMetadata$1, fieldName?: string): boolean;
23
36
 
24
- type CellType = 'text' | 'textarea' | 'email' | 'url' | 'phone' | 'citext' | 'bpchar' | 'number' | 'integer' | 'smallint' | 'decimal' | 'currency' | 'percentage' | 'date' | 'datetime' | 'time' | 'timestamptz' | 'interval' | 'boolean' | 'toggle' | 'bit' | 'json' | 'jsonb' | 'array' | 'text-array' | 'uuid-array' | 'number-array' | 'integer-array' | 'date-array' | 'geometry' | 'geometry-point' | 'geometry-collection' | 'inet' | 'image' | 'file' | 'video' | 'audio' | 'upload' | 'attachment' | 'uuid' | 'color' | 'rating' | 'tags' | 'tsvector' | 'origin' | 'relation' | 'unknown';
37
+ type CellType = 'text' | 'textarea' | 'email' | 'url' | 'phone' | 'citext' | 'bpchar' | 'number' | 'integer' | 'smallint' | 'bigint' | 'decimal' | 'currency' | 'percentage' | 'select' | 'multi-select' | 'date' | 'datetime' | 'time' | 'timestamptz' | 'interval' | 'boolean' | 'toggle' | 'bit' | 'bitstring' | 'json' | 'jsonb' | 'array' | 'range' | 'composite' | 'point' | 'text-array' | 'uuid-array' | 'number-array' | 'integer-array' | 'date-array' | 'geometry' | 'geometry-point' | 'geometry-collection' | 'inet' | 'image' | 'file' | 'video' | 'audio' | 'upload' | 'attachment' | 'uuid' | 'color' | 'rating' | 'tags' | 'tsvector' | 'origin' | 'path' | 'binary' | 'vector' | 'relation' | 'unknown';
25
38
  type CellCategory = 'text' | 'numeric' | 'date' | 'boolean' | 'structured' | 'geometric' | 'network' | 'media' | 'special' | 'other';
26
39
  type CellValue = string | number | boolean | Date | null | undefined | Array<any> | Record<string, any>;
27
40
  interface FieldMetadata {
@@ -153,6 +166,8 @@ interface SheetsCellStyleHint {
153
166
  faded?: boolean;
154
167
  /** This draft cell has a field-level validation error (draftMeta.errors[colKey]). */
155
168
  error?: boolean;
169
+ /** The server could not send this value: the cell shows a muted notice instead. */
170
+ unreadable?: boolean;
156
171
  [extra: string]: unknown;
157
172
  }
158
173
  /**
@@ -175,35 +190,49 @@ interface SheetsCell {
175
190
  };
176
191
  }
177
192
 
193
+ interface DraftFieldGap {
194
+ /** The model field without a value. */
195
+ field: string;
196
+ /** The grid column that fills it: the field itself, or the link column of the relation it keys. */
197
+ columnKey: string;
198
+ /** The column's label, as its header shows it. */
199
+ label: string;
200
+ }
201
+
178
202
  /** Result of submitting a draft row */
179
203
  interface DraftSubmitResult {
180
204
  /** The created row with its metadata-defined primary-key fields. */
181
205
  createdRow: Record<string, unknown> | null;
206
+ /** Required fields the draft still lacks, when Save was refused before sending. */
207
+ missing?: readonly DraftFieldGap[];
182
208
  }
183
209
 
184
210
  type RelationKind = 'belongsTo' | 'hasOne' | 'hasMany' | 'manyToMany';
211
+ /**
212
+ * Per-column relation facts for cell routing, draft rows and draft submission.
213
+ * Built from the table model by {@link relationInfoFromModel}; `relation` is the
214
+ * model's relation itself and is the source of truth for keys and labels.
215
+ */
185
216
  interface RelationInfo {
186
217
  kind: RelationKind;
218
+ /** GraphQL type name of the related table. */
187
219
  relatedTable?: string;
220
+ /** Fields that label a related record (the related table's display rule). */
188
221
  displayCandidates: string[];
222
+ /** The relation field on the row. */
189
223
  relationField?: string;
224
+ /** belongsTo only: the local key field this entry stands for (on the relation entry, the first one). */
190
225
  foreignKeyField?: string;
191
- junctionTable?: string;
192
- junctionLeftKeyField?: string;
193
- junctionRightKeyField?: string;
194
- displayName?: string;
226
+ /** The relation model behind this entry. */
227
+ relation?: RelationModel;
195
228
  }
196
- interface RelationInfoSlice {
197
- relationInfoCache: Record<string, Record<string, RelationInfo>>;
198
- relationInfoMapCache: Record<string, Map<string, RelationInfo>>;
199
- setRelationInfoForTable: (tableName: string, info: Record<string, RelationInfo>) => void;
200
- getRelationInfoForTable: (tableName: string) => Record<string, RelationInfo> | undefined;
201
- getRelationInfoMapForTable: (tableName: string) => Map<string, RelationInfo> | undefined;
202
- rebuildRelationInfo: (tableName: string, meta: MetaQuery | undefined) => void;
203
- ensureRelationInfo: (tableName: string, meta: MetaQuery | undefined) => Record<string, RelationInfo>;
204
- clearRelationInfoCache: () => void;
205
- }
206
- declare function buildRelationInfoFromMeta(tableName: string, meta: MetaQuery | undefined): Record<string, RelationInfo> | null;
229
+ /**
230
+ * Relation entries per column key, from the table model: one entry per relation
231
+ * column the grid shows, plus one per local key field of a shown belongsTo (so a
232
+ * draft submission sends those fields and skips the relation field). Derived, not
233
+ * cached: a new model (after a `_meta` refetch) gives new entries.
234
+ */
235
+ declare function relationInfoFromModel(model: TableModel | null | undefined): Map<string, RelationInfo>;
207
236
 
208
237
  /** A row locator accepted by Sheets CRUD operations. */
209
238
  type SheetsRowIdentifier = string | number | Readonly<Record<string, RowIdentityValue>>;
@@ -231,6 +260,12 @@ declare function resolveSheetsIdentifier(table: MetaTable, identifier: SheetsRow
231
260
  declare function sheetsIdentifierToWhere(table: MetaTable, identifier: SheetsRowIdentifier): Record<string, {
232
261
  equalTo: RowIdentityValue;
233
262
  }> | null;
263
+ /**
264
+ * The primary-key values a model document needs. A scalar identifier is the
265
+ * value of a one-field key, whatever that field is called; an object must
266
+ * carry every key field.
267
+ */
268
+ declare function sheetsIdentifierToRowKey(model: TableModel, identifier: SheetsRowIdentifier): RowKey;
234
269
  /** Use scalar IDs as cache keys for compatibility; use serialized identities otherwise. */
235
270
  declare function sheetsIdentifierCacheKey(table: MetaTable, identifier: SheetsRowIdentifier): string | number | null;
236
271
  /** Stable TanStack/selection/editor key with an index fallback only for non-writable rows. */
@@ -244,10 +279,20 @@ interface EditorProps {
244
279
  colKey: string;
245
280
  rowId: string;
246
281
  rowIdentifier?: SheetsRowIdentifier | null;
282
+ /** The row being edited (server or draft), or null. Relation editors read the row's own key values from it. */
283
+ row?: Readonly<Record<string, unknown>> | null;
247
284
  rowIndex: number;
248
285
  tableName?: string;
249
286
  fieldMeta?: FieldMetadata$1;
250
287
  relationInfo?: RelationInfo;
288
+ /** The table-model column behind this cell, or null when the cell is not a column. */
289
+ column?: ColumnModel | null;
290
+ /** The table-model relation behind this cell, or null when the cell is not a relation. */
291
+ relation?: RelationModel | null;
292
+ /** The table model of the grid, or null while it loads. */
293
+ table?: TableModel | null;
294
+ /** Why the cell cannot be written, from the table model; null when it can. */
295
+ readOnlyReason?: string | null;
251
296
  /**
252
297
  * Type-to-edit seed: when the overlay was opened by typing a printable char on the
253
298
  * active cell, this carries that char. Value editors (text/number) initialize their
@@ -284,10 +329,18 @@ interface CellCreationMetadata {
284
329
  fieldName: string;
285
330
  fieldMeta?: FieldMetadata$1;
286
331
  relationInfo?: RelationInfo;
332
+ /** The table-model column behind this cell, or null when the cell is not a column (a relation, a draft action). */
333
+ column?: ColumnModel | null;
334
+ /** The table-model relation behind this cell, or null when the cell is not a relation. */
335
+ relation?: RelationModel | null;
336
+ /** The table model of the grid, or null while it loads. */
337
+ table?: TableModel | null;
338
+ /** Every record a list relation links to when the relation reports a total, else null ("+N more"). */
339
+ relationTotalCount?: number | null;
287
340
  relationOptions?: RelationCellOptions;
288
341
  canEdit: boolean;
289
342
  isReadonly: boolean;
290
343
  activationBehavior: 'single-click' | 'double-click';
291
344
  }
292
345
 
293
- export { type BaseCellProps as B, type CellCreationMetadata as C, type DraftSubmitResult as D, type EditorProps as E, type FieldMetadata$1 as F, type RelationInfo as R, type SheetsCell as S, type TableSchema as T, type SheetsCellKind as a, type CellType as b, type CellCategory as c, type RelationInfoSlice as d, type SheetsRowIdentifier as e, type CellRegistryEntry as f, type CellRenderer as g, type CellPlugin as h, type ColumnSchema as i, type CellValue as j, type FieldMetadata as k, type RelationKind as l, type RowData as m, type SheetsRowIdentityResolution as n, buildRelationInfoFromMeta as o, canRunSheetsMutation as p, getSheetsWriteCapability as q, isImageField as r, resolveCellType as s, resolveSheetsIdentifier as t, resolveSheetsRowIdentity as u, sheetsIdentifierCacheKey as v, sheetsIdentifierToWhere as w, sheetsRowKey as x };
346
+ export { type BaseCellProps as B, type CellCreationMetadata as C, type DraftSubmitResult as D, type EditorProps as E, type FieldMetadata$1 as F, type RelationInfo as R, type SheetsCell as S, type TableSchema as T, type SheetsCellKind as a, type CellType as b, type CellCategory as c, type SheetsRowIdentifier as d, type CellRegistryEntry as e, type CellRenderer as f, type CellPlugin as g, type ColumnSchema as h, type CellValue as i, type FieldMetadata as j, type RelationKind as k, type RowData as l, type SheetsRowIdentityResolution as m, canRunSheetsMutation as n, getSheetsWriteCapability as o, isImageField as p, resolveCellType as q, relationInfoFromModel as r, resolveSheetsIdentifier as s, resolveSheetsRowIdentity as t, sheetsIdentifierCacheKey as u, sheetsIdentifierToRowKey as v, sheetsIdentifierToWhere as w, sheetsRowKey as x };