@constructive-io/sheets 0.3.0 → 0.6.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 +19 -24
- package/dist/advanced.cjs +659 -474
- package/dist/advanced.cjs.map +1 -1
- package/dist/advanced.d.cts +9 -10
- package/dist/advanced.d.ts +9 -10
- package/dist/advanced.js +3 -3
- package/dist/auth.cjs +10 -10
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +5 -4
- package/dist/auth.d.ts +5 -4
- package/dist/auth.js +3 -3
- package/dist/{chunk-GLVZSPV2.js → chunk-4EZ6A23C.js} +4 -3
- package/dist/chunk-4EZ6A23C.js.map +1 -0
- package/dist/{chunk-FNVHSOQQ.js → chunk-KKAWMVEG.js} +11 -11
- package/dist/chunk-KKAWMVEG.js.map +1 -0
- package/dist/{chunk-4PGPVMZB.js → chunk-KOZAW264.js} +4 -3
- package/dist/chunk-KOZAW264.js.map +1 -0
- package/dist/{chunk-ODUBS2NL.js → chunk-KVPVEXWB.js} +40 -17
- package/dist/chunk-KVPVEXWB.js.map +1 -0
- package/dist/{chunk-TU7ATZ4X.js → chunk-LR64FLWO.js} +301 -410
- package/dist/chunk-LR64FLWO.js.map +1 -0
- package/dist/chunk-ZETPUEXH.js +494 -0
- package/dist/chunk-ZETPUEXH.js.map +1 -0
- package/dist/{date-editor-CXKKGNL6.js → date-editor-QT47WY5T.js} +5 -3
- package/dist/date-editor-QT47WY5T.js.map +1 -0
- package/dist/{editor-props-M6Dh0P9f.d.ts → grid-cell-types-C3ARj148.d.cts} +70 -62
- package/dist/{editor-props-M6Dh0P9f.d.cts → grid-cell-types-C3ARj148.d.ts} +70 -62
- package/dist/index.cjs +1150 -703
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +123 -35
- package/dist/index.d.ts +123 -35
- package/dist/index.js +323 -99
- package/dist/index.js.map +1 -1
- package/dist/{sheets-context-CojEFlaY.d.cts → sheets-context-B03WDhZ9.d.cts} +36 -6
- package/dist/{sheets-context-Da55TTR9.d.ts → sheets-context-DmVCOgiX.d.ts} +36 -6
- package/dist/styles.css +6 -0
- package/dist/testing.cjs +476 -108
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +11 -7
- package/dist/testing.d.ts +11 -7
- package/dist/testing.js +34 -8
- package/dist/testing.js.map +1 -1
- package/package.json +15 -16
- package/dist/chunk-4PGPVMZB.js.map +0 -1
- package/dist/chunk-FNVHSOQQ.js.map +0 -1
- package/dist/chunk-GLVZSPV2.js.map +0 -1
- package/dist/chunk-H4JJTMP5.js +0 -160
- package/dist/chunk-H4JJTMP5.js.map +0 -1
- package/dist/chunk-ODUBS2NL.js.map +0 -1
- package/dist/chunk-TU7ATZ4X.js.map +0 -1
- package/dist/date-editor-CXKKGNL6.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -437,8 +437,10 @@ var init_date_editor = __esm({
|
|
|
437
437
|
const isDateTimeType = dateType === "datetime" || dateType === "timestamptz";
|
|
438
438
|
const handleDateSelect = (0, import_react44.useCallback)(
|
|
439
439
|
(dateValue2) => {
|
|
440
|
-
|
|
441
|
-
const
|
|
440
|
+
if (Array.isArray(dateValue2)) return;
|
|
441
|
+
const selectedValue = dateValue2;
|
|
442
|
+
setSelectedDate(selectedValue);
|
|
443
|
+
const jsDate = dateValueToDate(selectedValue);
|
|
442
444
|
if (jsDate) {
|
|
443
445
|
if (isDateTimeType && currentDateValue) {
|
|
444
446
|
const currentDate = new Date(currentDateValue);
|
|
@@ -611,7 +613,7 @@ __export(map_picker_exports, {
|
|
|
611
613
|
MapPicker: () => MapPicker
|
|
612
614
|
});
|
|
613
615
|
function MapLoading({ height }) {
|
|
614
|
-
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { style: { height: `${height}px` }, className: "bg-muted flex items-center justify-center rounded-lg border", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
616
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { style: { height: `${height}px` }, className: "bg-muted flex items-center justify-center rounded-lg border", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react4.Loader2, { className: "h-6 w-6 animate-spin text-muted-foreground" }) });
|
|
615
617
|
}
|
|
616
618
|
function MapPicker({
|
|
617
619
|
value,
|
|
@@ -689,7 +691,7 @@ function MapPicker({
|
|
|
689
691
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: cn("relative w-full", className), children: [
|
|
690
692
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "relative mb-2", children: [
|
|
691
693
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_input_group.InputGroup, { children: [
|
|
692
|
-
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_input_group.InputGroupAddon, { children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
694
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_input_group.InputGroupAddon, { children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react4.SearchIcon, {}) }),
|
|
693
695
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
694
696
|
import_input_group.InputGroupInput,
|
|
695
697
|
{
|
|
@@ -710,7 +712,7 @@ function MapPicker({
|
|
|
710
712
|
onClick: clearSearch,
|
|
711
713
|
disabled,
|
|
712
714
|
className: "h-7 w-7 p-0",
|
|
713
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
715
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react4.XIcon, { className: "h-3 w-3" })
|
|
714
716
|
}
|
|
715
717
|
),
|
|
716
718
|
position && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
@@ -722,7 +724,7 @@ function MapPicker({
|
|
|
722
724
|
onClick: clearLocation,
|
|
723
725
|
disabled,
|
|
724
726
|
className: "h-7 w-7 p-0",
|
|
725
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
727
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react4.MapPinIcon, { className: "h-3 w-3" })
|
|
726
728
|
}
|
|
727
729
|
)
|
|
728
730
|
] })
|
|
@@ -753,7 +755,7 @@ function MapPicker({
|
|
|
753
755
|
}
|
|
754
756
|
) }) }) }),
|
|
755
757
|
position && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "text-muted-foreground mt-2 text-xs", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
756
|
-
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
758
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react4.MapPinIcon, { className: "h-3 w-3" }),
|
|
757
759
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("span", { children: [
|
|
758
760
|
"Latitude: ",
|
|
759
761
|
position[0].toFixed(6),
|
|
@@ -763,13 +765,13 @@ function MapPicker({
|
|
|
763
765
|
] }) })
|
|
764
766
|
] });
|
|
765
767
|
}
|
|
766
|
-
var import_react46,
|
|
768
|
+
var import_react46, import_lucide_react4, import_button8, import_card, import_input_group, import_jsx_runtime31, createMapValue, extractPosition, searchLocation, LeafletMapInner;
|
|
767
769
|
var init_map_picker = __esm({
|
|
768
770
|
"src/utils/map-picker.tsx"() {
|
|
769
771
|
"use strict";
|
|
770
772
|
"use client";
|
|
771
773
|
import_react46 = __toESM(require("react"), 1);
|
|
772
|
-
|
|
774
|
+
import_lucide_react4 = require("lucide-react");
|
|
773
775
|
init_cn();
|
|
774
776
|
init_sheets_logger();
|
|
775
777
|
import_button8 = require("@constructive-io/ui/button");
|
|
@@ -903,7 +905,7 @@ __export(src_exports, {
|
|
|
903
905
|
BUILTIN_EDITOR_TYPES: () => BUILTIN_EDITOR_TYPES,
|
|
904
906
|
CellRegistry: () => CellRegistry,
|
|
905
907
|
DATE_TIME_TYPES: () => DATE_TIME_TYPES,
|
|
906
|
-
DataError: () =>
|
|
908
|
+
DataError: () => import_data3.DataError,
|
|
907
909
|
DockStatusBar: () => DockStatusBar,
|
|
908
910
|
DockStatusBarCompact: () => DockStatusBarCompact,
|
|
909
911
|
ENHANCED_TYPES: () => ENHANCED_TYPES,
|
|
@@ -932,6 +934,7 @@ __export(src_exports, {
|
|
|
932
934
|
buildRelationInfoFromMeta: () => buildRelationInfoFromMeta,
|
|
933
935
|
buildScalarFormSpec: () => buildScalarFormSpec,
|
|
934
936
|
buildZodSchema: () => buildZodSchema,
|
|
937
|
+
canRunSheetsMutation: () => canRunSheetsMutation,
|
|
935
938
|
clearSheetsSelection: () => clear,
|
|
936
939
|
computeDraftMetaSignature: () => computeDraftMetaSignature,
|
|
937
940
|
countConditions: () => countConditions,
|
|
@@ -951,6 +954,7 @@ __export(src_exports, {
|
|
|
951
954
|
findTableFormSpec: () => findTableFormSpec,
|
|
952
955
|
getCellsInRange: () => getCellsInRange,
|
|
953
956
|
getDraftMeta: () => getDraftMeta,
|
|
957
|
+
getSheetsWriteCapability: () => getSheetsWriteCapability,
|
|
954
958
|
isArrayCellType: () => isArrayCellType,
|
|
955
959
|
isDraftRow: () => isDraftRow,
|
|
956
960
|
isImageField: () => isImageField,
|
|
@@ -961,10 +965,16 @@ __export(src_exports, {
|
|
|
961
965
|
moveActive: () => moveActive,
|
|
962
966
|
queryKeys: () => sheetsTableQueryKeys,
|
|
963
967
|
resolveCellType: () => resolveCellType,
|
|
968
|
+
resolveDownloadUrl: () => resolveDownloadUrl,
|
|
969
|
+
resolveSheetsIdentifier: () => resolveSheetsIdentifier,
|
|
970
|
+
resolveSheetsRowIdentity: () => resolveSheetsRowIdentity,
|
|
964
971
|
selectCell: () => selectCell,
|
|
965
972
|
selectRange: () => selectRange,
|
|
966
973
|
selectRow: () => selectRow,
|
|
974
|
+
sheetsIdentifierCacheKey: () => sheetsIdentifierCacheKey,
|
|
975
|
+
sheetsIdentifierToWhere: () => sheetsIdentifierToWhere,
|
|
967
976
|
sheetsQueryKeys: () => sheetsQueryKeys,
|
|
977
|
+
sheetsRowKey: () => sheetsRowKey,
|
|
968
978
|
toTSV: () => toTSV,
|
|
969
979
|
toggleRow: () => toggleRow,
|
|
970
980
|
tokensFromCssVars: () => tokensFromCssVars,
|
|
@@ -997,6 +1007,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
997
1007
|
// src/context/sheets-provider.tsx
|
|
998
1008
|
var import_react3 = require("react");
|
|
999
1009
|
var import_react_query = require("@tanstack/react-query");
|
|
1010
|
+
var import_zustand2 = require("zustand");
|
|
1000
1011
|
|
|
1001
1012
|
// src/context/sheets-context.ts
|
|
1002
1013
|
var import_react = require("react");
|
|
@@ -1010,17 +1021,351 @@ function useSheetsContext() {
|
|
|
1010
1021
|
}
|
|
1011
1022
|
|
|
1012
1023
|
// src/context/sheets-execute.ts
|
|
1024
|
+
var import_graphql2 = require("graphql");
|
|
1025
|
+
var import_data2 = require("@constructive-io/data");
|
|
1026
|
+
|
|
1027
|
+
// src/context/sheets-upload-presigned.ts
|
|
1013
1028
|
var import_graphql = require("graphql");
|
|
1014
1029
|
var import_data = require("@constructive-io/data");
|
|
1015
|
-
|
|
1030
|
+
async function sha256HexFromBuffer(buffer) {
|
|
1031
|
+
if (!globalThis.crypto?.subtle) {
|
|
1032
|
+
throw import_data.createError.badRequest("Web Crypto (crypto.subtle) is unavailable; cannot hash file for upload.");
|
|
1033
|
+
}
|
|
1034
|
+
const digest = await crypto.subtle.digest("SHA-256", buffer);
|
|
1035
|
+
const bytes = new Uint8Array(digest);
|
|
1036
|
+
let hex = "";
|
|
1037
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
1038
|
+
hex += bytes[i].toString(16).padStart(2, "0");
|
|
1039
|
+
}
|
|
1040
|
+
return hex;
|
|
1041
|
+
}
|
|
1042
|
+
var capabilityCache = /* @__PURE__ */ new Map();
|
|
1043
|
+
function discoverUploadCapability(endpoint, execute) {
|
|
1044
|
+
const cached = capabilityCache.get(endpoint);
|
|
1045
|
+
if (cached) return cached;
|
|
1046
|
+
const promise = (async () => {
|
|
1047
|
+
const data = await execute((0, import_graphql.getIntrospectionQuery)());
|
|
1048
|
+
const schema = data?.__schema;
|
|
1049
|
+
if (!schema) {
|
|
1050
|
+
throw import_data.createError.badRequest("Uploads are not enabled for this endpoint.");
|
|
1051
|
+
}
|
|
1052
|
+
return resolveUploadCapability(schema);
|
|
1053
|
+
})();
|
|
1054
|
+
promise.catch(() => capabilityCache.delete(endpoint));
|
|
1055
|
+
capabilityCache.set(endpoint, promise);
|
|
1056
|
+
return promise;
|
|
1057
|
+
}
|
|
1058
|
+
function namedTypeName(ref) {
|
|
1059
|
+
let cur = ref;
|
|
1060
|
+
while (cur && (cur.kind === "NON_NULL" || cur.kind === "LIST")) {
|
|
1061
|
+
cur = cur.ofType ?? null;
|
|
1062
|
+
}
|
|
1063
|
+
return cur?.name ?? null;
|
|
1064
|
+
}
|
|
1065
|
+
function isListTypeRef(ref) {
|
|
1066
|
+
let cur = ref;
|
|
1067
|
+
while (cur && cur.kind === "NON_NULL") {
|
|
1068
|
+
cur = cur.ofType ?? null;
|
|
1069
|
+
}
|
|
1070
|
+
return cur?.kind === "LIST";
|
|
1071
|
+
}
|
|
1072
|
+
var PK_FIELD_NAME = "id";
|
|
1073
|
+
function resolveUploadCapability(schema) {
|
|
1074
|
+
const typeByName = /* @__PURE__ */ new Map();
|
|
1075
|
+
for (const t of schema.types) {
|
|
1076
|
+
if (t.name) typeByName.set(t.name, t);
|
|
1077
|
+
}
|
|
1078
|
+
const objectHasFields = (typeName, names) => {
|
|
1079
|
+
if (!typeName) return false;
|
|
1080
|
+
const t = typeByName.get(typeName);
|
|
1081
|
+
if (!t?.fields) return false;
|
|
1082
|
+
const present = new Set(t.fields.map((f) => f.name));
|
|
1083
|
+
return names.every((n) => present.has(n));
|
|
1084
|
+
};
|
|
1085
|
+
const inputHasFields = (typeName, names) => {
|
|
1086
|
+
if (!typeName) return false;
|
|
1087
|
+
const t = typeByName.get(typeName);
|
|
1088
|
+
if (!t?.inputFields) return false;
|
|
1089
|
+
const present = new Set(t.inputFields.map((f) => f.name));
|
|
1090
|
+
return names.every((n) => present.has(n));
|
|
1091
|
+
};
|
|
1092
|
+
const PAYLOAD_FIELDS = ["uploadUrl", "fileId", "deduplicated"];
|
|
1093
|
+
const INPUT_FIELDS = ["contentHash", "bucketKey", "contentType", "size"];
|
|
1094
|
+
const mutationType = schema.mutationType ? typeByName.get(schema.mutationType.name) : null;
|
|
1095
|
+
const queryType = schema.queryType ? typeByName.get(schema.queryType.name) : null;
|
|
1096
|
+
let upload = null;
|
|
1097
|
+
for (const field of mutationType?.fields ?? []) {
|
|
1098
|
+
const inputArg = field.args.find((a) => a.name === "input");
|
|
1099
|
+
if (!inputArg) continue;
|
|
1100
|
+
const inputTypeName = namedTypeName(inputArg.type);
|
|
1101
|
+
const payloadTypeName = namedTypeName(field.type);
|
|
1102
|
+
if (inputHasFields(inputTypeName, INPUT_FIELDS) && objectHasFields(payloadTypeName, PAYLOAD_FIELDS)) {
|
|
1103
|
+
upload = { uploadFieldName: field.name, inputTypeName };
|
|
1104
|
+
break;
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
if (!upload) {
|
|
1108
|
+
throw import_data.createError.badRequest("Uploads are not enabled for this endpoint.");
|
|
1109
|
+
}
|
|
1110
|
+
const downloadById = resolveDownloadByIdField(schema, typeByName, queryType, upload.uploadFieldName);
|
|
1111
|
+
return {
|
|
1112
|
+
...upload,
|
|
1113
|
+
...downloadById
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
function resolveDownloadByIdField(schema, typeByName, queryType, uploadFieldName) {
|
|
1117
|
+
const fileTypesWithDownloadUrl = /* @__PURE__ */ new Set();
|
|
1118
|
+
for (const t of schema.types) {
|
|
1119
|
+
if (t.kind === "OBJECT" && t.name && t.fields?.some((f) => f.name === "downloadUrl")) {
|
|
1120
|
+
fileTypesWithDownloadUrl.add(t.name);
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
for (const field of queryType?.fields ?? []) {
|
|
1124
|
+
const returnTypeName = namedTypeName(field.type);
|
|
1125
|
+
if (!returnTypeName || !fileTypesWithDownloadUrl.has(returnTypeName)) continue;
|
|
1126
|
+
if (field.args.length === 1 && field.args[0].name === PK_FIELD_NAME) {
|
|
1127
|
+
return {
|
|
1128
|
+
fileByIdField: field.name,
|
|
1129
|
+
fileByIdArgName: "id",
|
|
1130
|
+
fileTypeName: returnTypeName,
|
|
1131
|
+
idScalarName: namedTypeName(field.args[0].type) ?? void 0
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
const connection = resolveConnectionDownloadField(typeByName, queryType, fileTypesWithDownloadUrl, uploadFieldName);
|
|
1136
|
+
if (connection) return connection;
|
|
1137
|
+
const nodeField = queryType?.fields?.find(
|
|
1138
|
+
(f) => f.name === "node" && f.args.some((a) => a.name === "nodeId")
|
|
1139
|
+
);
|
|
1140
|
+
if (nodeField && fileTypesWithDownloadUrl.size > 0) {
|
|
1141
|
+
const preferred = uploadFieldName.replace(/^upload/, "");
|
|
1142
|
+
const fileTypeName = fileTypesWithDownloadUrl.has(preferred) ? preferred : [...fileTypesWithDownloadUrl][0];
|
|
1143
|
+
return { fileByIdField: "node", fileByIdArgName: "nodeId", fileTypeName };
|
|
1144
|
+
}
|
|
1145
|
+
throw import_data.createError.badRequest("Uploads are not enabled for this endpoint.");
|
|
1146
|
+
}
|
|
1147
|
+
function resolveConnectionDownloadField(typeByName, queryType, fileTypesWithDownloadUrl, uploadFieldName) {
|
|
1148
|
+
const EQUALITY_OPERATORS = ["equalTo", "eq"];
|
|
1149
|
+
const candidates = [];
|
|
1150
|
+
for (const field of queryType?.fields ?? []) {
|
|
1151
|
+
const connTypeName = namedTypeName(field.type);
|
|
1152
|
+
if (!connTypeName) continue;
|
|
1153
|
+
const connType = typeByName.get(connTypeName);
|
|
1154
|
+
if (connType?.kind !== "OBJECT" || !connType.fields) continue;
|
|
1155
|
+
const nodesField = connType.fields.find((f) => {
|
|
1156
|
+
if (!isListTypeRef(f.type)) return false;
|
|
1157
|
+
const elem = namedTypeName(f.type);
|
|
1158
|
+
return elem != null && fileTypesWithDownloadUrl.has(elem);
|
|
1159
|
+
});
|
|
1160
|
+
if (!nodesField) continue;
|
|
1161
|
+
const fileTypeName = namedTypeName(nodesField.type);
|
|
1162
|
+
for (const arg of field.args) {
|
|
1163
|
+
const filterTypeName = namedTypeName(arg.type);
|
|
1164
|
+
const filterType = filterTypeName ? typeByName.get(filterTypeName) : null;
|
|
1165
|
+
if (filterType?.kind !== "INPUT_OBJECT" || !filterType.inputFields) continue;
|
|
1166
|
+
const idField = filterType.inputFields.find((f) => f.name === PK_FIELD_NAME);
|
|
1167
|
+
if (!idField) continue;
|
|
1168
|
+
const idFieldTypeName = namedTypeName(idField.type);
|
|
1169
|
+
const idFieldType = idFieldTypeName ? typeByName.get(idFieldTypeName) : null;
|
|
1170
|
+
if (idFieldType?.kind === "INPUT_OBJECT" && idFieldType.inputFields) {
|
|
1171
|
+
const opField = EQUALITY_OPERATORS.map(
|
|
1172
|
+
(op) => idFieldType.inputFields.find((f) => f.name === op)
|
|
1173
|
+
).find((f) => f != null);
|
|
1174
|
+
if (opField) {
|
|
1175
|
+
candidates.push({
|
|
1176
|
+
fileByIdField: field.name,
|
|
1177
|
+
fileByIdArgName: "connection",
|
|
1178
|
+
fileTypeName,
|
|
1179
|
+
idScalarName: namedTypeName(opField.type) ?? void 0,
|
|
1180
|
+
connectionFilterArgName: arg.name,
|
|
1181
|
+
connectionIdField: idField.name,
|
|
1182
|
+
connectionIdOperator: opField.name,
|
|
1183
|
+
connectionNodesField: nodesField.name
|
|
1184
|
+
});
|
|
1185
|
+
break;
|
|
1186
|
+
}
|
|
1187
|
+
continue;
|
|
1188
|
+
}
|
|
1189
|
+
if (idFieldType?.kind === "SCALAR" || !idFieldType && idFieldTypeName) {
|
|
1190
|
+
candidates.push({
|
|
1191
|
+
fileByIdField: field.name,
|
|
1192
|
+
fileByIdArgName: "connection",
|
|
1193
|
+
fileTypeName,
|
|
1194
|
+
idScalarName: idFieldTypeName ?? void 0,
|
|
1195
|
+
connectionFilterArgName: arg.name,
|
|
1196
|
+
connectionIdField: idField.name,
|
|
1197
|
+
connectionNodesField: nodesField.name
|
|
1198
|
+
});
|
|
1199
|
+
break;
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
if (candidates.length === 0) return null;
|
|
1204
|
+
const preferred = uploadFieldName.replace(/^upload/, "");
|
|
1205
|
+
return candidates.find((c) => c.fileTypeName === preferred) ?? candidates[0];
|
|
1206
|
+
}
|
|
1207
|
+
async function callUploadOp(execute, cap, input) {
|
|
1208
|
+
const mutation = `
|
|
1209
|
+
mutation SheetsUpload($input: ${cap.inputTypeName}!) {
|
|
1210
|
+
${cap.uploadFieldName}(input: $input) {
|
|
1211
|
+
uploadUrl
|
|
1212
|
+
fileId
|
|
1213
|
+
key
|
|
1214
|
+
deduplicated
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
`.trim();
|
|
1218
|
+
const data = await execute(mutation, {
|
|
1219
|
+
input: {
|
|
1220
|
+
bucketKey: input.bucketKey,
|
|
1221
|
+
contentHash: input.contentHash,
|
|
1222
|
+
contentType: input.contentType,
|
|
1223
|
+
size: input.size,
|
|
1224
|
+
filename: input.filename
|
|
1225
|
+
}
|
|
1226
|
+
});
|
|
1227
|
+
const payload = data?.[cap.uploadFieldName];
|
|
1228
|
+
if (!payload) {
|
|
1229
|
+
throw import_data.createError.badRequest("Upload failed: no payload returned from upload mutation.");
|
|
1230
|
+
}
|
|
1231
|
+
return payload;
|
|
1232
|
+
}
|
|
1233
|
+
async function presignedPut(url, buffer, contentType, onProgress) {
|
|
1234
|
+
const total = buffer.byteLength;
|
|
1235
|
+
if (onProgress && typeof XMLHttpRequest !== "undefined") {
|
|
1236
|
+
await putWithXHR(url, buffer, contentType, total, onProgress);
|
|
1237
|
+
return;
|
|
1238
|
+
}
|
|
1239
|
+
let response;
|
|
1240
|
+
try {
|
|
1241
|
+
response = await fetch(url, {
|
|
1242
|
+
method: "PUT",
|
|
1243
|
+
headers: { "Content-Type": contentType },
|
|
1244
|
+
body: buffer
|
|
1245
|
+
});
|
|
1246
|
+
} catch (error) {
|
|
1247
|
+
throw import_data.createError.network(error instanceof Error ? error : void 0);
|
|
1248
|
+
}
|
|
1249
|
+
if (!response.ok) {
|
|
1250
|
+
const body = await response.text().catch(() => "");
|
|
1251
|
+
throw import_data.createError.badRequest(`Upload failed: ${response.status} ${response.statusText}${body ? ` \u2014 ${body}` : ""}`);
|
|
1252
|
+
}
|
|
1253
|
+
onProgress?.({ loaded: total, total, percentage: 100 });
|
|
1254
|
+
}
|
|
1255
|
+
function putWithXHR(url, buffer, contentType, total, onProgress) {
|
|
1256
|
+
return new Promise((resolve, reject) => {
|
|
1257
|
+
const xhr = new XMLHttpRequest();
|
|
1258
|
+
xhr.open("PUT", url);
|
|
1259
|
+
xhr.setRequestHeader("Content-Type", contentType);
|
|
1260
|
+
xhr.upload.addEventListener("progress", (event) => {
|
|
1261
|
+
if (event.lengthComputable) {
|
|
1262
|
+
onProgress({
|
|
1263
|
+
loaded: event.loaded,
|
|
1264
|
+
total: event.total,
|
|
1265
|
+
percentage: Math.round(event.loaded / event.total * 100)
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
});
|
|
1269
|
+
xhr.addEventListener("load", () => {
|
|
1270
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
1271
|
+
onProgress({ loaded: total, total, percentage: 100 });
|
|
1272
|
+
resolve();
|
|
1273
|
+
} else {
|
|
1274
|
+
reject(import_data.createError.badRequest(`Upload failed: ${xhr.status} ${xhr.statusText}${xhr.responseText ? ` \u2014 ${xhr.responseText}` : ""}`));
|
|
1275
|
+
}
|
|
1276
|
+
});
|
|
1277
|
+
xhr.addEventListener("error", () => reject(import_data.createError.network()));
|
|
1278
|
+
xhr.send(buffer);
|
|
1279
|
+
});
|
|
1280
|
+
}
|
|
1281
|
+
function toGlobalId(typeName, id) {
|
|
1282
|
+
if (typeof btoa !== "function") {
|
|
1283
|
+
throw import_data.createError.badRequest("Cannot encode the file node id: btoa is unavailable in this environment.");
|
|
1284
|
+
}
|
|
1285
|
+
return btoa(JSON.stringify([typeName, id]));
|
|
1286
|
+
}
|
|
1287
|
+
async function fetchDownloadUrl(execute, cap, fileId) {
|
|
1288
|
+
if (cap.fileByIdArgName === "nodeId") {
|
|
1289
|
+
const nodeId = toGlobalId(cap.fileTypeName, fileId);
|
|
1290
|
+
const query2 = `
|
|
1291
|
+
query SheetsDownloadUrl($nodeId: ID!) {
|
|
1292
|
+
${cap.fileByIdField}(nodeId: $nodeId) {
|
|
1293
|
+
... on ${cap.fileTypeName} {
|
|
1294
|
+
downloadUrl
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
`.trim();
|
|
1299
|
+
const data2 = await execute(query2, { nodeId });
|
|
1300
|
+
const node = data2?.[cap.fileByIdField];
|
|
1301
|
+
const url2 = node?.downloadUrl;
|
|
1302
|
+
if (!url2) {
|
|
1303
|
+
throw import_data.createError.badRequest("Upload succeeded but no downloadUrl was returned for the file.");
|
|
1304
|
+
}
|
|
1305
|
+
return url2;
|
|
1306
|
+
}
|
|
1307
|
+
if (cap.fileByIdArgName === "connection") {
|
|
1308
|
+
const idScalar2 = cap.idScalarName ?? "ID";
|
|
1309
|
+
const filterArg = cap.connectionFilterArgName;
|
|
1310
|
+
const idField = cap.connectionIdField;
|
|
1311
|
+
const nodesField = cap.connectionNodesField;
|
|
1312
|
+
const filterLiteral = cap.connectionIdOperator ? `{ ${idField}: { ${cap.connectionIdOperator}: $id } }` : `{ ${idField}: $id }`;
|
|
1313
|
+
const query2 = `
|
|
1314
|
+
query SheetsDownloadUrl($id: ${idScalar2}!) {
|
|
1315
|
+
${cap.fileByIdField}(${filterArg}: ${filterLiteral}, first: 1) {
|
|
1316
|
+
${nodesField} {
|
|
1317
|
+
downloadUrl
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
`.trim();
|
|
1322
|
+
const data2 = await execute(
|
|
1323
|
+
query2,
|
|
1324
|
+
{ id: fileId }
|
|
1325
|
+
);
|
|
1326
|
+
const conn = data2?.[cap.fileByIdField];
|
|
1327
|
+
const url2 = conn?.[nodesField]?.[0]?.downloadUrl;
|
|
1328
|
+
if (!url2) {
|
|
1329
|
+
throw import_data.createError.badRequest("Upload succeeded but no downloadUrl was returned for the file.");
|
|
1330
|
+
}
|
|
1331
|
+
return url2;
|
|
1332
|
+
}
|
|
1333
|
+
const idScalar = cap.idScalarName ?? "ID";
|
|
1334
|
+
const query = `
|
|
1335
|
+
query SheetsDownloadUrl($id: ${idScalar}!) {
|
|
1336
|
+
${cap.fileByIdField}(id: $id) {
|
|
1337
|
+
id
|
|
1338
|
+
downloadUrl
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
`.trim();
|
|
1342
|
+
const data = await execute(query, { id: fileId });
|
|
1343
|
+
const file = data?.[cap.fileByIdField];
|
|
1344
|
+
const url = file?.downloadUrl;
|
|
1345
|
+
if (!url) {
|
|
1346
|
+
throw import_data.createError.badRequest("Upload succeeded but no downloadUrl was returned for the file.");
|
|
1347
|
+
}
|
|
1348
|
+
return url;
|
|
1349
|
+
}
|
|
1350
|
+
async function resolveDownloadUrl(execute, endpoint, fileId) {
|
|
1351
|
+
try {
|
|
1352
|
+
const cap = await discoverUploadCapability(endpoint, execute);
|
|
1353
|
+
return await fetchDownloadUrl(execute, cap, fileId);
|
|
1354
|
+
} catch {
|
|
1355
|
+
return null;
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
// src/context/sheets-execute.ts
|
|
1360
|
+
var import_data3 = require("@constructive-io/data");
|
|
1016
1361
|
function documentToString(document2) {
|
|
1017
1362
|
if (typeof document2 === "string") return document2;
|
|
1018
1363
|
if (document2 instanceof String) return document2.toString();
|
|
1019
1364
|
if (document2 && typeof document2 === "object" && "kind" in document2) {
|
|
1020
|
-
return (0,
|
|
1365
|
+
return (0, import_graphql2.print)(document2);
|
|
1021
1366
|
}
|
|
1022
1367
|
if (document2 === null || document2 === void 0) {
|
|
1023
|
-
throw
|
|
1368
|
+
throw import_data2.createError.badRequest("Invalid GraphQL document: null or undefined");
|
|
1024
1369
|
}
|
|
1025
1370
|
return String(document2);
|
|
1026
1371
|
}
|
|
@@ -1035,18 +1380,18 @@ function parseGraphQLResponse(response, onAuthError) {
|
|
|
1035
1380
|
const message = error.message || "GraphQL query failed";
|
|
1036
1381
|
if (code === "UNAUTHENTICATED" || hasAuthMessage(message)) {
|
|
1037
1382
|
onAuthError?.();
|
|
1038
|
-
return
|
|
1383
|
+
return import_data2.createError.unauthorized("Authentication required. Please log in again.");
|
|
1039
1384
|
}
|
|
1040
1385
|
if (code === "FORBIDDEN") {
|
|
1041
|
-
return
|
|
1386
|
+
return import_data2.createError.forbidden("You do not have permission to perform this action.");
|
|
1042
1387
|
}
|
|
1043
|
-
return
|
|
1388
|
+
return import_data2.createError.graphql(message, code);
|
|
1044
1389
|
}
|
|
1045
1390
|
function createSheetsExecute(config, getToken) {
|
|
1046
1391
|
return async (document2, variables) => {
|
|
1047
1392
|
const url = config.endpoint;
|
|
1048
1393
|
if (!url) {
|
|
1049
|
-
throw
|
|
1394
|
+
throw import_data2.createError.badRequest("No GraphQL endpoint configured.");
|
|
1050
1395
|
}
|
|
1051
1396
|
const token = getToken();
|
|
1052
1397
|
const headers = {
|
|
@@ -1067,29 +1412,29 @@ function createSheetsExecute(config, getToken) {
|
|
|
1067
1412
|
})
|
|
1068
1413
|
});
|
|
1069
1414
|
} catch (error) {
|
|
1070
|
-
throw
|
|
1415
|
+
throw import_data2.createError.network(error instanceof Error ? error : void 0);
|
|
1071
1416
|
}
|
|
1072
1417
|
if (!response.ok) {
|
|
1073
1418
|
const { status, statusText } = response;
|
|
1074
1419
|
if (status === 401) {
|
|
1075
1420
|
config.onAuthError?.();
|
|
1076
|
-
throw
|
|
1421
|
+
throw import_data2.createError.unauthorized("Authentication required. Please log in again.");
|
|
1077
1422
|
}
|
|
1078
1423
|
if (status === 403) {
|
|
1079
|
-
throw
|
|
1424
|
+
throw import_data2.createError.forbidden("You do not have permission to perform this action.");
|
|
1080
1425
|
}
|
|
1081
1426
|
if (status === 404) {
|
|
1082
|
-
throw
|
|
1427
|
+
throw import_data2.createError.notFound("The requested endpoint does not exist.");
|
|
1083
1428
|
}
|
|
1084
1429
|
try {
|
|
1085
1430
|
const body = await response.json();
|
|
1086
1431
|
if (body.errors?.length) {
|
|
1087
|
-
throw
|
|
1432
|
+
throw import_data2.createError.graphql(body.errors[0].message || `Request failed: ${status}`, body.errors[0].extensions?.code);
|
|
1088
1433
|
}
|
|
1089
1434
|
} catch (e) {
|
|
1090
|
-
if (e instanceof
|
|
1435
|
+
if (e instanceof import_data2.DataError) throw e;
|
|
1091
1436
|
}
|
|
1092
|
-
throw
|
|
1437
|
+
throw import_data2.createError.badRequest(`Request failed: ${status} ${statusText}`);
|
|
1093
1438
|
}
|
|
1094
1439
|
const result = await response.json();
|
|
1095
1440
|
const graphqlError = parseGraphQLResponse(result, config.onAuthError);
|
|
@@ -1100,64 +1445,40 @@ function createSheetsExecute(config, getToken) {
|
|
|
1100
1445
|
};
|
|
1101
1446
|
}
|
|
1102
1447
|
function createSheetsUpload(config, getToken) {
|
|
1103
|
-
|
|
1448
|
+
const execute = config.execute ?? createSheetsExecute(config, getToken);
|
|
1449
|
+
return async (file, _path, options) => {
|
|
1104
1450
|
if (!config.endpoint) {
|
|
1105
|
-
throw
|
|
1106
|
-
}
|
|
1107
|
-
const
|
|
1108
|
-
const
|
|
1109
|
-
const
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
const
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
});
|
|
1123
|
-
} catch (error) {
|
|
1124
|
-
throw import_data.createError.network(error instanceof Error ? error : void 0);
|
|
1125
|
-
}
|
|
1126
|
-
if (!response.ok) {
|
|
1127
|
-
if (response.status === 401) {
|
|
1128
|
-
config.onAuthError?.();
|
|
1129
|
-
throw import_data.createError.unauthorized("Authentication required. Please log in again.");
|
|
1130
|
-
}
|
|
1131
|
-
if (response.status === 403) {
|
|
1132
|
-
throw import_data.createError.forbidden("You do not have permission to perform this action.");
|
|
1133
|
-
}
|
|
1134
|
-
try {
|
|
1135
|
-
const body = await response.json();
|
|
1136
|
-
const graphqlError = parseGraphQLResponse(body, config.onAuthError);
|
|
1137
|
-
if (graphqlError) {
|
|
1138
|
-
throw graphqlError;
|
|
1139
|
-
}
|
|
1140
|
-
if (body.errors?.length) {
|
|
1141
|
-
const firstError = body.errors[0];
|
|
1142
|
-
throw import_data.createError.graphql(firstError.message || "Upload failed", firstError.extensions?.code);
|
|
1143
|
-
}
|
|
1144
|
-
} catch (error) {
|
|
1145
|
-
if (error instanceof import_data.DataError) throw error;
|
|
1146
|
-
}
|
|
1147
|
-
if (response.status === 400) throw import_data.createError.badRequest("No file provided for upload.");
|
|
1148
|
-
if (response.status === 413) throw import_data.createError.badRequest("File is too large. Maximum size is 10 MB.");
|
|
1149
|
-
throw import_data.createError.badRequest(`Upload failed: ${response.status} ${response.statusText}`);
|
|
1150
|
-
}
|
|
1151
|
-
const result = await response.json();
|
|
1152
|
-
if (result.errors?.length) {
|
|
1153
|
-
const graphqlError = parseGraphQLResponse(result, config.onAuthError);
|
|
1154
|
-
if (graphqlError) {
|
|
1155
|
-
throw graphqlError;
|
|
1451
|
+
throw import_data2.createError.badRequest("No GraphQL endpoint configured.");
|
|
1452
|
+
}
|
|
1453
|
+
const bucketKey = config.upload?.bucketKey ?? "public";
|
|
1454
|
+
const contentType = file.type || "application/octet-stream";
|
|
1455
|
+
const buffer = await file.arrayBuffer();
|
|
1456
|
+
const contentHash = await sha256HexFromBuffer(buffer);
|
|
1457
|
+
const cap = await discoverUploadCapability(config.endpoint, execute);
|
|
1458
|
+
const payload = await callUploadOp(execute, cap, {
|
|
1459
|
+
bucketKey,
|
|
1460
|
+
contentHash,
|
|
1461
|
+
contentType,
|
|
1462
|
+
size: file.size,
|
|
1463
|
+
filename: file.name
|
|
1464
|
+
});
|
|
1465
|
+
if (!payload.deduplicated) {
|
|
1466
|
+
if (!payload.uploadUrl) {
|
|
1467
|
+
throw import_data2.createError.badRequest("Upload failed: server returned no uploadUrl for a non-deduplicated file.");
|
|
1156
1468
|
}
|
|
1157
|
-
|
|
1158
|
-
|
|
1469
|
+
await presignedPut(payload.uploadUrl, buffer, contentType, options?.onProgress);
|
|
1470
|
+
} else {
|
|
1471
|
+
options?.onProgress?.({ loaded: file.size, total: file.size, percentage: 100 });
|
|
1159
1472
|
}
|
|
1160
|
-
|
|
1473
|
+
const url = await fetchDownloadUrl(execute, cap, payload.fileId);
|
|
1474
|
+
return {
|
|
1475
|
+
url,
|
|
1476
|
+
filename: file.name,
|
|
1477
|
+
mime: file.type,
|
|
1478
|
+
size: file.size,
|
|
1479
|
+
key: payload.key,
|
|
1480
|
+
fileId: payload.fileId
|
|
1481
|
+
};
|
|
1161
1482
|
};
|
|
1162
1483
|
}
|
|
1163
1484
|
|
|
@@ -1496,11 +1817,11 @@ function hashString(input) {
|
|
|
1496
1817
|
|
|
1497
1818
|
// src/store/relation-info-slice.ts
|
|
1498
1819
|
var import_inflekt2 = require("inflekt");
|
|
1499
|
-
var
|
|
1820
|
+
var import_data5 = require("@constructive-io/data");
|
|
1500
1821
|
|
|
1501
1822
|
// src/utils/relation-utils.ts
|
|
1502
1823
|
var import_inflekt = require("inflekt");
|
|
1503
|
-
var
|
|
1824
|
+
var import_data4 = require("@constructive-io/data");
|
|
1504
1825
|
function codecNameToTableName(name) {
|
|
1505
1826
|
if (!name) return name;
|
|
1506
1827
|
const singular = (0, import_inflekt.singularize)(name);
|
|
@@ -1521,8 +1842,8 @@ function getAllRelationFields(relations, metaTables) {
|
|
|
1521
1842
|
if (metaTables) {
|
|
1522
1843
|
const leftFk = rel?.junctionLeftKeyAttributes?.[0]?.name;
|
|
1523
1844
|
const rightFk = rel?.junctionRightKeyAttributes?.[0]?.name;
|
|
1524
|
-
const leftFkCamel = leftFk ? (0,
|
|
1525
|
-
const rightFkCamel = rightFk ? (0,
|
|
1845
|
+
const leftFkCamel = leftFk ? (0, import_data4.pgFieldToCamelCase)(leftFk) : void 0;
|
|
1846
|
+
const rightFkCamel = rightFk ? (0, import_data4.pgFieldToCamelCase)(rightFk) : void 0;
|
|
1526
1847
|
const jtTableName = codecNameToTableName(jtName);
|
|
1527
1848
|
if (!isJunctionTablePure(jtTableName, leftFkCamel, rightFkCamel, metaTables)) return;
|
|
1528
1849
|
}
|
|
@@ -1542,8 +1863,8 @@ function getAllRelationFields(relations, metaTables) {
|
|
|
1542
1863
|
if (jtName) {
|
|
1543
1864
|
const leftFk = rel?.junctionLeftKeyAttributes?.[0]?.name;
|
|
1544
1865
|
const rightFk = rel?.junctionRightKeyAttributes?.[0]?.name;
|
|
1545
|
-
const leftFkCamel = leftFk ? (0,
|
|
1546
|
-
const rightFkCamel = rightFk ? (0,
|
|
1866
|
+
const leftFkCamel = leftFk ? (0, import_data4.pgFieldToCamelCase)(leftFk) : void 0;
|
|
1867
|
+
const rightFkCamel = rightFk ? (0, import_data4.pgFieldToCamelCase)(rightFk) : void 0;
|
|
1547
1868
|
const jtTableName = codecNameToTableName(jtName);
|
|
1548
1869
|
if (!isJunctionTablePure(jtTableName, leftFkCamel, rightFkCamel, metaTables)) return;
|
|
1549
1870
|
}
|
|
@@ -1560,7 +1881,7 @@ function isJunctionTablePure(junctionTableName, leftFkField, rightFkField, metaT
|
|
|
1560
1881
|
const exemptFields = /* @__PURE__ */ new Set(["id", leftFkField, rightFkField]);
|
|
1561
1882
|
for (const field of junctionMeta.fields) {
|
|
1562
1883
|
if (!field?.name) continue;
|
|
1563
|
-
const camelName = (0,
|
|
1884
|
+
const camelName = (0, import_data4.pgFieldToCamelCase)(field.name);
|
|
1564
1885
|
if (exemptFields.has(camelName)) continue;
|
|
1565
1886
|
if (field.isNotNull && !field.hasDefault) return false;
|
|
1566
1887
|
}
|
|
@@ -1619,7 +1940,7 @@ function createRelationInfoSlice(set, get) {
|
|
|
1619
1940
|
}
|
|
1620
1941
|
function toCleanTables(meta) {
|
|
1621
1942
|
const tables = meta?._meta?.tables ?? [];
|
|
1622
|
-
return tables.filter((table) => table != null).map((table) => (0,
|
|
1943
|
+
return tables.filter((table) => table != null).map((table) => (0, import_data5.cleanTable)(table));
|
|
1623
1944
|
}
|
|
1624
1945
|
function firstFieldName(fields) {
|
|
1625
1946
|
return fields[0]?.name;
|
|
@@ -1641,7 +1962,7 @@ function findForeignKeyInRelatedTable(currentTableName, relatedTableName, allTab
|
|
|
1641
1962
|
const refName = fk.refTable?.name;
|
|
1642
1963
|
if (refName && refName.toLowerCase() === currentTableName.toLowerCase()) {
|
|
1643
1964
|
const fieldName = fk.fields?.[0]?.name;
|
|
1644
|
-
if (fieldName) return (0,
|
|
1965
|
+
if (fieldName) return (0, import_data5.pgFieldToCamelCase)(fieldName);
|
|
1645
1966
|
}
|
|
1646
1967
|
}
|
|
1647
1968
|
}
|
|
@@ -1786,8 +2107,9 @@ function createSheetsStore() {
|
|
|
1786
2107
|
isAuthenticated: false,
|
|
1787
2108
|
accessToken: null,
|
|
1788
2109
|
expiresAt: null,
|
|
1789
|
-
|
|
1790
|
-
|
|
2110
|
+
identityKey: null,
|
|
2111
|
+
setAuthenticated: (token, expiresAt, identityKey = null) => set({ isAuthenticated: true, accessToken: token, expiresAt, identityKey }),
|
|
2112
|
+
setUnauthenticated: () => set({ isAuthenticated: false, accessToken: null, expiresAt: null, identityKey: null })
|
|
1791
2113
|
}));
|
|
1792
2114
|
}
|
|
1793
2115
|
var SheetsStoreContext = (0, import_react2.createContext)(null);
|
|
@@ -1827,16 +2149,17 @@ function getStoredToken(databaseId) {
|
|
|
1827
2149
|
if (!raw) return null;
|
|
1828
2150
|
const parsed = JSON.parse(raw);
|
|
1829
2151
|
if (!parsed.accessToken || !parsed.expiresAt) return null;
|
|
2152
|
+
if (parsed.identityKey != null && typeof parsed.identityKey !== "string") return null;
|
|
1830
2153
|
return parsed;
|
|
1831
2154
|
} catch {
|
|
1832
2155
|
return null;
|
|
1833
2156
|
}
|
|
1834
2157
|
}
|
|
1835
|
-
function setStoredToken(databaseId, accessToken, expiresAt) {
|
|
2158
|
+
function setStoredToken(databaseId, accessToken, expiresAt, identityKey) {
|
|
1836
2159
|
const storage = getStorage();
|
|
1837
2160
|
if (!storage) return;
|
|
1838
2161
|
try {
|
|
1839
|
-
const data = { accessToken, expiresAt };
|
|
2162
|
+
const data = { accessToken, expiresAt, identityKey };
|
|
1840
2163
|
storage.setItem(storageKey(databaseId), JSON.stringify(data));
|
|
1841
2164
|
} catch {
|
|
1842
2165
|
}
|
|
@@ -1845,12 +2168,41 @@ function setStoredToken(databaseId, accessToken, expiresAt) {
|
|
|
1845
2168
|
// src/context/sheets-provider.tsx
|
|
1846
2169
|
init_sheets_logger();
|
|
1847
2170
|
init_sheets_i18n();
|
|
2171
|
+
|
|
2172
|
+
// src/hooks/query-keys.ts
|
|
2173
|
+
function isSheetsScopeKey(value) {
|
|
2174
|
+
if (!value || typeof value !== "object") return false;
|
|
2175
|
+
const candidate = value;
|
|
2176
|
+
return "databaseId" in candidate && "endpoint" in candidate && "identityKey" in candidate;
|
|
2177
|
+
}
|
|
2178
|
+
var sheetsQueryKeys = {
|
|
2179
|
+
root: ["sheets"],
|
|
2180
|
+
scope: (scope) => ["sheets", scope],
|
|
2181
|
+
meta: (scope) => [...sheetsQueryKeys.scope(scope), "meta"],
|
|
2182
|
+
typeFields: (scope, typeName) => [...sheetsQueryKeys.scope(scope), "type-fields", typeName],
|
|
2183
|
+
enumValues: (scope, typeName) => [...sheetsQueryKeys.scope(scope), "enum-values", typeName],
|
|
2184
|
+
relations: (scope, tableName) => [...sheetsQueryKeys.scope(scope), "relations", tableName],
|
|
2185
|
+
table: (scope, tableName) => [...sheetsQueryKeys.scope(scope), "table", tableName],
|
|
2186
|
+
tableRows: (scope, tableName, options) => [...sheetsQueryKeys.table(scope, tableName), "rows", options],
|
|
2187
|
+
tableRow: (scope, tableName, id) => [...sheetsQueryKeys.table(scope, tableName), "row", id],
|
|
2188
|
+
tableCount: (scope, tableName, where) => [...sheetsQueryKeys.table(scope, tableName), "count", where],
|
|
2189
|
+
infiniteTable: (scope, tableName) => [...sheetsQueryKeys.scope(scope), "infinite-table", tableName],
|
|
2190
|
+
infiniteTablePage: (scope, tableName, pageIndex, options) => [...sheetsQueryKeys.infiniteTable(scope, tableName), "page", pageIndex, options],
|
|
2191
|
+
infiniteTableTotalCount: (scope, tableName, where) => [...sheetsQueryKeys.infiniteTable(scope, tableName), "totalCount", where],
|
|
2192
|
+
cursorTable: (scope, tableName, options) => [...sheetsQueryKeys.scope(scope), "cursor-table", tableName, options]
|
|
2193
|
+
};
|
|
2194
|
+
|
|
2195
|
+
// src/context/sheets-provider.tsx
|
|
1848
2196
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1849
2197
|
function SheetsProvider({ config, children }) {
|
|
2198
|
+
const providerInstanceId = (0, import_react3.useId)();
|
|
1850
2199
|
const storeRef = (0, import_react3.useRef)(null);
|
|
1851
2200
|
if (!storeRef.current) {
|
|
1852
2201
|
storeRef.current = createSheetsStore();
|
|
1853
2202
|
}
|
|
2203
|
+
const store = storeRef.current;
|
|
2204
|
+
const standaloneIdentityKey = (0, import_zustand2.useStore)(store, (state) => state.identityKey);
|
|
2205
|
+
const standaloneAccessToken = (0, import_zustand2.useStore)(store, (state) => state.accessToken);
|
|
1854
2206
|
setSheetsLogger(config.logger);
|
|
1855
2207
|
setSheetsLocale(config.locale);
|
|
1856
2208
|
(0, import_react3.useEffect)(() => {
|
|
@@ -1858,24 +2210,24 @@ function SheetsProvider({ config, children }) {
|
|
|
1858
2210
|
setSheetsLocale(config.locale);
|
|
1859
2211
|
}, [config.logger, config.locale]);
|
|
1860
2212
|
(0, import_react3.useEffect)(() => {
|
|
1861
|
-
const
|
|
1862
|
-
if (!
|
|
2213
|
+
const store2 = storeRef.current?.getState();
|
|
2214
|
+
if (!store2) return;
|
|
1863
2215
|
if (config.auth.mode !== "standalone") {
|
|
1864
|
-
|
|
2216
|
+
store2.setUnauthenticated();
|
|
1865
2217
|
return;
|
|
1866
2218
|
}
|
|
1867
2219
|
const databaseId = config.databaseId || "default";
|
|
1868
2220
|
const stored = getStoredToken(databaseId);
|
|
1869
2221
|
if (!stored) {
|
|
1870
|
-
|
|
2222
|
+
store2.setUnauthenticated();
|
|
1871
2223
|
return;
|
|
1872
2224
|
}
|
|
1873
2225
|
const expiresAt = new Date(stored.expiresAt);
|
|
1874
2226
|
if (expiresAt > /* @__PURE__ */ new Date()) {
|
|
1875
|
-
|
|
2227
|
+
store2.setAuthenticated(stored.accessToken, stored.expiresAt, stored.identityKey ?? null);
|
|
1876
2228
|
return;
|
|
1877
2229
|
}
|
|
1878
|
-
|
|
2230
|
+
store2.setUnauthenticated();
|
|
1879
2231
|
}, [config.auth.mode, config.databaseId]);
|
|
1880
2232
|
const internalQueryClient = (0, import_react3.useMemo)(
|
|
1881
2233
|
() => new import_react_query.QueryClient({
|
|
@@ -1894,8 +2246,8 @@ function SheetsProvider({ config, children }) {
|
|
|
1894
2246
|
if (config.auth.mode === "embedded") {
|
|
1895
2247
|
return config.auth.getToken;
|
|
1896
2248
|
}
|
|
1897
|
-
return () =>
|
|
1898
|
-
}, [config.auth]);
|
|
2249
|
+
return () => store.getState().accessToken ?? null;
|
|
2250
|
+
}, [config.auth, store]);
|
|
1899
2251
|
const execute = (0, import_react3.useMemo)(() => {
|
|
1900
2252
|
if (config.execute) return config.execute;
|
|
1901
2253
|
return createSheetsExecute(config, getToken);
|
|
@@ -1904,18 +2256,35 @@ function SheetsProvider({ config, children }) {
|
|
|
1904
2256
|
if (config.executeUpload) return config.executeUpload;
|
|
1905
2257
|
return createSheetsUpload(config, getToken);
|
|
1906
2258
|
}, [config, getToken]);
|
|
2259
|
+
const configuredIdentityKey = config.auth.mode === "embedded" ? config.auth.getIdentityKey?.() ?? null : standaloneIdentityKey;
|
|
2260
|
+
const activeToken = config.auth.mode === "embedded" ? config.auth.getToken() : standaloneAccessToken;
|
|
2261
|
+
const authGenerationRef = (0, import_react3.useRef)({ mode: config.auth.mode, token: activeToken, generation: 0 });
|
|
2262
|
+
if (authGenerationRef.current.mode !== config.auth.mode || authGenerationRef.current.token !== activeToken) {
|
|
2263
|
+
authGenerationRef.current = {
|
|
2264
|
+
mode: config.auth.mode,
|
|
2265
|
+
token: activeToken,
|
|
2266
|
+
generation: authGenerationRef.current.generation + 1
|
|
2267
|
+
};
|
|
2268
|
+
}
|
|
2269
|
+
const identityKey = configuredIdentityKey ?? `anonymous:${providerInstanceId}:${authGenerationRef.current.generation}`;
|
|
1907
2270
|
const scopeKey = (0, import_react3.useMemo)(
|
|
1908
2271
|
() => ({
|
|
1909
2272
|
databaseId: config.databaseId ?? null,
|
|
1910
|
-
endpoint: config.endpoint
|
|
2273
|
+
endpoint: config.endpoint,
|
|
2274
|
+
identityKey
|
|
1911
2275
|
}),
|
|
1912
|
-
[config.databaseId, config.endpoint]
|
|
2276
|
+
[config.databaseId, config.endpoint, identityKey]
|
|
1913
2277
|
);
|
|
2278
|
+
(0, import_react3.useEffect)(() => {
|
|
2279
|
+
return () => {
|
|
2280
|
+
void queryClient.cancelQueries({ queryKey: sheetsQueryKeys.scope(scopeKey) });
|
|
2281
|
+
};
|
|
2282
|
+
}, [queryClient, scopeKey]);
|
|
1914
2283
|
const contextValue = (0, import_react3.useMemo)(
|
|
1915
2284
|
() => ({ config, execute, executeUpload, scopeKey }),
|
|
1916
2285
|
[config, execute, executeUpload, scopeKey]
|
|
1917
2286
|
);
|
|
1918
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_query.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SheetsStoreContext.Provider, { value:
|
|
2287
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_query.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SheetsStoreContext.Provider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SheetsContext.Provider, { value: contextValue, children }) }) });
|
|
1919
2288
|
}
|
|
1920
2289
|
|
|
1921
2290
|
// src/grid/sheets.tsx
|
|
@@ -2320,7 +2689,9 @@ function SheetsControls(props) {
|
|
|
2320
2689
|
gridSelection,
|
|
2321
2690
|
deleteSelected,
|
|
2322
2691
|
onAddRow,
|
|
2323
|
-
onExport
|
|
2692
|
+
onExport,
|
|
2693
|
+
canDelete = true,
|
|
2694
|
+
readOnlyReason
|
|
2324
2695
|
} = props;
|
|
2325
2696
|
const filterableColumns = (0, import_react4.useMemo)(() => {
|
|
2326
2697
|
if (Object.keys(fieldTypeMap).length === 0) return columnKeys;
|
|
@@ -2355,7 +2726,16 @@ function SheetsControls(props) {
|
|
|
2355
2726
|
"data-part-id": "sheets-controls",
|
|
2356
2727
|
className: "flex shrink-0 flex-wrap items-center justify-between gap-4 py-4",
|
|
2357
2728
|
children: [
|
|
2358
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2729
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex min-w-0 flex-wrap items-center gap-2", children: [
|
|
2730
|
+
readOnlyReason && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2731
|
+
"span",
|
|
2732
|
+
{
|
|
2733
|
+
className: "border-border bg-muted text-muted-foreground inline-flex h-8 items-center rounded-md border px-2.5 text-xs",
|
|
2734
|
+
role: "status",
|
|
2735
|
+
title: readOnlyReason,
|
|
2736
|
+
children: "Read-only"
|
|
2737
|
+
}
|
|
2738
|
+
),
|
|
2359
2739
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_button.Button, { variant: "outline", size: "sm", onClick: () => openSearch?.(), children: [
|
|
2360
2740
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react5.RiSearch2Line, { className: "text-muted-foreground/60 -ms-1.5 size-5", "aria-hidden": "true" }),
|
|
2361
2741
|
"Search"
|
|
@@ -2377,11 +2757,20 @@ function SheetsControls(props) {
|
|
|
2377
2757
|
] }),
|
|
2378
2758
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2379
2759
|
showSelection && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_alert_dialog.AlertDialog, { children: [
|
|
2380
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_alert_dialog.AlertDialogTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2760
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_alert_dialog.AlertDialogTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
2761
|
+
import_button.Button,
|
|
2762
|
+
{
|
|
2763
|
+
variant: "destructive-outline",
|
|
2764
|
+
size: "sm",
|
|
2765
|
+
disabled: !canDelete || selectedRowCount === 0,
|
|
2766
|
+
title: !canDelete ? readOnlyReason ?? "Delete is unavailable for this table." : void 0,
|
|
2767
|
+
children: [
|
|
2768
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react5.RiDeleteBin6Line, { className: "-ms-1.5 size-5", "aria-hidden": "true" }),
|
|
2769
|
+
"Delete",
|
|
2770
|
+
selectedRowCount > 0 ? ` (${selectedRowCount})` : ""
|
|
2771
|
+
]
|
|
2772
|
+
}
|
|
2773
|
+
) }),
|
|
2385
2774
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_alert_dialog.AlertDialogContent, { children: [
|
|
2386
2775
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_alert_dialog.AlertDialogHeader, { children: [
|
|
2387
2776
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_alert_dialog.AlertDialogTitle, { children: "Delete rows?" }),
|
|
@@ -2475,7 +2864,9 @@ function buildContextMenuItems({
|
|
|
2475
2864
|
isEnabled,
|
|
2476
2865
|
onAddRow,
|
|
2477
2866
|
requestDelete,
|
|
2478
|
-
selectedRowCount
|
|
2867
|
+
selectedRowCount,
|
|
2868
|
+
canAddRows = true,
|
|
2869
|
+
canDeleteRows = true
|
|
2479
2870
|
}) {
|
|
2480
2871
|
const cmd = (key2, commandId, label, icon, shortcut) => ({
|
|
2481
2872
|
key: key2,
|
|
@@ -2495,6 +2886,7 @@ function buildContextMenuItems({
|
|
|
2495
2886
|
key: "add-row",
|
|
2496
2887
|
label: "Add row",
|
|
2497
2888
|
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react7.RiAddLine, { className: "size-4", "aria-hidden": "true" }),
|
|
2889
|
+
disabled: !canAddRows,
|
|
2498
2890
|
run: onAddRow
|
|
2499
2891
|
},
|
|
2500
2892
|
{
|
|
@@ -2502,7 +2894,7 @@ function buildContextMenuItems({
|
|
|
2502
2894
|
label: selectedRowCount > 1 ? `Delete ${selectedRowCount} rows` : "Delete row",
|
|
2503
2895
|
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react7.RiDeleteBin6Line, { className: "size-4", "aria-hidden": "true" }),
|
|
2504
2896
|
destructive: true,
|
|
2505
|
-
disabled: selectedRowCount === 0,
|
|
2897
|
+
disabled: !canDeleteRows || selectedRowCount === 0,
|
|
2506
2898
|
run: requestDelete
|
|
2507
2899
|
}
|
|
2508
2900
|
];
|
|
@@ -2514,7 +2906,9 @@ function SheetsContextMenu({
|
|
|
2514
2906
|
isEnabled,
|
|
2515
2907
|
onAddRow,
|
|
2516
2908
|
onDeleteRows,
|
|
2517
|
-
selectedRowCount
|
|
2909
|
+
selectedRowCount,
|
|
2910
|
+
canAddRows = true,
|
|
2911
|
+
canDeleteRows = true
|
|
2518
2912
|
}) {
|
|
2519
2913
|
const [confirmDelete, setConfirmDelete] = (0, import_react6.useState)(false);
|
|
2520
2914
|
const open = state !== null;
|
|
@@ -2523,7 +2917,9 @@ function SheetsContextMenu({
|
|
|
2523
2917
|
isEnabled,
|
|
2524
2918
|
onAddRow,
|
|
2525
2919
|
requestDelete: () => setConfirmDelete(true),
|
|
2526
|
-
selectedRowCount
|
|
2920
|
+
selectedRowCount,
|
|
2921
|
+
canAddRows,
|
|
2922
|
+
canDeleteRows
|
|
2527
2923
|
});
|
|
2528
2924
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
2529
2925
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_dropdown_menu.DropdownMenu, { open, onOpenChange: (next) => !next && onClose(), children: [
|
|
@@ -3049,12 +3445,12 @@ function SheetsErrorState({ error, onRetry }) {
|
|
|
3049
3445
|
onRetry && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_button3.Button, { variant: "outline", size: "sm", onClick: onRetry, children: "Retry" })
|
|
3050
3446
|
] });
|
|
3051
3447
|
}
|
|
3052
|
-
function SheetsEmptyState({ tableName, onAddRow }) {
|
|
3448
|
+
function SheetsEmptyState({ tableName, onAddRow, readOnlyReason }) {
|
|
3053
3449
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(SheetsStateShell, { children: [
|
|
3054
3450
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react15.RiInboxLine, { className: "text-muted-foreground h-8 w-8" }),
|
|
3055
3451
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-1", children: [
|
|
3056
3452
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-foreground text-sm font-medium", children: "No rows yet" }),
|
|
3057
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-muted-foreground max-w-md text-sm", children: tableName ? `The "${tableName}" table is empty.` : "This table is empty." })
|
|
3453
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-muted-foreground max-w-md text-sm", children: readOnlyReason ?? (tableName ? `The "${tableName}" table is empty.` : "This table is empty.") })
|
|
3058
3454
|
] }),
|
|
3059
3455
|
onAddRow && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_button3.Button, { variant: "outline", size: "sm", onClick: onAddRow, children: [
|
|
3060
3456
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react15.RiAddLine, { className: "h-4 w-4" }),
|
|
@@ -3296,6 +3692,8 @@ init_cell_type_groups();
|
|
|
3296
3692
|
init_cell_type_groups();
|
|
3297
3693
|
function mapToFrontendCellType(metadata) {
|
|
3298
3694
|
const { gqlType, isArray, pgAlias, pgType } = metadata;
|
|
3695
|
+
const encodedType = mapEncodingToCellType(metadata.encoding);
|
|
3696
|
+
if (encodedType) return encodedType;
|
|
3299
3697
|
if (pgAlias) {
|
|
3300
3698
|
const aliasType = mapAliasToCellType(pgAlias);
|
|
3301
3699
|
if (aliasType !== "unknown") return aliasType;
|
|
@@ -3311,6 +3709,38 @@ function mapToFrontendCellType(metadata) {
|
|
|
3311
3709
|
const fallbackResult = mapGraphQLTypeToCellType(gqlType, isArray, metadata.subtype, null);
|
|
3312
3710
|
return fallbackResult;
|
|
3313
3711
|
}
|
|
3712
|
+
function mapEncodingToCellType(encoding) {
|
|
3713
|
+
if (!encoding) return null;
|
|
3714
|
+
switch (encoding.kind) {
|
|
3715
|
+
case "bigint":
|
|
3716
|
+
return "integer";
|
|
3717
|
+
case "datetime":
|
|
3718
|
+
return "datetime";
|
|
3719
|
+
case "date":
|
|
3720
|
+
return "date";
|
|
3721
|
+
case "time":
|
|
3722
|
+
return "time";
|
|
3723
|
+
case "interval":
|
|
3724
|
+
return "interval";
|
|
3725
|
+
case "uuid":
|
|
3726
|
+
return "uuid";
|
|
3727
|
+
case "inet":
|
|
3728
|
+
return "inet";
|
|
3729
|
+
case "point":
|
|
3730
|
+
return "geometry-point";
|
|
3731
|
+
case "geojson":
|
|
3732
|
+
return encoding.geometrySubtype === "Point" ? "geometry-point" : "geometry";
|
|
3733
|
+
case "vector":
|
|
3734
|
+
return "number-array";
|
|
3735
|
+
case "composite":
|
|
3736
|
+
return "json";
|
|
3737
|
+
case "ltree":
|
|
3738
|
+
case "bytea":
|
|
3739
|
+
return "text";
|
|
3740
|
+
default:
|
|
3741
|
+
return null;
|
|
3742
|
+
}
|
|
3743
|
+
}
|
|
3314
3744
|
function mapAliasToCellType(alias) {
|
|
3315
3745
|
const aliasMap = {
|
|
3316
3746
|
// Media types
|
|
@@ -3515,9 +3945,9 @@ function isStructuredDataType(cellType) {
|
|
|
3515
3945
|
}
|
|
3516
3946
|
function createColumnSchemaFromMeta(field) {
|
|
3517
3947
|
const { name, type } = field;
|
|
3518
|
-
const { gqlType, isArray,
|
|
3948
|
+
const { gqlType, isArray, subtype } = type;
|
|
3519
3949
|
const nullable = !gqlType.endsWith("!");
|
|
3520
|
-
const cellType =
|
|
3950
|
+
const cellType = mapToFrontendCellType(field.type);
|
|
3521
3951
|
const label = name.replace(/([A-Z])/g, " $1").replace(/^./, (str) => str.toUpperCase()).trim();
|
|
3522
3952
|
return {
|
|
3523
3953
|
id: name,
|
|
@@ -3592,7 +4022,7 @@ function isImageField(fieldMeta, fieldName) {
|
|
|
3592
4022
|
}
|
|
3593
4023
|
|
|
3594
4024
|
// src/grid/sheets.utils.ts
|
|
3595
|
-
var
|
|
4025
|
+
var import_data6 = require("@constructive-io/data");
|
|
3596
4026
|
|
|
3597
4027
|
// src/grid/sheets.formatters.ts
|
|
3598
4028
|
function compactJsonPreview(value, maxLen = 80) {
|
|
@@ -3760,7 +4190,7 @@ function prepareDraftSubmissionPayload(values, options = {}) {
|
|
|
3760
4190
|
const { allowedColumns, relationInfoByKey } = options;
|
|
3761
4191
|
const allowsAll = !allowedColumns || allowedColumns.size === 0;
|
|
3762
4192
|
const { id: _id, ...valuesWithoutId } = values;
|
|
3763
|
-
const filtered = (0,
|
|
4193
|
+
const filtered = (0, import_data6.prepareCreateInput)(valuesWithoutId);
|
|
3764
4194
|
const payload = {};
|
|
3765
4195
|
const normalizeForeignKeyValue = (input) => {
|
|
3766
4196
|
if (input === void 0 || input === null) return void 0;
|
|
@@ -3882,48 +4312,25 @@ function createHeaderClickHandler(columnKeys, toggleSorting, sortableColumns) {
|
|
|
3882
4312
|
var import_react19 = require("react");
|
|
3883
4313
|
var import_react_query4 = require("@tanstack/react-query");
|
|
3884
4314
|
var import_inflekt4 = require("inflekt");
|
|
3885
|
-
var
|
|
4315
|
+
var import_data14 = require("@constructive-io/data");
|
|
3886
4316
|
|
|
3887
4317
|
// src/hooks/use-sheets-meta.ts
|
|
3888
4318
|
var import_react_query3 = require("@tanstack/react-query");
|
|
3889
4319
|
|
|
3890
4320
|
// src/adapter/postgraphile-adapter.ts
|
|
3891
|
-
var
|
|
4321
|
+
var import_data13 = require("@constructive-io/data");
|
|
3892
4322
|
|
|
3893
4323
|
// src/hooks/use-sheets-table.ts
|
|
3894
4324
|
var import_react18 = require("react");
|
|
3895
4325
|
var import_react_query2 = require("@tanstack/react-query");
|
|
3896
|
-
var import_data8 = require("@constructive-io/data");
|
|
3897
|
-
var import_data9 = require("@constructive-io/data");
|
|
3898
4326
|
var import_data10 = require("@constructive-io/data");
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
function isSheetsScopeKey(value) {
|
|
3902
|
-
if (!value || typeof value !== "object") return false;
|
|
3903
|
-
const candidate = value;
|
|
3904
|
-
return "databaseId" in candidate && "endpoint" in candidate;
|
|
3905
|
-
}
|
|
3906
|
-
var sheetsQueryKeys = {
|
|
3907
|
-
root: ["sheets"],
|
|
3908
|
-
scope: (scope) => ["sheets", scope],
|
|
3909
|
-
meta: (scope) => [...sheetsQueryKeys.scope(scope), "meta"],
|
|
3910
|
-
typeFields: (scope, typeName) => [...sheetsQueryKeys.scope(scope), "type-fields", typeName],
|
|
3911
|
-
enumValues: (scope, typeName) => [...sheetsQueryKeys.scope(scope), "enum-values", typeName],
|
|
3912
|
-
relations: (scope, tableName) => [...sheetsQueryKeys.scope(scope), "relations", tableName],
|
|
3913
|
-
table: (scope, tableName) => [...sheetsQueryKeys.scope(scope), "table", tableName],
|
|
3914
|
-
tableRows: (scope, tableName, options) => [...sheetsQueryKeys.table(scope, tableName), "rows", options],
|
|
3915
|
-
tableRow: (scope, tableName, id) => [...sheetsQueryKeys.table(scope, tableName), "row", id],
|
|
3916
|
-
tableCount: (scope, tableName, where) => [...sheetsQueryKeys.table(scope, tableName), "count", where],
|
|
3917
|
-
infiniteTable: (scope, tableName) => [...sheetsQueryKeys.scope(scope), "infinite-table", tableName],
|
|
3918
|
-
infiniteTablePage: (scope, tableName, pageIndex, options) => [...sheetsQueryKeys.infiniteTable(scope, tableName), "page", pageIndex, options],
|
|
3919
|
-
infiniteTableTotalCount: (scope, tableName, where) => [...sheetsQueryKeys.infiniteTable(scope, tableName), "totalCount", where],
|
|
3920
|
-
cursorTable: (scope, tableName, options) => [...sheetsQueryKeys.scope(scope), "cursor-table", tableName, options]
|
|
3921
|
-
};
|
|
4327
|
+
var import_data11 = require("@constructive-io/data");
|
|
4328
|
+
var import_data12 = require("@constructive-io/data");
|
|
3922
4329
|
|
|
3923
4330
|
// src/hooks/relation-field-resolution.ts
|
|
3924
4331
|
var import_inflekt3 = require("inflekt");
|
|
3925
|
-
var
|
|
3926
|
-
var TypeFieldsDoc = new
|
|
4332
|
+
var import_data7 = require("@constructive-io/data");
|
|
4333
|
+
var TypeFieldsDoc = new import_data7.TypedDocumentString(`
|
|
3927
4334
|
query TypeFields($typeName: String!) {
|
|
3928
4335
|
__type(name: $typeName) {
|
|
3929
4336
|
fields {
|
|
@@ -4091,8 +4498,8 @@ async function getTypeFieldSet(table, scopeKey, queryClient, execute) {
|
|
|
4091
4498
|
}
|
|
4092
4499
|
|
|
4093
4500
|
// src/hooks/orderby-enum-resolution.ts
|
|
4094
|
-
var
|
|
4095
|
-
var EnumValuesDoc = new
|
|
4501
|
+
var import_data8 = require("@constructive-io/data");
|
|
4502
|
+
var EnumValuesDoc = new import_data8.TypedDocumentString(`
|
|
4096
4503
|
query EnumValues($typeName: String!) {
|
|
4097
4504
|
__type(name: $typeName) {
|
|
4098
4505
|
enumValues {
|
|
@@ -4126,14 +4533,70 @@ async function validateOrderByVariables(variables, table, scopeKey, queryClient,
|
|
|
4126
4533
|
}
|
|
4127
4534
|
}
|
|
4128
4535
|
|
|
4129
|
-
// src/
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4536
|
+
// src/row-identity.ts
|
|
4537
|
+
var import_data9 = require("@constructive-io/data");
|
|
4538
|
+
function isLegacyScalarId(primaryKey) {
|
|
4539
|
+
const entries = Object.entries(primaryKey);
|
|
4540
|
+
return entries.length === 1 && entries[0][0] === "id" && (typeof entries[0][1] === "string" || typeof entries[0][1] === "number");
|
|
4541
|
+
}
|
|
4542
|
+
function resolveSheetsRowIdentity(table, row) {
|
|
4543
|
+
const resolution = (0, import_data9.resolveRowIdentity)(table, row);
|
|
4544
|
+
if (resolution.status === "read-only") {
|
|
4545
|
+
return { status: "unavailable", reason: "no-primary-key" };
|
|
4546
|
+
}
|
|
4547
|
+
if (resolution.status === "invalid-row") {
|
|
4548
|
+
return { status: "unavailable", reason: "invalid-row" };
|
|
4549
|
+
}
|
|
4550
|
+
const primaryKey = (0, import_data9.rowIdentityToPrimaryKey)(resolution.identity);
|
|
4551
|
+
return {
|
|
4552
|
+
status: "identified",
|
|
4553
|
+
identifier: isLegacyScalarId(primaryKey) ? primaryKey.id : primaryKey,
|
|
4554
|
+
primaryKey,
|
|
4555
|
+
key: (0, import_data9.serializeRowIdentity)(resolution.identity)
|
|
4556
|
+
};
|
|
4557
|
+
}
|
|
4558
|
+
function resolveSheetsIdentifier(table, identifier) {
|
|
4559
|
+
const row = typeof identifier === "object" && identifier !== null ? identifier : { id: identifier };
|
|
4560
|
+
return resolveSheetsRowIdentity(table, row);
|
|
4561
|
+
}
|
|
4562
|
+
function sheetsIdentifierToWhere(table, identifier) {
|
|
4563
|
+
const resolution = resolveSheetsIdentifier(table, identifier);
|
|
4564
|
+
if (resolution.status !== "identified") return null;
|
|
4565
|
+
return Object.fromEntries(
|
|
4566
|
+
Object.entries(resolution.primaryKey).map(([field, value]) => [field, { equalTo: value }])
|
|
4567
|
+
);
|
|
4568
|
+
}
|
|
4569
|
+
function sheetsIdentifierCacheKey(table, identifier) {
|
|
4570
|
+
const resolution = resolveSheetsIdentifier(table, identifier);
|
|
4571
|
+
if (resolution.status !== "identified") return null;
|
|
4572
|
+
return typeof resolution.identifier === "object" ? resolution.key : resolution.identifier;
|
|
4573
|
+
}
|
|
4574
|
+
function sheetsRowKey(table, row, index) {
|
|
4575
|
+
const resolution = resolveSheetsRowIdentity(table, row);
|
|
4576
|
+
if (resolution.status === "identified") {
|
|
4577
|
+
return typeof resolution.identifier === "object" ? resolution.key : String(resolution.identifier);
|
|
4578
|
+
}
|
|
4579
|
+
return `${table.schemaName ?? ""}:${table.name}:row:${index}`;
|
|
4580
|
+
}
|
|
4581
|
+
function getSheetsWriteCapability(table) {
|
|
4582
|
+
return table ? (0, import_data9.assessTableWriteCapability)(table) : null;
|
|
4583
|
+
}
|
|
4584
|
+
function canRunSheetsMutation(capability, operation) {
|
|
4585
|
+
if (!capability || capability.status !== "mutable") return false;
|
|
4586
|
+
return capability.operations[operation];
|
|
4587
|
+
}
|
|
4588
|
+
function assertSheetsMutationAllowed(table, operation) {
|
|
4589
|
+
const capability = (0, import_data9.assessTableWriteCapability)(table);
|
|
4590
|
+
if (capability.status === "read-only") {
|
|
4591
|
+
throw new Error(`Table '${table.name}' is read-only because it has no primary key.`);
|
|
4592
|
+
}
|
|
4593
|
+
if (!capability.operations[operation]) {
|
|
4594
|
+
const article = operation === "update" ? "an" : "a";
|
|
4595
|
+
throw new Error(`Table '${table.name}' does not expose ${article} ${operation} mutation.`);
|
|
4133
4596
|
}
|
|
4134
|
-
const candidate = row.id;
|
|
4135
|
-
return typeof candidate === "string" || typeof candidate === "number" ? candidate : null;
|
|
4136
4597
|
}
|
|
4598
|
+
|
|
4599
|
+
// src/hooks/use-sheets-table.ts
|
|
4137
4600
|
function transformRelationData(data, table) {
|
|
4138
4601
|
if (!data) return [];
|
|
4139
4602
|
if (!Array.isArray(data)) return data;
|
|
@@ -4185,10 +4648,10 @@ function transformToPostGraphileVariables(table, options = {}) {
|
|
|
4185
4648
|
}
|
|
4186
4649
|
if (options.orderBy && options.orderBy.length > 0) {
|
|
4187
4650
|
const availableFields = new Set(table.fields.map((field) => field.name));
|
|
4188
|
-
variables.orderBy = options.orderBy.filter(({ field }) => availableFields.has(field)).map(({ field, direction }) => (0,
|
|
4651
|
+
variables.orderBy = options.orderBy.filter(({ field }) => availableFields.has(field)).map(({ field, direction }) => (0, import_data12.toOrderByEnumValue)(field, direction));
|
|
4189
4652
|
}
|
|
4190
4653
|
if (options.where) {
|
|
4191
|
-
variables.
|
|
4654
|
+
variables.where = options.where;
|
|
4192
4655
|
}
|
|
4193
4656
|
return variables;
|
|
4194
4657
|
}
|
|
@@ -4197,14 +4660,33 @@ function useSheetsTable(tableName, options = {}) {
|
|
|
4197
4660
|
const { execute, scopeKey } = useSheetsContext();
|
|
4198
4661
|
const { data: meta } = useSheetsMeta();
|
|
4199
4662
|
const adapter = useSheetsAdapter();
|
|
4200
|
-
const
|
|
4663
|
+
const metaTables = (0, import_react18.useMemo)(() => {
|
|
4201
4664
|
if (!meta?._meta?.tables) return [];
|
|
4202
|
-
return meta._meta.tables.filter((candidate) => candidate != null)
|
|
4665
|
+
return meta._meta.tables.filter((candidate) => candidate != null);
|
|
4203
4666
|
}, [meta]);
|
|
4667
|
+
const tables = (0, import_react18.useMemo)(() => metaTables.map(import_data10.cleanTable), [metaTables]);
|
|
4204
4668
|
const table = (0, import_react18.useMemo)(
|
|
4205
4669
|
() => tables.find((candidate) => candidate.name === tableName) ?? null,
|
|
4206
4670
|
[tables, tableName]
|
|
4207
4671
|
);
|
|
4672
|
+
const tableMeta = (0, import_react18.useMemo)(
|
|
4673
|
+
() => metaTables.find((candidate) => candidate.name === tableName) ?? null,
|
|
4674
|
+
[metaTables, tableName]
|
|
4675
|
+
);
|
|
4676
|
+
const resolveIdentifier = (identifier) => {
|
|
4677
|
+
if (!tableMeta) throw import_data11.createError.notFound(`Table '${tableName}' not found`);
|
|
4678
|
+
const resolution = resolveSheetsIdentifier(tableMeta, identifier);
|
|
4679
|
+
if (resolution.status !== "identified") {
|
|
4680
|
+
throw import_data11.createError.badRequest(`Cannot resolve a primary-key identity for table '${tableName}'.`);
|
|
4681
|
+
}
|
|
4682
|
+
return resolution.identifier;
|
|
4683
|
+
};
|
|
4684
|
+
const rowCacheKey = (row) => {
|
|
4685
|
+
if (!tableMeta || !row) return null;
|
|
4686
|
+
const resolution = resolveSheetsRowIdentity(tableMeta, row);
|
|
4687
|
+
if (resolution.status !== "identified") return null;
|
|
4688
|
+
return typeof resolution.identifier === "object" ? resolution.key : resolution.identifier;
|
|
4689
|
+
};
|
|
4208
4690
|
const { enabled = true, select: fieldSelection, mutationOptions = {}, ...queryOptions } = options;
|
|
4209
4691
|
const finalQueryOptions = {
|
|
4210
4692
|
...queryOptions,
|
|
@@ -4219,7 +4701,7 @@ function useSheetsTable(tableName, options = {}) {
|
|
|
4219
4701
|
queryKey: sheetsTableQueryKeys.tableRows(scopeKey, tableName, finalQueryOptions),
|
|
4220
4702
|
queryFn: async () => {
|
|
4221
4703
|
if (!table) {
|
|
4222
|
-
throw
|
|
4704
|
+
throw import_data11.createError.notFound(`Table '${tableName}' not found`);
|
|
4223
4705
|
}
|
|
4224
4706
|
const variables = transformToPostGraphileVariables(table, finalQueryOptions);
|
|
4225
4707
|
const [relationFieldMap] = await Promise.all([
|
|
@@ -4235,7 +4717,7 @@ function useSheetsTable(tableName, options = {}) {
|
|
|
4235
4717
|
const validatedOrderByEnum = new Set(variables.orderBy ?? []);
|
|
4236
4718
|
const availableOrderByFields = new Set(table.fields.map((field) => field.name));
|
|
4237
4719
|
const validatedOrderBy = finalQueryOptions.orderBy?.filter(
|
|
4238
|
-
({ field, direction }) => availableOrderByFields.has(field) && validatedOrderByEnum.has((0,
|
|
4720
|
+
({ field, direction }) => availableOrderByFields.has(field) && validatedOrderByEnum.has((0, import_data12.toOrderByEnumValue)(field, direction))
|
|
4239
4721
|
);
|
|
4240
4722
|
const { rows, totalCount: totalCount2 } = await adapter.listRows(
|
|
4241
4723
|
{ table, allTables: tables, tableName },
|
|
@@ -4261,10 +4743,11 @@ function useSheetsTable(tableName, options = {}) {
|
|
|
4261
4743
|
const createMutation = (0, import_react_query2.useMutation)({
|
|
4262
4744
|
mutationKey: sheetsTableMutationKeys.create(scopeKey, tableName),
|
|
4263
4745
|
mutationFn: async (data2) => {
|
|
4264
|
-
if (!table) {
|
|
4265
|
-
throw
|
|
4746
|
+
if (!table || !tableMeta) {
|
|
4747
|
+
throw import_data11.createError.notFound(`Table '${tableName}' not found`);
|
|
4266
4748
|
}
|
|
4267
|
-
|
|
4749
|
+
assertSheetsMutationAllowed(tableMeta, "create");
|
|
4750
|
+
const allTables = meta?._meta?.tables ? meta._meta.tables.filter((t) => t != null).map(import_data10.cleanTable) : [];
|
|
4268
4751
|
const createdRow = await adapter.createRow({ table, allTables, tableName }, data2, execute, {
|
|
4269
4752
|
...mutationOptions,
|
|
4270
4753
|
fieldSelection: mutationOptions.fieldSelection || fieldSelection || "display"
|
|
@@ -4274,20 +4757,22 @@ function useSheetsTable(tableName, options = {}) {
|
|
|
4274
4757
|
onSuccess: ({ createdRow }) => {
|
|
4275
4758
|
queryClient.invalidateQueries({ queryKey: sheetsTableQueryKeys.table(scopeKey, tableName) });
|
|
4276
4759
|
queryClient.invalidateQueries({ queryKey: sheetsQueryKeys.infiniteTable(scopeKey, tableName) });
|
|
4277
|
-
const
|
|
4278
|
-
if (
|
|
4279
|
-
queryClient.setQueryData(sheetsTableQueryKeys.tableRow(scopeKey, tableName,
|
|
4760
|
+
const createdRowKey = rowCacheKey(createdRow);
|
|
4761
|
+
if (createdRowKey !== null) {
|
|
4762
|
+
queryClient.setQueryData(sheetsTableQueryKeys.tableRow(scopeKey, tableName, createdRowKey), createdRow);
|
|
4280
4763
|
}
|
|
4281
4764
|
}
|
|
4282
4765
|
});
|
|
4283
4766
|
const updateMutation = (0, import_react_query2.useMutation)({
|
|
4284
4767
|
mutationKey: sheetsTableMutationKeys.update(scopeKey, tableName),
|
|
4285
4768
|
mutationFn: async ({ id, patch }) => {
|
|
4286
|
-
if (!table) {
|
|
4287
|
-
throw
|
|
4769
|
+
if (!table || !tableMeta) {
|
|
4770
|
+
throw import_data11.createError.notFound(`Table '${tableName}' not found`);
|
|
4288
4771
|
}
|
|
4289
|
-
|
|
4290
|
-
const
|
|
4772
|
+
assertSheetsMutationAllowed(tableMeta, "update");
|
|
4773
|
+
const mutationIdentifier = resolveIdentifier(id);
|
|
4774
|
+
const allTables = meta?._meta?.tables ? meta._meta.tables.filter((t) => t != null).map(import_data10.cleanTable) : [];
|
|
4775
|
+
const updatedRow = await adapter.updateRow({ table, allTables, tableName }, mutationIdentifier, patch, execute, {
|
|
4291
4776
|
...mutationOptions,
|
|
4292
4777
|
fieldSelection: mutationOptions.fieldSelection || fieldSelection || "display"
|
|
4293
4778
|
});
|
|
@@ -4302,6 +4787,7 @@ function useSheetsTable(tableName, options = {}) {
|
|
|
4302
4787
|
onMutate: async ({ id, patch }) => {
|
|
4303
4788
|
const tablePrefix = sheetsTableQueryKeys.table(scopeKey, tableName);
|
|
4304
4789
|
await queryClient.cancelQueries({ queryKey: tablePrefix });
|
|
4790
|
+
const targetKey = tableMeta ? sheetsIdentifierCacheKey(tableMeta, id) : null;
|
|
4305
4791
|
const isRowsKey = (key2) => key2[key2.length - 2] === "rows";
|
|
4306
4792
|
const previousRows = queryClient.getQueriesData({ queryKey: tablePrefix }).filter(([key2]) => isRowsKey(key2));
|
|
4307
4793
|
for (const [key2] of previousRows) {
|
|
@@ -4309,7 +4795,7 @@ function useSheetsTable(tableName, options = {}) {
|
|
|
4309
4795
|
if (!old) return old;
|
|
4310
4796
|
let changed = false;
|
|
4311
4797
|
const rows = old.rows.map((row) => {
|
|
4312
|
-
if (
|
|
4798
|
+
if (targetKey !== null && rowCacheKey(row) === targetKey) {
|
|
4313
4799
|
changed = true;
|
|
4314
4800
|
return { ...row, ...patch };
|
|
4315
4801
|
}
|
|
@@ -4325,51 +4811,58 @@ function useSheetsTable(tableName, options = {}) {
|
|
|
4325
4811
|
},
|
|
4326
4812
|
onSuccess: ({ updatedRow }) => {
|
|
4327
4813
|
queryClient.invalidateQueries({ queryKey: sheetsTableQueryKeys.table(scopeKey, tableName) });
|
|
4328
|
-
const
|
|
4329
|
-
if (
|
|
4330
|
-
queryClient.setQueryData(sheetsTableQueryKeys.tableRow(scopeKey, tableName,
|
|
4814
|
+
const updatedRowKey = rowCacheKey(updatedRow);
|
|
4815
|
+
if (updatedRowKey !== null) {
|
|
4816
|
+
queryClient.setQueryData(sheetsTableQueryKeys.tableRow(scopeKey, tableName, updatedRowKey), updatedRow);
|
|
4331
4817
|
}
|
|
4332
4818
|
}
|
|
4333
4819
|
});
|
|
4334
4820
|
const deleteMutation = (0, import_react_query2.useMutation)({
|
|
4335
4821
|
mutationKey: sheetsTableMutationKeys.delete(scopeKey, tableName),
|
|
4336
4822
|
mutationFn: async (idOrPk) => {
|
|
4337
|
-
if (!table) {
|
|
4338
|
-
throw
|
|
4823
|
+
if (!table || !tableMeta) {
|
|
4824
|
+
throw import_data11.createError.notFound(`Table '${tableName}' not found`);
|
|
4339
4825
|
}
|
|
4340
|
-
|
|
4341
|
-
|
|
4826
|
+
assertSheetsMutationAllowed(tableMeta, "delete");
|
|
4827
|
+
const mutationIdentifier = resolveIdentifier(idOrPk);
|
|
4828
|
+
const allTables = meta?._meta?.tables ? meta._meta.tables.filter((t) => t != null).map(import_data10.cleanTable) : [];
|
|
4829
|
+
await adapter.deleteRow({ table, allTables, tableName }, mutationIdentifier, execute, mutationOptions);
|
|
4342
4830
|
return { deletedId: idOrPk, __rawResult: {} };
|
|
4343
4831
|
},
|
|
4344
4832
|
onSuccess: ({ deletedId }) => {
|
|
4345
4833
|
queryClient.invalidateQueries({ queryKey: sheetsTableQueryKeys.table(scopeKey, tableName) });
|
|
4346
4834
|
queryClient.invalidateQueries({ queryKey: sheetsQueryKeys.infiniteTable(scopeKey, tableName) });
|
|
4347
|
-
|
|
4835
|
+
const deletedRowKey = tableMeta ? sheetsIdentifierCacheKey(tableMeta, deletedId) : null;
|
|
4836
|
+
if (deletedRowKey !== null) {
|
|
4348
4837
|
queryClient.removeQueries({
|
|
4349
|
-
queryKey: sheetsTableQueryKeys.tableRow(scopeKey, tableName,
|
|
4838
|
+
queryKey: sheetsTableQueryKeys.tableRow(scopeKey, tableName, deletedRowKey)
|
|
4350
4839
|
});
|
|
4351
4840
|
}
|
|
4352
4841
|
}
|
|
4353
4842
|
});
|
|
4354
4843
|
const findOne = async (id) => {
|
|
4355
|
-
if (!table) {
|
|
4356
|
-
throw
|
|
4844
|
+
if (!table || !tableMeta) {
|
|
4845
|
+
throw import_data11.createError.notFound(`Table '${tableName}' not found`);
|
|
4357
4846
|
}
|
|
4358
|
-
const
|
|
4359
|
-
|
|
4847
|
+
const where = sheetsIdentifierToWhere(tableMeta, id);
|
|
4848
|
+
if (!where) {
|
|
4849
|
+
throw import_data11.createError.badRequest(`Cannot resolve a primary-key identity for table '${tableName}'.`);
|
|
4850
|
+
}
|
|
4851
|
+
const doc = (0, import_data12.buildSelect)(table, tables, {
|
|
4852
|
+
where,
|
|
4360
4853
|
limit: 1
|
|
4361
4854
|
});
|
|
4362
4855
|
const variables = transformToPostGraphileVariables(table, {
|
|
4363
|
-
where
|
|
4856
|
+
where,
|
|
4364
4857
|
limit: 1
|
|
4365
4858
|
});
|
|
4366
4859
|
const result = await execute(doc, variables);
|
|
4367
|
-
const singularName = (0,
|
|
4860
|
+
const singularName = (0, import_data12.toCamelCaseSingular)(tableName, table);
|
|
4368
4861
|
const singularData = result[singularName];
|
|
4369
4862
|
if (singularData && typeof singularData === "object") {
|
|
4370
4863
|
return singularData;
|
|
4371
4864
|
}
|
|
4372
|
-
const queryTableName = (0,
|
|
4865
|
+
const queryTableName = (0, import_data12.toCamelCasePlural)(tableName, table);
|
|
4373
4866
|
const data2 = result[queryTableName];
|
|
4374
4867
|
if (data2 && typeof data2 === "object" && "nodes" in data2) {
|
|
4375
4868
|
const nodes = data2.nodes || [];
|
|
@@ -4410,319 +4903,83 @@ function useSheetsTable(tableName, options = {}) {
|
|
|
4410
4903
|
}
|
|
4411
4904
|
|
|
4412
4905
|
// src/adapter/postgraphile-adapter.ts
|
|
4413
|
-
var
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
name
|
|
4458
|
-
type {
|
|
4459
|
-
gqlType
|
|
4460
|
-
isArray
|
|
4461
|
-
pgType
|
|
4462
|
-
}
|
|
4463
|
-
}
|
|
4464
|
-
}
|
|
4465
|
-
constraints {
|
|
4466
|
-
primaryKey {
|
|
4467
|
-
name
|
|
4468
|
-
fields {
|
|
4469
|
-
name
|
|
4470
|
-
type {
|
|
4471
|
-
gqlType
|
|
4472
|
-
isArray
|
|
4473
|
-
pgType
|
|
4474
|
-
}
|
|
4475
|
-
}
|
|
4476
|
-
}
|
|
4477
|
-
unique {
|
|
4478
|
-
name
|
|
4479
|
-
fields {
|
|
4480
|
-
name
|
|
4481
|
-
type {
|
|
4482
|
-
gqlType
|
|
4483
|
-
isArray
|
|
4484
|
-
pgType
|
|
4485
|
-
}
|
|
4486
|
-
}
|
|
4487
|
-
}
|
|
4488
|
-
foreignKey {
|
|
4489
|
-
name
|
|
4490
|
-
fields {
|
|
4491
|
-
name
|
|
4492
|
-
type {
|
|
4493
|
-
gqlType
|
|
4494
|
-
isArray
|
|
4495
|
-
pgType
|
|
4496
|
-
}
|
|
4497
|
-
}
|
|
4498
|
-
refFields {
|
|
4499
|
-
name
|
|
4500
|
-
type {
|
|
4501
|
-
gqlType
|
|
4502
|
-
isArray
|
|
4503
|
-
pgType
|
|
4504
|
-
}
|
|
4505
|
-
}
|
|
4506
|
-
refTable {
|
|
4507
|
-
name
|
|
4508
|
-
}
|
|
4509
|
-
}
|
|
4510
|
-
}
|
|
4511
|
-
foreignKeyConstraints {
|
|
4512
|
-
name
|
|
4513
|
-
fields {
|
|
4514
|
-
name
|
|
4515
|
-
type {
|
|
4516
|
-
gqlType
|
|
4517
|
-
isArray
|
|
4518
|
-
pgType
|
|
4519
|
-
}
|
|
4520
|
-
}
|
|
4521
|
-
refFields {
|
|
4522
|
-
name
|
|
4523
|
-
type {
|
|
4524
|
-
gqlType
|
|
4525
|
-
isArray
|
|
4526
|
-
pgType
|
|
4527
|
-
}
|
|
4528
|
-
}
|
|
4529
|
-
refTable {
|
|
4530
|
-
name
|
|
4531
|
-
}
|
|
4532
|
-
}
|
|
4533
|
-
primaryKeyConstraints {
|
|
4534
|
-
name
|
|
4535
|
-
fields {
|
|
4536
|
-
name
|
|
4537
|
-
type {
|
|
4538
|
-
gqlType
|
|
4539
|
-
isArray
|
|
4540
|
-
pgType
|
|
4541
|
-
}
|
|
4542
|
-
}
|
|
4543
|
-
}
|
|
4544
|
-
uniqueConstraints {
|
|
4545
|
-
name
|
|
4546
|
-
fields {
|
|
4547
|
-
name
|
|
4548
|
-
type {
|
|
4549
|
-
gqlType
|
|
4550
|
-
isArray
|
|
4551
|
-
pgType
|
|
4552
|
-
}
|
|
4553
|
-
}
|
|
4554
|
-
}
|
|
4555
|
-
relations {
|
|
4556
|
-
belongsTo {
|
|
4557
|
-
fieldName
|
|
4558
|
-
isUnique
|
|
4559
|
-
keys {
|
|
4560
|
-
name
|
|
4561
|
-
type {
|
|
4562
|
-
gqlType
|
|
4563
|
-
isArray
|
|
4564
|
-
pgType
|
|
4565
|
-
}
|
|
4566
|
-
}
|
|
4567
|
-
references {
|
|
4568
|
-
name
|
|
4569
|
-
}
|
|
4570
|
-
type
|
|
4571
|
-
}
|
|
4572
|
-
has {
|
|
4573
|
-
fieldName
|
|
4574
|
-
isUnique
|
|
4575
|
-
keys {
|
|
4576
|
-
name
|
|
4577
|
-
type {
|
|
4578
|
-
gqlType
|
|
4579
|
-
isArray
|
|
4580
|
-
pgType
|
|
4581
|
-
}
|
|
4582
|
-
}
|
|
4583
|
-
referencedBy {
|
|
4584
|
-
name
|
|
4585
|
-
}
|
|
4586
|
-
type
|
|
4587
|
-
}
|
|
4588
|
-
hasOne {
|
|
4589
|
-
fieldName
|
|
4590
|
-
isUnique
|
|
4591
|
-
keys {
|
|
4592
|
-
name
|
|
4593
|
-
type {
|
|
4594
|
-
gqlType
|
|
4595
|
-
isArray
|
|
4596
|
-
pgType
|
|
4597
|
-
}
|
|
4598
|
-
}
|
|
4599
|
-
referencedBy {
|
|
4600
|
-
name
|
|
4601
|
-
}
|
|
4602
|
-
type
|
|
4603
|
-
}
|
|
4604
|
-
hasMany {
|
|
4605
|
-
fieldName
|
|
4606
|
-
isUnique
|
|
4607
|
-
keys {
|
|
4608
|
-
name
|
|
4609
|
-
type {
|
|
4610
|
-
gqlType
|
|
4611
|
-
isArray
|
|
4612
|
-
pgType
|
|
4613
|
-
}
|
|
4614
|
-
}
|
|
4615
|
-
referencedBy {
|
|
4616
|
-
name
|
|
4617
|
-
}
|
|
4618
|
-
type
|
|
4619
|
-
}
|
|
4620
|
-
manyToMany {
|
|
4621
|
-
fieldName
|
|
4622
|
-
junctionLeftConstraint {
|
|
4623
|
-
name
|
|
4624
|
-
fields {
|
|
4625
|
-
name
|
|
4626
|
-
type {
|
|
4627
|
-
gqlType
|
|
4628
|
-
isArray
|
|
4629
|
-
pgType
|
|
4630
|
-
}
|
|
4631
|
-
}
|
|
4632
|
-
refFields {
|
|
4633
|
-
name
|
|
4634
|
-
type {
|
|
4635
|
-
gqlType
|
|
4636
|
-
isArray
|
|
4637
|
-
pgType
|
|
4638
|
-
}
|
|
4639
|
-
}
|
|
4640
|
-
refTable {
|
|
4641
|
-
name
|
|
4642
|
-
}
|
|
4643
|
-
}
|
|
4644
|
-
junctionLeftKeyAttributes {
|
|
4645
|
-
name
|
|
4646
|
-
type {
|
|
4647
|
-
gqlType
|
|
4648
|
-
isArray
|
|
4649
|
-
pgType
|
|
4650
|
-
}
|
|
4651
|
-
}
|
|
4652
|
-
junctionRightConstraint {
|
|
4653
|
-
name
|
|
4654
|
-
fields {
|
|
4655
|
-
name
|
|
4656
|
-
type {
|
|
4657
|
-
gqlType
|
|
4658
|
-
isArray
|
|
4659
|
-
pgType
|
|
4660
|
-
}
|
|
4661
|
-
}
|
|
4662
|
-
refFields {
|
|
4663
|
-
name
|
|
4664
|
-
type {
|
|
4665
|
-
gqlType
|
|
4666
|
-
isArray
|
|
4667
|
-
pgType
|
|
4668
|
-
}
|
|
4669
|
-
}
|
|
4670
|
-
refTable {
|
|
4671
|
-
name
|
|
4672
|
-
}
|
|
4673
|
-
}
|
|
4674
|
-
junctionRightKeyAttributes {
|
|
4675
|
-
name
|
|
4676
|
-
type {
|
|
4677
|
-
gqlType
|
|
4678
|
-
isArray
|
|
4679
|
-
pgType
|
|
4680
|
-
}
|
|
4681
|
-
}
|
|
4682
|
-
junctionTable {
|
|
4683
|
-
name
|
|
4684
|
-
}
|
|
4685
|
-
leftKeyAttributes {
|
|
4686
|
-
name
|
|
4687
|
-
type {
|
|
4688
|
-
gqlType
|
|
4689
|
-
isArray
|
|
4690
|
-
pgType
|
|
4691
|
-
}
|
|
4692
|
-
}
|
|
4693
|
-
rightKeyAttributes {
|
|
4694
|
-
name
|
|
4695
|
-
type {
|
|
4696
|
-
gqlType
|
|
4697
|
-
isArray
|
|
4698
|
-
pgType
|
|
4699
|
-
}
|
|
4700
|
-
}
|
|
4701
|
-
rightTable {
|
|
4702
|
-
name
|
|
4703
|
-
}
|
|
4704
|
-
type
|
|
4705
|
-
}
|
|
4706
|
-
}
|
|
4707
|
-
}
|
|
4708
|
-
}
|
|
4709
|
-
}
|
|
4710
|
-
`);
|
|
4906
|
+
var compatibilityChecks = /* @__PURE__ */ new WeakMap();
|
|
4907
|
+
var enumMappings = /* @__PURE__ */ new WeakMap();
|
|
4908
|
+
async function ensureCurrentMetaContract(execute) {
|
|
4909
|
+
const cached = compatibilityChecks.get(execute);
|
|
4910
|
+
if (cached) return cached;
|
|
4911
|
+
const check = execute(import_data13.META_CONTRACT_INTROSPECTION_DOCUMENT).then(
|
|
4912
|
+
(result) => {
|
|
4913
|
+
(0, import_data13.assertMetaContract)(result);
|
|
4914
|
+
}
|
|
4915
|
+
);
|
|
4916
|
+
compatibilityChecks.set(execute, check);
|
|
4917
|
+
try {
|
|
4918
|
+
await check;
|
|
4919
|
+
} catch (error) {
|
|
4920
|
+
if (compatibilityChecks.get(execute) === check) compatibilityChecks.delete(execute);
|
|
4921
|
+
throw error;
|
|
4922
|
+
}
|
|
4923
|
+
}
|
|
4924
|
+
function hasDeclaredEnums(meta) {
|
|
4925
|
+
return Boolean(meta._meta?.tables?.some(
|
|
4926
|
+
(table) => table?.fields?.some((field) => Boolean(field?.enumValues?.name))
|
|
4927
|
+
));
|
|
4928
|
+
}
|
|
4929
|
+
function schemaCompatibilityError(missingPaths) {
|
|
4930
|
+
const detail = missingPaths.length > 0 ? ` Missing: ${missingPaths.join(", ")}.` : "";
|
|
4931
|
+
return import_data13.createError.badRequest(
|
|
4932
|
+
`The GraphQL schema does not match the enum values declared by Constructive _meta.${detail}`,
|
|
4933
|
+
"SCHEMA_INTROSPECTION_INCOMPATIBLE"
|
|
4934
|
+
);
|
|
4935
|
+
}
|
|
4936
|
+
function normalizeMutationEnums(ctx, input, execute) {
|
|
4937
|
+
const hasEnumInput = ctx.table.fields.some(
|
|
4938
|
+
(field) => Boolean(field.enumValues?.length) && Object.prototype.hasOwnProperty.call(input, field.name)
|
|
4939
|
+
);
|
|
4940
|
+
if (!hasEnumInput) return input;
|
|
4941
|
+
const mappings = enumMappings.get(execute);
|
|
4942
|
+
if (!mappings) {
|
|
4943
|
+
throw import_data13.createError.badRequest(
|
|
4944
|
+
"Enum schema mappings are unavailable. Load table metadata before mutating enum fields.",
|
|
4945
|
+
"ENUM_MAPPING_UNAVAILABLE"
|
|
4946
|
+
);
|
|
4947
|
+
}
|
|
4948
|
+
return (0, import_data13.normalizeSchemaEnumInputValues)(input, ctx.table, mappings);
|
|
4949
|
+
}
|
|
4711
4950
|
function createPostGraphileAdapter() {
|
|
4712
4951
|
return {
|
|
4713
4952
|
async fetchMeta(execute) {
|
|
4714
|
-
|
|
4953
|
+
await ensureCurrentMetaContract(execute);
|
|
4954
|
+
const meta = await execute(import_data13.META_DOCUMENT);
|
|
4955
|
+
(0, import_data13.assertMetaQuery)(meta);
|
|
4956
|
+
if (!hasDeclaredEnums(meta)) {
|
|
4957
|
+
enumMappings.set(execute, []);
|
|
4958
|
+
return meta;
|
|
4959
|
+
}
|
|
4960
|
+
try {
|
|
4961
|
+
const introspection = await execute(import_data13.SCHEMA_INTROSPECTION_QUERY);
|
|
4962
|
+
const analysis = (0, import_data13.analyzeSchemaIntrospectionCompatibility)(introspection, meta);
|
|
4963
|
+
if (analysis.status !== "compatible") {
|
|
4964
|
+
throw schemaCompatibilityError(analysis.missingPaths);
|
|
4965
|
+
}
|
|
4966
|
+
enumMappings.set(execute, analysis.enumMappings);
|
|
4967
|
+
} catch (error) {
|
|
4968
|
+
enumMappings.delete(execute);
|
|
4969
|
+
throw error;
|
|
4970
|
+
}
|
|
4971
|
+
return meta;
|
|
4715
4972
|
},
|
|
4716
4973
|
async listRows(ctx, query, execute) {
|
|
4717
4974
|
const { table, allTables, tableName } = ctx;
|
|
4718
4975
|
const { relationFieldMap, ...queryOptions } = query;
|
|
4719
4976
|
const variables = transformToPostGraphileVariables(table, queryOptions);
|
|
4720
|
-
const doc = (0,
|
|
4977
|
+
const doc = (0, import_data13.buildSelect)(table, allTables, {
|
|
4721
4978
|
...queryOptions,
|
|
4722
4979
|
relationFieldMap
|
|
4723
4980
|
});
|
|
4724
4981
|
const result = await execute(doc, variables);
|
|
4725
|
-
const queryTableName = (0,
|
|
4982
|
+
const queryTableName = (0, import_data13.toCamelCasePlural)(tableName, table);
|
|
4726
4983
|
const connection = result[queryTableName];
|
|
4727
4984
|
if (connection && typeof connection === "object" && "nodes" in connection) {
|
|
4728
4985
|
const nodes = connection.nodes || [];
|
|
@@ -4735,54 +4992,56 @@ function createPostGraphileAdapter() {
|
|
|
4735
4992
|
const directData = connection || [];
|
|
4736
4993
|
return {
|
|
4737
4994
|
rows: transformRelationData(directData, table),
|
|
4738
|
-
// Non-Relay direct-array response: page length only, not a full filtered count.
|
|
4739
4995
|
totalCount: directData.length
|
|
4740
4996
|
};
|
|
4741
4997
|
},
|
|
4742
4998
|
async createRow(ctx, data, execute, options = {}) {
|
|
4743
4999
|
const { table, allTables, tableName } = ctx;
|
|
4744
|
-
const doc = (0,
|
|
5000
|
+
const doc = (0, import_data13.buildPostGraphileCreate)(table, allTables, {
|
|
4745
5001
|
...options,
|
|
4746
5002
|
fieldSelection: options.fieldSelection || "display"
|
|
4747
5003
|
});
|
|
4748
|
-
const singularName = (0,
|
|
4749
|
-
const sanitizedData = (
|
|
5004
|
+
const singularName = (0, import_data13.toCamelCaseSingular)(tableName, table);
|
|
5005
|
+
const sanitizedData = normalizeMutationEnums(
|
|
5006
|
+
ctx,
|
|
5007
|
+
(0, import_data13.prepareCreateInput)(data),
|
|
5008
|
+
execute
|
|
5009
|
+
);
|
|
4750
5010
|
const variables = {
|
|
4751
5011
|
input: {
|
|
4752
5012
|
[singularName]: sanitizedData
|
|
4753
5013
|
}
|
|
4754
5014
|
};
|
|
4755
5015
|
const result = await execute(doc, variables);
|
|
4756
|
-
const mutationName = (0,
|
|
5016
|
+
const mutationName = (0, import_data13.toCreateMutationName)(tableName, table);
|
|
4757
5017
|
const createdRow = result[mutationName]?.[singularName] ?? null;
|
|
4758
5018
|
return createdRow;
|
|
4759
5019
|
},
|
|
4760
5020
|
async updateRow(ctx, id, patch, execute, options = {}) {
|
|
4761
5021
|
const { table, allTables, tableName } = ctx;
|
|
4762
|
-
const doc = (0,
|
|
5022
|
+
const doc = (0, import_data13.buildPostGraphileUpdate)(table, allTables, {
|
|
4763
5023
|
...options,
|
|
4764
5024
|
fieldSelection: options.fieldSelection || "display"
|
|
4765
5025
|
});
|
|
4766
|
-
const patchFieldName = (0,
|
|
4767
|
-
const sanitizedPatch = (0,
|
|
4768
|
-
if (Object.keys(sanitizedPatch).length === 0)
|
|
4769
|
-
|
|
4770
|
-
}
|
|
5026
|
+
const patchFieldName = (0, import_data13.toPatchFieldName)(tableName, table);
|
|
5027
|
+
const sanitizedPatch = (0, import_data13.prepareUpdateInput)(patch);
|
|
5028
|
+
if (Object.keys(sanitizedPatch).length === 0) return null;
|
|
5029
|
+
const normalizedPatch = normalizeMutationEnums(ctx, sanitizedPatch, execute);
|
|
4771
5030
|
const variables = {
|
|
4772
5031
|
input: {
|
|
4773
|
-
id,
|
|
4774
|
-
[patchFieldName]:
|
|
5032
|
+
...typeof id === "object" ? id : { id },
|
|
5033
|
+
[patchFieldName]: normalizedPatch
|
|
4775
5034
|
}
|
|
4776
5035
|
};
|
|
4777
5036
|
const result = await execute(doc, variables);
|
|
4778
|
-
const mutationName = (0,
|
|
4779
|
-
const singularName = (0,
|
|
5037
|
+
const mutationName = (0, import_data13.toUpdateMutationName)(tableName, table);
|
|
5038
|
+
const singularName = (0, import_data13.toCamelCaseSingular)(tableName, table);
|
|
4780
5039
|
const updatedRow = result[mutationName]?.[singularName] ?? null;
|
|
4781
5040
|
return updatedRow;
|
|
4782
5041
|
},
|
|
4783
5042
|
async deleteRow(ctx, id, execute, options = {}) {
|
|
4784
5043
|
const { table, allTables } = ctx;
|
|
4785
|
-
const doc = (0,
|
|
5044
|
+
const doc = (0, import_data13.buildPostGraphileDelete)(table, allTables, options);
|
|
4786
5045
|
const variables = {
|
|
4787
5046
|
input: typeof id === "object" ? id : { id }
|
|
4788
5047
|
};
|
|
@@ -4851,7 +5110,7 @@ function useRelationMetadataCache(tableName) {
|
|
|
4851
5110
|
sheetsLogger().debug?.(`Table "${tableName}" not found in metadata`);
|
|
4852
5111
|
return null;
|
|
4853
5112
|
}
|
|
4854
|
-
return (0,
|
|
5113
|
+
return (0, import_data14.cleanTable)(metaTable);
|
|
4855
5114
|
},
|
|
4856
5115
|
...RELATION_CACHE_CONFIG,
|
|
4857
5116
|
refetchOnMount: true,
|
|
@@ -4911,7 +5170,7 @@ function useRelationMetadataCache(tableName) {
|
|
|
4911
5170
|
const refName = fk.refTable?.name;
|
|
4912
5171
|
if (refName && refName.toLowerCase() === (tableName || "").toLowerCase()) {
|
|
4913
5172
|
const fieldName = fk.fields?.[0]?.name;
|
|
4914
|
-
if (fieldName) return (0,
|
|
5173
|
+
if (fieldName) return (0, import_data14.pgFieldToCamelCase)(fieldName);
|
|
4915
5174
|
}
|
|
4916
5175
|
}
|
|
4917
5176
|
return void 0;
|
|
@@ -5670,6 +5929,9 @@ var DRAFT_ACTION_COLUMN_KEY = "__draft_action__";
|
|
|
5670
5929
|
|
|
5671
5930
|
// src/grid/hooks/use-cell-editing.ts
|
|
5672
5931
|
var import_react21 = require("react");
|
|
5932
|
+
function legacyRowIdentifier(row) {
|
|
5933
|
+
return typeof row.id === "string" || typeof row.id === "number" ? row.id : null;
|
|
5934
|
+
}
|
|
5673
5935
|
function normalizeRelationPatchValue(rawValue, relationKind) {
|
|
5674
5936
|
let value = rawValue;
|
|
5675
5937
|
if (typeof value === "string") {
|
|
@@ -5693,8 +5955,9 @@ function normalizeRelationPatchValue(rawValue, relationKind) {
|
|
|
5693
5955
|
if (value === "") value = null;
|
|
5694
5956
|
return value;
|
|
5695
5957
|
}
|
|
5696
|
-
function resolveServerPatch(colKey, rawValue, fieldMetaMap, relationInfoByField) {
|
|
5958
|
+
function resolveServerPatch(colKey, rawValue, fieldMetaMap, relationInfoByField, readOnlyFields) {
|
|
5697
5959
|
if (!colKey || colKey === DRAFT_ACTION_COLUMN_KEY) return { kind: "noop" };
|
|
5960
|
+
if (readOnlyFields?.has(colKey)) return { kind: "noop" };
|
|
5698
5961
|
const metaField = fieldMetaMap.get(colKey);
|
|
5699
5962
|
if (colKey === "id" && metaField?.type?.gqlType === "UUID") return { kind: "noop" };
|
|
5700
5963
|
const relationInfo = relationInfoByField.get(colKey);
|
|
@@ -5716,6 +5979,9 @@ function useCellEditing({
|
|
|
5716
5979
|
updateDraftCell,
|
|
5717
5980
|
tableKey,
|
|
5718
5981
|
update,
|
|
5982
|
+
getRowIdentifier = legacyRowIdentifier,
|
|
5983
|
+
readOnlyFields,
|
|
5984
|
+
canUpdate = true,
|
|
5719
5985
|
onCellEdit,
|
|
5720
5986
|
applyOptimisticPatch
|
|
5721
5987
|
}) {
|
|
@@ -5782,18 +6048,21 @@ function useCellEditing({
|
|
|
5782
6048
|
});
|
|
5783
6049
|
return { type: "draft" };
|
|
5784
6050
|
}
|
|
5785
|
-
|
|
6051
|
+
if (!canUpdate) return { type: "noop" };
|
|
6052
|
+
const resolution = resolveServerPatch(colKey, rawValue, fieldMetaMap, relationInfoByField, readOnlyFields);
|
|
5786
6053
|
if (resolution.kind === "noop") return { type: "noop" };
|
|
5787
6054
|
const { field: patchField, value } = resolution;
|
|
6055
|
+
const rowIdentifier = getRowIdentifier(rowData);
|
|
6056
|
+
if (rowIdentifier === null) return { type: "noop" };
|
|
5788
6057
|
const revertOptimisticPatch = applyOptimisticPatch?.(rowIndex, { [patchField]: value });
|
|
5789
6058
|
let result;
|
|
5790
6059
|
try {
|
|
5791
|
-
result = await update(
|
|
6060
|
+
result = await update(rowIdentifier, { [patchField]: value });
|
|
5792
6061
|
} catch (error) {
|
|
5793
6062
|
revertOptimisticPatch?.();
|
|
5794
6063
|
throw error;
|
|
5795
6064
|
}
|
|
5796
|
-
onCellEdit?.(
|
|
6065
|
+
onCellEdit?.(rowIdentifier, patchField, value);
|
|
5797
6066
|
return {
|
|
5798
6067
|
type: "server",
|
|
5799
6068
|
updatedRow: result?.updatedRow ?? null,
|
|
@@ -5801,17 +6070,23 @@ function useCellEditing({
|
|
|
5801
6070
|
patchValue: value
|
|
5802
6071
|
};
|
|
5803
6072
|
},
|
|
5804
|
-
[combinedRows, fieldMetaMap, relationInfoByField, tableKey, update, onCellEdit, updateDraftCell, applyOptimisticPatch]
|
|
6073
|
+
[combinedRows, fieldMetaMap, relationInfoByField, tableKey, update, getRowIdentifier, readOnlyFields, canUpdate, onCellEdit, updateDraftCell, applyOptimisticPatch]
|
|
5805
6074
|
);
|
|
5806
6075
|
}
|
|
5807
6076
|
|
|
5808
6077
|
// src/grid/hooks/use-batch-commit.ts
|
|
5809
6078
|
var import_react22 = require("react");
|
|
6079
|
+
function legacyRowIdentifier2(row) {
|
|
6080
|
+
return typeof row.id === "string" || typeof row.id === "number" ? row.id : null;
|
|
6081
|
+
}
|
|
5810
6082
|
function useBatchCommit({
|
|
5811
6083
|
combinedRows,
|
|
5812
6084
|
fieldMetaMap,
|
|
5813
6085
|
relationInfoByField,
|
|
5814
6086
|
update,
|
|
6087
|
+
getRowIdentifier = legacyRowIdentifier2,
|
|
6088
|
+
readOnlyFields,
|
|
6089
|
+
canUpdate = true,
|
|
5815
6090
|
applyOptimisticPatch,
|
|
5816
6091
|
resyncRow,
|
|
5817
6092
|
editCell,
|
|
@@ -5831,11 +6106,14 @@ function useBatchCommit({
|
|
|
5831
6106
|
draftWrites.push(w);
|
|
5832
6107
|
continue;
|
|
5833
6108
|
}
|
|
5834
|
-
|
|
6109
|
+
if (!canUpdate) continue;
|
|
6110
|
+
const resolution = resolveServerPatch(w.colKey, w.value, fieldMetaMap, relationInfoByField, readOnlyFields);
|
|
5835
6111
|
if (resolution.kind === "noop") continue;
|
|
6112
|
+
const rowIdentifier = getRowIdentifier(rowData);
|
|
6113
|
+
if (rowIdentifier === null) continue;
|
|
5836
6114
|
resolved.push({
|
|
5837
6115
|
rowIndex: w.rowIndex,
|
|
5838
|
-
rowId:
|
|
6116
|
+
rowId: rowIdentifier,
|
|
5839
6117
|
field: resolution.field,
|
|
5840
6118
|
value: resolution.value,
|
|
5841
6119
|
// Capture the PRIOR value of the patched field BEFORE any optimistic patch.
|
|
@@ -5890,7 +6168,7 @@ function useBatchCommit({
|
|
|
5890
6168
|
}
|
|
5891
6169
|
return { applied: resolved.length };
|
|
5892
6170
|
},
|
|
5893
|
-
[combinedRows, fieldMetaMap, relationInfoByField, update, applyOptimisticPatch, resyncRow, editCell, onCellEdit, record]
|
|
6171
|
+
[combinedRows, fieldMetaMap, relationInfoByField, update, getRowIdentifier, readOnlyFields, canUpdate, applyOptimisticPatch, resyncRow, editCell, onCellEdit, record]
|
|
5894
6172
|
);
|
|
5895
6173
|
commitRef.current = commitCells;
|
|
5896
6174
|
return commitCells;
|
|
@@ -6248,6 +6526,7 @@ function resolveGridCellRoute({
|
|
|
6248
6526
|
}
|
|
6249
6527
|
|
|
6250
6528
|
// src/grid-dom/use-sheets-content.ts
|
|
6529
|
+
init_cell_type_groups();
|
|
6251
6530
|
function isDraftId(value) {
|
|
6252
6531
|
return typeof value === "string" && value.startsWith("draft:");
|
|
6253
6532
|
}
|
|
@@ -6263,11 +6542,24 @@ function tagDraftStyle(cell, hasError) {
|
|
|
6263
6542
|
return { ...cell, styleHint: { ...cell.styleHint, draft: true, error: hasError } };
|
|
6264
6543
|
}
|
|
6265
6544
|
function useSheetsContent(args) {
|
|
6266
|
-
const {
|
|
6545
|
+
const {
|
|
6546
|
+
data,
|
|
6547
|
+
columnKeys,
|
|
6548
|
+
fieldMetaMap,
|
|
6549
|
+
registry,
|
|
6550
|
+
tableName,
|
|
6551
|
+
options,
|
|
6552
|
+
relationInfoByField,
|
|
6553
|
+
meta,
|
|
6554
|
+
serverRowsReadOnly = false,
|
|
6555
|
+
serverReadOnlyFields,
|
|
6556
|
+
getRowIdentifier,
|
|
6557
|
+
supportsScalarSelfCommit = true
|
|
6558
|
+
} = args;
|
|
6267
6559
|
const relationFieldNamesFromMeta = (0, import_react26.useMemo)(() => buildRelationFieldNameSet(meta, tableName), [meta, tableName]);
|
|
6268
6560
|
const cache2 = (0, import_react26.useMemo)(
|
|
6269
6561
|
() => /* @__PURE__ */ new Map(),
|
|
6270
|
-
[data, columnKeys, fieldMetaMap, registry, relationFieldNamesFromMeta, relationInfoByField, options]
|
|
6562
|
+
[data, columnKeys, fieldMetaMap, registry, relationFieldNamesFromMeta, relationInfoByField, options, serverRowsReadOnly, serverReadOnlyFields, getRowIdentifier, supportsScalarSelfCommit]
|
|
6271
6563
|
);
|
|
6272
6564
|
const getSheetsCell = (0, import_react26.useCallback)(
|
|
6273
6565
|
(rowIndex, colKey) => {
|
|
@@ -6309,6 +6601,7 @@ function useSheetsContent(args) {
|
|
|
6309
6601
|
isDraftIdCell,
|
|
6310
6602
|
hasForeignKeyField: canEditRelationInline
|
|
6311
6603
|
});
|
|
6604
|
+
const tableForcedReadOnly = !isDraftRow2 && (serverRowsReadOnly || Boolean(serverReadOnlyFields?.has(colKey)));
|
|
6312
6605
|
let valueForCell = rawValue;
|
|
6313
6606
|
if (relationInfo && relationInfo.relationField && relationInfo.relationField !== colKey) {
|
|
6314
6607
|
const relatedValue = rowData?.[relationInfo.relationField];
|
|
@@ -6336,17 +6629,22 @@ function useSheetsContent(args) {
|
|
|
6336
6629
|
fieldName: colKey
|
|
6337
6630
|
};
|
|
6338
6631
|
const cellType = registry.resolveTypeKey(matchInput, () => route.cellType);
|
|
6632
|
+
const rowIdentifier = !isDraftRow2 ? getRowIdentifier?.(rowData) : null;
|
|
6633
|
+
const selfCommittingEditor = isRelation || MEDIA_TYPES.has(cellType);
|
|
6634
|
+
const lacksScalarEditorIdentity = selfCommittingEditor && (!supportsScalarSelfCommit || rowIdentifier != null && typeof rowIdentifier === "object");
|
|
6635
|
+
const forcedReadOnly = tableForcedReadOnly || lacksScalarEditorIdentity;
|
|
6339
6636
|
const metadata = {
|
|
6340
6637
|
cellType,
|
|
6341
6638
|
fieldName: colKey,
|
|
6342
6639
|
fieldMeta,
|
|
6343
6640
|
relationInfo,
|
|
6344
6641
|
relationOptions: relationInfo ? options || {} : void 0,
|
|
6345
|
-
canEdit: route.canEdit,
|
|
6346
|
-
isReadonly: route.isReadonly,
|
|
6642
|
+
canEdit: route.canEdit && !forcedReadOnly,
|
|
6643
|
+
isReadonly: route.isReadonly || forcedReadOnly,
|
|
6347
6644
|
activationBehavior: route.activationBehavior
|
|
6348
6645
|
};
|
|
6349
|
-
const
|
|
6646
|
+
const resolvedCell = registry.toSheetsCell(cellType, valueForCell, { metadata });
|
|
6647
|
+
const cell = forcedReadOnly && !resolvedCell.readonly ? { ...resolvedCell, readonly: true } : resolvedCell;
|
|
6350
6648
|
const displaySafe = suppressDraftIdText(cell, {
|
|
6351
6649
|
isDraftRow: isDraftRow2,
|
|
6352
6650
|
colKey,
|
|
@@ -6361,7 +6659,7 @@ function useSheetsContent(args) {
|
|
|
6361
6659
|
cache2.set(cacheKey, { value: rawValue, resolution });
|
|
6362
6660
|
return resolution;
|
|
6363
6661
|
},
|
|
6364
|
-
[data, columnKeys, fieldMetaMap, registry, relationFieldNamesFromMeta, relationInfoByField, options]
|
|
6662
|
+
[data, columnKeys, fieldMetaMap, registry, relationFieldNamesFromMeta, relationInfoByField, options, serverRowsReadOnly, serverReadOnlyFields, getRowIdentifier, supportsScalarSelfCommit]
|
|
6365
6663
|
);
|
|
6366
6664
|
return { getSheetsCell };
|
|
6367
6665
|
}
|
|
@@ -6418,13 +6716,18 @@ function useGridOperations(data, deleteRow, gridSelection, clearSelection, optio
|
|
|
6418
6716
|
} else {
|
|
6419
6717
|
failures += 1;
|
|
6420
6718
|
}
|
|
6421
|
-
} else if (
|
|
6719
|
+
} else if (options?.canDeleteServerRows !== false) {
|
|
6720
|
+
const identifier = options?.getRowIdentifier ? options.getRowIdentifier(record) : typeof record?.id === "string" || typeof record?.id === "number" ? record.id : null;
|
|
6721
|
+
if (identifier === null) {
|
|
6722
|
+
failures += 1;
|
|
6723
|
+
continue;
|
|
6724
|
+
}
|
|
6422
6725
|
try {
|
|
6423
|
-
await deleteRow(
|
|
6726
|
+
await deleteRow(identifier);
|
|
6424
6727
|
successes += 1;
|
|
6425
6728
|
serverSuccesses += 1;
|
|
6426
6729
|
} catch (error) {
|
|
6427
|
-
sheetsLogger().error(
|
|
6730
|
+
sheetsLogger().error("Failed to delete record", { identifier, error });
|
|
6428
6731
|
failures += 1;
|
|
6429
6732
|
}
|
|
6430
6733
|
} else {
|
|
@@ -6854,9 +7157,9 @@ var import_react31 = require("react");
|
|
|
6854
7157
|
// src/hooks/use-sheets-infinite-table.ts
|
|
6855
7158
|
var import_react30 = require("react");
|
|
6856
7159
|
var import_react_query5 = require("@tanstack/react-query");
|
|
6857
|
-
var import_data13 = require("@constructive-io/data");
|
|
6858
|
-
var import_data14 = require("@constructive-io/data");
|
|
6859
7160
|
var import_data15 = require("@constructive-io/data");
|
|
7161
|
+
var import_data16 = require("@constructive-io/data");
|
|
7162
|
+
var import_data17 = require("@constructive-io/data");
|
|
6860
7163
|
var sheetsInfiniteTableKeys = {
|
|
6861
7164
|
all: (scope, tableName) => sheetsQueryKeys.infiniteTable(scope, tableName),
|
|
6862
7165
|
page: (scope, tableName, pageIndex, optionsKey) => [...sheetsQueryKeys.infiniteTable(scope, tableName), "page", pageIndex, optionsKey],
|
|
@@ -6890,7 +7193,7 @@ function useSheetsInfiniteTable(tableName, options = {}) {
|
|
|
6890
7193
|
const prevTableNameRef = (0, import_react30.useRef)(tableName);
|
|
6891
7194
|
const tables = (0, import_react30.useMemo)(() => {
|
|
6892
7195
|
if (!meta?._meta?.tables) return [];
|
|
6893
|
-
return meta._meta.tables.filter((candidate) => candidate != null).map((metaTable) => (0,
|
|
7196
|
+
return meta._meta.tables.filter((candidate) => candidate != null).map((metaTable) => (0, import_data15.cleanTable)(metaTable));
|
|
6894
7197
|
}, [meta]);
|
|
6895
7198
|
const table = (0, import_react30.useMemo)(
|
|
6896
7199
|
() => tables.find((candidate) => candidate.name === tableName) ?? null,
|
|
@@ -6937,7 +7240,7 @@ function useSheetsInfiniteTable(tableName, options = {}) {
|
|
|
6937
7240
|
queryKey: sheetsInfiniteTableKeys.page(scopeKey, tableName, pageIndex, stableOptionsKey),
|
|
6938
7241
|
queryFn: async () => {
|
|
6939
7242
|
if (!table) {
|
|
6940
|
-
throw
|
|
7243
|
+
throw import_data16.createError.notFound(`Table '${tableName}' not found`);
|
|
6941
7244
|
}
|
|
6942
7245
|
const queryOptions = {
|
|
6943
7246
|
first: pageSize,
|
|
@@ -6968,7 +7271,7 @@ function useSheetsInfiniteTable(tableName, options = {}) {
|
|
|
6968
7271
|
const validatedOrderByEnum = new Set(variables.orderBy ?? []);
|
|
6969
7272
|
const availableOrderByFields = new Set(table.fields.map((field) => field.name));
|
|
6970
7273
|
const validatedOrderBy = orderBy?.filter(
|
|
6971
|
-
({ field, direction }) => availableOrderByFields.has(field) && validatedOrderByEnum.has((0,
|
|
7274
|
+
({ field, direction }) => availableOrderByFields.has(field) && validatedOrderByEnum.has((0, import_data17.toOrderByEnumValue)(field, direction))
|
|
6972
7275
|
);
|
|
6973
7276
|
const res = await adapter.listRows(
|
|
6974
7277
|
{ table, allTables: tables, tableName },
|
|
@@ -7298,6 +7601,7 @@ function useInfiniteGridData({
|
|
|
7298
7601
|
|
|
7299
7602
|
// src/grid/hooks/use-load-grid.ts
|
|
7300
7603
|
var import_react32 = require("react");
|
|
7604
|
+
var import_data18 = require("@constructive-io/data");
|
|
7301
7605
|
function buildFieldMetaMap2(fields, tableName, fieldTypeOverrides) {
|
|
7302
7606
|
const map = /* @__PURE__ */ new Map();
|
|
7303
7607
|
if (!fields || fields.length === 0) return map;
|
|
@@ -7331,6 +7635,10 @@ function useDataLoading({
|
|
|
7331
7635
|
return candidate ?? null;
|
|
7332
7636
|
}, [meta, tableName]);
|
|
7333
7637
|
const tableSchema = (0, import_react32.useMemo)(() => buildTableSchema(tableMeta), [tableMeta]);
|
|
7638
|
+
const writeCapability = (0, import_react32.useMemo)(
|
|
7639
|
+
() => tableMeta ? (0, import_data18.assessTableWriteCapability)(tableMeta) : null,
|
|
7640
|
+
[tableMeta]
|
|
7641
|
+
);
|
|
7334
7642
|
const fieldMetaMap = (0, import_react32.useMemo)(() => {
|
|
7335
7643
|
const candidate = meta?._meta?.tables?.find((t) => t?.name === tableName);
|
|
7336
7644
|
const fields = candidate?.fields || [];
|
|
@@ -7366,8 +7674,12 @@ function useDataLoading({
|
|
|
7366
7674
|
const create9 = async (payload) => {
|
|
7367
7675
|
const result = await createRow(payload);
|
|
7368
7676
|
const createdRow = result?.createdRow;
|
|
7369
|
-
if (!createdRow || typeof createdRow
|
|
7370
|
-
|
|
7677
|
+
if (!createdRow || typeof createdRow !== "object" || !tableMeta) {
|
|
7678
|
+
throw new Error(`Create mutation for '${tableName}' did not return a row identity.`);
|
|
7679
|
+
}
|
|
7680
|
+
const identity = resolveSheetsRowIdentity(tableMeta, createdRow);
|
|
7681
|
+
if (identity.status !== "identified") {
|
|
7682
|
+
throw new Error(`Create mutation for '${tableName}' returned an incomplete primary-key identity.`);
|
|
7371
7683
|
}
|
|
7372
7684
|
return { createdRow };
|
|
7373
7685
|
};
|
|
@@ -7387,6 +7699,7 @@ function useDataLoading({
|
|
|
7387
7699
|
refetch,
|
|
7388
7700
|
meta,
|
|
7389
7701
|
tableMeta,
|
|
7702
|
+
writeCapability,
|
|
7390
7703
|
tableSchema,
|
|
7391
7704
|
fieldMetaMap,
|
|
7392
7705
|
allRelationFields
|
|
@@ -7403,6 +7716,7 @@ function useDataLoading({
|
|
|
7403
7716
|
refetch,
|
|
7404
7717
|
meta,
|
|
7405
7718
|
tableMeta,
|
|
7719
|
+
writeCapability,
|
|
7406
7720
|
tableSchema,
|
|
7407
7721
|
fieldMetaMap,
|
|
7408
7722
|
allRelationFields
|
|
@@ -7420,7 +7734,8 @@ function buildTableSchema(metaTable) {
|
|
|
7420
7734
|
if (!field) continue;
|
|
7421
7735
|
columns.push(createColumnSchemaFromMeta(field));
|
|
7422
7736
|
}
|
|
7423
|
-
const
|
|
7737
|
+
const identity = (0, import_data18.getRowIdentityDefinition)(metaTable);
|
|
7738
|
+
const primaryKeyFields = identity.status === "keyed" ? identity.fields.map((field) => field.fieldName) : [];
|
|
7424
7739
|
const inflection = metaTable.inflection;
|
|
7425
7740
|
const metadata = {
|
|
7426
7741
|
label: metaTable.name ?? void 0,
|
|
@@ -7557,6 +7872,33 @@ function useSheets(props) {
|
|
|
7557
7872
|
isInitialLoading: ctx.isLoading && rows.length === 0
|
|
7558
7873
|
};
|
|
7559
7874
|
}, [infiniteScroll, infiniteGridData, dataLoadingResult.contextValue]);
|
|
7875
|
+
const writeCapability = (0, import_react33.useMemo)(() => getSheetsWriteCapability(tableMeta), [tableMeta]);
|
|
7876
|
+
const canCreate = canRunSheetsMutation(writeCapability, "create");
|
|
7877
|
+
const canUpdate = canRunSheetsMutation(writeCapability, "update");
|
|
7878
|
+
const canDelete = canRunSheetsMutation(writeCapability, "delete");
|
|
7879
|
+
const primaryKeyFields = (0, import_react33.useMemo)(
|
|
7880
|
+
() => new Set(writeCapability?.status === "mutable" ? writeCapability.primaryKeyFields : []),
|
|
7881
|
+
[writeCapability]
|
|
7882
|
+
);
|
|
7883
|
+
const supportsScalarSelfCommit = writeCapability?.status === "mutable" && writeCapability.primaryKeyFields.length === 1 && writeCapability.primaryKeyFields[0] === "id";
|
|
7884
|
+
const readOnlyReason = writeCapability?.status === "read-only" ? "This table is read-only because it has no primary key." : null;
|
|
7885
|
+
const getRowIdentifier = (0, import_react33.useCallback)(
|
|
7886
|
+
(row) => {
|
|
7887
|
+
if (!tableMeta) return null;
|
|
7888
|
+
const resolution = resolveSheetsRowIdentity(tableMeta, row);
|
|
7889
|
+
return resolution.status === "identified" ? resolution.identifier : null;
|
|
7890
|
+
},
|
|
7891
|
+
[tableMeta]
|
|
7892
|
+
);
|
|
7893
|
+
const getRowId = (0, import_react33.useCallback)(
|
|
7894
|
+
(row, index) => {
|
|
7895
|
+
const draftMeta = getDraftMeta(row);
|
|
7896
|
+
if (draftMeta) return draftMeta.draftRowId;
|
|
7897
|
+
if (row && tableMeta) return sheetsRowKey(tableMeta, row, index);
|
|
7898
|
+
return `${tableMeta?.schemaName ?? ""}:${tableName}:row:${index}`;
|
|
7899
|
+
},
|
|
7900
|
+
[tableMeta, tableName]
|
|
7901
|
+
);
|
|
7560
7902
|
const lastLoadEmitRef = (0, import_react33.useRef)(null);
|
|
7561
7903
|
(0, import_react33.useEffect)(() => {
|
|
7562
7904
|
if (dataError) {
|
|
@@ -7707,7 +8049,11 @@ function useSheets(props) {
|
|
|
7707
8049
|
tableName,
|
|
7708
8050
|
options: { relationChipLimit, relationLabelMaxLength },
|
|
7709
8051
|
relationInfoByField,
|
|
7710
|
-
meta: filterMeta
|
|
8052
|
+
meta: filterMeta,
|
|
8053
|
+
serverRowsReadOnly: !canUpdate,
|
|
8054
|
+
serverReadOnlyFields: primaryKeyFields,
|
|
8055
|
+
getRowIdentifier,
|
|
8056
|
+
supportsScalarSelfCommit
|
|
7711
8057
|
});
|
|
7712
8058
|
const effectiveColumnOrder = (0, import_react33.useMemo)(() => {
|
|
7713
8059
|
if (columnKeys.length > 0) return columnKeys;
|
|
@@ -7769,9 +8115,11 @@ function useSheets(props) {
|
|
|
7769
8115
|
const gridOpsOptions = (0, import_react33.useMemo)(
|
|
7770
8116
|
() => ({
|
|
7771
8117
|
onRemoveDraftRow: (draftRowId) => removeDraftRow(tableKey, draftRowId),
|
|
8118
|
+
getRowIdentifier,
|
|
8119
|
+
canDeleteServerRows: canDelete,
|
|
7772
8120
|
feedback: operationFeedback
|
|
7773
8121
|
}),
|
|
7774
|
-
[removeDraftRow, tableKey, operationFeedback]
|
|
8122
|
+
[removeDraftRow, tableKey, getRowIdentifier, canDelete, operationFeedback]
|
|
7775
8123
|
);
|
|
7776
8124
|
const { deleteSelected: baseDeleteSelected } = useGridOperations(
|
|
7777
8125
|
combinedRows,
|
|
@@ -7813,6 +8161,9 @@ function useSheets(props) {
|
|
|
7813
8161
|
updateDraftCell,
|
|
7814
8162
|
tableKey,
|
|
7815
8163
|
update,
|
|
8164
|
+
getRowIdentifier,
|
|
8165
|
+
readOnlyFields: primaryKeyFields,
|
|
8166
|
+
canUpdate,
|
|
7816
8167
|
onCellEdit,
|
|
7817
8168
|
applyOptimisticPatch: applyOptimisticCellPatch
|
|
7818
8169
|
});
|
|
@@ -7830,6 +8181,9 @@ function useSheets(props) {
|
|
|
7830
8181
|
fieldMetaMap,
|
|
7831
8182
|
relationInfoByField,
|
|
7832
8183
|
update,
|
|
8184
|
+
getRowIdentifier,
|
|
8185
|
+
readOnlyFields: primaryKeyFields,
|
|
8186
|
+
canUpdate,
|
|
7833
8187
|
applyOptimisticPatch: applyOptimisticCellPatch,
|
|
7834
8188
|
resyncRow,
|
|
7835
8189
|
editCell,
|
|
@@ -7867,6 +8221,7 @@ function useSheets(props) {
|
|
|
7867
8221
|
if (infiniteScroll) infiniteGridData.invalidate();
|
|
7868
8222
|
}, [infiniteScroll, infiniteGridData]);
|
|
7869
8223
|
const handleRowAppended = (0, import_react33.useCallback)(async () => {
|
|
8224
|
+
if (!canCreate) return void 0;
|
|
7870
8225
|
if (draftRows.length > 0) {
|
|
7871
8226
|
return serverRowCount + draftRows.length - 1;
|
|
7872
8227
|
}
|
|
@@ -7890,6 +8245,7 @@ function useSheets(props) {
|
|
|
7890
8245
|
tableKey,
|
|
7891
8246
|
draftRows,
|
|
7892
8247
|
serverRowCount,
|
|
8248
|
+
canCreate,
|
|
7893
8249
|
emit
|
|
7894
8250
|
]);
|
|
7895
8251
|
const { selectedRowCount, selectedDraftRowEntries, hasDraftSelection } = useGridSelectionState({
|
|
@@ -8035,6 +8391,11 @@ function useSheets(props) {
|
|
|
8035
8391
|
resizeColumn: gridActions.resizeColumn,
|
|
8036
8392
|
frozenCount,
|
|
8037
8393
|
selectedRowCount,
|
|
8394
|
+
canCreate,
|
|
8395
|
+
canUpdate,
|
|
8396
|
+
canDelete,
|
|
8397
|
+
readOnlyReason,
|
|
8398
|
+
getRowId,
|
|
8038
8399
|
isSubmittingDrafts,
|
|
8039
8400
|
submitDraftButtonDisabled,
|
|
8040
8401
|
submitDraftLabel,
|
|
@@ -8756,8 +9117,44 @@ function GeometryCellView(props) {
|
|
|
8756
9117
|
}
|
|
8757
9118
|
|
|
8758
9119
|
// src/cell-model/views/image-view.tsx
|
|
9120
|
+
var import_lucide_react2 = require("lucide-react");
|
|
8759
9121
|
init_cn();
|
|
8760
9122
|
|
|
9123
|
+
// src/utils/file.utils.ts
|
|
9124
|
+
var getImageUrl = (imageValue) => {
|
|
9125
|
+
if (!imageValue) return null;
|
|
9126
|
+
if (typeof imageValue === "string") {
|
|
9127
|
+
return imageValue;
|
|
9128
|
+
}
|
|
9129
|
+
if (typeof imageValue === "object" && imageValue !== null) {
|
|
9130
|
+
const urlCandidates = ["url", "src", "href", "link", "path"];
|
|
9131
|
+
for (const candidate of urlCandidates) {
|
|
9132
|
+
const obj = imageValue;
|
|
9133
|
+
if (obj[candidate] && typeof obj[candidate] === "string") {
|
|
9134
|
+
return obj[candidate];
|
|
9135
|
+
}
|
|
9136
|
+
}
|
|
9137
|
+
}
|
|
9138
|
+
return null;
|
|
9139
|
+
};
|
|
9140
|
+
var getImageMetadata = (imageValue) => {
|
|
9141
|
+
if (!imageValue || typeof imageValue !== "object") return null;
|
|
9142
|
+
const obj = imageValue;
|
|
9143
|
+
return {
|
|
9144
|
+
filename: obj.filename || obj.name || "Unknown",
|
|
9145
|
+
size: obj.size || obj.fileSize || 0,
|
|
9146
|
+
mime: obj.mime || obj.type || obj.contentType || "unknown",
|
|
9147
|
+
url: getImageUrl(imageValue) || ""
|
|
9148
|
+
};
|
|
9149
|
+
};
|
|
9150
|
+
var formatFileSize = (bytes) => {
|
|
9151
|
+
if (bytes === 0) return "0 B";
|
|
9152
|
+
const k = 1024;
|
|
9153
|
+
const sizes = ["B", "KB", "MB", "GB"];
|
|
9154
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
9155
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + " " + sizes[i];
|
|
9156
|
+
};
|
|
9157
|
+
|
|
8761
9158
|
// src/cell-model/image-cache.ts
|
|
8762
9159
|
var CAP = 256;
|
|
8763
9160
|
var cache = /* @__PURE__ */ new Map();
|
|
@@ -8786,8 +9183,34 @@ function readUrl(data) {
|
|
|
8786
9183
|
if (Array.isArray(data) && typeof data[0] === "string") return data[0];
|
|
8787
9184
|
return "";
|
|
8788
9185
|
}
|
|
9186
|
+
function basename(url) {
|
|
9187
|
+
const path = url.split(/[?#]/)[0];
|
|
9188
|
+
const seg = path.slice(path.lastIndexOf("/") + 1);
|
|
9189
|
+
return seg || url;
|
|
9190
|
+
}
|
|
9191
|
+
function isNonImageFile(cellType, value) {
|
|
9192
|
+
if (cellType === "image" || value == null) return false;
|
|
9193
|
+
const mime = getImageMetadata(value)?.mime;
|
|
9194
|
+
return !(mime && mime !== "unknown" && mime.startsWith("image/"));
|
|
9195
|
+
}
|
|
8789
9196
|
function ImageCellView(props) {
|
|
8790
9197
|
const url = readUrl(props.cell.data);
|
|
9198
|
+
if (url && isNonImageFile(props.column.cellType, props.value)) {
|
|
9199
|
+
const meta = getImageMetadata(props.value);
|
|
9200
|
+
const filename = meta?.filename && meta.filename !== "Unknown" ? meta.filename : basename(url);
|
|
9201
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
9202
|
+
"div",
|
|
9203
|
+
{
|
|
9204
|
+
"data-slot": "file-cell",
|
|
9205
|
+
role: "gridcell",
|
|
9206
|
+
className: cn("flex h-full w-full items-center gap-1.5 overflow-hidden px-2"),
|
|
9207
|
+
children: [
|
|
9208
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react2.FileIcon, { className: "size-3.5 shrink-0 text-muted-foreground", "aria-hidden": "true" }),
|
|
9209
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "truncate text-sm", title: filename, children: filename })
|
|
9210
|
+
]
|
|
9211
|
+
}
|
|
9212
|
+
);
|
|
9213
|
+
}
|
|
8791
9214
|
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
8792
9215
|
"div",
|
|
8793
9216
|
{
|
|
@@ -8959,7 +9382,7 @@ function parseNumeric(text) {
|
|
|
8959
9382
|
const n = Number(trimmed);
|
|
8960
9383
|
return Number.isFinite(n) ? { ok: true, value: n } : { ok: false, value: null };
|
|
8961
9384
|
}
|
|
8962
|
-
function InlineCellEditor({ value, initialText, numeric, onCommit, onCancel }) {
|
|
9385
|
+
function InlineCellEditor({ ariaLabel, value, initialText, numeric, onCommit, onCancel }) {
|
|
8963
9386
|
const [text, setText] = (0, import_react36.useState)(() => initialText != null ? initialText : seedText(value));
|
|
8964
9387
|
const inputRef = (0, import_react36.useRef)(null);
|
|
8965
9388
|
const gridRef = (0, import_react36.useRef)(null);
|
|
@@ -9003,6 +9426,7 @@ function InlineCellEditor({ value, initialText, numeric, onCommit, onCancel }) {
|
|
|
9003
9426
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
9004
9427
|
"input",
|
|
9005
9428
|
{
|
|
9429
|
+
"aria-label": ariaLabel,
|
|
9006
9430
|
ref: inputRef,
|
|
9007
9431
|
value: text,
|
|
9008
9432
|
onChange: (e) => setText(e.target.value),
|
|
@@ -9119,15 +9543,15 @@ var SheetsCellHostInner = (0, import_react37.memo)(
|
|
|
9119
9543
|
draftClasses,
|
|
9120
9544
|
props.className
|
|
9121
9545
|
),
|
|
9122
|
-
children: isDraftActionCell ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
9546
|
+
children: isDraftActionCell ? draftAction ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
9123
9547
|
DraftActionCellView,
|
|
9124
9548
|
{
|
|
9125
|
-
status: draftAction
|
|
9126
|
-
errored: draftAction
|
|
9127
|
-
disabled: draftAction
|
|
9549
|
+
status: draftAction.status,
|
|
9550
|
+
errored: draftAction.errored,
|
|
9551
|
+
disabled: draftAction.disabled,
|
|
9128
9552
|
onSubmit: submitDraft
|
|
9129
9553
|
}
|
|
9130
|
-
) : props.isEditing ? (
|
|
9554
|
+
) : null : props.isEditing ? (
|
|
9131
9555
|
// Inline (in-cell) edit for the simple text-representable types — a bare <input>
|
|
9132
9556
|
// overlaying the view. `isEditing` is set true ONLY for inline-edit intents (the
|
|
9133
9557
|
// shell short-circuits inline-toggle/overlay/none before here), so the cell kind is
|
|
@@ -9135,6 +9559,7 @@ var SheetsCellHostInner = (0, import_react37.memo)(
|
|
|
9135
9559
|
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
9136
9560
|
InlineCellEditor,
|
|
9137
9561
|
{
|
|
9562
|
+
ariaLabel: `Edit ${props.resolution.fieldMeta?.name ?? props.colKey}`,
|
|
9138
9563
|
value: props.value,
|
|
9139
9564
|
initialText: props.inlineInitialText,
|
|
9140
9565
|
numeric: props.resolution.cell.kind === "number",
|
|
@@ -9378,7 +9803,7 @@ init_cell_type_groups();
|
|
|
9378
9803
|
var import_react43 = require("react");
|
|
9379
9804
|
var import_badge = require("@constructive-io/ui/badge");
|
|
9380
9805
|
var import_button6 = require("@constructive-io/ui/button");
|
|
9381
|
-
var
|
|
9806
|
+
var import_lucide_react3 = require("lucide-react");
|
|
9382
9807
|
init_editor_focus_trap();
|
|
9383
9808
|
init_overlay_presets();
|
|
9384
9809
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
@@ -9495,7 +9920,7 @@ function ArrayEditor({ value, onChange, onFinished }) {
|
|
|
9495
9920
|
},
|
|
9496
9921
|
"aria-label": `Remove ${String(item)}`,
|
|
9497
9922
|
tabIndex: -1,
|
|
9498
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
9923
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react3.XIcon, { className: "size-3" })
|
|
9499
9924
|
}
|
|
9500
9925
|
)
|
|
9501
9926
|
]
|
|
@@ -9577,7 +10002,7 @@ var import_react48 = require("react");
|
|
|
9577
10002
|
|
|
9578
10003
|
// src/grid/editors/geometry-editor.tsx
|
|
9579
10004
|
var import_react47 = require("react");
|
|
9580
|
-
var
|
|
10005
|
+
var import_lucide_react5 = require("lucide-react");
|
|
9581
10006
|
init_cn();
|
|
9582
10007
|
var import_button9 = require("@constructive-io/ui/button");
|
|
9583
10008
|
var import_tabs = require("@constructive-io/ui/tabs");
|
|
@@ -9589,7 +10014,7 @@ var MapPicker2 = (0, import_react47.lazy)(
|
|
|
9589
10014
|
() => Promise.resolve().then(() => (init_map_picker(), map_picker_exports)).then((m) => ({ default: m.MapPicker }))
|
|
9590
10015
|
);
|
|
9591
10016
|
function MapPickerLoading() {
|
|
9592
|
-
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "flex h-[280px] w-full items-center justify-center rounded-lg border bg-muted/30", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
10017
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "flex h-[280px] w-full items-center justify-center rounded-lg border bg-muted/30", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_lucide_react5.Loader2, { className: "h-6 w-6 animate-spin text-muted-foreground" }) });
|
|
9593
10018
|
}
|
|
9594
10019
|
var VALID_GEOJSON_TYPES = [
|
|
9595
10020
|
"Point",
|
|
@@ -9853,17 +10278,17 @@ var GeometryEditor = ({ value, onFinishedEditing, expectedType }) => {
|
|
|
9853
10278
|
}, [overlayMaxHeight]);
|
|
9854
10279
|
const header = /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex items-center justify-between px-3 py-2", children: [
|
|
9855
10280
|
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
9856
|
-
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
10281
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_lucide_react5.MapPin, { className: "text-muted-foreground h-3.5 w-3.5" }),
|
|
9857
10282
|
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "text-sm font-medium", children: "Geometry" }),
|
|
9858
10283
|
expectedType && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "bg-muted text-muted-foreground rounded px-1.5 py-0.5 text-xs", children: expectedType })
|
|
9859
10284
|
] }),
|
|
9860
10285
|
canShowMap && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_tabs.TabsList, { className: "h-7", children: [
|
|
9861
10286
|
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_tabs.TabsTrigger, { value: "map", className: "flex items-center gap-1.5 px-2.5 text-xs", children: [
|
|
9862
|
-
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
10287
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_lucide_react5.Map, { className: "h-3 w-3" }),
|
|
9863
10288
|
"Map"
|
|
9864
10289
|
] }),
|
|
9865
10290
|
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_tabs.TabsTrigger, { value: "json", className: "flex items-center gap-1.5 px-2.5 text-xs", children: [
|
|
9866
|
-
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
10291
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_lucide_react5.FileText, { className: "h-3 w-3" }),
|
|
9867
10292
|
"JSON"
|
|
9868
10293
|
] })
|
|
9869
10294
|
] })
|
|
@@ -9881,11 +10306,11 @@ var GeometryEditor = ({ value, onFinishedEditing, expectedType }) => {
|
|
|
9881
10306
|
}
|
|
9882
10307
|
),
|
|
9883
10308
|
validationError && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "text-destructive flex items-center gap-2 text-sm", children: [
|
|
9884
|
-
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
10309
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_lucide_react5.AlertCircle, { className: "h-4 w-4 shrink-0" }),
|
|
9885
10310
|
validationError
|
|
9886
10311
|
] }),
|
|
9887
10312
|
(!expectedType || RANDOMIZABLE_TYPES.includes(expectedType)) && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_button9.Button, { variant: "ghost", size: "xs", onClick: handleRandomize, title: "Generate random geometry", children: [
|
|
9888
|
-
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
10313
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_lucide_react5.Shuffle, { className: "mr-1 h-3 w-3" }),
|
|
9889
10314
|
"Randomize"
|
|
9890
10315
|
] })
|
|
9891
10316
|
] });
|
|
@@ -9953,21 +10378,21 @@ var import_react54 = require("react");
|
|
|
9953
10378
|
|
|
9954
10379
|
// src/grid/editors/image-editor.tsx
|
|
9955
10380
|
var import_react52 = require("react");
|
|
9956
|
-
var
|
|
10381
|
+
var import_lucide_react6 = require("lucide-react");
|
|
9957
10382
|
var import_react53 = require("motion/react");
|
|
9958
10383
|
var import_toast2 = require("@constructive-io/ui/toast");
|
|
9959
10384
|
|
|
9960
10385
|
// src/hooks/use-sheets-upload.ts
|
|
9961
10386
|
var import_react49 = require("react");
|
|
9962
10387
|
var import_react_query6 = require("@tanstack/react-query");
|
|
9963
|
-
var
|
|
9964
|
-
var
|
|
10388
|
+
var import_data19 = require("@constructive-io/data");
|
|
10389
|
+
var import_data20 = require("@constructive-io/data");
|
|
9965
10390
|
function resolveUploadNaming(tableName, table) {
|
|
9966
10391
|
return {
|
|
9967
|
-
mutationName: (0,
|
|
9968
|
-
singularName: (0,
|
|
9969
|
-
patchFieldName: (0,
|
|
9970
|
-
updateInputTypeName: (0,
|
|
10392
|
+
mutationName: (0, import_data20.toUpdateMutationName)(tableName, table),
|
|
10393
|
+
singularName: (0, import_data20.toCamelCaseSingular)(tableName, table),
|
|
10394
|
+
patchFieldName: (0, import_data20.toPatchFieldName)(tableName, table),
|
|
10395
|
+
updateInputTypeName: (0, import_data20.toUpdateInputTypeName)(tableName)
|
|
9971
10396
|
};
|
|
9972
10397
|
}
|
|
9973
10398
|
function resolveTransport(endpoint, getToken, options) {
|
|
@@ -10044,7 +10469,7 @@ function useSheetsFieldUpload(tableName, fieldName, recordId, options = {}) {
|
|
|
10044
10469
|
const table = (0, import_react49.useMemo)(() => {
|
|
10045
10470
|
if (!meta?._meta?.tables) return null;
|
|
10046
10471
|
const candidate = meta._meta.tables.find((item) => item?.name === tableName);
|
|
10047
|
-
return candidate ? (0,
|
|
10472
|
+
return candidate ? (0, import_data19.cleanTable)(candidate) : null;
|
|
10048
10473
|
}, [meta, tableName]);
|
|
10049
10474
|
const resolvedNaming = (0, import_react49.useMemo)(() => resolveUploadNaming(tableName, table), [tableName, table]);
|
|
10050
10475
|
const getToken = (0, import_react49.useMemo)(() => {
|
|
@@ -10093,7 +10518,7 @@ function useSheetsImageUpload(tableName, fieldName, recordId, options = {}) {
|
|
|
10093
10518
|
const table = (0, import_react49.useMemo)(() => {
|
|
10094
10519
|
if (!meta?._meta?.tables) return null;
|
|
10095
10520
|
const candidate = meta._meta.tables.find((item) => item?.name === tableName);
|
|
10096
|
-
return candidate ? (0,
|
|
10521
|
+
return candidate ? (0, import_data19.cleanTable)(candidate) : null;
|
|
10097
10522
|
}, [meta, tableName]);
|
|
10098
10523
|
const resolvedNaming = (0, import_react49.useMemo)(() => resolveUploadNaming(tableName, table), [tableName, table]);
|
|
10099
10524
|
const getToken = (0, import_react49.useMemo)(() => {
|
|
@@ -10142,41 +10567,6 @@ function useSheetsImageUpload(tableName, fieldName, recordId, options = {}) {
|
|
|
10142
10567
|
});
|
|
10143
10568
|
}
|
|
10144
10569
|
|
|
10145
|
-
// src/utils/file.utils.ts
|
|
10146
|
-
var getImageUrl = (imageValue) => {
|
|
10147
|
-
if (!imageValue) return null;
|
|
10148
|
-
if (typeof imageValue === "string") {
|
|
10149
|
-
return imageValue;
|
|
10150
|
-
}
|
|
10151
|
-
if (typeof imageValue === "object" && imageValue !== null) {
|
|
10152
|
-
const urlCandidates = ["url", "src", "href", "link", "path"];
|
|
10153
|
-
for (const candidate of urlCandidates) {
|
|
10154
|
-
const obj = imageValue;
|
|
10155
|
-
if (obj[candidate] && typeof obj[candidate] === "string") {
|
|
10156
|
-
return obj[candidate];
|
|
10157
|
-
}
|
|
10158
|
-
}
|
|
10159
|
-
}
|
|
10160
|
-
return null;
|
|
10161
|
-
};
|
|
10162
|
-
var getImageMetadata = (imageValue) => {
|
|
10163
|
-
if (!imageValue || typeof imageValue !== "object") return null;
|
|
10164
|
-
const obj = imageValue;
|
|
10165
|
-
return {
|
|
10166
|
-
filename: obj.filename || obj.name || "Unknown",
|
|
10167
|
-
size: obj.size || obj.fileSize || 0,
|
|
10168
|
-
mime: obj.mime || obj.type || obj.contentType || "unknown",
|
|
10169
|
-
url: getImageUrl(imageValue) || ""
|
|
10170
|
-
};
|
|
10171
|
-
};
|
|
10172
|
-
var formatFileSize = (bytes) => {
|
|
10173
|
-
if (bytes === 0) return "0 B";
|
|
10174
|
-
const k = 1024;
|
|
10175
|
-
const sizes = ["B", "KB", "MB", "GB"];
|
|
10176
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
10177
|
-
return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + " " + sizes[i];
|
|
10178
|
-
};
|
|
10179
|
-
|
|
10180
10570
|
// src/grid/editors/image-editor.tsx
|
|
10181
10571
|
init_sheets_logger();
|
|
10182
10572
|
|
|
@@ -10272,10 +10662,24 @@ function RemoveButton({ onClick, label }) {
|
|
|
10272
10662
|
onClick();
|
|
10273
10663
|
},
|
|
10274
10664
|
"aria-label": label,
|
|
10275
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
10665
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react6.XIcon, { className: "size-3.5", "aria-hidden": "true" })
|
|
10276
10666
|
}
|
|
10277
10667
|
) });
|
|
10278
10668
|
}
|
|
10669
|
+
function FilePreview({ name, size, mime }) {
|
|
10670
|
+
const hasMime = !!mime && mime !== "unknown";
|
|
10671
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex size-full flex-col items-center justify-center gap-2 p-4 text-center", children: [
|
|
10672
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "bg-muted/60 flex size-12 shrink-0 items-center justify-center rounded-lg", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react6.FileIcon, { className: "text-muted-foreground size-6" }) }),
|
|
10673
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "min-w-0 max-w-full", children: [
|
|
10674
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "truncate text-sm font-medium", title: name, children: name || "File" }),
|
|
10675
|
+
(size || hasMime) && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("p", { className: "text-muted-foreground mt-0.5 text-xs", children: [
|
|
10676
|
+
size ? formatFileSize(size) : null,
|
|
10677
|
+
size && hasMime ? " \u2022 " : null,
|
|
10678
|
+
hasMime ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "uppercase", children: mime }) : null
|
|
10679
|
+
] })
|
|
10680
|
+
] })
|
|
10681
|
+
] });
|
|
10682
|
+
}
|
|
10279
10683
|
var ImageEditor = ({
|
|
10280
10684
|
value,
|
|
10281
10685
|
onFinishedEditing,
|
|
@@ -10285,8 +10689,11 @@ var ImageEditor = ({
|
|
|
10285
10689
|
onSaveComplete,
|
|
10286
10690
|
isDraftRow: isDraftRow2 = false,
|
|
10287
10691
|
onSubmitDraft,
|
|
10288
|
-
onDraftUploadComplete
|
|
10692
|
+
onDraftUploadComplete,
|
|
10693
|
+
acceptAnyFile = false
|
|
10289
10694
|
}) => {
|
|
10695
|
+
const noun = acceptAnyFile ? "file" : "image";
|
|
10696
|
+
const Noun = acceptAnyFile ? "File" : "Image";
|
|
10290
10697
|
const [uploadState, setUploadState] = (0, import_react52.useState)("idle");
|
|
10291
10698
|
const { config } = useSheetsContext();
|
|
10292
10699
|
const storeApi = useSheetsStoreApi();
|
|
@@ -10309,10 +10716,12 @@ var ImageEditor = ({
|
|
|
10309
10716
|
const isUploading = uploadState === "uploading";
|
|
10310
10717
|
const isBusy = uploadState !== "idle";
|
|
10311
10718
|
const imageUrl = (0, import_react52.useMemo)(() => getImageUrl(imageValue), [imageValue]);
|
|
10312
|
-
const imageStatus = useImageStatus(imageUrl || void 0);
|
|
10313
|
-
const imageLoadFailed = imageUrl != null && imageStatus === "error";
|
|
10314
|
-
const hasImage = imageUrl != null && !imageLoadFailed;
|
|
10315
10719
|
const imageMetadata = (0, import_react52.useMemo)(() => getImageMetadata(imageValue), [imageValue]);
|
|
10720
|
+
const storedMime = imageMetadata?.mime;
|
|
10721
|
+
const storedIsImage = !acceptAnyFile || !!storedMime && storedMime.startsWith("image/");
|
|
10722
|
+
const imageStatus = useImageStatus(storedIsImage ? imageUrl || void 0 : void 0);
|
|
10723
|
+
const imageLoadFailed = storedIsImage && imageUrl != null && imageStatus === "error";
|
|
10724
|
+
const hasImage = imageUrl != null && !imageLoadFailed && storedIsImage;
|
|
10316
10725
|
const revokePreviewUrl = (0, import_react52.useCallback)(() => {
|
|
10317
10726
|
if (previewUrlRef.current) {
|
|
10318
10727
|
URL.revokeObjectURL(previewUrlRef.current);
|
|
@@ -10332,8 +10741,8 @@ var ImageEditor = ({
|
|
|
10332
10741
|
setImageValue(normalized);
|
|
10333
10742
|
onSaveComplete?.({ imageData: normalized });
|
|
10334
10743
|
onFinishedEditing();
|
|
10335
|
-
import_toast2.toast.success({ message:
|
|
10336
|
-
}, [resetFileState, onSaveComplete, onFinishedEditing]);
|
|
10744
|
+
import_toast2.toast.success({ message: `${Noun} uploaded successfully` });
|
|
10745
|
+
}, [resetFileState, onSaveComplete, onFinishedEditing, Noun]);
|
|
10337
10746
|
const handleUploadError = (0, import_react52.useCallback)((error) => {
|
|
10338
10747
|
setUploadState("idle");
|
|
10339
10748
|
sheetsLogger().error("[image-editor] upload failed:", error);
|
|
@@ -10353,20 +10762,22 @@ var ImageEditor = ({
|
|
|
10353
10762
|
const handleFileSelection = (0, import_react52.useCallback)((acceptedFiles) => {
|
|
10354
10763
|
if (acceptedFiles.length === 0) return;
|
|
10355
10764
|
const file = acceptedFiles[0];
|
|
10356
|
-
if (!
|
|
10357
|
-
|
|
10358
|
-
|
|
10359
|
-
|
|
10360
|
-
|
|
10361
|
-
|
|
10362
|
-
|
|
10765
|
+
if (!acceptAnyFile) {
|
|
10766
|
+
if (!file.type.startsWith("image/")) {
|
|
10767
|
+
import_toast2.toast.error({ message: "Please select an image file" });
|
|
10768
|
+
return;
|
|
10769
|
+
}
|
|
10770
|
+
if (file.size > 10 * 1024 * 1024) {
|
|
10771
|
+
import_toast2.toast.error({ message: "File size must be less than 10MB" });
|
|
10772
|
+
return;
|
|
10773
|
+
}
|
|
10363
10774
|
}
|
|
10364
10775
|
revokePreviewUrl();
|
|
10365
10776
|
setSelectedFile(file);
|
|
10366
10777
|
const url = URL.createObjectURL(file);
|
|
10367
10778
|
previewUrlRef.current = url;
|
|
10368
10779
|
setPreviewUrl(url);
|
|
10369
|
-
}, [revokePreviewUrl]);
|
|
10780
|
+
}, [revokePreviewUrl, acceptAnyFile]);
|
|
10370
10781
|
const handleDragEnter = (0, import_react52.useCallback)((e) => {
|
|
10371
10782
|
e.preventDefault();
|
|
10372
10783
|
e.stopPropagation();
|
|
@@ -10401,7 +10812,7 @@ var ImageEditor = ({
|
|
|
10401
10812
|
const committedId = committedRecordIdRef.current ?? recordId;
|
|
10402
10813
|
if (committedRecordIdRef.current != null) {
|
|
10403
10814
|
try {
|
|
10404
|
-
import_toast2.toast.info({ message:
|
|
10815
|
+
import_toast2.toast.info({ message: `Uploading ${noun}...` });
|
|
10405
10816
|
setUploadState("uploading");
|
|
10406
10817
|
const uploadResult = await executeFieldUpload(
|
|
10407
10818
|
tableName,
|
|
@@ -10417,7 +10828,7 @@ var ImageEditor = ({
|
|
|
10417
10828
|
resetFileState();
|
|
10418
10829
|
setImageValue(normalized);
|
|
10419
10830
|
onDraftUploadComplete?.();
|
|
10420
|
-
import_toast2.toast.success({ message:
|
|
10831
|
+
import_toast2.toast.success({ message: `${Noun} uploaded successfully` });
|
|
10421
10832
|
onFinishedEditing();
|
|
10422
10833
|
} catch (error) {
|
|
10423
10834
|
onDraftUploadComplete?.();
|
|
@@ -10435,14 +10846,17 @@ var ImageEditor = ({
|
|
|
10435
10846
|
import_toast2.toast.info({ message: "Creating row..." });
|
|
10436
10847
|
setUploadState("submitting-draft");
|
|
10437
10848
|
const result = await onSubmitDraft();
|
|
10438
|
-
|
|
10439
|
-
|
|
10440
|
-
|
|
10849
|
+
const createdId = result.createdRow?.id;
|
|
10850
|
+
if (typeof createdId !== "string" && typeof createdId !== "number") {
|
|
10851
|
+
throw new Error("Image uploads require a scalar id primary key.");
|
|
10852
|
+
}
|
|
10853
|
+
committedRecordIdRef.current = createdId;
|
|
10854
|
+
import_toast2.toast.info({ message: `Uploading ${noun}...` });
|
|
10441
10855
|
setUploadState("uploading");
|
|
10442
10856
|
const uploadResult = await executeFieldUpload(
|
|
10443
10857
|
tableName,
|
|
10444
10858
|
fieldName,
|
|
10445
|
-
|
|
10859
|
+
createdId,
|
|
10446
10860
|
selectedFile,
|
|
10447
10861
|
config.endpoint,
|
|
10448
10862
|
getToken,
|
|
@@ -10453,7 +10867,7 @@ var ImageEditor = ({
|
|
|
10453
10867
|
resetFileState();
|
|
10454
10868
|
setImageValue(normalized);
|
|
10455
10869
|
onDraftUploadComplete?.();
|
|
10456
|
-
import_toast2.toast.success({ message:
|
|
10870
|
+
import_toast2.toast.success({ message: `Row created and ${noun} uploaded` });
|
|
10457
10871
|
onFinishedEditing();
|
|
10458
10872
|
} catch (error) {
|
|
10459
10873
|
onDraftUploadComplete?.();
|
|
@@ -10468,7 +10882,7 @@ var ImageEditor = ({
|
|
|
10468
10882
|
}
|
|
10469
10883
|
setUploadState("uploading");
|
|
10470
10884
|
uploadMutation.mutate(selectedFile);
|
|
10471
|
-
}, [selectedFile, uploadMutation, tableName, fieldName, recordId, isDraftRow2, onSubmitDraft, config.endpoint, config.onAuthError, getToken, resetFileState, onDraftUploadComplete, onFinishedEditing]);
|
|
10885
|
+
}, [selectedFile, uploadMutation, tableName, fieldName, recordId, isDraftRow2, onSubmitDraft, config.endpoint, config.onAuthError, getToken, resetFileState, onDraftUploadComplete, onFinishedEditing, noun, Noun]);
|
|
10472
10886
|
const handleSave = (0, import_react52.useCallback)(() => {
|
|
10473
10887
|
if (!imageValue) {
|
|
10474
10888
|
onFinishedEditing(null);
|
|
@@ -10493,12 +10907,13 @@ var ImageEditor = ({
|
|
|
10493
10907
|
handleSave();
|
|
10494
10908
|
}
|
|
10495
10909
|
}, [handleSave]);
|
|
10496
|
-
const
|
|
10910
|
+
const hasStoredFile = acceptAnyFile && !!imageUrl && !storedIsImage;
|
|
10911
|
+
const dropzoneKey = isBusy ? "busy" : previewUrl ? "preview" : hasImage ? "loaded" : hasStoredFile ? "file" : imageLoadFailed ? "broken" : "empty";
|
|
10497
10912
|
const renderDropzoneContent = () => {
|
|
10498
10913
|
if (isBusy) {
|
|
10499
10914
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { "data-state": uploadState, className: "text-muted-foreground flex w-full flex-col items-center justify-center p-6", children: [
|
|
10500
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
10501
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "text-sm", children: isSubmittingDraft ? "Creating row..." :
|
|
10915
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react6.Loader2, { className: "mb-2 size-6 animate-spin" }),
|
|
10916
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "text-sm", children: isSubmittingDraft ? "Creating row..." : `Uploading ${noun}...` }),
|
|
10502
10917
|
isUploading && uploadProgress && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "mt-3 w-full max-w-xs", children: [
|
|
10503
10918
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "bg-muted h-1.5 overflow-hidden rounded-full", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
10504
10919
|
"div",
|
|
@@ -10515,8 +10930,9 @@ var ImageEditor = ({
|
|
|
10515
10930
|
] });
|
|
10516
10931
|
}
|
|
10517
10932
|
if (previewUrl) {
|
|
10933
|
+
const selectedIsImage = !acceptAnyFile || (selectedFile?.type.startsWith("image/") ?? false);
|
|
10518
10934
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "relative w-full", style: { height: "13rem" }, children: [
|
|
10519
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("img", { src: previewUrl, alt: selectedFile?.name || "
|
|
10935
|
+
selectedIsImage ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("img", { src: previewUrl, alt: selectedFile?.name || "Selected file", className: "size-full object-contain p-2" }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(FilePreview, { name: selectedFile?.name, size: selectedFile?.size, mime: selectedFile?.type }),
|
|
10520
10936
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RemoveButton, { onClick: removeFile, label: "Remove selected file" })
|
|
10521
10937
|
] });
|
|
10522
10938
|
}
|
|
@@ -10535,6 +10951,12 @@ var ImageEditor = ({
|
|
|
10535
10951
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RemoveButton, { onClick: handleRemoveImage, label: "Remove image" })
|
|
10536
10952
|
] });
|
|
10537
10953
|
}
|
|
10954
|
+
if (hasStoredFile) {
|
|
10955
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "relative w-full", style: { height: "13rem" }, children: [
|
|
10956
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(FilePreview, { name: imageMetadata?.filename, size: imageMetadata?.size, mime: imageMetadata?.mime }),
|
|
10957
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RemoveButton, { onClick: handleRemoveImage, label: "Remove file" })
|
|
10958
|
+
] });
|
|
10959
|
+
}
|
|
10538
10960
|
if (imageLoadFailed) {
|
|
10539
10961
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex w-full flex-col items-center justify-center px-4 py-6 text-center", children: [
|
|
10540
10962
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
@@ -10542,7 +10964,7 @@ var ImageEditor = ({
|
|
|
10542
10964
|
{
|
|
10543
10965
|
className: "mb-3 flex size-10 shrink-0 items-center justify-center rounded-full\n border border-dashed border-amber-500/25 bg-amber-500/[0.06]",
|
|
10544
10966
|
"aria-hidden": "true",
|
|
10545
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
10967
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react6.ImageOff, { className: "size-4 text-amber-500/50" })
|
|
10546
10968
|
}
|
|
10547
10969
|
),
|
|
10548
10970
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "text-sm font-medium", children: "Image unavailable" }),
|
|
@@ -10565,7 +10987,7 @@ var ImageEditor = ({
|
|
|
10565
10987
|
openFileDialog();
|
|
10566
10988
|
},
|
|
10567
10989
|
children: [
|
|
10568
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
10990
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react6.UploadIcon, { className: "-ms-0.5 opacity-60", "aria-hidden": "true" }),
|
|
10569
10991
|
"Replace"
|
|
10570
10992
|
]
|
|
10571
10993
|
}
|
|
@@ -10587,9 +11009,13 @@ var ImageEditor = ({
|
|
|
10587
11009
|
] });
|
|
10588
11010
|
}
|
|
10589
11011
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex w-full flex-col items-center justify-center px-4 py-6 text-center", children: [
|
|
10590
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "bg-muted/60 mb-3 flex size-10 shrink-0 items-center justify-center rounded-full", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
10591
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.
|
|
10592
|
-
|
|
11012
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "bg-muted/60 mb-3 flex size-10 shrink-0 items-center justify-center rounded-full", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react6.UploadIcon, { className: "text-muted-foreground size-4" }) }),
|
|
11013
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("p", { className: "text-sm font-medium", children: [
|
|
11014
|
+
"Drop ",
|
|
11015
|
+
noun,
|
|
11016
|
+
" here or browse"
|
|
11017
|
+
] }),
|
|
11018
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "text-muted-foreground mt-1 text-xs", children: acceptAnyFile ? "Any file type" : "SVG, PNG, JPG or GIF (max. 10MB)" }),
|
|
10593
11019
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
10594
11020
|
import_button10.Button,
|
|
10595
11021
|
{
|
|
@@ -10602,8 +11028,9 @@ var ImageEditor = ({
|
|
|
10602
11028
|
},
|
|
10603
11029
|
disabled: isBusy,
|
|
10604
11030
|
children: [
|
|
10605
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
10606
|
-
"Select
|
|
11031
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react6.UploadIcon, { className: "-ms-0.5 opacity-60", "aria-hidden": "true" }),
|
|
11032
|
+
"Select ",
|
|
11033
|
+
noun
|
|
10607
11034
|
]
|
|
10608
11035
|
}
|
|
10609
11036
|
)
|
|
@@ -10618,17 +11045,17 @@ var ImageEditor = ({
|
|
|
10618
11045
|
style: overlayMaxHeight > 0 ? { maxHeight: overlayMaxHeight } : void 0,
|
|
10619
11046
|
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { onKeyDown: handleEditorKeyDown, className: "flex min-h-0 flex-1 flex-col", children: [
|
|
10620
11047
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex shrink-0 items-center gap-2 border-b px-6 py-3", children: [
|
|
10621
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
10622
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("h3", { className: "text-sm font-medium", children: imageUrl ?
|
|
11048
|
+
acceptAnyFile ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react6.FileIcon, { className: "text-muted-foreground size-4" }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react6.ImageIcon, { className: "text-muted-foreground size-4" }),
|
|
11049
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("h3", { className: "text-sm font-medium", children: imageUrl ? `Edit ${Noun}` : `Add ${Noun}` })
|
|
10623
11050
|
] }),
|
|
10624
11051
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
10625
11052
|
"input",
|
|
10626
11053
|
{
|
|
10627
11054
|
ref: fileInputRef,
|
|
10628
11055
|
type: "file",
|
|
10629
|
-
accept: "image/*",
|
|
11056
|
+
accept: acceptAnyFile ? void 0 : "image/*",
|
|
10630
11057
|
className: "hidden",
|
|
10631
|
-
"aria-label":
|
|
11058
|
+
"aria-label": `Upload ${noun}`,
|
|
10632
11059
|
tabIndex: -1,
|
|
10633
11060
|
onChange: (e) => {
|
|
10634
11061
|
const files = Array.from(e.target.files || []);
|
|
@@ -10664,7 +11091,7 @@ var ImageEditor = ({
|
|
|
10664
11091
|
}
|
|
10665
11092
|
),
|
|
10666
11093
|
dragErrors.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "text-destructive mt-2 flex items-center gap-1.5 text-xs", role: "alert", children: [
|
|
10667
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
11094
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react6.AlertCircleIcon, { className: "size-3 shrink-0" }),
|
|
10668
11095
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { children: dragErrors[0] })
|
|
10669
11096
|
] }),
|
|
10670
11097
|
!isBusy && (selectedFile || imageMetadata && hasImage) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "text-muted-foreground mt-2 text-center text-xs", children: selectedFile ? /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
|
@@ -10688,7 +11115,7 @@ var ImageEditor = ({
|
|
|
10688
11115
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex shrink-0 justify-end gap-2 border-t px-6 py-3", children: [
|
|
10689
11116
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_button10.Button, { type: "button", variant: "outline", size: "sm", onClick: handleCancel, disabled: isBusy, children: "Cancel" }),
|
|
10690
11117
|
selectedFile && !isBusy ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_button10.Button, { type: "button", size: "sm", onClick: handleConfirmUpload, children: isDraftRow2 ? "Create Row & Upload" : "Upload & Save" }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_button10.Button, { type: "button", size: "sm", onClick: handleSave, disabled: isBusy, children: [
|
|
10691
|
-
isBusy && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
11118
|
+
isBusy && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react6.Loader2, { className: "size-3.5 animate-spin" }),
|
|
10692
11119
|
saveLabel
|
|
10693
11120
|
] })
|
|
10694
11121
|
] })
|
|
@@ -10702,6 +11129,7 @@ var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
|
10702
11129
|
var DRAFT_PREFIX = "draft:";
|
|
10703
11130
|
function ImageEditorDom({
|
|
10704
11131
|
value,
|
|
11132
|
+
cell,
|
|
10705
11133
|
colKey,
|
|
10706
11134
|
rowId,
|
|
10707
11135
|
tableName,
|
|
@@ -10711,6 +11139,8 @@ function ImageEditorDom({
|
|
|
10711
11139
|
onInvalidateData
|
|
10712
11140
|
}) {
|
|
10713
11141
|
const isDraftRow2 = rowId.startsWith(DRAFT_PREFIX);
|
|
11142
|
+
const cellType = cell.meta?.cellType;
|
|
11143
|
+
const acceptAnyFile = cellType != null && cellType !== "image";
|
|
10714
11144
|
const handleSaveComplete = onCommitPatch ? (saveData) => onCommitPatch({ [colKey]: saveData.imageData }) : void 0;
|
|
10715
11145
|
const handleSubmitDraft = isDraftRow2 && onSubmitDraftRow ? async () => {
|
|
10716
11146
|
const createdRow = await onSubmitDraftRow(rowId);
|
|
@@ -10720,6 +11150,7 @@ function ImageEditorDom({
|
|
|
10720
11150
|
ImageEditor,
|
|
10721
11151
|
{
|
|
10722
11152
|
value,
|
|
11153
|
+
acceptAnyFile,
|
|
10723
11154
|
onFinishedEditing: () => onCancel(),
|
|
10724
11155
|
tableName,
|
|
10725
11156
|
fieldName: colKey,
|
|
@@ -10889,7 +11320,7 @@ function InetEditorDom({ value, onCommit, onCancel }) {
|
|
|
10889
11320
|
|
|
10890
11321
|
// src/grid/editors/interval-editor.tsx
|
|
10891
11322
|
var import_react56 = require("react");
|
|
10892
|
-
var
|
|
11323
|
+
var import_lucide_react7 = require("lucide-react");
|
|
10893
11324
|
var import_button12 = require("@constructive-io/ui/button");
|
|
10894
11325
|
var import_input2 = require("@constructive-io/ui/input");
|
|
10895
11326
|
var import_label = require("@constructive-io/ui/label");
|
|
@@ -10965,7 +11396,7 @@ var IntervalEditor = ({ value, onFinishedEditing }) => {
|
|
|
10965
11396
|
const previewText = formatIntervalValue(editingValue);
|
|
10966
11397
|
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(EditorFocusTrap, { onEscape: handleCancel, className: `bg-popover flex ${OVERLAY.sm} flex-col gap-4 rounded-lg border p-4 shadow-lg`, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { onKeyDown: handleEditorKeyDown, children: [
|
|
10967
11398
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
10968
|
-
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
11399
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_lucide_react7.Clock, { className: "text-muted-foreground h-4 w-4" }),
|
|
10969
11400
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("h3", { className: "text-sm font-medium", children: "Edit Time Interval" })
|
|
10970
11401
|
] }),
|
|
10971
11402
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "grid grid-cols-2 gap-3", children: [
|
|
@@ -11039,11 +11470,11 @@ var IntervalEditor = ({ value, onFinishedEditing }) => {
|
|
|
11039
11470
|
] }),
|
|
11040
11471
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "flex justify-end gap-2", children: [
|
|
11041
11472
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_button12.Button, { variant: "outline", size: "sm", onClick: handleCancel, children: [
|
|
11042
|
-
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
11473
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_lucide_react7.X, { className: "mr-1 h-3 w-3" }),
|
|
11043
11474
|
"Cancel"
|
|
11044
11475
|
] }),
|
|
11045
11476
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_button12.Button, { size: "sm", onClick: handleSave, children: [
|
|
11046
|
-
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
11477
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_lucide_react7.Check, { className: "mr-1 h-3 w-3" }),
|
|
11047
11478
|
"Save"
|
|
11048
11479
|
] })
|
|
11049
11480
|
] })
|
|
@@ -11254,7 +11685,7 @@ function parseValue(text) {
|
|
|
11254
11685
|
if (trimmed === "") return null;
|
|
11255
11686
|
return Number(trimmed);
|
|
11256
11687
|
}
|
|
11257
|
-
function NumberEditorDom({ value, initialText, onCommit, onCancel }) {
|
|
11688
|
+
function NumberEditorDom({ value, initialText, colKey, fieldMeta, onCommit, onCancel }) {
|
|
11258
11689
|
const [text, setText] = (0, import_react58.useState)(() => initialText != null ? initialText : seedText2(value));
|
|
11259
11690
|
const escapedRef = (0, import_react58.useRef)(false);
|
|
11260
11691
|
const parsed = parseValue(text);
|
|
@@ -11291,6 +11722,7 @@ function NumberEditorDom({ value, initialText, onCommit, onCancel }) {
|
|
|
11291
11722
|
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
11292
11723
|
"input",
|
|
11293
11724
|
{
|
|
11725
|
+
"aria-label": `Edit ${fieldMeta?.name ?? colKey}`,
|
|
11294
11726
|
value: text,
|
|
11295
11727
|
onChange: (e) => setText(e.target.value),
|
|
11296
11728
|
onKeyDown: handleKeyDown,
|
|
@@ -11310,15 +11742,15 @@ NumberEditorDom.commitsOnBlur = true;
|
|
|
11310
11742
|
|
|
11311
11743
|
// src/grid/editors/relation-editor.tsx
|
|
11312
11744
|
var import_react62 = require("react");
|
|
11313
|
-
var
|
|
11745
|
+
var import_lucide_react8 = require("lucide-react");
|
|
11314
11746
|
var import_react_query8 = require("@tanstack/react-query");
|
|
11315
11747
|
|
|
11316
11748
|
// src/hooks/use-sheets-table-cursor.ts
|
|
11317
11749
|
var import_react59 = require("react");
|
|
11318
11750
|
var import_react_query7 = require("@tanstack/react-query");
|
|
11319
|
-
var
|
|
11320
|
-
var
|
|
11321
|
-
var
|
|
11751
|
+
var import_data21 = require("@constructive-io/data");
|
|
11752
|
+
var import_data22 = require("@constructive-io/data");
|
|
11753
|
+
var import_data23 = require("@constructive-io/data");
|
|
11322
11754
|
function useSheetsTableCursor(tableName, options = {}) {
|
|
11323
11755
|
const queryClient = (0, import_react_query7.useQueryClient)();
|
|
11324
11756
|
const { execute, scopeKey } = useSheetsContext();
|
|
@@ -11326,7 +11758,7 @@ function useSheetsTableCursor(tableName, options = {}) {
|
|
|
11326
11758
|
const adapter = useSheetsAdapter();
|
|
11327
11759
|
const tables = (0, import_react59.useMemo)(() => {
|
|
11328
11760
|
if (!meta?._meta?.tables) return [];
|
|
11329
|
-
return meta._meta.tables.filter((candidate) => candidate != null).map((metaTable) => (0,
|
|
11761
|
+
return meta._meta.tables.filter((candidate) => candidate != null).map((metaTable) => (0, import_data21.cleanTable)(metaTable));
|
|
11330
11762
|
}, [meta]);
|
|
11331
11763
|
const table = (0, import_react59.useMemo)(
|
|
11332
11764
|
() => tables.find((candidate) => candidate.name === tableName) ?? null,
|
|
@@ -11358,7 +11790,7 @@ function useSheetsTableCursor(tableName, options = {}) {
|
|
|
11358
11790
|
queryKey: sheetsQueryKeys.cursorTable(scopeKey, tableName, stableOptions),
|
|
11359
11791
|
queryFn: async ({ pageParam }) => {
|
|
11360
11792
|
if (!table) {
|
|
11361
|
-
throw
|
|
11793
|
+
throw import_data22.createError.notFound(`Table '${tableName}' not found`);
|
|
11362
11794
|
}
|
|
11363
11795
|
const cursor = pageParam;
|
|
11364
11796
|
const variableOptions = {
|
|
@@ -11381,7 +11813,7 @@ function useSheetsTableCursor(tableName, options = {}) {
|
|
|
11381
11813
|
const validatedOrderByEnum = new Set(variables.orderBy ?? []);
|
|
11382
11814
|
const availableOrderByFields = new Set(table.fields.map((field) => field.name));
|
|
11383
11815
|
const validatedOrderBy = orderBy?.filter(
|
|
11384
|
-
({ field, direction }) => availableOrderByFields.has(field) && validatedOrderByEnum.has((0,
|
|
11816
|
+
({ field, direction }) => availableOrderByFields.has(field) && validatedOrderByEnum.has((0, import_data23.toOrderByEnumValue)(field, direction))
|
|
11385
11817
|
);
|
|
11386
11818
|
const res = await adapter.listRows(
|
|
11387
11819
|
{ table, allTables: tables, tableName },
|
|
@@ -11879,7 +12311,7 @@ var RelationEditor = ({
|
|
|
11879
12311
|
className: `bg-popover flex ${OVERLAY.md} flex-col gap-4 rounded-lg border p-4 shadow-lg`,
|
|
11880
12312
|
children: [
|
|
11881
12313
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
11882
|
-
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
12314
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_lucide_react8.Link, { className: "text-muted-foreground h-4 w-4" }),
|
|
11883
12315
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h3", { className: "text-sm font-medium", children: canPersist ? "Edit Relations" : "Related Records" }),
|
|
11884
12316
|
isMulti && editingValue.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_badge2.Badge, { variant: "secondary", size: "sm", className: "ml-auto tabular-nums", children: editingValue.length })
|
|
11885
12317
|
] }),
|
|
@@ -11902,7 +12334,7 @@ var RelationEditor = ({
|
|
|
11902
12334
|
onClick: () => handleRemoveRelation(index),
|
|
11903
12335
|
disabled: !canPersist,
|
|
11904
12336
|
className: "text-muted-foreground hover:text-destructive h-6 w-6 shrink-0 p-0",
|
|
11905
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
12337
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_lucide_react8.X, { className: "h-3 w-3" })
|
|
11906
12338
|
}
|
|
11907
12339
|
)
|
|
11908
12340
|
] }, index);
|
|
@@ -11919,7 +12351,7 @@ var RelationEditor = ({
|
|
|
11919
12351
|
] })
|
|
11920
12352
|
] }),
|
|
11921
12353
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_input_group2.InputGroup, { children: [
|
|
11922
|
-
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_input_group2.InputGroupAddon, { children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
12354
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_input_group2.InputGroupAddon, { children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_lucide_react8.Search, {}) }),
|
|
11923
12355
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
11924
12356
|
import_input_group2.InputGroupInput,
|
|
11925
12357
|
{
|
|
@@ -11964,23 +12396,23 @@ var RelationEditor = ({
|
|
|
11964
12396
|
children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
11965
12397
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(RelationRecordTooltip, { record: row }),
|
|
11966
12398
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "min-w-0 flex-1 truncate text-sm", children: label }),
|
|
11967
|
-
active3 && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
12399
|
+
active3 && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_lucide_react8.Check, { className: "text-primary h-3.5 w-3.5 shrink-0" }),
|
|
11968
12400
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_badge2.Badge, { variant: "outline", className: cn("text-2xs shrink-0", active3 && "border-primary/40 text-primary"), children: String(row?.id ?? "\u2014").slice(0, 8) })
|
|
11969
12401
|
] })
|
|
11970
12402
|
},
|
|
11971
12403
|
id
|
|
11972
12404
|
);
|
|
11973
12405
|
}),
|
|
11974
|
-
hasNextPage && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { ref: sentinelRef, className: "flex justify-center py-2", children: isFetchingNextPage ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
12406
|
+
hasNextPage && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { ref: sentinelRef, className: "flex justify-center py-2", children: isFetchingNextPage ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_lucide_react8.Loader2, { className: "text-muted-foreground h-4 w-4 animate-spin" }) : /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "text-muted-foreground text-xs", children: "Scroll for more" }) })
|
|
11975
12407
|
] }) })
|
|
11976
12408
|
] }),
|
|
11977
12409
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex justify-end gap-2", children: [
|
|
11978
12410
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_button15.Button, { variant: "outline", size: "sm", onClick: handleCancel, disabled: isSaving, children: [
|
|
11979
|
-
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
12411
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_lucide_react8.X, { className: "mr-1 h-3 w-3" }),
|
|
11980
12412
|
canPersist ? "Cancel" : "Close"
|
|
11981
12413
|
] }),
|
|
11982
12414
|
canPersist && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_button15.Button, { size: "sm", onClick: handleSave, disabled: isSaving || isLoading || isManyToMany && isJunctionLoading, children: [
|
|
11983
|
-
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
12415
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_lucide_react8.Check, { className: "mr-1 h-3 w-3" }),
|
|
11984
12416
|
"Save"
|
|
11985
12417
|
] })
|
|
11986
12418
|
] })
|
|
@@ -12043,7 +12475,7 @@ var import_button16 = require("@constructive-io/ui/button");
|
|
|
12043
12475
|
init_overlay_presets();
|
|
12044
12476
|
init_cn();
|
|
12045
12477
|
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
12046
|
-
function TextEditor({ value, initialText, onCommit, onCancel }) {
|
|
12478
|
+
function TextEditor({ value, initialText, colKey, fieldMeta, onCommit, onCancel }) {
|
|
12047
12479
|
const [text, setText] = (0, import_react63.useState)(() => initialText != null ? initialText : String(value ?? ""));
|
|
12048
12480
|
const escapedRef = (0, import_react63.useRef)(false);
|
|
12049
12481
|
function handleKeyDown(e) {
|
|
@@ -12069,6 +12501,7 @@ function TextEditor({ value, initialText, onCommit, onCancel }) {
|
|
|
12069
12501
|
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
12070
12502
|
"input",
|
|
12071
12503
|
{
|
|
12504
|
+
"aria-label": `Edit ${fieldMeta?.name ?? colKey}`,
|
|
12072
12505
|
value: text,
|
|
12073
12506
|
onChange: (e) => setText(e.target.value),
|
|
12074
12507
|
onKeyDown: handleKeyDown,
|
|
@@ -12085,7 +12518,7 @@ TextEditor.commitsOnBlur = true;
|
|
|
12085
12518
|
|
|
12086
12519
|
// src/grid/editors/tsvector-editor.tsx
|
|
12087
12520
|
var import_react64 = require("react");
|
|
12088
|
-
var
|
|
12521
|
+
var import_lucide_react9 = require("lucide-react");
|
|
12089
12522
|
init_cn();
|
|
12090
12523
|
var import_button17 = require("@constructive-io/ui/button");
|
|
12091
12524
|
var import_label3 = require("@constructive-io/ui/label");
|
|
@@ -12119,7 +12552,7 @@ var TsvectorEditor = ({ value, onFinishedEditing }) => {
|
|
|
12119
12552
|
const handleClose = (0, import_react64.useCallback)(() => onFinishedEditing(), [onFinishedEditing]);
|
|
12120
12553
|
return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(EditorFocusTrap, { onEscape: handleClose, className: `bg-popover flex ${OVERLAY.md} flex-col gap-4 rounded-lg border p-4 shadow-lg`, children: [
|
|
12121
12554
|
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
12122
|
-
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
12555
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_lucide_react9.Search, { className: "text-muted-foreground h-4 w-4" }),
|
|
12123
12556
|
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("h3", { className: "text-sm font-medium", children: "View Text Search Vector" })
|
|
12124
12557
|
] }),
|
|
12125
12558
|
parsedTokens.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "space-y-2", children: [
|
|
@@ -12142,14 +12575,14 @@ var TsvectorEditor = ({ value, onFinishedEditing }) => {
|
|
|
12142
12575
|
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "bg-muted/30 max-h-40 overflow-auto rounded-md p-2", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("pre", { className: "m-0 font-mono text-xs break-all whitespace-pre-wrap", children: rawValue }) })
|
|
12143
12576
|
] }),
|
|
12144
12577
|
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "text-muted-foreground flex items-start gap-2 text-xs", children: [
|
|
12145
|
-
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
12578
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_lucide_react9.Info, { className: "mt-0.5 h-3 w-3 flex-shrink-0" }),
|
|
12146
12579
|
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { children: [
|
|
12147
12580
|
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { children: "Values are generated server-side from your full-text configuration." }),
|
|
12148
12581
|
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { className: "mt-1", children: "Weights: A (highest), B, C, D (lowest)." })
|
|
12149
12582
|
] })
|
|
12150
12583
|
] }),
|
|
12151
12584
|
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "flex justify-end gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_button17.Button, { variant: "outline", size: "sm", onClick: handleClose, children: [
|
|
12152
|
-
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
12585
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_lucide_react9.X, { className: "mr-1 h-3 w-3" }),
|
|
12153
12586
|
"Close"
|
|
12154
12587
|
] }) })
|
|
12155
12588
|
] });
|
|
@@ -12163,7 +12596,7 @@ function TsvectorEditorDom({ value, onCancel }) {
|
|
|
12163
12596
|
|
|
12164
12597
|
// src/grid/editors/url-editor.tsx
|
|
12165
12598
|
var import_react65 = require("react");
|
|
12166
|
-
var
|
|
12599
|
+
var import_lucide_react10 = require("lucide-react");
|
|
12167
12600
|
init_cn();
|
|
12168
12601
|
var import_button18 = require("@constructive-io/ui/button");
|
|
12169
12602
|
var import_input3 = require("@constructive-io/ui/input");
|
|
@@ -12236,7 +12669,7 @@ var UrlEditor = ({ value, onFinishedEditing }) => {
|
|
|
12236
12669
|
const displayText = editingValue.trim() ? displayUrl(editingValue.trim()) : "";
|
|
12237
12670
|
return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(EditorFocusTrap, { onEscape: handleCancel, className: `bg-popover flex ${OVERLAY.md} flex-col gap-4 rounded-lg border p-4 shadow-lg`, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { onKeyDown: handleEditorKeyDown, children: [
|
|
12238
12671
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
12239
|
-
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
12672
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_lucide_react10.Link, { className: "text-muted-foreground h-4 w-4" }),
|
|
12240
12673
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("h3", { className: "text-sm font-medium", children: "Edit URL" })
|
|
12241
12674
|
] }),
|
|
12242
12675
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "space-y-2", children: [
|
|
@@ -12258,7 +12691,7 @@ var UrlEditor = ({ value, onFinishedEditing }) => {
|
|
|
12258
12691
|
editingValue.trim() && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "space-y-2", children: [
|
|
12259
12692
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_label4.Label, { className: "text-muted-foreground text-xs", children: "Preview" }),
|
|
12260
12693
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "bg-muted flex items-center gap-2 rounded p-2 text-sm", children: [
|
|
12261
|
-
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
12694
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_lucide_react10.Link, { className: "text-muted-foreground h-3 w-3 flex-shrink-0" }),
|
|
12262
12695
|
isValid ? /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [
|
|
12263
12696
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "text-primary truncate", children: displayText }),
|
|
12264
12697
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
@@ -12269,7 +12702,7 @@ var UrlEditor = ({ value, onFinishedEditing }) => {
|
|
|
12269
12702
|
onClick: handleTestUrl,
|
|
12270
12703
|
className: "text-muted-foreground hover:text-primary h-6 w-6 p-0",
|
|
12271
12704
|
title: "Test URL",
|
|
12272
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
12705
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_lucide_react10.ExternalLink, { className: "h-3 w-3" })
|
|
12273
12706
|
}
|
|
12274
12707
|
)
|
|
12275
12708
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "text-destructive truncate", children: editingValue })
|
|
@@ -12285,11 +12718,11 @@ var UrlEditor = ({ value, onFinishedEditing }) => {
|
|
|
12285
12718
|
] }),
|
|
12286
12719
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex justify-end gap-2", children: [
|
|
12287
12720
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_button18.Button, { variant: "outline", size: "sm", onClick: handleCancel, children: [
|
|
12288
|
-
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
12721
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_lucide_react10.X, { className: "mr-1 h-3 w-3" }),
|
|
12289
12722
|
"Cancel"
|
|
12290
12723
|
] }),
|
|
12291
12724
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_button18.Button, { size: "sm", onClick: handleSave, disabled: !!validationError, children: [
|
|
12292
|
-
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
12725
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_lucide_react10.Check, { className: "mr-1 h-3 w-3" }),
|
|
12293
12726
|
"Save"
|
|
12294
12727
|
] })
|
|
12295
12728
|
] })
|
|
@@ -13055,10 +13488,6 @@ var Sheets = (0, import_react66.forwardRef)(SheetsInnerComponent);
|
|
|
13055
13488
|
var EMPTY_OBJ = {};
|
|
13056
13489
|
var noop = () => {
|
|
13057
13490
|
};
|
|
13058
|
-
function rowIdAt(rows, index) {
|
|
13059
|
-
const id = rows[index]?.id;
|
|
13060
|
-
return id != null ? String(id) : String(index);
|
|
13061
|
-
}
|
|
13062
13491
|
var OVERLAY_MARGIN_PX = 12;
|
|
13063
13492
|
var OVERLAY_MIN_BELOW_PX = 320;
|
|
13064
13493
|
function SheetsDomInner({
|
|
@@ -13120,6 +13549,7 @@ function SheetsDomInner({
|
|
|
13120
13549
|
[columnSizing, resizeColumn]
|
|
13121
13550
|
);
|
|
13122
13551
|
const combinedRows = shell.combinedRows;
|
|
13552
|
+
const getRowId = shell.getRowId;
|
|
13123
13553
|
const selection = s.selection.gridSelection;
|
|
13124
13554
|
const setSelection = s.selection.setGridSelection;
|
|
13125
13555
|
const activeCell = selection?.current?.cell;
|
|
@@ -13127,15 +13557,15 @@ function SheetsDomInner({
|
|
|
13127
13557
|
if (!selection) return EMPTY_OBJ;
|
|
13128
13558
|
const map = {};
|
|
13129
13559
|
for (const index of selection.rows.toArray()) {
|
|
13130
|
-
map[
|
|
13560
|
+
map[getRowId(combinedRows[index], index)] = true;
|
|
13131
13561
|
}
|
|
13132
13562
|
return map;
|
|
13133
|
-
}, [selection, combinedRows]);
|
|
13563
|
+
}, [selection, combinedRows, getRowId]);
|
|
13134
13564
|
const onRowSelectionChange = (0, import_react66.useCallback)(
|
|
13135
13565
|
(updater) => {
|
|
13136
13566
|
const next = (0, import_react_table3.functionalUpdate)(updater, rowSelection);
|
|
13137
13567
|
const indexById = /* @__PURE__ */ new Map();
|
|
13138
|
-
for (let i = 0; i < combinedRows.length; i++) indexById.set(
|
|
13568
|
+
for (let i = 0; i < combinedRows.length; i++) indexById.set(getRowId(combinedRows[i], i), i);
|
|
13139
13569
|
let rows = RangeSet.empty();
|
|
13140
13570
|
let lowest;
|
|
13141
13571
|
for (const id of Object.keys(next)) {
|
|
@@ -13151,7 +13581,7 @@ function SheetsDomInner({
|
|
|
13151
13581
|
}
|
|
13152
13582
|
setSelection({ current: { cell: [0, lowest] }, rows, columns: RangeSet.empty() });
|
|
13153
13583
|
},
|
|
13154
|
-
[rowSelection, combinedRows, setSelection]
|
|
13584
|
+
[rowSelection, combinedRows, getRowId, setSelection]
|
|
13155
13585
|
);
|
|
13156
13586
|
const table = useSheetsTableInstance({
|
|
13157
13587
|
columns,
|
|
@@ -13162,7 +13592,8 @@ function SheetsDomInner({
|
|
|
13162
13592
|
onColumnSizingChange,
|
|
13163
13593
|
// Pinning is shell-derived (frozenCount), never edited from the grid → no writer needed.
|
|
13164
13594
|
onColumnPinningChange: noop,
|
|
13165
|
-
onRowSelectionChange
|
|
13595
|
+
onRowSelectionChange,
|
|
13596
|
+
getRowId
|
|
13166
13597
|
});
|
|
13167
13598
|
const rowCount = combinedRows.length;
|
|
13168
13599
|
const shiftAnchorRef = (0, import_react66.useRef)(null);
|
|
@@ -13477,7 +13908,7 @@ function SheetsDomInner({
|
|
|
13477
13908
|
value: rowValue,
|
|
13478
13909
|
cell: resolution.cell,
|
|
13479
13910
|
colKey: active3.colKey,
|
|
13480
|
-
rowId:
|
|
13911
|
+
rowId: getRowId(combinedRows[active3.rowIndex], active3.rowIndex),
|
|
13481
13912
|
rowIndex: active3.rowIndex,
|
|
13482
13913
|
tableName: props.tableName,
|
|
13483
13914
|
fieldMeta: resolution.fieldMeta,
|
|
@@ -13576,9 +14007,10 @@ function SheetsDomInner({
|
|
|
13576
14007
|
SheetsEmptyState,
|
|
13577
14008
|
{
|
|
13578
14009
|
tableName,
|
|
13579
|
-
|
|
14010
|
+
readOnlyReason: shell.readOnlyReason,
|
|
14011
|
+
onAddRow: shell.canCreate ? () => {
|
|
13580
14012
|
void s.draft.appendRow();
|
|
13581
|
-
}
|
|
14013
|
+
} : void 0
|
|
13582
14014
|
}
|
|
13583
14015
|
);
|
|
13584
14016
|
}
|
|
@@ -13600,7 +14032,9 @@ function SheetsDomInner({
|
|
|
13600
14032
|
gridSelection: s.selection.gridSelection ?? null,
|
|
13601
14033
|
setGridSelection: shell.setGridSelectionForControls,
|
|
13602
14034
|
deleteSelected: s.draft.deleteSelected,
|
|
13603
|
-
onAddRow: handleAddRow,
|
|
14035
|
+
onAddRow: shell.canCreate ? handleAddRow : void 0,
|
|
14036
|
+
canDelete: shell.canDelete,
|
|
14037
|
+
readOnlyReason: shell.readOnlyReason,
|
|
13604
14038
|
onExport: handleExport
|
|
13605
14039
|
}
|
|
13606
14040
|
) }),
|
|
@@ -13683,7 +14117,9 @@ function SheetsDomInner({
|
|
|
13683
14117
|
isEnabled: isCommandEnabled,
|
|
13684
14118
|
onAddRow: handleAddRow,
|
|
13685
14119
|
onDeleteRows: s.draft.deleteSelected,
|
|
13686
|
-
selectedRowCount: selection?.rows.length ?? 0
|
|
14120
|
+
selectedRowCount: selection?.rows.length ?? 0,
|
|
14121
|
+
canAddRows: shell.canCreate,
|
|
14122
|
+
canDeleteRows: shell.canDelete
|
|
13687
14123
|
}
|
|
13688
14124
|
)
|
|
13689
14125
|
] });
|
|
@@ -13712,7 +14148,7 @@ function tokensFromCssVars(el = typeof document !== "undefined" ? document.docum
|
|
|
13712
14148
|
// src/grid/sheets.table-selector.tsx
|
|
13713
14149
|
var import_react68 = require("react");
|
|
13714
14150
|
var import_react69 = require("@remixicon/react");
|
|
13715
|
-
var
|
|
14151
|
+
var import_lucide_react11 = require("lucide-react");
|
|
13716
14152
|
var import_react70 = require("motion/react");
|
|
13717
14153
|
init_cn();
|
|
13718
14154
|
var import_button20 = require("@constructive-io/ui/button");
|
|
@@ -13728,17 +14164,21 @@ var BLUR_HEIGHT_MAX_PX = 140;
|
|
|
13728
14164
|
var TableItem = (0, import_react68.memo)(function TableItem2({ table, activeTable, onTableSelect, itemRef }) {
|
|
13729
14165
|
const isActive = activeTable === table.value;
|
|
13730
14166
|
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
13731
|
-
|
|
14167
|
+
import_button20.Button,
|
|
13732
14168
|
{
|
|
13733
14169
|
ref: isActive ? itemRef : void 0,
|
|
14170
|
+
"aria-pressed": isActive,
|
|
13734
14171
|
"data-testid": "table-item",
|
|
14172
|
+
static: true,
|
|
14173
|
+
size: "sm",
|
|
14174
|
+
type: "button",
|
|
14175
|
+
variant: "ghost",
|
|
13735
14176
|
className: cn(
|
|
13736
|
-
|
|
13737
|
-
duration-200`,
|
|
14177
|
+
"group relative my-1 flex h-8 w-full shrink items-center justify-between rounded-lg px-2 text-left text-xs font-normal transition-colors duration-150",
|
|
13738
14178
|
isActive ? "bg-primary/10 text-foreground ring-primary/30 dark:bg-primary/15 dark:ring-primary/40 ring-1" : "text-muted-foreground hover:text-foreground"
|
|
13739
14179
|
),
|
|
13740
14180
|
onClick: () => onTableSelect(table.value),
|
|
13741
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("
|
|
14181
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "flex min-w-0 flex-1 items-center", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_tooltip.Tooltip, { children: [
|
|
13742
14182
|
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_tooltip.TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "truncate text-xs", children: table.label }) }),
|
|
13743
14183
|
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_tooltip.TooltipContent, { side: "right", align: "start", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "text-xs font-medium", children: table.label }) })
|
|
13744
14184
|
] }) })
|
|
@@ -13941,7 +14381,7 @@ function SheetsTableListByCategory({
|
|
|
13941
14381
|
animate: { rotate: isExpanded ? 90 : 0 },
|
|
13942
14382
|
transition: { type: "spring", stiffness: 400, damping: 25 },
|
|
13943
14383
|
className: "flex shrink-0 items-center justify-center",
|
|
13944
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
14384
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_lucide_react11.ChevronRight, { className: "text-muted-foreground/60 h-3.5 w-3.5" })
|
|
13945
14385
|
}
|
|
13946
14386
|
),
|
|
13947
14387
|
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "text-muted-foreground text-xs font-medium", children: title }),
|
|
@@ -14105,7 +14545,8 @@ function createScalarFieldSpec(metaField, options, uniqueFields, primaryFields)
|
|
|
14105
14545
|
isArray: metaField.type.isArray,
|
|
14106
14546
|
pgAlias: metaField.type.pgAlias,
|
|
14107
14547
|
pgType: metaField.type.pgType,
|
|
14108
|
-
subtype: metaField.type.subtype ?? void 0
|
|
14548
|
+
subtype: metaField.type.subtype ?? void 0,
|
|
14549
|
+
encoding: metaField.type.encoding
|
|
14109
14550
|
});
|
|
14110
14551
|
if (metaField.type.isArray) {
|
|
14111
14552
|
return null;
|
|
@@ -14133,13 +14574,17 @@ function createScalarFieldSpec(metaField, options, uniqueFields, primaryFields)
|
|
|
14133
14574
|
pgAlias: metaField.type.pgAlias ?? void 0,
|
|
14134
14575
|
pgType: metaField.type.pgType ?? void 0,
|
|
14135
14576
|
subtype: metaField.type.subtype ?? void 0,
|
|
14136
|
-
typmod: metaField.type.typmod ?? void 0
|
|
14577
|
+
typmod: metaField.type.typmod ?? void 0,
|
|
14578
|
+
encoding: metaField.type.encoding ?? void 0
|
|
14137
14579
|
},
|
|
14138
14580
|
constraints: {
|
|
14139
14581
|
isUnique: uniqueFields.has(metaField.name) || void 0,
|
|
14140
14582
|
isPrimaryKey: primaryFields.has(metaField.name) || void 0
|
|
14141
14583
|
}
|
|
14142
14584
|
};
|
|
14585
|
+
if (metaField.enumValues?.values?.length) {
|
|
14586
|
+
spec.enumValues = [...metaField.enumValues.values];
|
|
14587
|
+
}
|
|
14143
14588
|
if (maxLength != null) {
|
|
14144
14589
|
spec.maxLength = maxLength;
|
|
14145
14590
|
}
|
|
@@ -14163,6 +14608,7 @@ function createScalarFieldSpec(metaField, options, uniqueFields, primaryFields)
|
|
|
14163
14608
|
return spec;
|
|
14164
14609
|
}
|
|
14165
14610
|
function buildDescription(metaField) {
|
|
14611
|
+
if (metaField.description) return metaField.description;
|
|
14166
14612
|
const details = [];
|
|
14167
14613
|
const { pgAlias, pgType, subtype } = metaField.type;
|
|
14168
14614
|
if (pgAlias && pgAlias !== pgType) {
|
|
@@ -14180,6 +14626,7 @@ function humanize(name) {
|
|
|
14180
14626
|
return name.replace(HUMAN_CASE_REGEX, "$1 $2").replace(/^./, (str) => str.toUpperCase());
|
|
14181
14627
|
}
|
|
14182
14628
|
function isFieldNullable(metaField) {
|
|
14629
|
+
if (metaField.isNotNull === true || metaField.type.isNotNull === true) return false;
|
|
14183
14630
|
const gqlType = metaField.type.gqlType;
|
|
14184
14631
|
if (gqlType.endsWith("!")) return false;
|
|
14185
14632
|
return true;
|
|
@@ -14683,12 +15130,12 @@ function useSheetsLogin() {
|
|
|
14683
15130
|
if (!token) {
|
|
14684
15131
|
throw createInvalidCredentialsError();
|
|
14685
15132
|
}
|
|
14686
|
-
return { token, email: credentials.email };
|
|
15133
|
+
return { token, email: credentials.email, identityKey: signInResult.userId };
|
|
14687
15134
|
},
|
|
14688
|
-
onSuccess: ({ token }) => {
|
|
15135
|
+
onSuccess: ({ token, identityKey }) => {
|
|
14689
15136
|
const databaseId = config.databaseId || "default";
|
|
14690
|
-
setStoredToken(databaseId, token.accessToken, token.expiresAt);
|
|
14691
|
-
storeApi.getState().setAuthenticated(token.accessToken, token.expiresAt);
|
|
15137
|
+
setStoredToken(databaseId, token.accessToken, token.expiresAt, identityKey);
|
|
15138
|
+
storeApi.getState().setAuthenticated(token.accessToken, token.expiresAt, identityKey);
|
|
14692
15139
|
queryClient.invalidateQueries({ queryKey: ["sheets"] });
|
|
14693
15140
|
}
|
|
14694
15141
|
});
|
|
@@ -14733,13 +15180,13 @@ function useSheetsRegister() {
|
|
|
14733
15180
|
);
|
|
14734
15181
|
const signUpResult = result.signUp?.result;
|
|
14735
15182
|
const token = signUpResult ? toAuthToken(signUpResult) : null;
|
|
14736
|
-
return { token, email: formData.email };
|
|
15183
|
+
return { token, email: formData.email, identityKey: signUpResult?.userId ?? null };
|
|
14737
15184
|
},
|
|
14738
|
-
onSuccess: ({ token }) => {
|
|
15185
|
+
onSuccess: ({ token, identityKey }) => {
|
|
14739
15186
|
if (token) {
|
|
14740
15187
|
const databaseId = config.databaseId || "default";
|
|
14741
|
-
setStoredToken(databaseId, token.accessToken, token.expiresAt);
|
|
14742
|
-
storeApi.getState().setAuthenticated(token.accessToken, token.expiresAt);
|
|
15188
|
+
setStoredToken(databaseId, token.accessToken, token.expiresAt, identityKey);
|
|
15189
|
+
storeApi.getState().setAuthenticated(token.accessToken, token.expiresAt, identityKey);
|
|
14743
15190
|
}
|
|
14744
15191
|
queryClient.invalidateQueries({ queryKey: ["sheets"] });
|
|
14745
15192
|
},
|
|
@@ -14861,7 +15308,7 @@ var import_button22 = require("@constructive-io/ui/button");
|
|
|
14861
15308
|
var import_checkbox3 = require("@constructive-io/ui/checkbox");
|
|
14862
15309
|
|
|
14863
15310
|
// src/auth/ui/auth-error-alert.tsx
|
|
14864
|
-
var
|
|
15311
|
+
var import_lucide_react12 = require("lucide-react");
|
|
14865
15312
|
init_cn();
|
|
14866
15313
|
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
14867
15314
|
function AuthErrorAlert({ error, className }) {
|
|
@@ -14888,7 +15335,7 @@ function AuthErrorAlert({ error, className }) {
|
|
|
14888
15335
|
hasError ? "opacity-100" : "opacity-0"
|
|
14889
15336
|
),
|
|
14890
15337
|
children: [
|
|
14891
|
-
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
15338
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_lucide_react12.AlertCircleIcon, { className: "mt-0.5 h-4 w-4 shrink-0" }),
|
|
14892
15339
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "text-pretty leading-snug", children: error })
|
|
14893
15340
|
]
|
|
14894
15341
|
}
|
|
@@ -14898,7 +15345,7 @@ function AuthErrorAlert({ error, className }) {
|
|
|
14898
15345
|
}
|
|
14899
15346
|
|
|
14900
15347
|
// src/auth/ui/auth-loading-button.tsx
|
|
14901
|
-
var
|
|
15348
|
+
var import_lucide_react13 = require("lucide-react");
|
|
14902
15349
|
init_cn();
|
|
14903
15350
|
var import_button21 = require("@constructive-io/ui/button");
|
|
14904
15351
|
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
@@ -14911,7 +15358,7 @@ function AuthLoadingButton({
|
|
|
14911
15358
|
...props
|
|
14912
15359
|
}) {
|
|
14913
15360
|
return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_button21.Button, { disabled: disabled || isLoading, className: cn("relative", className), ...props, children: [
|
|
14914
|
-
isLoading && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
15361
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_lucide_react13.LoaderIcon, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
14915
15362
|
isLoading ? loadingText : children
|
|
14916
15363
|
] });
|
|
14917
15364
|
}
|
|
@@ -15237,7 +15684,7 @@ function SheetsRegisterForm({ onRegister, onShowLogin, defaultEmail = "" }) {
|
|
|
15237
15684
|
// src/auth/ui/forgot-password-form.tsx
|
|
15238
15685
|
var import_react73 = require("react");
|
|
15239
15686
|
var import_react_form3 = require("@tanstack/react-form");
|
|
15240
|
-
var
|
|
15687
|
+
var import_lucide_react14 = require("lucide-react");
|
|
15241
15688
|
var import_button24 = require("@constructive-io/ui/button");
|
|
15242
15689
|
|
|
15243
15690
|
// src/auth/ui/auth-screen-header.tsx
|
|
@@ -15302,7 +15749,7 @@ function SheetsForgotPasswordForm({ onForgotPassword, onShowLogin }) {
|
|
|
15302
15749
|
});
|
|
15303
15750
|
if (isSuccess) {
|
|
15304
15751
|
return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: "space-y-5 text-center", children: [
|
|
15305
|
-
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "bg-success/10 flex h-12 w-12 items-center justify-center rounded-full", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
15752
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "bg-success/10 flex h-12 w-12 items-center justify-center rounded-full", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_lucide_react14.CheckCircleIcon, { className: "text-success h-6 w-6" }) }) }),
|
|
15306
15753
|
/* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: "space-y-1.5", children: [
|
|
15307
15754
|
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("h3", { className: "text-lg font-semibold", children: "Check your email" }),
|
|
15308
15755
|
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("p", { className: "text-muted-foreground text-sm", children: "We've sent a password reset link to your email address." })
|
|
@@ -15379,7 +15826,7 @@ function SheetsForgotPasswordForm({ onForgotPassword, onShowLogin }) {
|
|
|
15379
15826
|
// src/auth/ui/reset-password-form.tsx
|
|
15380
15827
|
var React18 = __toESM(require("react"), 1);
|
|
15381
15828
|
var import_react_form4 = require("@tanstack/react-form");
|
|
15382
|
-
var
|
|
15829
|
+
var import_lucide_react15 = require("lucide-react");
|
|
15383
15830
|
var import_button25 = require("@constructive-io/ui/button");
|
|
15384
15831
|
|
|
15385
15832
|
// src/auth/utils/validators.ts
|
|
@@ -15478,7 +15925,7 @@ function SheetsResetPasswordForm({
|
|
|
15478
15925
|
});
|
|
15479
15926
|
if (isSuccess) {
|
|
15480
15927
|
return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("div", { className: "space-y-5 text-center", children: [
|
|
15481
|
-
/* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "bg-success/10 flex h-12 w-12 items-center justify-center rounded-full", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
|
|
15928
|
+
/* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "bg-success/10 flex h-12 w-12 items-center justify-center rounded-full", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_lucide_react15.CheckCircleIcon, { className: "text-success h-6 w-6" }) }) }),
|
|
15482
15929
|
/* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("div", { className: "space-y-1.5", children: [
|
|
15483
15930
|
/* @__PURE__ */ (0, import_jsx_runtime62.jsx)("h3", { className: "text-lg font-semibold", children: "Password reset successful" }),
|
|
15484
15931
|
/* @__PURE__ */ (0, import_jsx_runtime62.jsx)("p", { className: "text-muted-foreground text-sm", children: "Your password has been reset successfully. You can now sign in with your new password." })
|