@constructive-io/sheets 0.3.0 → 0.4.1
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/dist/advanced.cjs +449 -109
- package/dist/advanced.cjs.map +1 -1
- package/dist/advanced.js +3 -3
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.js +2 -2
- package/dist/{chunk-FNVHSOQQ.js → chunk-3BNOZQIJ.js} +2 -2
- package/dist/{chunk-ODUBS2NL.js → chunk-BWJVRYJT.js} +3 -3
- package/dist/{chunk-TU7ATZ4X.js → chunk-BWKB52JB.js} +73 -34
- package/dist/chunk-BWKB52JB.js.map +1 -0
- package/dist/{chunk-4PGPVMZB.js → chunk-FG2LRZP5.js} +1 -1
- package/dist/chunk-FG2LRZP5.js.map +1 -0
- package/dist/chunk-SDKHWE7G.js +469 -0
- package/dist/chunk-SDKHWE7G.js.map +1 -0
- package/dist/index.cjs +630 -254
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -3
- package/dist/index.d.ts +40 -3
- package/dist/index.js +66 -34
- package/dist/index.js.map +1 -1
- package/dist/{sheets-context-Da55TTR9.d.ts → sheets-context-9u9r7Bs0.d.ts} +23 -0
- package/dist/{sheets-context-CojEFlaY.d.cts → sheets-context-BjGIHocT.d.cts} +23 -0
- package/dist/testing.cjs +391 -89
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +3 -3
- package/package.json +3 -3
- package/dist/chunk-4PGPVMZB.js.map +0 -1
- package/dist/chunk-H4JJTMP5.js +0 -160
- package/dist/chunk-H4JJTMP5.js.map +0 -1
- package/dist/chunk-TU7ATZ4X.js.map +0 -1
- /package/dist/{chunk-FNVHSOQQ.js.map → chunk-3BNOZQIJ.js.map} +0 -0
- /package/dist/{chunk-ODUBS2NL.js.map → chunk-BWJVRYJT.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -611,7 +611,7 @@ __export(map_picker_exports, {
|
|
|
611
611
|
MapPicker: () => MapPicker
|
|
612
612
|
});
|
|
613
613
|
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)(
|
|
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)(import_lucide_react4.Loader2, { className: "h-6 w-6 animate-spin text-muted-foreground" }) });
|
|
615
615
|
}
|
|
616
616
|
function MapPicker({
|
|
617
617
|
value,
|
|
@@ -689,7 +689,7 @@ function MapPicker({
|
|
|
689
689
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: cn("relative w-full", className), children: [
|
|
690
690
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "relative mb-2", children: [
|
|
691
691
|
/* @__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)(
|
|
692
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_input_group.InputGroupAddon, { children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react4.SearchIcon, {}) }),
|
|
693
693
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
694
694
|
import_input_group.InputGroupInput,
|
|
695
695
|
{
|
|
@@ -710,7 +710,7 @@ function MapPicker({
|
|
|
710
710
|
onClick: clearSearch,
|
|
711
711
|
disabled,
|
|
712
712
|
className: "h-7 w-7 p-0",
|
|
713
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
713
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react4.XIcon, { className: "h-3 w-3" })
|
|
714
714
|
}
|
|
715
715
|
),
|
|
716
716
|
position && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
@@ -722,7 +722,7 @@ function MapPicker({
|
|
|
722
722
|
onClick: clearLocation,
|
|
723
723
|
disabled,
|
|
724
724
|
className: "h-7 w-7 p-0",
|
|
725
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
725
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react4.MapPinIcon, { className: "h-3 w-3" })
|
|
726
726
|
}
|
|
727
727
|
)
|
|
728
728
|
] })
|
|
@@ -753,7 +753,7 @@ function MapPicker({
|
|
|
753
753
|
}
|
|
754
754
|
) }) }) }),
|
|
755
755
|
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)(
|
|
756
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_lucide_react4.MapPinIcon, { className: "h-3 w-3" }),
|
|
757
757
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("span", { children: [
|
|
758
758
|
"Latitude: ",
|
|
759
759
|
position[0].toFixed(6),
|
|
@@ -763,13 +763,13 @@ function MapPicker({
|
|
|
763
763
|
] }) })
|
|
764
764
|
] });
|
|
765
765
|
}
|
|
766
|
-
var import_react46,
|
|
766
|
+
var import_react46, import_lucide_react4, import_button8, import_card, import_input_group, import_jsx_runtime31, createMapValue, extractPosition, searchLocation, LeafletMapInner;
|
|
767
767
|
var init_map_picker = __esm({
|
|
768
768
|
"src/utils/map-picker.tsx"() {
|
|
769
769
|
"use strict";
|
|
770
770
|
"use client";
|
|
771
771
|
import_react46 = __toESM(require("react"), 1);
|
|
772
|
-
|
|
772
|
+
import_lucide_react4 = require("lucide-react");
|
|
773
773
|
init_cn();
|
|
774
774
|
init_sheets_logger();
|
|
775
775
|
import_button8 = require("@constructive-io/ui/button");
|
|
@@ -903,7 +903,7 @@ __export(src_exports, {
|
|
|
903
903
|
BUILTIN_EDITOR_TYPES: () => BUILTIN_EDITOR_TYPES,
|
|
904
904
|
CellRegistry: () => CellRegistry,
|
|
905
905
|
DATE_TIME_TYPES: () => DATE_TIME_TYPES,
|
|
906
|
-
DataError: () =>
|
|
906
|
+
DataError: () => import_data3.DataError,
|
|
907
907
|
DockStatusBar: () => DockStatusBar,
|
|
908
908
|
DockStatusBarCompact: () => DockStatusBarCompact,
|
|
909
909
|
ENHANCED_TYPES: () => ENHANCED_TYPES,
|
|
@@ -961,6 +961,7 @@ __export(src_exports, {
|
|
|
961
961
|
moveActive: () => moveActive,
|
|
962
962
|
queryKeys: () => sheetsTableQueryKeys,
|
|
963
963
|
resolveCellType: () => resolveCellType,
|
|
964
|
+
resolveDownloadUrl: () => resolveDownloadUrl,
|
|
964
965
|
selectCell: () => selectCell,
|
|
965
966
|
selectRange: () => selectRange,
|
|
966
967
|
selectRow: () => selectRow,
|
|
@@ -1010,17 +1011,351 @@ function useSheetsContext() {
|
|
|
1010
1011
|
}
|
|
1011
1012
|
|
|
1012
1013
|
// src/context/sheets-execute.ts
|
|
1014
|
+
var import_graphql2 = require("graphql");
|
|
1015
|
+
var import_data2 = require("@constructive-io/data");
|
|
1016
|
+
|
|
1017
|
+
// src/context/sheets-upload-presigned.ts
|
|
1013
1018
|
var import_graphql = require("graphql");
|
|
1014
1019
|
var import_data = require("@constructive-io/data");
|
|
1015
|
-
|
|
1020
|
+
async function sha256HexFromBuffer(buffer) {
|
|
1021
|
+
if (!globalThis.crypto?.subtle) {
|
|
1022
|
+
throw import_data.createError.badRequest("Web Crypto (crypto.subtle) is unavailable; cannot hash file for upload.");
|
|
1023
|
+
}
|
|
1024
|
+
const digest = await crypto.subtle.digest("SHA-256", buffer);
|
|
1025
|
+
const bytes = new Uint8Array(digest);
|
|
1026
|
+
let hex = "";
|
|
1027
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
1028
|
+
hex += bytes[i].toString(16).padStart(2, "0");
|
|
1029
|
+
}
|
|
1030
|
+
return hex;
|
|
1031
|
+
}
|
|
1032
|
+
var capabilityCache = /* @__PURE__ */ new Map();
|
|
1033
|
+
function discoverUploadCapability(endpoint, execute) {
|
|
1034
|
+
const cached = capabilityCache.get(endpoint);
|
|
1035
|
+
if (cached) return cached;
|
|
1036
|
+
const promise = (async () => {
|
|
1037
|
+
const data = await execute((0, import_graphql.getIntrospectionQuery)());
|
|
1038
|
+
const schema = data?.__schema;
|
|
1039
|
+
if (!schema) {
|
|
1040
|
+
throw import_data.createError.badRequest("Uploads are not enabled for this endpoint.");
|
|
1041
|
+
}
|
|
1042
|
+
return resolveUploadCapability(schema);
|
|
1043
|
+
})();
|
|
1044
|
+
promise.catch(() => capabilityCache.delete(endpoint));
|
|
1045
|
+
capabilityCache.set(endpoint, promise);
|
|
1046
|
+
return promise;
|
|
1047
|
+
}
|
|
1048
|
+
function namedTypeName(ref) {
|
|
1049
|
+
let cur = ref;
|
|
1050
|
+
while (cur && (cur.kind === "NON_NULL" || cur.kind === "LIST")) {
|
|
1051
|
+
cur = cur.ofType ?? null;
|
|
1052
|
+
}
|
|
1053
|
+
return cur?.name ?? null;
|
|
1054
|
+
}
|
|
1055
|
+
function isListTypeRef(ref) {
|
|
1056
|
+
let cur = ref;
|
|
1057
|
+
while (cur && cur.kind === "NON_NULL") {
|
|
1058
|
+
cur = cur.ofType ?? null;
|
|
1059
|
+
}
|
|
1060
|
+
return cur?.kind === "LIST";
|
|
1061
|
+
}
|
|
1062
|
+
var PK_FIELD_NAME = "id";
|
|
1063
|
+
function resolveUploadCapability(schema) {
|
|
1064
|
+
const typeByName = /* @__PURE__ */ new Map();
|
|
1065
|
+
for (const t of schema.types) {
|
|
1066
|
+
if (t.name) typeByName.set(t.name, t);
|
|
1067
|
+
}
|
|
1068
|
+
const objectHasFields = (typeName, names) => {
|
|
1069
|
+
if (!typeName) return false;
|
|
1070
|
+
const t = typeByName.get(typeName);
|
|
1071
|
+
if (!t?.fields) return false;
|
|
1072
|
+
const present = new Set(t.fields.map((f) => f.name));
|
|
1073
|
+
return names.every((n) => present.has(n));
|
|
1074
|
+
};
|
|
1075
|
+
const inputHasFields = (typeName, names) => {
|
|
1076
|
+
if (!typeName) return false;
|
|
1077
|
+
const t = typeByName.get(typeName);
|
|
1078
|
+
if (!t?.inputFields) return false;
|
|
1079
|
+
const present = new Set(t.inputFields.map((f) => f.name));
|
|
1080
|
+
return names.every((n) => present.has(n));
|
|
1081
|
+
};
|
|
1082
|
+
const PAYLOAD_FIELDS = ["uploadUrl", "fileId", "deduplicated"];
|
|
1083
|
+
const INPUT_FIELDS = ["contentHash", "bucketKey", "contentType", "size"];
|
|
1084
|
+
const mutationType = schema.mutationType ? typeByName.get(schema.mutationType.name) : null;
|
|
1085
|
+
const queryType = schema.queryType ? typeByName.get(schema.queryType.name) : null;
|
|
1086
|
+
let upload = null;
|
|
1087
|
+
for (const field of mutationType?.fields ?? []) {
|
|
1088
|
+
const inputArg = field.args.find((a) => a.name === "input");
|
|
1089
|
+
if (!inputArg) continue;
|
|
1090
|
+
const inputTypeName = namedTypeName(inputArg.type);
|
|
1091
|
+
const payloadTypeName = namedTypeName(field.type);
|
|
1092
|
+
if (inputHasFields(inputTypeName, INPUT_FIELDS) && objectHasFields(payloadTypeName, PAYLOAD_FIELDS)) {
|
|
1093
|
+
upload = { uploadFieldName: field.name, inputTypeName };
|
|
1094
|
+
break;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
if (!upload) {
|
|
1098
|
+
throw import_data.createError.badRequest("Uploads are not enabled for this endpoint.");
|
|
1099
|
+
}
|
|
1100
|
+
const downloadById = resolveDownloadByIdField(schema, typeByName, queryType, upload.uploadFieldName);
|
|
1101
|
+
return {
|
|
1102
|
+
...upload,
|
|
1103
|
+
...downloadById
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
function resolveDownloadByIdField(schema, typeByName, queryType, uploadFieldName) {
|
|
1107
|
+
const fileTypesWithDownloadUrl = /* @__PURE__ */ new Set();
|
|
1108
|
+
for (const t of schema.types) {
|
|
1109
|
+
if (t.kind === "OBJECT" && t.name && t.fields?.some((f) => f.name === "downloadUrl")) {
|
|
1110
|
+
fileTypesWithDownloadUrl.add(t.name);
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
for (const field of queryType?.fields ?? []) {
|
|
1114
|
+
const returnTypeName = namedTypeName(field.type);
|
|
1115
|
+
if (!returnTypeName || !fileTypesWithDownloadUrl.has(returnTypeName)) continue;
|
|
1116
|
+
if (field.args.length === 1 && field.args[0].name === PK_FIELD_NAME) {
|
|
1117
|
+
return {
|
|
1118
|
+
fileByIdField: field.name,
|
|
1119
|
+
fileByIdArgName: "id",
|
|
1120
|
+
fileTypeName: returnTypeName,
|
|
1121
|
+
idScalarName: namedTypeName(field.args[0].type) ?? void 0
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
const connection = resolveConnectionDownloadField(typeByName, queryType, fileTypesWithDownloadUrl, uploadFieldName);
|
|
1126
|
+
if (connection) return connection;
|
|
1127
|
+
const nodeField = queryType?.fields?.find(
|
|
1128
|
+
(f) => f.name === "node" && f.args.some((a) => a.name === "nodeId")
|
|
1129
|
+
);
|
|
1130
|
+
if (nodeField && fileTypesWithDownloadUrl.size > 0) {
|
|
1131
|
+
const preferred = uploadFieldName.replace(/^upload/, "");
|
|
1132
|
+
const fileTypeName = fileTypesWithDownloadUrl.has(preferred) ? preferred : [...fileTypesWithDownloadUrl][0];
|
|
1133
|
+
return { fileByIdField: "node", fileByIdArgName: "nodeId", fileTypeName };
|
|
1134
|
+
}
|
|
1135
|
+
throw import_data.createError.badRequest("Uploads are not enabled for this endpoint.");
|
|
1136
|
+
}
|
|
1137
|
+
function resolveConnectionDownloadField(typeByName, queryType, fileTypesWithDownloadUrl, uploadFieldName) {
|
|
1138
|
+
const EQUALITY_OPERATORS = ["equalTo", "eq"];
|
|
1139
|
+
const candidates = [];
|
|
1140
|
+
for (const field of queryType?.fields ?? []) {
|
|
1141
|
+
const connTypeName = namedTypeName(field.type);
|
|
1142
|
+
if (!connTypeName) continue;
|
|
1143
|
+
const connType = typeByName.get(connTypeName);
|
|
1144
|
+
if (connType?.kind !== "OBJECT" || !connType.fields) continue;
|
|
1145
|
+
const nodesField = connType.fields.find((f) => {
|
|
1146
|
+
if (!isListTypeRef(f.type)) return false;
|
|
1147
|
+
const elem = namedTypeName(f.type);
|
|
1148
|
+
return elem != null && fileTypesWithDownloadUrl.has(elem);
|
|
1149
|
+
});
|
|
1150
|
+
if (!nodesField) continue;
|
|
1151
|
+
const fileTypeName = namedTypeName(nodesField.type);
|
|
1152
|
+
for (const arg of field.args) {
|
|
1153
|
+
const filterTypeName = namedTypeName(arg.type);
|
|
1154
|
+
const filterType = filterTypeName ? typeByName.get(filterTypeName) : null;
|
|
1155
|
+
if (filterType?.kind !== "INPUT_OBJECT" || !filterType.inputFields) continue;
|
|
1156
|
+
const idField = filterType.inputFields.find((f) => f.name === PK_FIELD_NAME);
|
|
1157
|
+
if (!idField) continue;
|
|
1158
|
+
const idFieldTypeName = namedTypeName(idField.type);
|
|
1159
|
+
const idFieldType = idFieldTypeName ? typeByName.get(idFieldTypeName) : null;
|
|
1160
|
+
if (idFieldType?.kind === "INPUT_OBJECT" && idFieldType.inputFields) {
|
|
1161
|
+
const opField = EQUALITY_OPERATORS.map(
|
|
1162
|
+
(op) => idFieldType.inputFields.find((f) => f.name === op)
|
|
1163
|
+
).find((f) => f != null);
|
|
1164
|
+
if (opField) {
|
|
1165
|
+
candidates.push({
|
|
1166
|
+
fileByIdField: field.name,
|
|
1167
|
+
fileByIdArgName: "connection",
|
|
1168
|
+
fileTypeName,
|
|
1169
|
+
idScalarName: namedTypeName(opField.type) ?? void 0,
|
|
1170
|
+
connectionFilterArgName: arg.name,
|
|
1171
|
+
connectionIdField: idField.name,
|
|
1172
|
+
connectionIdOperator: opField.name,
|
|
1173
|
+
connectionNodesField: nodesField.name
|
|
1174
|
+
});
|
|
1175
|
+
break;
|
|
1176
|
+
}
|
|
1177
|
+
continue;
|
|
1178
|
+
}
|
|
1179
|
+
if (idFieldType?.kind === "SCALAR" || !idFieldType && idFieldTypeName) {
|
|
1180
|
+
candidates.push({
|
|
1181
|
+
fileByIdField: field.name,
|
|
1182
|
+
fileByIdArgName: "connection",
|
|
1183
|
+
fileTypeName,
|
|
1184
|
+
idScalarName: idFieldTypeName ?? void 0,
|
|
1185
|
+
connectionFilterArgName: arg.name,
|
|
1186
|
+
connectionIdField: idField.name,
|
|
1187
|
+
connectionNodesField: nodesField.name
|
|
1188
|
+
});
|
|
1189
|
+
break;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
if (candidates.length === 0) return null;
|
|
1194
|
+
const preferred = uploadFieldName.replace(/^upload/, "");
|
|
1195
|
+
return candidates.find((c) => c.fileTypeName === preferred) ?? candidates[0];
|
|
1196
|
+
}
|
|
1197
|
+
async function callUploadOp(execute, cap, input) {
|
|
1198
|
+
const mutation = `
|
|
1199
|
+
mutation SheetsUpload($input: ${cap.inputTypeName}!) {
|
|
1200
|
+
${cap.uploadFieldName}(input: $input) {
|
|
1201
|
+
uploadUrl
|
|
1202
|
+
fileId
|
|
1203
|
+
key
|
|
1204
|
+
deduplicated
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
`.trim();
|
|
1208
|
+
const data = await execute(mutation, {
|
|
1209
|
+
input: {
|
|
1210
|
+
bucketKey: input.bucketKey,
|
|
1211
|
+
contentHash: input.contentHash,
|
|
1212
|
+
contentType: input.contentType,
|
|
1213
|
+
size: input.size,
|
|
1214
|
+
filename: input.filename
|
|
1215
|
+
}
|
|
1216
|
+
});
|
|
1217
|
+
const payload = data?.[cap.uploadFieldName];
|
|
1218
|
+
if (!payload) {
|
|
1219
|
+
throw import_data.createError.badRequest("Upload failed: no payload returned from upload mutation.");
|
|
1220
|
+
}
|
|
1221
|
+
return payload;
|
|
1222
|
+
}
|
|
1223
|
+
async function presignedPut(url, buffer, contentType, onProgress) {
|
|
1224
|
+
const total = buffer.byteLength;
|
|
1225
|
+
if (onProgress && typeof XMLHttpRequest !== "undefined") {
|
|
1226
|
+
await putWithXHR(url, buffer, contentType, total, onProgress);
|
|
1227
|
+
return;
|
|
1228
|
+
}
|
|
1229
|
+
let response;
|
|
1230
|
+
try {
|
|
1231
|
+
response = await fetch(url, {
|
|
1232
|
+
method: "PUT",
|
|
1233
|
+
headers: { "Content-Type": contentType },
|
|
1234
|
+
body: buffer
|
|
1235
|
+
});
|
|
1236
|
+
} catch (error) {
|
|
1237
|
+
throw import_data.createError.network(error instanceof Error ? error : void 0);
|
|
1238
|
+
}
|
|
1239
|
+
if (!response.ok) {
|
|
1240
|
+
const body = await response.text().catch(() => "");
|
|
1241
|
+
throw import_data.createError.badRequest(`Upload failed: ${response.status} ${response.statusText}${body ? ` \u2014 ${body}` : ""}`);
|
|
1242
|
+
}
|
|
1243
|
+
onProgress?.({ loaded: total, total, percentage: 100 });
|
|
1244
|
+
}
|
|
1245
|
+
function putWithXHR(url, buffer, contentType, total, onProgress) {
|
|
1246
|
+
return new Promise((resolve, reject) => {
|
|
1247
|
+
const xhr = new XMLHttpRequest();
|
|
1248
|
+
xhr.open("PUT", url);
|
|
1249
|
+
xhr.setRequestHeader("Content-Type", contentType);
|
|
1250
|
+
xhr.upload.addEventListener("progress", (event) => {
|
|
1251
|
+
if (event.lengthComputable) {
|
|
1252
|
+
onProgress({
|
|
1253
|
+
loaded: event.loaded,
|
|
1254
|
+
total: event.total,
|
|
1255
|
+
percentage: Math.round(event.loaded / event.total * 100)
|
|
1256
|
+
});
|
|
1257
|
+
}
|
|
1258
|
+
});
|
|
1259
|
+
xhr.addEventListener("load", () => {
|
|
1260
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
1261
|
+
onProgress({ loaded: total, total, percentage: 100 });
|
|
1262
|
+
resolve();
|
|
1263
|
+
} else {
|
|
1264
|
+
reject(import_data.createError.badRequest(`Upload failed: ${xhr.status} ${xhr.statusText}${xhr.responseText ? ` \u2014 ${xhr.responseText}` : ""}`));
|
|
1265
|
+
}
|
|
1266
|
+
});
|
|
1267
|
+
xhr.addEventListener("error", () => reject(import_data.createError.network()));
|
|
1268
|
+
xhr.send(buffer);
|
|
1269
|
+
});
|
|
1270
|
+
}
|
|
1271
|
+
function toGlobalId(typeName, id) {
|
|
1272
|
+
if (typeof btoa !== "function") {
|
|
1273
|
+
throw import_data.createError.badRequest("Cannot encode the file node id: btoa is unavailable in this environment.");
|
|
1274
|
+
}
|
|
1275
|
+
return btoa(JSON.stringify([typeName, id]));
|
|
1276
|
+
}
|
|
1277
|
+
async function fetchDownloadUrl(execute, cap, fileId) {
|
|
1278
|
+
if (cap.fileByIdArgName === "nodeId") {
|
|
1279
|
+
const nodeId = toGlobalId(cap.fileTypeName, fileId);
|
|
1280
|
+
const query2 = `
|
|
1281
|
+
query SheetsDownloadUrl($nodeId: ID!) {
|
|
1282
|
+
${cap.fileByIdField}(nodeId: $nodeId) {
|
|
1283
|
+
... on ${cap.fileTypeName} {
|
|
1284
|
+
downloadUrl
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
`.trim();
|
|
1289
|
+
const data2 = await execute(query2, { nodeId });
|
|
1290
|
+
const node = data2?.[cap.fileByIdField];
|
|
1291
|
+
const url2 = node?.downloadUrl;
|
|
1292
|
+
if (!url2) {
|
|
1293
|
+
throw import_data.createError.badRequest("Upload succeeded but no downloadUrl was returned for the file.");
|
|
1294
|
+
}
|
|
1295
|
+
return url2;
|
|
1296
|
+
}
|
|
1297
|
+
if (cap.fileByIdArgName === "connection") {
|
|
1298
|
+
const idScalar2 = cap.idScalarName ?? "ID";
|
|
1299
|
+
const filterArg = cap.connectionFilterArgName;
|
|
1300
|
+
const idField = cap.connectionIdField;
|
|
1301
|
+
const nodesField = cap.connectionNodesField;
|
|
1302
|
+
const filterLiteral = cap.connectionIdOperator ? `{ ${idField}: { ${cap.connectionIdOperator}: $id } }` : `{ ${idField}: $id }`;
|
|
1303
|
+
const query2 = `
|
|
1304
|
+
query SheetsDownloadUrl($id: ${idScalar2}!) {
|
|
1305
|
+
${cap.fileByIdField}(${filterArg}: ${filterLiteral}, first: 1) {
|
|
1306
|
+
${nodesField} {
|
|
1307
|
+
downloadUrl
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
`.trim();
|
|
1312
|
+
const data2 = await execute(
|
|
1313
|
+
query2,
|
|
1314
|
+
{ id: fileId }
|
|
1315
|
+
);
|
|
1316
|
+
const conn = data2?.[cap.fileByIdField];
|
|
1317
|
+
const url2 = conn?.[nodesField]?.[0]?.downloadUrl;
|
|
1318
|
+
if (!url2) {
|
|
1319
|
+
throw import_data.createError.badRequest("Upload succeeded but no downloadUrl was returned for the file.");
|
|
1320
|
+
}
|
|
1321
|
+
return url2;
|
|
1322
|
+
}
|
|
1323
|
+
const idScalar = cap.idScalarName ?? "ID";
|
|
1324
|
+
const query = `
|
|
1325
|
+
query SheetsDownloadUrl($id: ${idScalar}!) {
|
|
1326
|
+
${cap.fileByIdField}(id: $id) {
|
|
1327
|
+
id
|
|
1328
|
+
downloadUrl
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
`.trim();
|
|
1332
|
+
const data = await execute(query, { id: fileId });
|
|
1333
|
+
const file = data?.[cap.fileByIdField];
|
|
1334
|
+
const url = file?.downloadUrl;
|
|
1335
|
+
if (!url) {
|
|
1336
|
+
throw import_data.createError.badRequest("Upload succeeded but no downloadUrl was returned for the file.");
|
|
1337
|
+
}
|
|
1338
|
+
return url;
|
|
1339
|
+
}
|
|
1340
|
+
async function resolveDownloadUrl(execute, endpoint, fileId) {
|
|
1341
|
+
try {
|
|
1342
|
+
const cap = await discoverUploadCapability(endpoint, execute);
|
|
1343
|
+
return await fetchDownloadUrl(execute, cap, fileId);
|
|
1344
|
+
} catch {
|
|
1345
|
+
return null;
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
// src/context/sheets-execute.ts
|
|
1350
|
+
var import_data3 = require("@constructive-io/data");
|
|
1016
1351
|
function documentToString(document2) {
|
|
1017
1352
|
if (typeof document2 === "string") return document2;
|
|
1018
1353
|
if (document2 instanceof String) return document2.toString();
|
|
1019
1354
|
if (document2 && typeof document2 === "object" && "kind" in document2) {
|
|
1020
|
-
return (0,
|
|
1355
|
+
return (0, import_graphql2.print)(document2);
|
|
1021
1356
|
}
|
|
1022
1357
|
if (document2 === null || document2 === void 0) {
|
|
1023
|
-
throw
|
|
1358
|
+
throw import_data2.createError.badRequest("Invalid GraphQL document: null or undefined");
|
|
1024
1359
|
}
|
|
1025
1360
|
return String(document2);
|
|
1026
1361
|
}
|
|
@@ -1035,18 +1370,18 @@ function parseGraphQLResponse(response, onAuthError) {
|
|
|
1035
1370
|
const message = error.message || "GraphQL query failed";
|
|
1036
1371
|
if (code === "UNAUTHENTICATED" || hasAuthMessage(message)) {
|
|
1037
1372
|
onAuthError?.();
|
|
1038
|
-
return
|
|
1373
|
+
return import_data2.createError.unauthorized("Authentication required. Please log in again.");
|
|
1039
1374
|
}
|
|
1040
1375
|
if (code === "FORBIDDEN") {
|
|
1041
|
-
return
|
|
1376
|
+
return import_data2.createError.forbidden("You do not have permission to perform this action.");
|
|
1042
1377
|
}
|
|
1043
|
-
return
|
|
1378
|
+
return import_data2.createError.graphql(message, code);
|
|
1044
1379
|
}
|
|
1045
1380
|
function createSheetsExecute(config, getToken) {
|
|
1046
1381
|
return async (document2, variables) => {
|
|
1047
1382
|
const url = config.endpoint;
|
|
1048
1383
|
if (!url) {
|
|
1049
|
-
throw
|
|
1384
|
+
throw import_data2.createError.badRequest("No GraphQL endpoint configured.");
|
|
1050
1385
|
}
|
|
1051
1386
|
const token = getToken();
|
|
1052
1387
|
const headers = {
|
|
@@ -1067,29 +1402,29 @@ function createSheetsExecute(config, getToken) {
|
|
|
1067
1402
|
})
|
|
1068
1403
|
});
|
|
1069
1404
|
} catch (error) {
|
|
1070
|
-
throw
|
|
1405
|
+
throw import_data2.createError.network(error instanceof Error ? error : void 0);
|
|
1071
1406
|
}
|
|
1072
1407
|
if (!response.ok) {
|
|
1073
1408
|
const { status, statusText } = response;
|
|
1074
1409
|
if (status === 401) {
|
|
1075
1410
|
config.onAuthError?.();
|
|
1076
|
-
throw
|
|
1411
|
+
throw import_data2.createError.unauthorized("Authentication required. Please log in again.");
|
|
1077
1412
|
}
|
|
1078
1413
|
if (status === 403) {
|
|
1079
|
-
throw
|
|
1414
|
+
throw import_data2.createError.forbidden("You do not have permission to perform this action.");
|
|
1080
1415
|
}
|
|
1081
1416
|
if (status === 404) {
|
|
1082
|
-
throw
|
|
1417
|
+
throw import_data2.createError.notFound("The requested endpoint does not exist.");
|
|
1083
1418
|
}
|
|
1084
1419
|
try {
|
|
1085
1420
|
const body = await response.json();
|
|
1086
1421
|
if (body.errors?.length) {
|
|
1087
|
-
throw
|
|
1422
|
+
throw import_data2.createError.graphql(body.errors[0].message || `Request failed: ${status}`, body.errors[0].extensions?.code);
|
|
1088
1423
|
}
|
|
1089
1424
|
} catch (e) {
|
|
1090
|
-
if (e instanceof
|
|
1425
|
+
if (e instanceof import_data2.DataError) throw e;
|
|
1091
1426
|
}
|
|
1092
|
-
throw
|
|
1427
|
+
throw import_data2.createError.badRequest(`Request failed: ${status} ${statusText}`);
|
|
1093
1428
|
}
|
|
1094
1429
|
const result = await response.json();
|
|
1095
1430
|
const graphqlError = parseGraphQLResponse(result, config.onAuthError);
|
|
@@ -1100,64 +1435,40 @@ function createSheetsExecute(config, getToken) {
|
|
|
1100
1435
|
};
|
|
1101
1436
|
}
|
|
1102
1437
|
function createSheetsUpload(config, getToken) {
|
|
1103
|
-
|
|
1438
|
+
const execute = config.execute ?? createSheetsExecute(config, getToken);
|
|
1439
|
+
return async (file, _path, options) => {
|
|
1104
1440
|
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;
|
|
1441
|
+
throw import_data2.createError.badRequest("No GraphQL endpoint configured.");
|
|
1442
|
+
}
|
|
1443
|
+
const bucketKey = config.upload?.bucketKey ?? "public";
|
|
1444
|
+
const contentType = file.type || "application/octet-stream";
|
|
1445
|
+
const buffer = await file.arrayBuffer();
|
|
1446
|
+
const contentHash = await sha256HexFromBuffer(buffer);
|
|
1447
|
+
const cap = await discoverUploadCapability(config.endpoint, execute);
|
|
1448
|
+
const payload = await callUploadOp(execute, cap, {
|
|
1449
|
+
bucketKey,
|
|
1450
|
+
contentHash,
|
|
1451
|
+
contentType,
|
|
1452
|
+
size: file.size,
|
|
1453
|
+
filename: file.name
|
|
1454
|
+
});
|
|
1455
|
+
if (!payload.deduplicated) {
|
|
1456
|
+
if (!payload.uploadUrl) {
|
|
1457
|
+
throw import_data2.createError.badRequest("Upload failed: server returned no uploadUrl for a non-deduplicated file.");
|
|
1156
1458
|
}
|
|
1157
|
-
|
|
1158
|
-
|
|
1459
|
+
await presignedPut(payload.uploadUrl, buffer, contentType, options?.onProgress);
|
|
1460
|
+
} else {
|
|
1461
|
+
options?.onProgress?.({ loaded: file.size, total: file.size, percentage: 100 });
|
|
1159
1462
|
}
|
|
1160
|
-
|
|
1463
|
+
const url = await fetchDownloadUrl(execute, cap, payload.fileId);
|
|
1464
|
+
return {
|
|
1465
|
+
url,
|
|
1466
|
+
filename: file.name,
|
|
1467
|
+
mime: file.type,
|
|
1468
|
+
size: file.size,
|
|
1469
|
+
key: payload.key,
|
|
1470
|
+
fileId: payload.fileId
|
|
1471
|
+
};
|
|
1161
1472
|
};
|
|
1162
1473
|
}
|
|
1163
1474
|
|
|
@@ -1496,11 +1807,11 @@ function hashString(input) {
|
|
|
1496
1807
|
|
|
1497
1808
|
// src/store/relation-info-slice.ts
|
|
1498
1809
|
var import_inflekt2 = require("inflekt");
|
|
1499
|
-
var
|
|
1810
|
+
var import_data5 = require("@constructive-io/data");
|
|
1500
1811
|
|
|
1501
1812
|
// src/utils/relation-utils.ts
|
|
1502
1813
|
var import_inflekt = require("inflekt");
|
|
1503
|
-
var
|
|
1814
|
+
var import_data4 = require("@constructive-io/data");
|
|
1504
1815
|
function codecNameToTableName(name) {
|
|
1505
1816
|
if (!name) return name;
|
|
1506
1817
|
const singular = (0, import_inflekt.singularize)(name);
|
|
@@ -1521,8 +1832,8 @@ function getAllRelationFields(relations, metaTables) {
|
|
|
1521
1832
|
if (metaTables) {
|
|
1522
1833
|
const leftFk = rel?.junctionLeftKeyAttributes?.[0]?.name;
|
|
1523
1834
|
const rightFk = rel?.junctionRightKeyAttributes?.[0]?.name;
|
|
1524
|
-
const leftFkCamel = leftFk ? (0,
|
|
1525
|
-
const rightFkCamel = rightFk ? (0,
|
|
1835
|
+
const leftFkCamel = leftFk ? (0, import_data4.pgFieldToCamelCase)(leftFk) : void 0;
|
|
1836
|
+
const rightFkCamel = rightFk ? (0, import_data4.pgFieldToCamelCase)(rightFk) : void 0;
|
|
1526
1837
|
const jtTableName = codecNameToTableName(jtName);
|
|
1527
1838
|
if (!isJunctionTablePure(jtTableName, leftFkCamel, rightFkCamel, metaTables)) return;
|
|
1528
1839
|
}
|
|
@@ -1542,8 +1853,8 @@ function getAllRelationFields(relations, metaTables) {
|
|
|
1542
1853
|
if (jtName) {
|
|
1543
1854
|
const leftFk = rel?.junctionLeftKeyAttributes?.[0]?.name;
|
|
1544
1855
|
const rightFk = rel?.junctionRightKeyAttributes?.[0]?.name;
|
|
1545
|
-
const leftFkCamel = leftFk ? (0,
|
|
1546
|
-
const rightFkCamel = rightFk ? (0,
|
|
1856
|
+
const leftFkCamel = leftFk ? (0, import_data4.pgFieldToCamelCase)(leftFk) : void 0;
|
|
1857
|
+
const rightFkCamel = rightFk ? (0, import_data4.pgFieldToCamelCase)(rightFk) : void 0;
|
|
1547
1858
|
const jtTableName = codecNameToTableName(jtName);
|
|
1548
1859
|
if (!isJunctionTablePure(jtTableName, leftFkCamel, rightFkCamel, metaTables)) return;
|
|
1549
1860
|
}
|
|
@@ -1560,7 +1871,7 @@ function isJunctionTablePure(junctionTableName, leftFkField, rightFkField, metaT
|
|
|
1560
1871
|
const exemptFields = /* @__PURE__ */ new Set(["id", leftFkField, rightFkField]);
|
|
1561
1872
|
for (const field of junctionMeta.fields) {
|
|
1562
1873
|
if (!field?.name) continue;
|
|
1563
|
-
const camelName = (0,
|
|
1874
|
+
const camelName = (0, import_data4.pgFieldToCamelCase)(field.name);
|
|
1564
1875
|
if (exemptFields.has(camelName)) continue;
|
|
1565
1876
|
if (field.isNotNull && !field.hasDefault) return false;
|
|
1566
1877
|
}
|
|
@@ -1619,7 +1930,7 @@ function createRelationInfoSlice(set, get) {
|
|
|
1619
1930
|
}
|
|
1620
1931
|
function toCleanTables(meta) {
|
|
1621
1932
|
const tables = meta?._meta?.tables ?? [];
|
|
1622
|
-
return tables.filter((table) => table != null).map((table) => (0,
|
|
1933
|
+
return tables.filter((table) => table != null).map((table) => (0, import_data5.cleanTable)(table));
|
|
1623
1934
|
}
|
|
1624
1935
|
function firstFieldName(fields) {
|
|
1625
1936
|
return fields[0]?.name;
|
|
@@ -1641,7 +1952,7 @@ function findForeignKeyInRelatedTable(currentTableName, relatedTableName, allTab
|
|
|
1641
1952
|
const refName = fk.refTable?.name;
|
|
1642
1953
|
if (refName && refName.toLowerCase() === currentTableName.toLowerCase()) {
|
|
1643
1954
|
const fieldName = fk.fields?.[0]?.name;
|
|
1644
|
-
if (fieldName) return (0,
|
|
1955
|
+
if (fieldName) return (0, import_data5.pgFieldToCamelCase)(fieldName);
|
|
1645
1956
|
}
|
|
1646
1957
|
}
|
|
1647
1958
|
}
|
|
@@ -3592,7 +3903,7 @@ function isImageField(fieldMeta, fieldName) {
|
|
|
3592
3903
|
}
|
|
3593
3904
|
|
|
3594
3905
|
// src/grid/sheets.utils.ts
|
|
3595
|
-
var
|
|
3906
|
+
var import_data6 = require("@constructive-io/data");
|
|
3596
3907
|
|
|
3597
3908
|
// src/grid/sheets.formatters.ts
|
|
3598
3909
|
function compactJsonPreview(value, maxLen = 80) {
|
|
@@ -3760,7 +4071,7 @@ function prepareDraftSubmissionPayload(values, options = {}) {
|
|
|
3760
4071
|
const { allowedColumns, relationInfoByKey } = options;
|
|
3761
4072
|
const allowsAll = !allowedColumns || allowedColumns.size === 0;
|
|
3762
4073
|
const { id: _id, ...valuesWithoutId } = values;
|
|
3763
|
-
const filtered = (0,
|
|
4074
|
+
const filtered = (0, import_data6.prepareCreateInput)(valuesWithoutId);
|
|
3764
4075
|
const payload = {};
|
|
3765
4076
|
const normalizeForeignKeyValue = (input) => {
|
|
3766
4077
|
if (input === void 0 || input === null) return void 0;
|
|
@@ -3882,20 +4193,20 @@ function createHeaderClickHandler(columnKeys, toggleSorting, sortableColumns) {
|
|
|
3882
4193
|
var import_react19 = require("react");
|
|
3883
4194
|
var import_react_query4 = require("@tanstack/react-query");
|
|
3884
4195
|
var import_inflekt4 = require("inflekt");
|
|
3885
|
-
var
|
|
4196
|
+
var import_data13 = require("@constructive-io/data");
|
|
3886
4197
|
|
|
3887
4198
|
// src/hooks/use-sheets-meta.ts
|
|
3888
4199
|
var import_react_query3 = require("@tanstack/react-query");
|
|
3889
4200
|
|
|
3890
4201
|
// src/adapter/postgraphile-adapter.ts
|
|
3891
|
-
var
|
|
4202
|
+
var import_data12 = require("@constructive-io/data");
|
|
3892
4203
|
|
|
3893
4204
|
// src/hooks/use-sheets-table.ts
|
|
3894
4205
|
var import_react18 = require("react");
|
|
3895
4206
|
var import_react_query2 = require("@tanstack/react-query");
|
|
3896
|
-
var import_data8 = require("@constructive-io/data");
|
|
3897
4207
|
var import_data9 = require("@constructive-io/data");
|
|
3898
4208
|
var import_data10 = require("@constructive-io/data");
|
|
4209
|
+
var import_data11 = require("@constructive-io/data");
|
|
3899
4210
|
|
|
3900
4211
|
// src/hooks/query-keys.ts
|
|
3901
4212
|
function isSheetsScopeKey(value) {
|
|
@@ -3922,8 +4233,8 @@ var sheetsQueryKeys = {
|
|
|
3922
4233
|
|
|
3923
4234
|
// src/hooks/relation-field-resolution.ts
|
|
3924
4235
|
var import_inflekt3 = require("inflekt");
|
|
3925
|
-
var
|
|
3926
|
-
var TypeFieldsDoc = new
|
|
4236
|
+
var import_data7 = require("@constructive-io/data");
|
|
4237
|
+
var TypeFieldsDoc = new import_data7.TypedDocumentString(`
|
|
3927
4238
|
query TypeFields($typeName: String!) {
|
|
3928
4239
|
__type(name: $typeName) {
|
|
3929
4240
|
fields {
|
|
@@ -4091,8 +4402,8 @@ async function getTypeFieldSet(table, scopeKey, queryClient, execute) {
|
|
|
4091
4402
|
}
|
|
4092
4403
|
|
|
4093
4404
|
// src/hooks/orderby-enum-resolution.ts
|
|
4094
|
-
var
|
|
4095
|
-
var EnumValuesDoc = new
|
|
4405
|
+
var import_data8 = require("@constructive-io/data");
|
|
4406
|
+
var EnumValuesDoc = new import_data8.TypedDocumentString(`
|
|
4096
4407
|
query EnumValues($typeName: String!) {
|
|
4097
4408
|
__type(name: $typeName) {
|
|
4098
4409
|
enumValues {
|
|
@@ -4185,10 +4496,10 @@ function transformToPostGraphileVariables(table, options = {}) {
|
|
|
4185
4496
|
}
|
|
4186
4497
|
if (options.orderBy && options.orderBy.length > 0) {
|
|
4187
4498
|
const availableFields = new Set(table.fields.map((field) => field.name));
|
|
4188
|
-
variables.orderBy = options.orderBy.filter(({ field }) => availableFields.has(field)).map(({ field, direction }) => (0,
|
|
4499
|
+
variables.orderBy = options.orderBy.filter(({ field }) => availableFields.has(field)).map(({ field, direction }) => (0, import_data11.toOrderByEnumValue)(field, direction));
|
|
4189
4500
|
}
|
|
4190
4501
|
if (options.where) {
|
|
4191
|
-
variables.
|
|
4502
|
+
variables.where = options.where;
|
|
4192
4503
|
}
|
|
4193
4504
|
return variables;
|
|
4194
4505
|
}
|
|
@@ -4199,7 +4510,7 @@ function useSheetsTable(tableName, options = {}) {
|
|
|
4199
4510
|
const adapter = useSheetsAdapter();
|
|
4200
4511
|
const tables = (0, import_react18.useMemo)(() => {
|
|
4201
4512
|
if (!meta?._meta?.tables) return [];
|
|
4202
|
-
return meta._meta.tables.filter((candidate) => candidate != null).map((metaTable) => (0,
|
|
4513
|
+
return meta._meta.tables.filter((candidate) => candidate != null).map((metaTable) => (0, import_data9.cleanTable)(metaTable));
|
|
4203
4514
|
}, [meta]);
|
|
4204
4515
|
const table = (0, import_react18.useMemo)(
|
|
4205
4516
|
() => tables.find((candidate) => candidate.name === tableName) ?? null,
|
|
@@ -4219,7 +4530,7 @@ function useSheetsTable(tableName, options = {}) {
|
|
|
4219
4530
|
queryKey: sheetsTableQueryKeys.tableRows(scopeKey, tableName, finalQueryOptions),
|
|
4220
4531
|
queryFn: async () => {
|
|
4221
4532
|
if (!table) {
|
|
4222
|
-
throw
|
|
4533
|
+
throw import_data10.createError.notFound(`Table '${tableName}' not found`);
|
|
4223
4534
|
}
|
|
4224
4535
|
const variables = transformToPostGraphileVariables(table, finalQueryOptions);
|
|
4225
4536
|
const [relationFieldMap] = await Promise.all([
|
|
@@ -4235,7 +4546,7 @@ function useSheetsTable(tableName, options = {}) {
|
|
|
4235
4546
|
const validatedOrderByEnum = new Set(variables.orderBy ?? []);
|
|
4236
4547
|
const availableOrderByFields = new Set(table.fields.map((field) => field.name));
|
|
4237
4548
|
const validatedOrderBy = finalQueryOptions.orderBy?.filter(
|
|
4238
|
-
({ field, direction }) => availableOrderByFields.has(field) && validatedOrderByEnum.has((0,
|
|
4549
|
+
({ field, direction }) => availableOrderByFields.has(field) && validatedOrderByEnum.has((0, import_data11.toOrderByEnumValue)(field, direction))
|
|
4239
4550
|
);
|
|
4240
4551
|
const { rows, totalCount: totalCount2 } = await adapter.listRows(
|
|
4241
4552
|
{ table, allTables: tables, tableName },
|
|
@@ -4262,9 +4573,9 @@ function useSheetsTable(tableName, options = {}) {
|
|
|
4262
4573
|
mutationKey: sheetsTableMutationKeys.create(scopeKey, tableName),
|
|
4263
4574
|
mutationFn: async (data2) => {
|
|
4264
4575
|
if (!table) {
|
|
4265
|
-
throw
|
|
4576
|
+
throw import_data10.createError.notFound(`Table '${tableName}' not found`);
|
|
4266
4577
|
}
|
|
4267
|
-
const allTables = meta?._meta?.tables ? meta._meta.tables.filter((t) => t != null).map(
|
|
4578
|
+
const allTables = meta?._meta?.tables ? meta._meta.tables.filter((t) => t != null).map(import_data9.cleanTable) : [];
|
|
4268
4579
|
const createdRow = await adapter.createRow({ table, allTables, tableName }, data2, execute, {
|
|
4269
4580
|
...mutationOptions,
|
|
4270
4581
|
fieldSelection: mutationOptions.fieldSelection || fieldSelection || "display"
|
|
@@ -4284,9 +4595,9 @@ function useSheetsTable(tableName, options = {}) {
|
|
|
4284
4595
|
mutationKey: sheetsTableMutationKeys.update(scopeKey, tableName),
|
|
4285
4596
|
mutationFn: async ({ id, patch }) => {
|
|
4286
4597
|
if (!table) {
|
|
4287
|
-
throw
|
|
4598
|
+
throw import_data10.createError.notFound(`Table '${tableName}' not found`);
|
|
4288
4599
|
}
|
|
4289
|
-
const allTables = meta?._meta?.tables ? meta._meta.tables.filter((t) => t != null).map(
|
|
4600
|
+
const allTables = meta?._meta?.tables ? meta._meta.tables.filter((t) => t != null).map(import_data9.cleanTable) : [];
|
|
4290
4601
|
const updatedRow = await adapter.updateRow({ table, allTables, tableName }, id, patch, execute, {
|
|
4291
4602
|
...mutationOptions,
|
|
4292
4603
|
fieldSelection: mutationOptions.fieldSelection || fieldSelection || "display"
|
|
@@ -4335,9 +4646,9 @@ function useSheetsTable(tableName, options = {}) {
|
|
|
4335
4646
|
mutationKey: sheetsTableMutationKeys.delete(scopeKey, tableName),
|
|
4336
4647
|
mutationFn: async (idOrPk) => {
|
|
4337
4648
|
if (!table) {
|
|
4338
|
-
throw
|
|
4649
|
+
throw import_data10.createError.notFound(`Table '${tableName}' not found`);
|
|
4339
4650
|
}
|
|
4340
|
-
const allTables = meta?._meta?.tables ? meta._meta.tables.filter((t) => t != null).map(
|
|
4651
|
+
const allTables = meta?._meta?.tables ? meta._meta.tables.filter((t) => t != null).map(import_data9.cleanTable) : [];
|
|
4341
4652
|
await adapter.deleteRow({ table, allTables, tableName }, idOrPk, execute, mutationOptions);
|
|
4342
4653
|
return { deletedId: idOrPk, __rawResult: {} };
|
|
4343
4654
|
},
|
|
@@ -4353,9 +4664,9 @@ function useSheetsTable(tableName, options = {}) {
|
|
|
4353
4664
|
});
|
|
4354
4665
|
const findOne = async (id) => {
|
|
4355
4666
|
if (!table) {
|
|
4356
|
-
throw
|
|
4667
|
+
throw import_data10.createError.notFound(`Table '${tableName}' not found`);
|
|
4357
4668
|
}
|
|
4358
|
-
const doc = (0,
|
|
4669
|
+
const doc = (0, import_data11.buildSelect)(table, tables, {
|
|
4359
4670
|
where: { id: { equalTo: id } },
|
|
4360
4671
|
limit: 1
|
|
4361
4672
|
});
|
|
@@ -4364,12 +4675,12 @@ function useSheetsTable(tableName, options = {}) {
|
|
|
4364
4675
|
limit: 1
|
|
4365
4676
|
});
|
|
4366
4677
|
const result = await execute(doc, variables);
|
|
4367
|
-
const singularName = (0,
|
|
4678
|
+
const singularName = (0, import_data11.toCamelCaseSingular)(tableName, table);
|
|
4368
4679
|
const singularData = result[singularName];
|
|
4369
4680
|
if (singularData && typeof singularData === "object") {
|
|
4370
4681
|
return singularData;
|
|
4371
4682
|
}
|
|
4372
|
-
const queryTableName = (0,
|
|
4683
|
+
const queryTableName = (0, import_data11.toCamelCasePlural)(tableName, table);
|
|
4373
4684
|
const data2 = result[queryTableName];
|
|
4374
4685
|
if (data2 && typeof data2 === "object" && "nodes" in data2) {
|
|
4375
4686
|
const nodes = data2.nodes || [];
|
|
@@ -4410,7 +4721,7 @@ function useSheetsTable(tableName, options = {}) {
|
|
|
4410
4721
|
}
|
|
4411
4722
|
|
|
4412
4723
|
// src/adapter/postgraphile-adapter.ts
|
|
4413
|
-
var MetaDoc = new
|
|
4724
|
+
var MetaDoc = new import_data12.TypedDocumentString(`
|
|
4414
4725
|
query Meta {
|
|
4415
4726
|
_meta {
|
|
4416
4727
|
tables {
|
|
@@ -4717,12 +5028,12 @@ function createPostGraphileAdapter() {
|
|
|
4717
5028
|
const { table, allTables, tableName } = ctx;
|
|
4718
5029
|
const { relationFieldMap, ...queryOptions } = query;
|
|
4719
5030
|
const variables = transformToPostGraphileVariables(table, queryOptions);
|
|
4720
|
-
const doc = (0,
|
|
5031
|
+
const doc = (0, import_data12.buildSelect)(table, allTables, {
|
|
4721
5032
|
...queryOptions,
|
|
4722
5033
|
relationFieldMap
|
|
4723
5034
|
});
|
|
4724
5035
|
const result = await execute(doc, variables);
|
|
4725
|
-
const queryTableName = (0,
|
|
5036
|
+
const queryTableName = (0, import_data12.toCamelCasePlural)(tableName, table);
|
|
4726
5037
|
const connection = result[queryTableName];
|
|
4727
5038
|
if (connection && typeof connection === "object" && "nodes" in connection) {
|
|
4728
5039
|
const nodes = connection.nodes || [];
|
|
@@ -4741,30 +5052,30 @@ function createPostGraphileAdapter() {
|
|
|
4741
5052
|
},
|
|
4742
5053
|
async createRow(ctx, data, execute, options = {}) {
|
|
4743
5054
|
const { table, allTables, tableName } = ctx;
|
|
4744
|
-
const doc = (0,
|
|
5055
|
+
const doc = (0, import_data12.buildPostGraphileCreate)(table, allTables, {
|
|
4745
5056
|
...options,
|
|
4746
5057
|
fieldSelection: options.fieldSelection || "display"
|
|
4747
5058
|
});
|
|
4748
|
-
const singularName = (0,
|
|
4749
|
-
const sanitizedData = (0,
|
|
5059
|
+
const singularName = (0, import_data12.toCamelCaseSingular)(tableName, table);
|
|
5060
|
+
const sanitizedData = (0, import_data12.prepareCreateInput)(data);
|
|
4750
5061
|
const variables = {
|
|
4751
5062
|
input: {
|
|
4752
5063
|
[singularName]: sanitizedData
|
|
4753
5064
|
}
|
|
4754
5065
|
};
|
|
4755
5066
|
const result = await execute(doc, variables);
|
|
4756
|
-
const mutationName = (0,
|
|
5067
|
+
const mutationName = (0, import_data12.toCreateMutationName)(tableName, table);
|
|
4757
5068
|
const createdRow = result[mutationName]?.[singularName] ?? null;
|
|
4758
5069
|
return createdRow;
|
|
4759
5070
|
},
|
|
4760
5071
|
async updateRow(ctx, id, patch, execute, options = {}) {
|
|
4761
5072
|
const { table, allTables, tableName } = ctx;
|
|
4762
|
-
const doc = (0,
|
|
5073
|
+
const doc = (0, import_data12.buildPostGraphileUpdate)(table, allTables, {
|
|
4763
5074
|
...options,
|
|
4764
5075
|
fieldSelection: options.fieldSelection || "display"
|
|
4765
5076
|
});
|
|
4766
|
-
const patchFieldName = (0,
|
|
4767
|
-
const sanitizedPatch = (0,
|
|
5077
|
+
const patchFieldName = (0, import_data12.toPatchFieldName)(tableName, table);
|
|
5078
|
+
const sanitizedPatch = (0, import_data12.prepareUpdateInput)(patch);
|
|
4768
5079
|
if (Object.keys(sanitizedPatch).length === 0) {
|
|
4769
5080
|
return null;
|
|
4770
5081
|
}
|
|
@@ -4775,14 +5086,14 @@ function createPostGraphileAdapter() {
|
|
|
4775
5086
|
}
|
|
4776
5087
|
};
|
|
4777
5088
|
const result = await execute(doc, variables);
|
|
4778
|
-
const mutationName = (0,
|
|
4779
|
-
const singularName = (0,
|
|
5089
|
+
const mutationName = (0, import_data12.toUpdateMutationName)(tableName, table);
|
|
5090
|
+
const singularName = (0, import_data12.toCamelCaseSingular)(tableName, table);
|
|
4780
5091
|
const updatedRow = result[mutationName]?.[singularName] ?? null;
|
|
4781
5092
|
return updatedRow;
|
|
4782
5093
|
},
|
|
4783
5094
|
async deleteRow(ctx, id, execute, options = {}) {
|
|
4784
5095
|
const { table, allTables } = ctx;
|
|
4785
|
-
const doc = (0,
|
|
5096
|
+
const doc = (0, import_data12.buildPostGraphileDelete)(table, allTables, options);
|
|
4786
5097
|
const variables = {
|
|
4787
5098
|
input: typeof id === "object" ? id : { id }
|
|
4788
5099
|
};
|
|
@@ -4851,7 +5162,7 @@ function useRelationMetadataCache(tableName) {
|
|
|
4851
5162
|
sheetsLogger().debug?.(`Table "${tableName}" not found in metadata`);
|
|
4852
5163
|
return null;
|
|
4853
5164
|
}
|
|
4854
|
-
return (0,
|
|
5165
|
+
return (0, import_data13.cleanTable)(metaTable);
|
|
4855
5166
|
},
|
|
4856
5167
|
...RELATION_CACHE_CONFIG,
|
|
4857
5168
|
refetchOnMount: true,
|
|
@@ -4911,7 +5222,7 @@ function useRelationMetadataCache(tableName) {
|
|
|
4911
5222
|
const refName = fk.refTable?.name;
|
|
4912
5223
|
if (refName && refName.toLowerCase() === (tableName || "").toLowerCase()) {
|
|
4913
5224
|
const fieldName = fk.fields?.[0]?.name;
|
|
4914
|
-
if (fieldName) return (0,
|
|
5225
|
+
if (fieldName) return (0, import_data13.pgFieldToCamelCase)(fieldName);
|
|
4915
5226
|
}
|
|
4916
5227
|
}
|
|
4917
5228
|
return void 0;
|
|
@@ -6854,9 +7165,9 @@ var import_react31 = require("react");
|
|
|
6854
7165
|
// src/hooks/use-sheets-infinite-table.ts
|
|
6855
7166
|
var import_react30 = require("react");
|
|
6856
7167
|
var import_react_query5 = require("@tanstack/react-query");
|
|
6857
|
-
var import_data13 = require("@constructive-io/data");
|
|
6858
7168
|
var import_data14 = require("@constructive-io/data");
|
|
6859
7169
|
var import_data15 = require("@constructive-io/data");
|
|
7170
|
+
var import_data16 = require("@constructive-io/data");
|
|
6860
7171
|
var sheetsInfiniteTableKeys = {
|
|
6861
7172
|
all: (scope, tableName) => sheetsQueryKeys.infiniteTable(scope, tableName),
|
|
6862
7173
|
page: (scope, tableName, pageIndex, optionsKey) => [...sheetsQueryKeys.infiniteTable(scope, tableName), "page", pageIndex, optionsKey],
|
|
@@ -6890,7 +7201,7 @@ function useSheetsInfiniteTable(tableName, options = {}) {
|
|
|
6890
7201
|
const prevTableNameRef = (0, import_react30.useRef)(tableName);
|
|
6891
7202
|
const tables = (0, import_react30.useMemo)(() => {
|
|
6892
7203
|
if (!meta?._meta?.tables) return [];
|
|
6893
|
-
return meta._meta.tables.filter((candidate) => candidate != null).map((metaTable) => (0,
|
|
7204
|
+
return meta._meta.tables.filter((candidate) => candidate != null).map((metaTable) => (0, import_data14.cleanTable)(metaTable));
|
|
6894
7205
|
}, [meta]);
|
|
6895
7206
|
const table = (0, import_react30.useMemo)(
|
|
6896
7207
|
() => tables.find((candidate) => candidate.name === tableName) ?? null,
|
|
@@ -6937,7 +7248,7 @@ function useSheetsInfiniteTable(tableName, options = {}) {
|
|
|
6937
7248
|
queryKey: sheetsInfiniteTableKeys.page(scopeKey, tableName, pageIndex, stableOptionsKey),
|
|
6938
7249
|
queryFn: async () => {
|
|
6939
7250
|
if (!table) {
|
|
6940
|
-
throw
|
|
7251
|
+
throw import_data15.createError.notFound(`Table '${tableName}' not found`);
|
|
6941
7252
|
}
|
|
6942
7253
|
const queryOptions = {
|
|
6943
7254
|
first: pageSize,
|
|
@@ -6968,7 +7279,7 @@ function useSheetsInfiniteTable(tableName, options = {}) {
|
|
|
6968
7279
|
const validatedOrderByEnum = new Set(variables.orderBy ?? []);
|
|
6969
7280
|
const availableOrderByFields = new Set(table.fields.map((field) => field.name));
|
|
6970
7281
|
const validatedOrderBy = orderBy?.filter(
|
|
6971
|
-
({ field, direction }) => availableOrderByFields.has(field) && validatedOrderByEnum.has((0,
|
|
7282
|
+
({ field, direction }) => availableOrderByFields.has(field) && validatedOrderByEnum.has((0, import_data16.toOrderByEnumValue)(field, direction))
|
|
6972
7283
|
);
|
|
6973
7284
|
const res = await adapter.listRows(
|
|
6974
7285
|
{ table, allTables: tables, tableName },
|
|
@@ -8756,8 +9067,44 @@ function GeometryCellView(props) {
|
|
|
8756
9067
|
}
|
|
8757
9068
|
|
|
8758
9069
|
// src/cell-model/views/image-view.tsx
|
|
9070
|
+
var import_lucide_react2 = require("lucide-react");
|
|
8759
9071
|
init_cn();
|
|
8760
9072
|
|
|
9073
|
+
// src/utils/file.utils.ts
|
|
9074
|
+
var getImageUrl = (imageValue) => {
|
|
9075
|
+
if (!imageValue) return null;
|
|
9076
|
+
if (typeof imageValue === "string") {
|
|
9077
|
+
return imageValue;
|
|
9078
|
+
}
|
|
9079
|
+
if (typeof imageValue === "object" && imageValue !== null) {
|
|
9080
|
+
const urlCandidates = ["url", "src", "href", "link", "path"];
|
|
9081
|
+
for (const candidate of urlCandidates) {
|
|
9082
|
+
const obj = imageValue;
|
|
9083
|
+
if (obj[candidate] && typeof obj[candidate] === "string") {
|
|
9084
|
+
return obj[candidate];
|
|
9085
|
+
}
|
|
9086
|
+
}
|
|
9087
|
+
}
|
|
9088
|
+
return null;
|
|
9089
|
+
};
|
|
9090
|
+
var getImageMetadata = (imageValue) => {
|
|
9091
|
+
if (!imageValue || typeof imageValue !== "object") return null;
|
|
9092
|
+
const obj = imageValue;
|
|
9093
|
+
return {
|
|
9094
|
+
filename: obj.filename || obj.name || "Unknown",
|
|
9095
|
+
size: obj.size || obj.fileSize || 0,
|
|
9096
|
+
mime: obj.mime || obj.type || obj.contentType || "unknown",
|
|
9097
|
+
url: getImageUrl(imageValue) || ""
|
|
9098
|
+
};
|
|
9099
|
+
};
|
|
9100
|
+
var formatFileSize = (bytes) => {
|
|
9101
|
+
if (bytes === 0) return "0 B";
|
|
9102
|
+
const k = 1024;
|
|
9103
|
+
const sizes = ["B", "KB", "MB", "GB"];
|
|
9104
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
9105
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + " " + sizes[i];
|
|
9106
|
+
};
|
|
9107
|
+
|
|
8761
9108
|
// src/cell-model/image-cache.ts
|
|
8762
9109
|
var CAP = 256;
|
|
8763
9110
|
var cache = /* @__PURE__ */ new Map();
|
|
@@ -8786,8 +9133,34 @@ function readUrl(data) {
|
|
|
8786
9133
|
if (Array.isArray(data) && typeof data[0] === "string") return data[0];
|
|
8787
9134
|
return "";
|
|
8788
9135
|
}
|
|
9136
|
+
function basename(url) {
|
|
9137
|
+
const path = url.split(/[?#]/)[0];
|
|
9138
|
+
const seg = path.slice(path.lastIndexOf("/") + 1);
|
|
9139
|
+
return seg || url;
|
|
9140
|
+
}
|
|
9141
|
+
function isNonImageFile(cellType, value) {
|
|
9142
|
+
if (cellType === "image" || value == null) return false;
|
|
9143
|
+
const mime = getImageMetadata(value)?.mime;
|
|
9144
|
+
return !(mime && mime !== "unknown" && mime.startsWith("image/"));
|
|
9145
|
+
}
|
|
8789
9146
|
function ImageCellView(props) {
|
|
8790
9147
|
const url = readUrl(props.cell.data);
|
|
9148
|
+
if (url && isNonImageFile(props.column.cellType, props.value)) {
|
|
9149
|
+
const meta = getImageMetadata(props.value);
|
|
9150
|
+
const filename = meta?.filename && meta.filename !== "Unknown" ? meta.filename : basename(url);
|
|
9151
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
9152
|
+
"div",
|
|
9153
|
+
{
|
|
9154
|
+
"data-slot": "file-cell",
|
|
9155
|
+
role: "gridcell",
|
|
9156
|
+
className: cn("flex h-full w-full items-center gap-1.5 overflow-hidden px-2"),
|
|
9157
|
+
children: [
|
|
9158
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react2.FileIcon, { className: "size-3.5 shrink-0 text-muted-foreground", "aria-hidden": "true" }),
|
|
9159
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "truncate text-sm", title: filename, children: filename })
|
|
9160
|
+
]
|
|
9161
|
+
}
|
|
9162
|
+
);
|
|
9163
|
+
}
|
|
8791
9164
|
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
8792
9165
|
"div",
|
|
8793
9166
|
{
|
|
@@ -9378,7 +9751,7 @@ init_cell_type_groups();
|
|
|
9378
9751
|
var import_react43 = require("react");
|
|
9379
9752
|
var import_badge = require("@constructive-io/ui/badge");
|
|
9380
9753
|
var import_button6 = require("@constructive-io/ui/button");
|
|
9381
|
-
var
|
|
9754
|
+
var import_lucide_react3 = require("lucide-react");
|
|
9382
9755
|
init_editor_focus_trap();
|
|
9383
9756
|
init_overlay_presets();
|
|
9384
9757
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
@@ -9495,7 +9868,7 @@ function ArrayEditor({ value, onChange, onFinished }) {
|
|
|
9495
9868
|
},
|
|
9496
9869
|
"aria-label": `Remove ${String(item)}`,
|
|
9497
9870
|
tabIndex: -1,
|
|
9498
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
9871
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react3.XIcon, { className: "size-3" })
|
|
9499
9872
|
}
|
|
9500
9873
|
)
|
|
9501
9874
|
]
|
|
@@ -9577,7 +9950,7 @@ var import_react48 = require("react");
|
|
|
9577
9950
|
|
|
9578
9951
|
// src/grid/editors/geometry-editor.tsx
|
|
9579
9952
|
var import_react47 = require("react");
|
|
9580
|
-
var
|
|
9953
|
+
var import_lucide_react5 = require("lucide-react");
|
|
9581
9954
|
init_cn();
|
|
9582
9955
|
var import_button9 = require("@constructive-io/ui/button");
|
|
9583
9956
|
var import_tabs = require("@constructive-io/ui/tabs");
|
|
@@ -9589,7 +9962,7 @@ var MapPicker2 = (0, import_react47.lazy)(
|
|
|
9589
9962
|
() => Promise.resolve().then(() => (init_map_picker(), map_picker_exports)).then((m) => ({ default: m.MapPicker }))
|
|
9590
9963
|
);
|
|
9591
9964
|
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)(
|
|
9965
|
+
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
9966
|
}
|
|
9594
9967
|
var VALID_GEOJSON_TYPES = [
|
|
9595
9968
|
"Point",
|
|
@@ -9853,17 +10226,17 @@ var GeometryEditor = ({ value, onFinishedEditing, expectedType }) => {
|
|
|
9853
10226
|
}, [overlayMaxHeight]);
|
|
9854
10227
|
const header = /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex items-center justify-between px-3 py-2", children: [
|
|
9855
10228
|
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
9856
|
-
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
10229
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_lucide_react5.MapPin, { className: "text-muted-foreground h-3.5 w-3.5" }),
|
|
9857
10230
|
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "text-sm font-medium", children: "Geometry" }),
|
|
9858
10231
|
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
10232
|
] }),
|
|
9860
10233
|
canShowMap && /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_tabs.TabsList, { className: "h-7", children: [
|
|
9861
10234
|
/* @__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)(
|
|
10235
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_lucide_react5.Map, { className: "h-3 w-3" }),
|
|
9863
10236
|
"Map"
|
|
9864
10237
|
] }),
|
|
9865
10238
|
/* @__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)(
|
|
10239
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_lucide_react5.FileText, { className: "h-3 w-3" }),
|
|
9867
10240
|
"JSON"
|
|
9868
10241
|
] })
|
|
9869
10242
|
] })
|
|
@@ -9881,11 +10254,11 @@ var GeometryEditor = ({ value, onFinishedEditing, expectedType }) => {
|
|
|
9881
10254
|
}
|
|
9882
10255
|
),
|
|
9883
10256
|
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)(
|
|
10257
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_lucide_react5.AlertCircle, { className: "h-4 w-4 shrink-0" }),
|
|
9885
10258
|
validationError
|
|
9886
10259
|
] }),
|
|
9887
10260
|
(!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)(
|
|
10261
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_lucide_react5.Shuffle, { className: "mr-1 h-3 w-3" }),
|
|
9889
10262
|
"Randomize"
|
|
9890
10263
|
] })
|
|
9891
10264
|
] });
|
|
@@ -9953,21 +10326,21 @@ var import_react54 = require("react");
|
|
|
9953
10326
|
|
|
9954
10327
|
// src/grid/editors/image-editor.tsx
|
|
9955
10328
|
var import_react52 = require("react");
|
|
9956
|
-
var
|
|
10329
|
+
var import_lucide_react6 = require("lucide-react");
|
|
9957
10330
|
var import_react53 = require("motion/react");
|
|
9958
10331
|
var import_toast2 = require("@constructive-io/ui/toast");
|
|
9959
10332
|
|
|
9960
10333
|
// src/hooks/use-sheets-upload.ts
|
|
9961
10334
|
var import_react49 = require("react");
|
|
9962
10335
|
var import_react_query6 = require("@tanstack/react-query");
|
|
9963
|
-
var import_data16 = require("@constructive-io/data");
|
|
9964
10336
|
var import_data17 = require("@constructive-io/data");
|
|
10337
|
+
var import_data18 = require("@constructive-io/data");
|
|
9965
10338
|
function resolveUploadNaming(tableName, table) {
|
|
9966
10339
|
return {
|
|
9967
|
-
mutationName: (0,
|
|
9968
|
-
singularName: (0,
|
|
9969
|
-
patchFieldName: (0,
|
|
9970
|
-
updateInputTypeName: (0,
|
|
10340
|
+
mutationName: (0, import_data18.toUpdateMutationName)(tableName, table),
|
|
10341
|
+
singularName: (0, import_data18.toCamelCaseSingular)(tableName, table),
|
|
10342
|
+
patchFieldName: (0, import_data18.toPatchFieldName)(tableName, table),
|
|
10343
|
+
updateInputTypeName: (0, import_data18.toUpdateInputTypeName)(tableName)
|
|
9971
10344
|
};
|
|
9972
10345
|
}
|
|
9973
10346
|
function resolveTransport(endpoint, getToken, options) {
|
|
@@ -10044,7 +10417,7 @@ function useSheetsFieldUpload(tableName, fieldName, recordId, options = {}) {
|
|
|
10044
10417
|
const table = (0, import_react49.useMemo)(() => {
|
|
10045
10418
|
if (!meta?._meta?.tables) return null;
|
|
10046
10419
|
const candidate = meta._meta.tables.find((item) => item?.name === tableName);
|
|
10047
|
-
return candidate ? (0,
|
|
10420
|
+
return candidate ? (0, import_data17.cleanTable)(candidate) : null;
|
|
10048
10421
|
}, [meta, tableName]);
|
|
10049
10422
|
const resolvedNaming = (0, import_react49.useMemo)(() => resolveUploadNaming(tableName, table), [tableName, table]);
|
|
10050
10423
|
const getToken = (0, import_react49.useMemo)(() => {
|
|
@@ -10093,7 +10466,7 @@ function useSheetsImageUpload(tableName, fieldName, recordId, options = {}) {
|
|
|
10093
10466
|
const table = (0, import_react49.useMemo)(() => {
|
|
10094
10467
|
if (!meta?._meta?.tables) return null;
|
|
10095
10468
|
const candidate = meta._meta.tables.find((item) => item?.name === tableName);
|
|
10096
|
-
return candidate ? (0,
|
|
10469
|
+
return candidate ? (0, import_data17.cleanTable)(candidate) : null;
|
|
10097
10470
|
}, [meta, tableName]);
|
|
10098
10471
|
const resolvedNaming = (0, import_react49.useMemo)(() => resolveUploadNaming(tableName, table), [tableName, table]);
|
|
10099
10472
|
const getToken = (0, import_react49.useMemo)(() => {
|
|
@@ -10142,41 +10515,6 @@ function useSheetsImageUpload(tableName, fieldName, recordId, options = {}) {
|
|
|
10142
10515
|
});
|
|
10143
10516
|
}
|
|
10144
10517
|
|
|
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
10518
|
// src/grid/editors/image-editor.tsx
|
|
10181
10519
|
init_sheets_logger();
|
|
10182
10520
|
|
|
@@ -10272,10 +10610,24 @@ function RemoveButton({ onClick, label }) {
|
|
|
10272
10610
|
onClick();
|
|
10273
10611
|
},
|
|
10274
10612
|
"aria-label": label,
|
|
10275
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
10613
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react6.XIcon, { className: "size-3.5", "aria-hidden": "true" })
|
|
10276
10614
|
}
|
|
10277
10615
|
) });
|
|
10278
10616
|
}
|
|
10617
|
+
function FilePreview({ name, size, mime }) {
|
|
10618
|
+
const hasMime = !!mime && mime !== "unknown";
|
|
10619
|
+
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: [
|
|
10620
|
+
/* @__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" }) }),
|
|
10621
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "min-w-0 max-w-full", children: [
|
|
10622
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "truncate text-sm font-medium", title: name, children: name || "File" }),
|
|
10623
|
+
(size || hasMime) && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("p", { className: "text-muted-foreground mt-0.5 text-xs", children: [
|
|
10624
|
+
size ? formatFileSize(size) : null,
|
|
10625
|
+
size && hasMime ? " \u2022 " : null,
|
|
10626
|
+
hasMime ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "uppercase", children: mime }) : null
|
|
10627
|
+
] })
|
|
10628
|
+
] })
|
|
10629
|
+
] });
|
|
10630
|
+
}
|
|
10279
10631
|
var ImageEditor = ({
|
|
10280
10632
|
value,
|
|
10281
10633
|
onFinishedEditing,
|
|
@@ -10285,8 +10637,11 @@ var ImageEditor = ({
|
|
|
10285
10637
|
onSaveComplete,
|
|
10286
10638
|
isDraftRow: isDraftRow2 = false,
|
|
10287
10639
|
onSubmitDraft,
|
|
10288
|
-
onDraftUploadComplete
|
|
10640
|
+
onDraftUploadComplete,
|
|
10641
|
+
acceptAnyFile = false
|
|
10289
10642
|
}) => {
|
|
10643
|
+
const noun = acceptAnyFile ? "file" : "image";
|
|
10644
|
+
const Noun = acceptAnyFile ? "File" : "Image";
|
|
10290
10645
|
const [uploadState, setUploadState] = (0, import_react52.useState)("idle");
|
|
10291
10646
|
const { config } = useSheetsContext();
|
|
10292
10647
|
const storeApi = useSheetsStoreApi();
|
|
@@ -10309,10 +10664,12 @@ var ImageEditor = ({
|
|
|
10309
10664
|
const isUploading = uploadState === "uploading";
|
|
10310
10665
|
const isBusy = uploadState !== "idle";
|
|
10311
10666
|
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
10667
|
const imageMetadata = (0, import_react52.useMemo)(() => getImageMetadata(imageValue), [imageValue]);
|
|
10668
|
+
const storedMime = imageMetadata?.mime;
|
|
10669
|
+
const storedIsImage = !acceptAnyFile || !!storedMime && storedMime.startsWith("image/");
|
|
10670
|
+
const imageStatus = useImageStatus(storedIsImage ? imageUrl || void 0 : void 0);
|
|
10671
|
+
const imageLoadFailed = storedIsImage && imageUrl != null && imageStatus === "error";
|
|
10672
|
+
const hasImage = imageUrl != null && !imageLoadFailed && storedIsImage;
|
|
10316
10673
|
const revokePreviewUrl = (0, import_react52.useCallback)(() => {
|
|
10317
10674
|
if (previewUrlRef.current) {
|
|
10318
10675
|
URL.revokeObjectURL(previewUrlRef.current);
|
|
@@ -10332,8 +10689,8 @@ var ImageEditor = ({
|
|
|
10332
10689
|
setImageValue(normalized);
|
|
10333
10690
|
onSaveComplete?.({ imageData: normalized });
|
|
10334
10691
|
onFinishedEditing();
|
|
10335
|
-
import_toast2.toast.success({ message:
|
|
10336
|
-
}, [resetFileState, onSaveComplete, onFinishedEditing]);
|
|
10692
|
+
import_toast2.toast.success({ message: `${Noun} uploaded successfully` });
|
|
10693
|
+
}, [resetFileState, onSaveComplete, onFinishedEditing, Noun]);
|
|
10337
10694
|
const handleUploadError = (0, import_react52.useCallback)((error) => {
|
|
10338
10695
|
setUploadState("idle");
|
|
10339
10696
|
sheetsLogger().error("[image-editor] upload failed:", error);
|
|
@@ -10353,20 +10710,22 @@ var ImageEditor = ({
|
|
|
10353
10710
|
const handleFileSelection = (0, import_react52.useCallback)((acceptedFiles) => {
|
|
10354
10711
|
if (acceptedFiles.length === 0) return;
|
|
10355
10712
|
const file = acceptedFiles[0];
|
|
10356
|
-
if (!
|
|
10357
|
-
|
|
10358
|
-
|
|
10359
|
-
|
|
10360
|
-
|
|
10361
|
-
|
|
10362
|
-
|
|
10713
|
+
if (!acceptAnyFile) {
|
|
10714
|
+
if (!file.type.startsWith("image/")) {
|
|
10715
|
+
import_toast2.toast.error({ message: "Please select an image file" });
|
|
10716
|
+
return;
|
|
10717
|
+
}
|
|
10718
|
+
if (file.size > 10 * 1024 * 1024) {
|
|
10719
|
+
import_toast2.toast.error({ message: "File size must be less than 10MB" });
|
|
10720
|
+
return;
|
|
10721
|
+
}
|
|
10363
10722
|
}
|
|
10364
10723
|
revokePreviewUrl();
|
|
10365
10724
|
setSelectedFile(file);
|
|
10366
10725
|
const url = URL.createObjectURL(file);
|
|
10367
10726
|
previewUrlRef.current = url;
|
|
10368
10727
|
setPreviewUrl(url);
|
|
10369
|
-
}, [revokePreviewUrl]);
|
|
10728
|
+
}, [revokePreviewUrl, acceptAnyFile]);
|
|
10370
10729
|
const handleDragEnter = (0, import_react52.useCallback)((e) => {
|
|
10371
10730
|
e.preventDefault();
|
|
10372
10731
|
e.stopPropagation();
|
|
@@ -10401,7 +10760,7 @@ var ImageEditor = ({
|
|
|
10401
10760
|
const committedId = committedRecordIdRef.current ?? recordId;
|
|
10402
10761
|
if (committedRecordIdRef.current != null) {
|
|
10403
10762
|
try {
|
|
10404
|
-
import_toast2.toast.info({ message:
|
|
10763
|
+
import_toast2.toast.info({ message: `Uploading ${noun}...` });
|
|
10405
10764
|
setUploadState("uploading");
|
|
10406
10765
|
const uploadResult = await executeFieldUpload(
|
|
10407
10766
|
tableName,
|
|
@@ -10417,7 +10776,7 @@ var ImageEditor = ({
|
|
|
10417
10776
|
resetFileState();
|
|
10418
10777
|
setImageValue(normalized);
|
|
10419
10778
|
onDraftUploadComplete?.();
|
|
10420
|
-
import_toast2.toast.success({ message:
|
|
10779
|
+
import_toast2.toast.success({ message: `${Noun} uploaded successfully` });
|
|
10421
10780
|
onFinishedEditing();
|
|
10422
10781
|
} catch (error) {
|
|
10423
10782
|
onDraftUploadComplete?.();
|
|
@@ -10437,7 +10796,7 @@ var ImageEditor = ({
|
|
|
10437
10796
|
const result = await onSubmitDraft();
|
|
10438
10797
|
if (!result.createdRow?.id) throw new Error("Failed to create row");
|
|
10439
10798
|
committedRecordIdRef.current = result.createdRow.id;
|
|
10440
|
-
import_toast2.toast.info({ message:
|
|
10799
|
+
import_toast2.toast.info({ message: `Uploading ${noun}...` });
|
|
10441
10800
|
setUploadState("uploading");
|
|
10442
10801
|
const uploadResult = await executeFieldUpload(
|
|
10443
10802
|
tableName,
|
|
@@ -10453,7 +10812,7 @@ var ImageEditor = ({
|
|
|
10453
10812
|
resetFileState();
|
|
10454
10813
|
setImageValue(normalized);
|
|
10455
10814
|
onDraftUploadComplete?.();
|
|
10456
|
-
import_toast2.toast.success({ message:
|
|
10815
|
+
import_toast2.toast.success({ message: `Row created and ${noun} uploaded` });
|
|
10457
10816
|
onFinishedEditing();
|
|
10458
10817
|
} catch (error) {
|
|
10459
10818
|
onDraftUploadComplete?.();
|
|
@@ -10468,7 +10827,7 @@ var ImageEditor = ({
|
|
|
10468
10827
|
}
|
|
10469
10828
|
setUploadState("uploading");
|
|
10470
10829
|
uploadMutation.mutate(selectedFile);
|
|
10471
|
-
}, [selectedFile, uploadMutation, tableName, fieldName, recordId, isDraftRow2, onSubmitDraft, config.endpoint, config.onAuthError, getToken, resetFileState, onDraftUploadComplete, onFinishedEditing]);
|
|
10830
|
+
}, [selectedFile, uploadMutation, tableName, fieldName, recordId, isDraftRow2, onSubmitDraft, config.endpoint, config.onAuthError, getToken, resetFileState, onDraftUploadComplete, onFinishedEditing, noun, Noun]);
|
|
10472
10831
|
const handleSave = (0, import_react52.useCallback)(() => {
|
|
10473
10832
|
if (!imageValue) {
|
|
10474
10833
|
onFinishedEditing(null);
|
|
@@ -10493,12 +10852,13 @@ var ImageEditor = ({
|
|
|
10493
10852
|
handleSave();
|
|
10494
10853
|
}
|
|
10495
10854
|
}, [handleSave]);
|
|
10496
|
-
const
|
|
10855
|
+
const hasStoredFile = acceptAnyFile && !!imageUrl && !storedIsImage;
|
|
10856
|
+
const dropzoneKey = isBusy ? "busy" : previewUrl ? "preview" : hasImage ? "loaded" : hasStoredFile ? "file" : imageLoadFailed ? "broken" : "empty";
|
|
10497
10857
|
const renderDropzoneContent = () => {
|
|
10498
10858
|
if (isBusy) {
|
|
10499
10859
|
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..." :
|
|
10860
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react6.Loader2, { className: "mb-2 size-6 animate-spin" }),
|
|
10861
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "text-sm", children: isSubmittingDraft ? "Creating row..." : `Uploading ${noun}...` }),
|
|
10502
10862
|
isUploading && uploadProgress && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "mt-3 w-full max-w-xs", children: [
|
|
10503
10863
|
/* @__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
10864
|
"div",
|
|
@@ -10515,8 +10875,9 @@ var ImageEditor = ({
|
|
|
10515
10875
|
] });
|
|
10516
10876
|
}
|
|
10517
10877
|
if (previewUrl) {
|
|
10878
|
+
const selectedIsImage = !acceptAnyFile || (selectedFile?.type.startsWith("image/") ?? false);
|
|
10518
10879
|
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 || "
|
|
10880
|
+
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
10881
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RemoveButton, { onClick: removeFile, label: "Remove selected file" })
|
|
10521
10882
|
] });
|
|
10522
10883
|
}
|
|
@@ -10535,6 +10896,12 @@ var ImageEditor = ({
|
|
|
10535
10896
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RemoveButton, { onClick: handleRemoveImage, label: "Remove image" })
|
|
10536
10897
|
] });
|
|
10537
10898
|
}
|
|
10899
|
+
if (hasStoredFile) {
|
|
10900
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "relative w-full", style: { height: "13rem" }, children: [
|
|
10901
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(FilePreview, { name: imageMetadata?.filename, size: imageMetadata?.size, mime: imageMetadata?.mime }),
|
|
10902
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(RemoveButton, { onClick: handleRemoveImage, label: "Remove file" })
|
|
10903
|
+
] });
|
|
10904
|
+
}
|
|
10538
10905
|
if (imageLoadFailed) {
|
|
10539
10906
|
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
10907
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
@@ -10542,7 +10909,7 @@ var ImageEditor = ({
|
|
|
10542
10909
|
{
|
|
10543
10910
|
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
10911
|
"aria-hidden": "true",
|
|
10545
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
10912
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react6.ImageOff, { className: "size-4 text-amber-500/50" })
|
|
10546
10913
|
}
|
|
10547
10914
|
),
|
|
10548
10915
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "text-sm font-medium", children: "Image unavailable" }),
|
|
@@ -10565,7 +10932,7 @@ var ImageEditor = ({
|
|
|
10565
10932
|
openFileDialog();
|
|
10566
10933
|
},
|
|
10567
10934
|
children: [
|
|
10568
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
10935
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react6.UploadIcon, { className: "-ms-0.5 opacity-60", "aria-hidden": "true" }),
|
|
10569
10936
|
"Replace"
|
|
10570
10937
|
]
|
|
10571
10938
|
}
|
|
@@ -10587,9 +10954,13 @@ var ImageEditor = ({
|
|
|
10587
10954
|
] });
|
|
10588
10955
|
}
|
|
10589
10956
|
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
|
-
|
|
10957
|
+
/* @__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" }) }),
|
|
10958
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("p", { className: "text-sm font-medium", children: [
|
|
10959
|
+
"Drop ",
|
|
10960
|
+
noun,
|
|
10961
|
+
" here or browse"
|
|
10962
|
+
] }),
|
|
10963
|
+
/* @__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
10964
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
10594
10965
|
import_button10.Button,
|
|
10595
10966
|
{
|
|
@@ -10602,8 +10973,9 @@ var ImageEditor = ({
|
|
|
10602
10973
|
},
|
|
10603
10974
|
disabled: isBusy,
|
|
10604
10975
|
children: [
|
|
10605
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
10606
|
-
"Select
|
|
10976
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react6.UploadIcon, { className: "-ms-0.5 opacity-60", "aria-hidden": "true" }),
|
|
10977
|
+
"Select ",
|
|
10978
|
+
noun
|
|
10607
10979
|
]
|
|
10608
10980
|
}
|
|
10609
10981
|
)
|
|
@@ -10618,17 +10990,17 @@ var ImageEditor = ({
|
|
|
10618
10990
|
style: overlayMaxHeight > 0 ? { maxHeight: overlayMaxHeight } : void 0,
|
|
10619
10991
|
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { onKeyDown: handleEditorKeyDown, className: "flex min-h-0 flex-1 flex-col", children: [
|
|
10620
10992
|
/* @__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 ?
|
|
10993
|
+
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" }),
|
|
10994
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("h3", { className: "text-sm font-medium", children: imageUrl ? `Edit ${Noun}` : `Add ${Noun}` })
|
|
10623
10995
|
] }),
|
|
10624
10996
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
10625
10997
|
"input",
|
|
10626
10998
|
{
|
|
10627
10999
|
ref: fileInputRef,
|
|
10628
11000
|
type: "file",
|
|
10629
|
-
accept: "image/*",
|
|
11001
|
+
accept: acceptAnyFile ? void 0 : "image/*",
|
|
10630
11002
|
className: "hidden",
|
|
10631
|
-
"aria-label":
|
|
11003
|
+
"aria-label": `Upload ${noun}`,
|
|
10632
11004
|
tabIndex: -1,
|
|
10633
11005
|
onChange: (e) => {
|
|
10634
11006
|
const files = Array.from(e.target.files || []);
|
|
@@ -10664,7 +11036,7 @@ var ImageEditor = ({
|
|
|
10664
11036
|
}
|
|
10665
11037
|
),
|
|
10666
11038
|
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)(
|
|
11039
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react6.AlertCircleIcon, { className: "size-3 shrink-0" }),
|
|
10668
11040
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { children: dragErrors[0] })
|
|
10669
11041
|
] }),
|
|
10670
11042
|
!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 +11060,7 @@ var ImageEditor = ({
|
|
|
10688
11060
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex shrink-0 justify-end gap-2 border-t px-6 py-3", children: [
|
|
10689
11061
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_button10.Button, { type: "button", variant: "outline", size: "sm", onClick: handleCancel, disabled: isBusy, children: "Cancel" }),
|
|
10690
11062
|
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)(
|
|
11063
|
+
isBusy && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react6.Loader2, { className: "size-3.5 animate-spin" }),
|
|
10692
11064
|
saveLabel
|
|
10693
11065
|
] })
|
|
10694
11066
|
] })
|
|
@@ -10702,6 +11074,7 @@ var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
|
10702
11074
|
var DRAFT_PREFIX = "draft:";
|
|
10703
11075
|
function ImageEditorDom({
|
|
10704
11076
|
value,
|
|
11077
|
+
cell,
|
|
10705
11078
|
colKey,
|
|
10706
11079
|
rowId,
|
|
10707
11080
|
tableName,
|
|
@@ -10711,6 +11084,8 @@ function ImageEditorDom({
|
|
|
10711
11084
|
onInvalidateData
|
|
10712
11085
|
}) {
|
|
10713
11086
|
const isDraftRow2 = rowId.startsWith(DRAFT_PREFIX);
|
|
11087
|
+
const cellType = cell.meta?.cellType;
|
|
11088
|
+
const acceptAnyFile = cellType != null && cellType !== "image";
|
|
10714
11089
|
const handleSaveComplete = onCommitPatch ? (saveData) => onCommitPatch({ [colKey]: saveData.imageData }) : void 0;
|
|
10715
11090
|
const handleSubmitDraft = isDraftRow2 && onSubmitDraftRow ? async () => {
|
|
10716
11091
|
const createdRow = await onSubmitDraftRow(rowId);
|
|
@@ -10720,6 +11095,7 @@ function ImageEditorDom({
|
|
|
10720
11095
|
ImageEditor,
|
|
10721
11096
|
{
|
|
10722
11097
|
value,
|
|
11098
|
+
acceptAnyFile,
|
|
10723
11099
|
onFinishedEditing: () => onCancel(),
|
|
10724
11100
|
tableName,
|
|
10725
11101
|
fieldName: colKey,
|
|
@@ -10889,7 +11265,7 @@ function InetEditorDom({ value, onCommit, onCancel }) {
|
|
|
10889
11265
|
|
|
10890
11266
|
// src/grid/editors/interval-editor.tsx
|
|
10891
11267
|
var import_react56 = require("react");
|
|
10892
|
-
var
|
|
11268
|
+
var import_lucide_react7 = require("lucide-react");
|
|
10893
11269
|
var import_button12 = require("@constructive-io/ui/button");
|
|
10894
11270
|
var import_input2 = require("@constructive-io/ui/input");
|
|
10895
11271
|
var import_label = require("@constructive-io/ui/label");
|
|
@@ -10965,7 +11341,7 @@ var IntervalEditor = ({ value, onFinishedEditing }) => {
|
|
|
10965
11341
|
const previewText = formatIntervalValue(editingValue);
|
|
10966
11342
|
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
11343
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
10968
|
-
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
11344
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_lucide_react7.Clock, { className: "text-muted-foreground h-4 w-4" }),
|
|
10969
11345
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("h3", { className: "text-sm font-medium", children: "Edit Time Interval" })
|
|
10970
11346
|
] }),
|
|
10971
11347
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "grid grid-cols-2 gap-3", children: [
|
|
@@ -11039,11 +11415,11 @@ var IntervalEditor = ({ value, onFinishedEditing }) => {
|
|
|
11039
11415
|
] }),
|
|
11040
11416
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "flex justify-end gap-2", children: [
|
|
11041
11417
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_button12.Button, { variant: "outline", size: "sm", onClick: handleCancel, children: [
|
|
11042
|
-
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
11418
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_lucide_react7.X, { className: "mr-1 h-3 w-3" }),
|
|
11043
11419
|
"Cancel"
|
|
11044
11420
|
] }),
|
|
11045
11421
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_button12.Button, { size: "sm", onClick: handleSave, children: [
|
|
11046
|
-
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
11422
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_lucide_react7.Check, { className: "mr-1 h-3 w-3" }),
|
|
11047
11423
|
"Save"
|
|
11048
11424
|
] })
|
|
11049
11425
|
] })
|
|
@@ -11310,15 +11686,15 @@ NumberEditorDom.commitsOnBlur = true;
|
|
|
11310
11686
|
|
|
11311
11687
|
// src/grid/editors/relation-editor.tsx
|
|
11312
11688
|
var import_react62 = require("react");
|
|
11313
|
-
var
|
|
11689
|
+
var import_lucide_react8 = require("lucide-react");
|
|
11314
11690
|
var import_react_query8 = require("@tanstack/react-query");
|
|
11315
11691
|
|
|
11316
11692
|
// src/hooks/use-sheets-table-cursor.ts
|
|
11317
11693
|
var import_react59 = require("react");
|
|
11318
11694
|
var import_react_query7 = require("@tanstack/react-query");
|
|
11319
|
-
var import_data18 = require("@constructive-io/data");
|
|
11320
11695
|
var import_data19 = require("@constructive-io/data");
|
|
11321
11696
|
var import_data20 = require("@constructive-io/data");
|
|
11697
|
+
var import_data21 = require("@constructive-io/data");
|
|
11322
11698
|
function useSheetsTableCursor(tableName, options = {}) {
|
|
11323
11699
|
const queryClient = (0, import_react_query7.useQueryClient)();
|
|
11324
11700
|
const { execute, scopeKey } = useSheetsContext();
|
|
@@ -11326,7 +11702,7 @@ function useSheetsTableCursor(tableName, options = {}) {
|
|
|
11326
11702
|
const adapter = useSheetsAdapter();
|
|
11327
11703
|
const tables = (0, import_react59.useMemo)(() => {
|
|
11328
11704
|
if (!meta?._meta?.tables) return [];
|
|
11329
|
-
return meta._meta.tables.filter((candidate) => candidate != null).map((metaTable) => (0,
|
|
11705
|
+
return meta._meta.tables.filter((candidate) => candidate != null).map((metaTable) => (0, import_data19.cleanTable)(metaTable));
|
|
11330
11706
|
}, [meta]);
|
|
11331
11707
|
const table = (0, import_react59.useMemo)(
|
|
11332
11708
|
() => tables.find((candidate) => candidate.name === tableName) ?? null,
|
|
@@ -11358,7 +11734,7 @@ function useSheetsTableCursor(tableName, options = {}) {
|
|
|
11358
11734
|
queryKey: sheetsQueryKeys.cursorTable(scopeKey, tableName, stableOptions),
|
|
11359
11735
|
queryFn: async ({ pageParam }) => {
|
|
11360
11736
|
if (!table) {
|
|
11361
|
-
throw
|
|
11737
|
+
throw import_data20.createError.notFound(`Table '${tableName}' not found`);
|
|
11362
11738
|
}
|
|
11363
11739
|
const cursor = pageParam;
|
|
11364
11740
|
const variableOptions = {
|
|
@@ -11381,7 +11757,7 @@ function useSheetsTableCursor(tableName, options = {}) {
|
|
|
11381
11757
|
const validatedOrderByEnum = new Set(variables.orderBy ?? []);
|
|
11382
11758
|
const availableOrderByFields = new Set(table.fields.map((field) => field.name));
|
|
11383
11759
|
const validatedOrderBy = orderBy?.filter(
|
|
11384
|
-
({ field, direction }) => availableOrderByFields.has(field) && validatedOrderByEnum.has((0,
|
|
11760
|
+
({ field, direction }) => availableOrderByFields.has(field) && validatedOrderByEnum.has((0, import_data21.toOrderByEnumValue)(field, direction))
|
|
11385
11761
|
);
|
|
11386
11762
|
const res = await adapter.listRows(
|
|
11387
11763
|
{ table, allTables: tables, tableName },
|
|
@@ -11879,7 +12255,7 @@ var RelationEditor = ({
|
|
|
11879
12255
|
className: `bg-popover flex ${OVERLAY.md} flex-col gap-4 rounded-lg border p-4 shadow-lg`,
|
|
11880
12256
|
children: [
|
|
11881
12257
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
11882
|
-
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
12258
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_lucide_react8.Link, { className: "text-muted-foreground h-4 w-4" }),
|
|
11883
12259
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h3", { className: "text-sm font-medium", children: canPersist ? "Edit Relations" : "Related Records" }),
|
|
11884
12260
|
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
12261
|
] }),
|
|
@@ -11902,7 +12278,7 @@ var RelationEditor = ({
|
|
|
11902
12278
|
onClick: () => handleRemoveRelation(index),
|
|
11903
12279
|
disabled: !canPersist,
|
|
11904
12280
|
className: "text-muted-foreground hover:text-destructive h-6 w-6 shrink-0 p-0",
|
|
11905
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
12281
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_lucide_react8.X, { className: "h-3 w-3" })
|
|
11906
12282
|
}
|
|
11907
12283
|
)
|
|
11908
12284
|
] }, index);
|
|
@@ -11919,7 +12295,7 @@ var RelationEditor = ({
|
|
|
11919
12295
|
] })
|
|
11920
12296
|
] }),
|
|
11921
12297
|
/* @__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)(
|
|
12298
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_input_group2.InputGroupAddon, { children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_lucide_react8.Search, {}) }),
|
|
11923
12299
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
11924
12300
|
import_input_group2.InputGroupInput,
|
|
11925
12301
|
{
|
|
@@ -11964,23 +12340,23 @@ var RelationEditor = ({
|
|
|
11964
12340
|
children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
11965
12341
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(RelationRecordTooltip, { record: row }),
|
|
11966
12342
|
/* @__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)(
|
|
12343
|
+
active3 && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_lucide_react8.Check, { className: "text-primary h-3.5 w-3.5 shrink-0" }),
|
|
11968
12344
|
/* @__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
12345
|
] })
|
|
11970
12346
|
},
|
|
11971
12347
|
id
|
|
11972
12348
|
);
|
|
11973
12349
|
}),
|
|
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)(
|
|
12350
|
+
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
12351
|
] }) })
|
|
11976
12352
|
] }),
|
|
11977
12353
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex justify-end gap-2", children: [
|
|
11978
12354
|
/* @__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)(
|
|
12355
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_lucide_react8.X, { className: "mr-1 h-3 w-3" }),
|
|
11980
12356
|
canPersist ? "Cancel" : "Close"
|
|
11981
12357
|
] }),
|
|
11982
12358
|
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)(
|
|
12359
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_lucide_react8.Check, { className: "mr-1 h-3 w-3" }),
|
|
11984
12360
|
"Save"
|
|
11985
12361
|
] })
|
|
11986
12362
|
] })
|
|
@@ -12085,7 +12461,7 @@ TextEditor.commitsOnBlur = true;
|
|
|
12085
12461
|
|
|
12086
12462
|
// src/grid/editors/tsvector-editor.tsx
|
|
12087
12463
|
var import_react64 = require("react");
|
|
12088
|
-
var
|
|
12464
|
+
var import_lucide_react9 = require("lucide-react");
|
|
12089
12465
|
init_cn();
|
|
12090
12466
|
var import_button17 = require("@constructive-io/ui/button");
|
|
12091
12467
|
var import_label3 = require("@constructive-io/ui/label");
|
|
@@ -12119,7 +12495,7 @@ var TsvectorEditor = ({ value, onFinishedEditing }) => {
|
|
|
12119
12495
|
const handleClose = (0, import_react64.useCallback)(() => onFinishedEditing(), [onFinishedEditing]);
|
|
12120
12496
|
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
12497
|
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
12122
|
-
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
12498
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_lucide_react9.Search, { className: "text-muted-foreground h-4 w-4" }),
|
|
12123
12499
|
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("h3", { className: "text-sm font-medium", children: "View Text Search Vector" })
|
|
12124
12500
|
] }),
|
|
12125
12501
|
parsedTokens.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "space-y-2", children: [
|
|
@@ -12142,14 +12518,14 @@ var TsvectorEditor = ({ value, onFinishedEditing }) => {
|
|
|
12142
12518
|
/* @__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
12519
|
] }),
|
|
12144
12520
|
/* @__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)(
|
|
12521
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_lucide_react9.Info, { className: "mt-0.5 h-3 w-3 flex-shrink-0" }),
|
|
12146
12522
|
/* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { children: [
|
|
12147
12523
|
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { children: "Values are generated server-side from your full-text configuration." }),
|
|
12148
12524
|
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { className: "mt-1", children: "Weights: A (highest), B, C, D (lowest)." })
|
|
12149
12525
|
] })
|
|
12150
12526
|
] }),
|
|
12151
12527
|
/* @__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)(
|
|
12528
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_lucide_react9.X, { className: "mr-1 h-3 w-3" }),
|
|
12153
12529
|
"Close"
|
|
12154
12530
|
] }) })
|
|
12155
12531
|
] });
|
|
@@ -12163,7 +12539,7 @@ function TsvectorEditorDom({ value, onCancel }) {
|
|
|
12163
12539
|
|
|
12164
12540
|
// src/grid/editors/url-editor.tsx
|
|
12165
12541
|
var import_react65 = require("react");
|
|
12166
|
-
var
|
|
12542
|
+
var import_lucide_react10 = require("lucide-react");
|
|
12167
12543
|
init_cn();
|
|
12168
12544
|
var import_button18 = require("@constructive-io/ui/button");
|
|
12169
12545
|
var import_input3 = require("@constructive-io/ui/input");
|
|
@@ -12236,7 +12612,7 @@ var UrlEditor = ({ value, onFinishedEditing }) => {
|
|
|
12236
12612
|
const displayText = editingValue.trim() ? displayUrl(editingValue.trim()) : "";
|
|
12237
12613
|
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
12614
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
12239
|
-
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
12615
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_lucide_react10.Link, { className: "text-muted-foreground h-4 w-4" }),
|
|
12240
12616
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("h3", { className: "text-sm font-medium", children: "Edit URL" })
|
|
12241
12617
|
] }),
|
|
12242
12618
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "space-y-2", children: [
|
|
@@ -12258,7 +12634,7 @@ var UrlEditor = ({ value, onFinishedEditing }) => {
|
|
|
12258
12634
|
editingValue.trim() && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "space-y-2", children: [
|
|
12259
12635
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_label4.Label, { className: "text-muted-foreground text-xs", children: "Preview" }),
|
|
12260
12636
|
/* @__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)(
|
|
12637
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_lucide_react10.Link, { className: "text-muted-foreground h-3 w-3 flex-shrink-0" }),
|
|
12262
12638
|
isValid ? /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [
|
|
12263
12639
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "text-primary truncate", children: displayText }),
|
|
12264
12640
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
@@ -12269,7 +12645,7 @@ var UrlEditor = ({ value, onFinishedEditing }) => {
|
|
|
12269
12645
|
onClick: handleTestUrl,
|
|
12270
12646
|
className: "text-muted-foreground hover:text-primary h-6 w-6 p-0",
|
|
12271
12647
|
title: "Test URL",
|
|
12272
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
12648
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_lucide_react10.ExternalLink, { className: "h-3 w-3" })
|
|
12273
12649
|
}
|
|
12274
12650
|
)
|
|
12275
12651
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "text-destructive truncate", children: editingValue })
|
|
@@ -12285,11 +12661,11 @@ var UrlEditor = ({ value, onFinishedEditing }) => {
|
|
|
12285
12661
|
] }),
|
|
12286
12662
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { className: "flex justify-end gap-2", children: [
|
|
12287
12663
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_button18.Button, { variant: "outline", size: "sm", onClick: handleCancel, children: [
|
|
12288
|
-
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
12664
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_lucide_react10.X, { className: "mr-1 h-3 w-3" }),
|
|
12289
12665
|
"Cancel"
|
|
12290
12666
|
] }),
|
|
12291
12667
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_button18.Button, { size: "sm", onClick: handleSave, disabled: !!validationError, children: [
|
|
12292
|
-
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
12668
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_lucide_react10.Check, { className: "mr-1 h-3 w-3" }),
|
|
12293
12669
|
"Save"
|
|
12294
12670
|
] })
|
|
12295
12671
|
] })
|
|
@@ -13712,7 +14088,7 @@ function tokensFromCssVars(el = typeof document !== "undefined" ? document.docum
|
|
|
13712
14088
|
// src/grid/sheets.table-selector.tsx
|
|
13713
14089
|
var import_react68 = require("react");
|
|
13714
14090
|
var import_react69 = require("@remixicon/react");
|
|
13715
|
-
var
|
|
14091
|
+
var import_lucide_react11 = require("lucide-react");
|
|
13716
14092
|
var import_react70 = require("motion/react");
|
|
13717
14093
|
init_cn();
|
|
13718
14094
|
var import_button20 = require("@constructive-io/ui/button");
|
|
@@ -13941,7 +14317,7 @@ function SheetsTableListByCategory({
|
|
|
13941
14317
|
animate: { rotate: isExpanded ? 90 : 0 },
|
|
13942
14318
|
transition: { type: "spring", stiffness: 400, damping: 25 },
|
|
13943
14319
|
className: "flex shrink-0 items-center justify-center",
|
|
13944
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
14320
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_lucide_react11.ChevronRight, { className: "text-muted-foreground/60 h-3.5 w-3.5" })
|
|
13945
14321
|
}
|
|
13946
14322
|
),
|
|
13947
14323
|
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "text-muted-foreground text-xs font-medium", children: title }),
|
|
@@ -14861,7 +15237,7 @@ var import_button22 = require("@constructive-io/ui/button");
|
|
|
14861
15237
|
var import_checkbox3 = require("@constructive-io/ui/checkbox");
|
|
14862
15238
|
|
|
14863
15239
|
// src/auth/ui/auth-error-alert.tsx
|
|
14864
|
-
var
|
|
15240
|
+
var import_lucide_react12 = require("lucide-react");
|
|
14865
15241
|
init_cn();
|
|
14866
15242
|
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
14867
15243
|
function AuthErrorAlert({ error, className }) {
|
|
@@ -14888,7 +15264,7 @@ function AuthErrorAlert({ error, className }) {
|
|
|
14888
15264
|
hasError ? "opacity-100" : "opacity-0"
|
|
14889
15265
|
),
|
|
14890
15266
|
children: [
|
|
14891
|
-
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
15267
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_lucide_react12.AlertCircleIcon, { className: "mt-0.5 h-4 w-4 shrink-0" }),
|
|
14892
15268
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("span", { className: "text-pretty leading-snug", children: error })
|
|
14893
15269
|
]
|
|
14894
15270
|
}
|
|
@@ -14898,7 +15274,7 @@ function AuthErrorAlert({ error, className }) {
|
|
|
14898
15274
|
}
|
|
14899
15275
|
|
|
14900
15276
|
// src/auth/ui/auth-loading-button.tsx
|
|
14901
|
-
var
|
|
15277
|
+
var import_lucide_react13 = require("lucide-react");
|
|
14902
15278
|
init_cn();
|
|
14903
15279
|
var import_button21 = require("@constructive-io/ui/button");
|
|
14904
15280
|
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
@@ -14911,7 +15287,7 @@ function AuthLoadingButton({
|
|
|
14911
15287
|
...props
|
|
14912
15288
|
}) {
|
|
14913
15289
|
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)(
|
|
15290
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_lucide_react13.LoaderIcon, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
14915
15291
|
isLoading ? loadingText : children
|
|
14916
15292
|
] });
|
|
14917
15293
|
}
|
|
@@ -15237,7 +15613,7 @@ function SheetsRegisterForm({ onRegister, onShowLogin, defaultEmail = "" }) {
|
|
|
15237
15613
|
// src/auth/ui/forgot-password-form.tsx
|
|
15238
15614
|
var import_react73 = require("react");
|
|
15239
15615
|
var import_react_form3 = require("@tanstack/react-form");
|
|
15240
|
-
var
|
|
15616
|
+
var import_lucide_react14 = require("lucide-react");
|
|
15241
15617
|
var import_button24 = require("@constructive-io/ui/button");
|
|
15242
15618
|
|
|
15243
15619
|
// src/auth/ui/auth-screen-header.tsx
|
|
@@ -15302,7 +15678,7 @@ function SheetsForgotPasswordForm({ onForgotPassword, onShowLogin }) {
|
|
|
15302
15678
|
});
|
|
15303
15679
|
if (isSuccess) {
|
|
15304
15680
|
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)(
|
|
15681
|
+
/* @__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
15682
|
/* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: "space-y-1.5", children: [
|
|
15307
15683
|
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("h3", { className: "text-lg font-semibold", children: "Check your email" }),
|
|
15308
15684
|
/* @__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 +15755,7 @@ function SheetsForgotPasswordForm({ onForgotPassword, onShowLogin }) {
|
|
|
15379
15755
|
// src/auth/ui/reset-password-form.tsx
|
|
15380
15756
|
var React18 = __toESM(require("react"), 1);
|
|
15381
15757
|
var import_react_form4 = require("@tanstack/react-form");
|
|
15382
|
-
var
|
|
15758
|
+
var import_lucide_react15 = require("lucide-react");
|
|
15383
15759
|
var import_button25 = require("@constructive-io/ui/button");
|
|
15384
15760
|
|
|
15385
15761
|
// src/auth/utils/validators.ts
|
|
@@ -15478,7 +15854,7 @@ function SheetsResetPasswordForm({
|
|
|
15478
15854
|
});
|
|
15479
15855
|
if (isSuccess) {
|
|
15480
15856
|
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)(
|
|
15857
|
+
/* @__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
15858
|
/* @__PURE__ */ (0, import_jsx_runtime62.jsxs)("div", { className: "space-y-1.5", children: [
|
|
15483
15859
|
/* @__PURE__ */ (0, import_jsx_runtime62.jsx)("h3", { className: "text-lg font-semibold", children: "Password reset successful" }),
|
|
15484
15860
|
/* @__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." })
|