@constructive-io/sheets 0.3.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -24
- package/dist/advanced.cjs +659 -474
- package/dist/advanced.cjs.map +1 -1
- package/dist/advanced.d.cts +9 -10
- package/dist/advanced.d.ts +9 -10
- package/dist/advanced.js +3 -3
- package/dist/auth.cjs +10 -10
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +5 -4
- package/dist/auth.d.ts +5 -4
- package/dist/auth.js +3 -3
- package/dist/{chunk-GLVZSPV2.js → chunk-4EZ6A23C.js} +4 -3
- package/dist/chunk-4EZ6A23C.js.map +1 -0
- package/dist/{chunk-FNVHSOQQ.js → chunk-KKAWMVEG.js} +11 -11
- package/dist/chunk-KKAWMVEG.js.map +1 -0
- package/dist/{chunk-4PGPVMZB.js → chunk-KOZAW264.js} +4 -3
- package/dist/chunk-KOZAW264.js.map +1 -0
- package/dist/{chunk-ODUBS2NL.js → chunk-KVPVEXWB.js} +40 -17
- package/dist/chunk-KVPVEXWB.js.map +1 -0
- package/dist/{chunk-TU7ATZ4X.js → chunk-LR64FLWO.js} +301 -410
- package/dist/chunk-LR64FLWO.js.map +1 -0
- package/dist/chunk-ZETPUEXH.js +494 -0
- package/dist/chunk-ZETPUEXH.js.map +1 -0
- package/dist/{date-editor-CXKKGNL6.js → date-editor-QT47WY5T.js} +5 -3
- package/dist/date-editor-QT47WY5T.js.map +1 -0
- package/dist/{editor-props-M6Dh0P9f.d.ts → grid-cell-types-C3ARj148.d.cts} +70 -62
- package/dist/{editor-props-M6Dh0P9f.d.cts → grid-cell-types-C3ARj148.d.ts} +70 -62
- package/dist/index.cjs +1150 -703
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +123 -35
- package/dist/index.d.ts +123 -35
- package/dist/index.js +323 -99
- package/dist/index.js.map +1 -1
- package/dist/{sheets-context-CojEFlaY.d.cts → sheets-context-B03WDhZ9.d.cts} +36 -6
- package/dist/{sheets-context-Da55TTR9.d.ts → sheets-context-DmVCOgiX.d.ts} +36 -6
- package/dist/styles.css +6 -0
- package/dist/testing.cjs +476 -108
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +11 -7
- package/dist/testing.d.ts +11 -7
- package/dist/testing.js +34 -8
- package/dist/testing.js.map +1 -1
- package/package.json +15 -16
- package/dist/chunk-4PGPVMZB.js.map +0 -1
- package/dist/chunk-FNVHSOQQ.js.map +0 -1
- package/dist/chunk-GLVZSPV2.js.map +0 -1
- package/dist/chunk-H4JJTMP5.js +0 -160
- package/dist/chunk-H4JJTMP5.js.map +0 -1
- package/dist/chunk-ODUBS2NL.js.map +0 -1
- package/dist/chunk-TU7ATZ4X.js.map +0 -1
- package/dist/date-editor-CXKKGNL6.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -2,13 +2,19 @@
|
|
|
2
2
|
import {
|
|
3
3
|
DOM_EDITOR_REGISTRY,
|
|
4
4
|
OverlayMeasureContext,
|
|
5
|
+
canRunSheetsMutation,
|
|
5
6
|
computeOverlayGeometry,
|
|
6
7
|
createPostGraphileAdapter,
|
|
7
8
|
createSheetsCell,
|
|
8
9
|
executeFieldUpload,
|
|
9
|
-
|
|
10
|
+
getImageMetadata,
|
|
11
|
+
getSheetsWriteCapability,
|
|
10
12
|
resolveRelationFieldMap,
|
|
11
|
-
|
|
13
|
+
resolveSheetsIdentifier,
|
|
14
|
+
resolveSheetsRowIdentity,
|
|
15
|
+
sheetsIdentifierCacheKey,
|
|
16
|
+
sheetsIdentifierToWhere,
|
|
17
|
+
sheetsRowKey,
|
|
12
18
|
sheetsTableQueryKeys,
|
|
13
19
|
transformToPostGraphileVariables,
|
|
14
20
|
useSheetsAdapter,
|
|
@@ -18,23 +24,26 @@ import {
|
|
|
18
24
|
useSheetsTable,
|
|
19
25
|
useSheetsTableCursor,
|
|
20
26
|
validateOrderByVariables
|
|
21
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-LR64FLWO.js";
|
|
22
28
|
import {
|
|
23
29
|
SheetsAuthGate,
|
|
24
30
|
useSheetsForgotPassword,
|
|
25
31
|
useSheetsLogin,
|
|
26
32
|
useSheetsRegister,
|
|
27
33
|
useSheetsResetPassword
|
|
28
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-KKAWMVEG.js";
|
|
29
35
|
import {
|
|
30
36
|
SheetsProvider
|
|
31
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-KVPVEXWB.js";
|
|
32
38
|
import {
|
|
33
39
|
DataError,
|
|
34
40
|
createSheetsExecute,
|
|
35
|
-
createSheetsUpload
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
createSheetsUpload,
|
|
42
|
+
isSheetsScopeKey,
|
|
43
|
+
resolveDownloadUrl,
|
|
44
|
+
sheetsQueryKeys
|
|
45
|
+
} from "./chunk-ZETPUEXH.js";
|
|
46
|
+
import "./chunk-4EZ6A23C.js";
|
|
38
47
|
import {
|
|
39
48
|
SheetsContext,
|
|
40
49
|
buildRelationInfoFromMeta,
|
|
@@ -45,7 +54,7 @@ import {
|
|
|
45
54
|
useSheetsContext,
|
|
46
55
|
useSheetsStore,
|
|
47
56
|
useSheetsStoreApi
|
|
48
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-KOZAW264.js";
|
|
49
58
|
import {
|
|
50
59
|
BOOLEAN_TYPES,
|
|
51
60
|
BUILTIN_EDITOR_TYPES,
|
|
@@ -493,7 +502,9 @@ function SheetsControls(props) {
|
|
|
493
502
|
gridSelection,
|
|
494
503
|
deleteSelected,
|
|
495
504
|
onAddRow,
|
|
496
|
-
onExport
|
|
505
|
+
onExport,
|
|
506
|
+
canDelete = true,
|
|
507
|
+
readOnlyReason
|
|
497
508
|
} = props;
|
|
498
509
|
const filterableColumns = useMemo(() => {
|
|
499
510
|
if (Object.keys(fieldTypeMap).length === 0) return columnKeys;
|
|
@@ -528,7 +539,16 @@ function SheetsControls(props) {
|
|
|
528
539
|
"data-part-id": "sheets-controls",
|
|
529
540
|
className: "flex shrink-0 flex-wrap items-center justify-between gap-4 py-4",
|
|
530
541
|
children: [
|
|
531
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
542
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-2", children: [
|
|
543
|
+
readOnlyReason && /* @__PURE__ */ jsx(
|
|
544
|
+
"span",
|
|
545
|
+
{
|
|
546
|
+
className: "border-border bg-muted text-muted-foreground inline-flex h-8 items-center rounded-md border px-2.5 text-xs",
|
|
547
|
+
role: "status",
|
|
548
|
+
title: readOnlyReason,
|
|
549
|
+
children: "Read-only"
|
|
550
|
+
}
|
|
551
|
+
),
|
|
532
552
|
/* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", onClick: () => openSearch?.(), children: [
|
|
533
553
|
/* @__PURE__ */ jsx(RiSearch2Line, { className: "text-muted-foreground/60 -ms-1.5 size-5", "aria-hidden": "true" }),
|
|
534
554
|
"Search"
|
|
@@ -550,11 +570,20 @@ function SheetsControls(props) {
|
|
|
550
570
|
] }),
|
|
551
571
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
552
572
|
showSelection && /* @__PURE__ */ jsxs(AlertDialog, { children: [
|
|
553
|
-
/* @__PURE__ */ jsx(AlertDialogTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
573
|
+
/* @__PURE__ */ jsx(AlertDialogTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
574
|
+
Button,
|
|
575
|
+
{
|
|
576
|
+
variant: "destructive-outline",
|
|
577
|
+
size: "sm",
|
|
578
|
+
disabled: !canDelete || selectedRowCount === 0,
|
|
579
|
+
title: !canDelete ? readOnlyReason ?? "Delete is unavailable for this table." : void 0,
|
|
580
|
+
children: [
|
|
581
|
+
/* @__PURE__ */ jsx(RiDeleteBin6Line, { className: "-ms-1.5 size-5", "aria-hidden": "true" }),
|
|
582
|
+
"Delete",
|
|
583
|
+
selectedRowCount > 0 ? ` (${selectedRowCount})` : ""
|
|
584
|
+
]
|
|
585
|
+
}
|
|
586
|
+
) }),
|
|
558
587
|
/* @__PURE__ */ jsxs(AlertDialogContent, { children: [
|
|
559
588
|
/* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
|
|
560
589
|
/* @__PURE__ */ jsx(AlertDialogTitle, { children: "Delete rows?" }),
|
|
@@ -664,7 +693,9 @@ function buildContextMenuItems({
|
|
|
664
693
|
isEnabled,
|
|
665
694
|
onAddRow,
|
|
666
695
|
requestDelete,
|
|
667
|
-
selectedRowCount
|
|
696
|
+
selectedRowCount,
|
|
697
|
+
canAddRows = true,
|
|
698
|
+
canDeleteRows = true
|
|
668
699
|
}) {
|
|
669
700
|
const cmd = (key2, commandId, label, icon, shortcut) => ({
|
|
670
701
|
key: key2,
|
|
@@ -684,6 +715,7 @@ function buildContextMenuItems({
|
|
|
684
715
|
key: "add-row",
|
|
685
716
|
label: "Add row",
|
|
686
717
|
icon: /* @__PURE__ */ jsx2(RiAddLine2, { className: "size-4", "aria-hidden": "true" }),
|
|
718
|
+
disabled: !canAddRows,
|
|
687
719
|
run: onAddRow
|
|
688
720
|
},
|
|
689
721
|
{
|
|
@@ -691,7 +723,7 @@ function buildContextMenuItems({
|
|
|
691
723
|
label: selectedRowCount > 1 ? `Delete ${selectedRowCount} rows` : "Delete row",
|
|
692
724
|
icon: /* @__PURE__ */ jsx2(RiDeleteBin6Line2, { className: "size-4", "aria-hidden": "true" }),
|
|
693
725
|
destructive: true,
|
|
694
|
-
disabled: selectedRowCount === 0,
|
|
726
|
+
disabled: !canDeleteRows || selectedRowCount === 0,
|
|
695
727
|
run: requestDelete
|
|
696
728
|
}
|
|
697
729
|
];
|
|
@@ -703,7 +735,9 @@ function SheetsContextMenu({
|
|
|
703
735
|
isEnabled,
|
|
704
736
|
onAddRow,
|
|
705
737
|
onDeleteRows,
|
|
706
|
-
selectedRowCount
|
|
738
|
+
selectedRowCount,
|
|
739
|
+
canAddRows = true,
|
|
740
|
+
canDeleteRows = true
|
|
707
741
|
}) {
|
|
708
742
|
const [confirmDelete, setConfirmDelete] = useState2(false);
|
|
709
743
|
const open = state !== null;
|
|
@@ -712,7 +746,9 @@ function SheetsContextMenu({
|
|
|
712
746
|
isEnabled,
|
|
713
747
|
onAddRow,
|
|
714
748
|
requestDelete: () => setConfirmDelete(true),
|
|
715
|
-
selectedRowCount
|
|
749
|
+
selectedRowCount,
|
|
750
|
+
canAddRows,
|
|
751
|
+
canDeleteRows
|
|
716
752
|
});
|
|
717
753
|
return /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
718
754
|
/* @__PURE__ */ jsxs2(DropdownMenu, { open, onOpenChange: (next) => !next && onClose(), children: [
|
|
@@ -1234,12 +1270,12 @@ function SheetsErrorState({ error, onRetry }) {
|
|
|
1234
1270
|
onRetry && /* @__PURE__ */ jsx6(Button3, { variant: "outline", size: "sm", onClick: onRetry, children: "Retry" })
|
|
1235
1271
|
] });
|
|
1236
1272
|
}
|
|
1237
|
-
function SheetsEmptyState({ tableName, onAddRow }) {
|
|
1273
|
+
function SheetsEmptyState({ tableName, onAddRow, readOnlyReason }) {
|
|
1238
1274
|
return /* @__PURE__ */ jsxs5(SheetsStateShell, { children: [
|
|
1239
1275
|
/* @__PURE__ */ jsx6(RiInboxLine, { className: "text-muted-foreground h-8 w-8" }),
|
|
1240
1276
|
/* @__PURE__ */ jsxs5("div", { className: "space-y-1", children: [
|
|
1241
1277
|
/* @__PURE__ */ jsx6("p", { className: "text-foreground text-sm font-medium", children: "No rows yet" }),
|
|
1242
|
-
/* @__PURE__ */ jsx6("p", { className: "text-muted-foreground max-w-md text-sm", children: tableName ? `The "${tableName}" table is empty.` : "This table is empty." })
|
|
1278
|
+
/* @__PURE__ */ jsx6("p", { className: "text-muted-foreground max-w-md text-sm", children: readOnlyReason ?? (tableName ? `The "${tableName}" table is empty.` : "This table is empty.") })
|
|
1243
1279
|
] }),
|
|
1244
1280
|
onAddRow && /* @__PURE__ */ jsxs5(Button3, { variant: "outline", size: "sm", onClick: onAddRow, children: [
|
|
1245
1281
|
/* @__PURE__ */ jsx6(RiAddLine3, { className: "h-4 w-4" }),
|
|
@@ -1477,6 +1513,8 @@ var CellRegistry = new CellRegistryClass();
|
|
|
1477
1513
|
// src/cell-types/type-mapping.ts
|
|
1478
1514
|
function mapToFrontendCellType(metadata) {
|
|
1479
1515
|
const { gqlType, isArray, pgAlias, pgType } = metadata;
|
|
1516
|
+
const encodedType = mapEncodingToCellType(metadata.encoding);
|
|
1517
|
+
if (encodedType) return encodedType;
|
|
1480
1518
|
if (pgAlias) {
|
|
1481
1519
|
const aliasType = mapAliasToCellType(pgAlias);
|
|
1482
1520
|
if (aliasType !== "unknown") return aliasType;
|
|
@@ -1492,6 +1530,38 @@ function mapToFrontendCellType(metadata) {
|
|
|
1492
1530
|
const fallbackResult = mapGraphQLTypeToCellType(gqlType, isArray, metadata.subtype, null);
|
|
1493
1531
|
return fallbackResult;
|
|
1494
1532
|
}
|
|
1533
|
+
function mapEncodingToCellType(encoding) {
|
|
1534
|
+
if (!encoding) return null;
|
|
1535
|
+
switch (encoding.kind) {
|
|
1536
|
+
case "bigint":
|
|
1537
|
+
return "integer";
|
|
1538
|
+
case "datetime":
|
|
1539
|
+
return "datetime";
|
|
1540
|
+
case "date":
|
|
1541
|
+
return "date";
|
|
1542
|
+
case "time":
|
|
1543
|
+
return "time";
|
|
1544
|
+
case "interval":
|
|
1545
|
+
return "interval";
|
|
1546
|
+
case "uuid":
|
|
1547
|
+
return "uuid";
|
|
1548
|
+
case "inet":
|
|
1549
|
+
return "inet";
|
|
1550
|
+
case "point":
|
|
1551
|
+
return "geometry-point";
|
|
1552
|
+
case "geojson":
|
|
1553
|
+
return encoding.geometrySubtype === "Point" ? "geometry-point" : "geometry";
|
|
1554
|
+
case "vector":
|
|
1555
|
+
return "number-array";
|
|
1556
|
+
case "composite":
|
|
1557
|
+
return "json";
|
|
1558
|
+
case "ltree":
|
|
1559
|
+
case "bytea":
|
|
1560
|
+
return "text";
|
|
1561
|
+
default:
|
|
1562
|
+
return null;
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1495
1565
|
function mapAliasToCellType(alias) {
|
|
1496
1566
|
const aliasMap = {
|
|
1497
1567
|
// Media types
|
|
@@ -1696,9 +1766,9 @@ function isStructuredDataType(cellType) {
|
|
|
1696
1766
|
}
|
|
1697
1767
|
function createColumnSchemaFromMeta(field) {
|
|
1698
1768
|
const { name, type } = field;
|
|
1699
|
-
const { gqlType, isArray,
|
|
1769
|
+
const { gqlType, isArray, subtype } = type;
|
|
1700
1770
|
const nullable = !gqlType.endsWith("!");
|
|
1701
|
-
const cellType =
|
|
1771
|
+
const cellType = mapToFrontendCellType(field.type);
|
|
1702
1772
|
const label = name.replace(/([A-Z])/g, " $1").replace(/^./, (str) => str.toUpperCase()).trim();
|
|
1703
1773
|
return {
|
|
1704
1774
|
id: name,
|
|
@@ -2498,6 +2568,9 @@ var DRAFT_ACTION_COLUMN_KEY = "__draft_action__";
|
|
|
2498
2568
|
|
|
2499
2569
|
// src/grid/hooks/use-cell-editing.ts
|
|
2500
2570
|
import { useCallback as useCallback7 } from "react";
|
|
2571
|
+
function legacyRowIdentifier(row) {
|
|
2572
|
+
return typeof row.id === "string" || typeof row.id === "number" ? row.id : null;
|
|
2573
|
+
}
|
|
2501
2574
|
function normalizeRelationPatchValue(rawValue, relationKind) {
|
|
2502
2575
|
let value = rawValue;
|
|
2503
2576
|
if (typeof value === "string") {
|
|
@@ -2521,8 +2594,9 @@ function normalizeRelationPatchValue(rawValue, relationKind) {
|
|
|
2521
2594
|
if (value === "") value = null;
|
|
2522
2595
|
return value;
|
|
2523
2596
|
}
|
|
2524
|
-
function resolveServerPatch(colKey, rawValue, fieldMetaMap, relationInfoByField) {
|
|
2597
|
+
function resolveServerPatch(colKey, rawValue, fieldMetaMap, relationInfoByField, readOnlyFields) {
|
|
2525
2598
|
if (!colKey || colKey === DRAFT_ACTION_COLUMN_KEY) return { kind: "noop" };
|
|
2599
|
+
if (readOnlyFields?.has(colKey)) return { kind: "noop" };
|
|
2526
2600
|
const metaField = fieldMetaMap.get(colKey);
|
|
2527
2601
|
if (colKey === "id" && metaField?.type?.gqlType === "UUID") return { kind: "noop" };
|
|
2528
2602
|
const relationInfo = relationInfoByField.get(colKey);
|
|
@@ -2544,6 +2618,9 @@ function useCellEditing({
|
|
|
2544
2618
|
updateDraftCell,
|
|
2545
2619
|
tableKey,
|
|
2546
2620
|
update,
|
|
2621
|
+
getRowIdentifier = legacyRowIdentifier,
|
|
2622
|
+
readOnlyFields,
|
|
2623
|
+
canUpdate = true,
|
|
2547
2624
|
onCellEdit,
|
|
2548
2625
|
applyOptimisticPatch
|
|
2549
2626
|
}) {
|
|
@@ -2610,18 +2687,21 @@ function useCellEditing({
|
|
|
2610
2687
|
});
|
|
2611
2688
|
return { type: "draft" };
|
|
2612
2689
|
}
|
|
2613
|
-
|
|
2690
|
+
if (!canUpdate) return { type: "noop" };
|
|
2691
|
+
const resolution = resolveServerPatch(colKey, rawValue, fieldMetaMap, relationInfoByField, readOnlyFields);
|
|
2614
2692
|
if (resolution.kind === "noop") return { type: "noop" };
|
|
2615
2693
|
const { field: patchField, value } = resolution;
|
|
2694
|
+
const rowIdentifier = getRowIdentifier(rowData);
|
|
2695
|
+
if (rowIdentifier === null) return { type: "noop" };
|
|
2616
2696
|
const revertOptimisticPatch = applyOptimisticPatch?.(rowIndex, { [patchField]: value });
|
|
2617
2697
|
let result;
|
|
2618
2698
|
try {
|
|
2619
|
-
result = await update(
|
|
2699
|
+
result = await update(rowIdentifier, { [patchField]: value });
|
|
2620
2700
|
} catch (error) {
|
|
2621
2701
|
revertOptimisticPatch?.();
|
|
2622
2702
|
throw error;
|
|
2623
2703
|
}
|
|
2624
|
-
onCellEdit?.(
|
|
2704
|
+
onCellEdit?.(rowIdentifier, patchField, value);
|
|
2625
2705
|
return {
|
|
2626
2706
|
type: "server",
|
|
2627
2707
|
updatedRow: result?.updatedRow ?? null,
|
|
@@ -2629,17 +2709,23 @@ function useCellEditing({
|
|
|
2629
2709
|
patchValue: value
|
|
2630
2710
|
};
|
|
2631
2711
|
},
|
|
2632
|
-
[combinedRows, fieldMetaMap, relationInfoByField, tableKey, update, onCellEdit, updateDraftCell, applyOptimisticPatch]
|
|
2712
|
+
[combinedRows, fieldMetaMap, relationInfoByField, tableKey, update, getRowIdentifier, readOnlyFields, canUpdate, onCellEdit, updateDraftCell, applyOptimisticPatch]
|
|
2633
2713
|
);
|
|
2634
2714
|
}
|
|
2635
2715
|
|
|
2636
2716
|
// src/grid/hooks/use-batch-commit.ts
|
|
2637
2717
|
import { useCallback as useCallback8, useRef as useRef2 } from "react";
|
|
2718
|
+
function legacyRowIdentifier2(row) {
|
|
2719
|
+
return typeof row.id === "string" || typeof row.id === "number" ? row.id : null;
|
|
2720
|
+
}
|
|
2638
2721
|
function useBatchCommit({
|
|
2639
2722
|
combinedRows,
|
|
2640
2723
|
fieldMetaMap,
|
|
2641
2724
|
relationInfoByField,
|
|
2642
2725
|
update,
|
|
2726
|
+
getRowIdentifier = legacyRowIdentifier2,
|
|
2727
|
+
readOnlyFields,
|
|
2728
|
+
canUpdate = true,
|
|
2643
2729
|
applyOptimisticPatch,
|
|
2644
2730
|
resyncRow,
|
|
2645
2731
|
editCell,
|
|
@@ -2659,11 +2745,14 @@ function useBatchCommit({
|
|
|
2659
2745
|
draftWrites.push(w);
|
|
2660
2746
|
continue;
|
|
2661
2747
|
}
|
|
2662
|
-
|
|
2748
|
+
if (!canUpdate) continue;
|
|
2749
|
+
const resolution = resolveServerPatch(w.colKey, w.value, fieldMetaMap, relationInfoByField, readOnlyFields);
|
|
2663
2750
|
if (resolution.kind === "noop") continue;
|
|
2751
|
+
const rowIdentifier = getRowIdentifier(rowData);
|
|
2752
|
+
if (rowIdentifier === null) continue;
|
|
2664
2753
|
resolved.push({
|
|
2665
2754
|
rowIndex: w.rowIndex,
|
|
2666
|
-
rowId:
|
|
2755
|
+
rowId: rowIdentifier,
|
|
2667
2756
|
field: resolution.field,
|
|
2668
2757
|
value: resolution.value,
|
|
2669
2758
|
// Capture the PRIOR value of the patched field BEFORE any optimistic patch.
|
|
@@ -2718,7 +2807,7 @@ function useBatchCommit({
|
|
|
2718
2807
|
}
|
|
2719
2808
|
return { applied: resolved.length };
|
|
2720
2809
|
},
|
|
2721
|
-
[combinedRows, fieldMetaMap, relationInfoByField, update, applyOptimisticPatch, resyncRow, editCell, onCellEdit, record]
|
|
2810
|
+
[combinedRows, fieldMetaMap, relationInfoByField, update, getRowIdentifier, readOnlyFields, canUpdate, applyOptimisticPatch, resyncRow, editCell, onCellEdit, record]
|
|
2722
2811
|
);
|
|
2723
2812
|
commitRef.current = commitCells;
|
|
2724
2813
|
return commitCells;
|
|
@@ -3090,11 +3179,24 @@ function tagDraftStyle(cell, hasError) {
|
|
|
3090
3179
|
return { ...cell, styleHint: { ...cell.styleHint, draft: true, error: hasError } };
|
|
3091
3180
|
}
|
|
3092
3181
|
function useSheetsContent(args) {
|
|
3093
|
-
const {
|
|
3182
|
+
const {
|
|
3183
|
+
data,
|
|
3184
|
+
columnKeys,
|
|
3185
|
+
fieldMetaMap,
|
|
3186
|
+
registry,
|
|
3187
|
+
tableName,
|
|
3188
|
+
options,
|
|
3189
|
+
relationInfoByField,
|
|
3190
|
+
meta,
|
|
3191
|
+
serverRowsReadOnly = false,
|
|
3192
|
+
serverReadOnlyFields,
|
|
3193
|
+
getRowIdentifier,
|
|
3194
|
+
supportsScalarSelfCommit = true
|
|
3195
|
+
} = args;
|
|
3094
3196
|
const relationFieldNamesFromMeta = useMemo7(() => buildRelationFieldNameSet(meta, tableName), [meta, tableName]);
|
|
3095
3197
|
const cache2 = useMemo7(
|
|
3096
3198
|
() => /* @__PURE__ */ new Map(),
|
|
3097
|
-
[data, columnKeys, fieldMetaMap, registry, relationFieldNamesFromMeta, relationInfoByField, options]
|
|
3199
|
+
[data, columnKeys, fieldMetaMap, registry, relationFieldNamesFromMeta, relationInfoByField, options, serverRowsReadOnly, serverReadOnlyFields, getRowIdentifier, supportsScalarSelfCommit]
|
|
3098
3200
|
);
|
|
3099
3201
|
const getSheetsCell = useCallback11(
|
|
3100
3202
|
(rowIndex, colKey) => {
|
|
@@ -3136,6 +3238,7 @@ function useSheetsContent(args) {
|
|
|
3136
3238
|
isDraftIdCell,
|
|
3137
3239
|
hasForeignKeyField: canEditRelationInline
|
|
3138
3240
|
});
|
|
3241
|
+
const tableForcedReadOnly = !isDraftRow2 && (serverRowsReadOnly || Boolean(serverReadOnlyFields?.has(colKey)));
|
|
3139
3242
|
let valueForCell = rawValue;
|
|
3140
3243
|
if (relationInfo && relationInfo.relationField && relationInfo.relationField !== colKey) {
|
|
3141
3244
|
const relatedValue = rowData?.[relationInfo.relationField];
|
|
@@ -3163,17 +3266,22 @@ function useSheetsContent(args) {
|
|
|
3163
3266
|
fieldName: colKey
|
|
3164
3267
|
};
|
|
3165
3268
|
const cellType = registry.resolveTypeKey(matchInput, () => route.cellType);
|
|
3269
|
+
const rowIdentifier = !isDraftRow2 ? getRowIdentifier?.(rowData) : null;
|
|
3270
|
+
const selfCommittingEditor = isRelation || MEDIA_TYPES.has(cellType);
|
|
3271
|
+
const lacksScalarEditorIdentity = selfCommittingEditor && (!supportsScalarSelfCommit || rowIdentifier != null && typeof rowIdentifier === "object");
|
|
3272
|
+
const forcedReadOnly = tableForcedReadOnly || lacksScalarEditorIdentity;
|
|
3166
3273
|
const metadata = {
|
|
3167
3274
|
cellType,
|
|
3168
3275
|
fieldName: colKey,
|
|
3169
3276
|
fieldMeta,
|
|
3170
3277
|
relationInfo,
|
|
3171
3278
|
relationOptions: relationInfo ? options || {} : void 0,
|
|
3172
|
-
canEdit: route.canEdit,
|
|
3173
|
-
isReadonly: route.isReadonly,
|
|
3279
|
+
canEdit: route.canEdit && !forcedReadOnly,
|
|
3280
|
+
isReadonly: route.isReadonly || forcedReadOnly,
|
|
3174
3281
|
activationBehavior: route.activationBehavior
|
|
3175
3282
|
};
|
|
3176
|
-
const
|
|
3283
|
+
const resolvedCell = registry.toSheetsCell(cellType, valueForCell, { metadata });
|
|
3284
|
+
const cell = forcedReadOnly && !resolvedCell.readonly ? { ...resolvedCell, readonly: true } : resolvedCell;
|
|
3177
3285
|
const displaySafe = suppressDraftIdText(cell, {
|
|
3178
3286
|
isDraftRow: isDraftRow2,
|
|
3179
3287
|
colKey,
|
|
@@ -3188,7 +3296,7 @@ function useSheetsContent(args) {
|
|
|
3188
3296
|
cache2.set(cacheKey, { value: rawValue, resolution });
|
|
3189
3297
|
return resolution;
|
|
3190
3298
|
},
|
|
3191
|
-
[data, columnKeys, fieldMetaMap, registry, relationFieldNamesFromMeta, relationInfoByField, options]
|
|
3299
|
+
[data, columnKeys, fieldMetaMap, registry, relationFieldNamesFromMeta, relationInfoByField, options, serverRowsReadOnly, serverReadOnlyFields, getRowIdentifier, supportsScalarSelfCommit]
|
|
3192
3300
|
);
|
|
3193
3301
|
return { getSheetsCell };
|
|
3194
3302
|
}
|
|
@@ -3244,13 +3352,18 @@ function useGridOperations(data, deleteRow, gridSelection, clearSelection, optio
|
|
|
3244
3352
|
} else {
|
|
3245
3353
|
failures += 1;
|
|
3246
3354
|
}
|
|
3247
|
-
} else if (
|
|
3355
|
+
} else if (options?.canDeleteServerRows !== false) {
|
|
3356
|
+
const identifier = options?.getRowIdentifier ? options.getRowIdentifier(record) : typeof record?.id === "string" || typeof record?.id === "number" ? record.id : null;
|
|
3357
|
+
if (identifier === null) {
|
|
3358
|
+
failures += 1;
|
|
3359
|
+
continue;
|
|
3360
|
+
}
|
|
3248
3361
|
try {
|
|
3249
|
-
await deleteRow(
|
|
3362
|
+
await deleteRow(identifier);
|
|
3250
3363
|
successes += 1;
|
|
3251
3364
|
serverSuccesses += 1;
|
|
3252
3365
|
} catch (error) {
|
|
3253
|
-
sheetsLogger().error(
|
|
3366
|
+
sheetsLogger().error("Failed to delete record", { identifier, error });
|
|
3254
3367
|
failures += 1;
|
|
3255
3368
|
}
|
|
3256
3369
|
} else {
|
|
@@ -4126,6 +4239,7 @@ function useInfiniteGridData({
|
|
|
4126
4239
|
|
|
4127
4240
|
// src/grid/hooks/use-load-grid.ts
|
|
4128
4241
|
import { useMemo as useMemo12 } from "react";
|
|
4242
|
+
import { assessTableWriteCapability, getRowIdentityDefinition } from "@constructive-io/data";
|
|
4129
4243
|
function buildFieldMetaMap2(fields, tableName, fieldTypeOverrides) {
|
|
4130
4244
|
const map = /* @__PURE__ */ new Map();
|
|
4131
4245
|
if (!fields || fields.length === 0) return map;
|
|
@@ -4159,6 +4273,10 @@ function useDataLoading({
|
|
|
4159
4273
|
return candidate ?? null;
|
|
4160
4274
|
}, [meta, tableName]);
|
|
4161
4275
|
const tableSchema = useMemo12(() => buildTableSchema(tableMeta), [tableMeta]);
|
|
4276
|
+
const writeCapability = useMemo12(
|
|
4277
|
+
() => tableMeta ? assessTableWriteCapability(tableMeta) : null,
|
|
4278
|
+
[tableMeta]
|
|
4279
|
+
);
|
|
4162
4280
|
const fieldMetaMap = useMemo12(() => {
|
|
4163
4281
|
const candidate = meta?._meta?.tables?.find((t) => t?.name === tableName);
|
|
4164
4282
|
const fields = candidate?.fields || [];
|
|
@@ -4194,8 +4312,12 @@ function useDataLoading({
|
|
|
4194
4312
|
const create = async (payload) => {
|
|
4195
4313
|
const result = await createRow(payload);
|
|
4196
4314
|
const createdRow = result?.createdRow;
|
|
4197
|
-
if (!createdRow || typeof createdRow
|
|
4198
|
-
|
|
4315
|
+
if (!createdRow || typeof createdRow !== "object" || !tableMeta) {
|
|
4316
|
+
throw new Error(`Create mutation for '${tableName}' did not return a row identity.`);
|
|
4317
|
+
}
|
|
4318
|
+
const identity = resolveSheetsRowIdentity(tableMeta, createdRow);
|
|
4319
|
+
if (identity.status !== "identified") {
|
|
4320
|
+
throw new Error(`Create mutation for '${tableName}' returned an incomplete primary-key identity.`);
|
|
4199
4321
|
}
|
|
4200
4322
|
return { createdRow };
|
|
4201
4323
|
};
|
|
@@ -4215,6 +4337,7 @@ function useDataLoading({
|
|
|
4215
4337
|
refetch,
|
|
4216
4338
|
meta,
|
|
4217
4339
|
tableMeta,
|
|
4340
|
+
writeCapability,
|
|
4218
4341
|
tableSchema,
|
|
4219
4342
|
fieldMetaMap,
|
|
4220
4343
|
allRelationFields
|
|
@@ -4231,6 +4354,7 @@ function useDataLoading({
|
|
|
4231
4354
|
refetch,
|
|
4232
4355
|
meta,
|
|
4233
4356
|
tableMeta,
|
|
4357
|
+
writeCapability,
|
|
4234
4358
|
tableSchema,
|
|
4235
4359
|
fieldMetaMap,
|
|
4236
4360
|
allRelationFields
|
|
@@ -4248,7 +4372,8 @@ function buildTableSchema(metaTable) {
|
|
|
4248
4372
|
if (!field) continue;
|
|
4249
4373
|
columns.push(createColumnSchemaFromMeta(field));
|
|
4250
4374
|
}
|
|
4251
|
-
const
|
|
4375
|
+
const identity = getRowIdentityDefinition(metaTable);
|
|
4376
|
+
const primaryKeyFields = identity.status === "keyed" ? identity.fields.map((field) => field.fieldName) : [];
|
|
4252
4377
|
const inflection = metaTable.inflection;
|
|
4253
4378
|
const metadata = {
|
|
4254
4379
|
label: metaTable.name ?? void 0,
|
|
@@ -4385,6 +4510,33 @@ function useSheets(props) {
|
|
|
4385
4510
|
isInitialLoading: ctx.isLoading && rows.length === 0
|
|
4386
4511
|
};
|
|
4387
4512
|
}, [infiniteScroll, infiniteGridData, dataLoadingResult.contextValue]);
|
|
4513
|
+
const writeCapability = useMemo13(() => getSheetsWriteCapability(tableMeta), [tableMeta]);
|
|
4514
|
+
const canCreate = canRunSheetsMutation(writeCapability, "create");
|
|
4515
|
+
const canUpdate = canRunSheetsMutation(writeCapability, "update");
|
|
4516
|
+
const canDelete = canRunSheetsMutation(writeCapability, "delete");
|
|
4517
|
+
const primaryKeyFields = useMemo13(
|
|
4518
|
+
() => new Set(writeCapability?.status === "mutable" ? writeCapability.primaryKeyFields : []),
|
|
4519
|
+
[writeCapability]
|
|
4520
|
+
);
|
|
4521
|
+
const supportsScalarSelfCommit = writeCapability?.status === "mutable" && writeCapability.primaryKeyFields.length === 1 && writeCapability.primaryKeyFields[0] === "id";
|
|
4522
|
+
const readOnlyReason = writeCapability?.status === "read-only" ? "This table is read-only because it has no primary key." : null;
|
|
4523
|
+
const getRowIdentifier = useCallback16(
|
|
4524
|
+
(row) => {
|
|
4525
|
+
if (!tableMeta) return null;
|
|
4526
|
+
const resolution = resolveSheetsRowIdentity(tableMeta, row);
|
|
4527
|
+
return resolution.status === "identified" ? resolution.identifier : null;
|
|
4528
|
+
},
|
|
4529
|
+
[tableMeta]
|
|
4530
|
+
);
|
|
4531
|
+
const getRowId = useCallback16(
|
|
4532
|
+
(row, index) => {
|
|
4533
|
+
const draftMeta = getDraftMeta(row);
|
|
4534
|
+
if (draftMeta) return draftMeta.draftRowId;
|
|
4535
|
+
if (row && tableMeta) return sheetsRowKey(tableMeta, row, index);
|
|
4536
|
+
return `${tableMeta?.schemaName ?? ""}:${tableName}:row:${index}`;
|
|
4537
|
+
},
|
|
4538
|
+
[tableMeta, tableName]
|
|
4539
|
+
);
|
|
4388
4540
|
const lastLoadEmitRef = useRef5(null);
|
|
4389
4541
|
useEffect4(() => {
|
|
4390
4542
|
if (dataError) {
|
|
@@ -4535,7 +4687,11 @@ function useSheets(props) {
|
|
|
4535
4687
|
tableName,
|
|
4536
4688
|
options: { relationChipLimit, relationLabelMaxLength },
|
|
4537
4689
|
relationInfoByField,
|
|
4538
|
-
meta: filterMeta
|
|
4690
|
+
meta: filterMeta,
|
|
4691
|
+
serverRowsReadOnly: !canUpdate,
|
|
4692
|
+
serverReadOnlyFields: primaryKeyFields,
|
|
4693
|
+
getRowIdentifier,
|
|
4694
|
+
supportsScalarSelfCommit
|
|
4539
4695
|
});
|
|
4540
4696
|
const effectiveColumnOrder = useMemo13(() => {
|
|
4541
4697
|
if (columnKeys.length > 0) return columnKeys;
|
|
@@ -4597,9 +4753,11 @@ function useSheets(props) {
|
|
|
4597
4753
|
const gridOpsOptions = useMemo13(
|
|
4598
4754
|
() => ({
|
|
4599
4755
|
onRemoveDraftRow: (draftRowId) => removeDraftRow(tableKey, draftRowId),
|
|
4756
|
+
getRowIdentifier,
|
|
4757
|
+
canDeleteServerRows: canDelete,
|
|
4600
4758
|
feedback: operationFeedback
|
|
4601
4759
|
}),
|
|
4602
|
-
[removeDraftRow, tableKey, operationFeedback]
|
|
4760
|
+
[removeDraftRow, tableKey, getRowIdentifier, canDelete, operationFeedback]
|
|
4603
4761
|
);
|
|
4604
4762
|
const { deleteSelected: baseDeleteSelected } = useGridOperations(
|
|
4605
4763
|
combinedRows,
|
|
@@ -4641,6 +4799,9 @@ function useSheets(props) {
|
|
|
4641
4799
|
updateDraftCell,
|
|
4642
4800
|
tableKey,
|
|
4643
4801
|
update,
|
|
4802
|
+
getRowIdentifier,
|
|
4803
|
+
readOnlyFields: primaryKeyFields,
|
|
4804
|
+
canUpdate,
|
|
4644
4805
|
onCellEdit,
|
|
4645
4806
|
applyOptimisticPatch: applyOptimisticCellPatch
|
|
4646
4807
|
});
|
|
@@ -4658,6 +4819,9 @@ function useSheets(props) {
|
|
|
4658
4819
|
fieldMetaMap,
|
|
4659
4820
|
relationInfoByField,
|
|
4660
4821
|
update,
|
|
4822
|
+
getRowIdentifier,
|
|
4823
|
+
readOnlyFields: primaryKeyFields,
|
|
4824
|
+
canUpdate,
|
|
4661
4825
|
applyOptimisticPatch: applyOptimisticCellPatch,
|
|
4662
4826
|
resyncRow,
|
|
4663
4827
|
editCell,
|
|
@@ -4695,6 +4859,7 @@ function useSheets(props) {
|
|
|
4695
4859
|
if (infiniteScroll) infiniteGridData.invalidate();
|
|
4696
4860
|
}, [infiniteScroll, infiniteGridData]);
|
|
4697
4861
|
const handleRowAppended = useCallback16(async () => {
|
|
4862
|
+
if (!canCreate) return void 0;
|
|
4698
4863
|
if (draftRows.length > 0) {
|
|
4699
4864
|
return serverRowCount + draftRows.length - 1;
|
|
4700
4865
|
}
|
|
@@ -4718,6 +4883,7 @@ function useSheets(props) {
|
|
|
4718
4883
|
tableKey,
|
|
4719
4884
|
draftRows,
|
|
4720
4885
|
serverRowCount,
|
|
4886
|
+
canCreate,
|
|
4721
4887
|
emit
|
|
4722
4888
|
]);
|
|
4723
4889
|
const { selectedRowCount, selectedDraftRowEntries, hasDraftSelection } = useGridSelectionState({
|
|
@@ -4863,6 +5029,11 @@ function useSheets(props) {
|
|
|
4863
5029
|
resizeColumn: gridActions.resizeColumn,
|
|
4864
5030
|
frozenCount,
|
|
4865
5031
|
selectedRowCount,
|
|
5032
|
+
canCreate,
|
|
5033
|
+
canUpdate,
|
|
5034
|
+
canDelete,
|
|
5035
|
+
readOnlyReason,
|
|
5036
|
+
getRowId,
|
|
4866
5037
|
isSubmittingDrafts,
|
|
4867
5038
|
submitDraftButtonDisabled,
|
|
4868
5039
|
submitDraftLabel,
|
|
@@ -5584,6 +5755,9 @@ function GeometryCellView(props) {
|
|
|
5584
5755
|
);
|
|
5585
5756
|
}
|
|
5586
5757
|
|
|
5758
|
+
// src/cell-model/views/image-view.tsx
|
|
5759
|
+
import { FileIcon } from "lucide-react";
|
|
5760
|
+
|
|
5587
5761
|
// src/cell-model/image-cache.ts
|
|
5588
5762
|
var CAP = 256;
|
|
5589
5763
|
var cache = /* @__PURE__ */ new Map();
|
|
@@ -5607,13 +5781,39 @@ function warmImage(url) {
|
|
|
5607
5781
|
}
|
|
5608
5782
|
|
|
5609
5783
|
// src/cell-model/views/image-view.tsx
|
|
5610
|
-
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
5784
|
+
import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
5611
5785
|
function readUrl(data) {
|
|
5612
5786
|
if (Array.isArray(data) && typeof data[0] === "string") return data[0];
|
|
5613
5787
|
return "";
|
|
5614
5788
|
}
|
|
5789
|
+
function basename(url) {
|
|
5790
|
+
const path = url.split(/[?#]/)[0];
|
|
5791
|
+
const seg = path.slice(path.lastIndexOf("/") + 1);
|
|
5792
|
+
return seg || url;
|
|
5793
|
+
}
|
|
5794
|
+
function isNonImageFile(cellType, value) {
|
|
5795
|
+
if (cellType === "image" || value == null) return false;
|
|
5796
|
+
const mime = getImageMetadata(value)?.mime;
|
|
5797
|
+
return !(mime && mime !== "unknown" && mime.startsWith("image/"));
|
|
5798
|
+
}
|
|
5615
5799
|
function ImageCellView(props) {
|
|
5616
5800
|
const url = readUrl(props.cell.data);
|
|
5801
|
+
if (url && isNonImageFile(props.column.cellType, props.value)) {
|
|
5802
|
+
const meta = getImageMetadata(props.value);
|
|
5803
|
+
const filename = meta?.filename && meta.filename !== "Unknown" ? meta.filename : basename(url);
|
|
5804
|
+
return /* @__PURE__ */ jsxs10(
|
|
5805
|
+
"div",
|
|
5806
|
+
{
|
|
5807
|
+
"data-slot": "file-cell",
|
|
5808
|
+
role: "gridcell",
|
|
5809
|
+
className: cn("flex h-full w-full items-center gap-1.5 overflow-hidden px-2"),
|
|
5810
|
+
children: [
|
|
5811
|
+
/* @__PURE__ */ jsx14(FileIcon, { className: "size-3.5 shrink-0 text-muted-foreground", "aria-hidden": "true" }),
|
|
5812
|
+
/* @__PURE__ */ jsx14("span", { className: "truncate text-sm", title: filename, children: filename })
|
|
5813
|
+
]
|
|
5814
|
+
}
|
|
5815
|
+
);
|
|
5816
|
+
}
|
|
5617
5817
|
return /* @__PURE__ */ jsx14(
|
|
5618
5818
|
"div",
|
|
5619
5819
|
{
|
|
@@ -5671,7 +5871,7 @@ function NumberCellView(props) {
|
|
|
5671
5871
|
}
|
|
5672
5872
|
|
|
5673
5873
|
// src/cell-model/views/relation-view.tsx
|
|
5674
|
-
import { jsx as jsx17, jsxs as
|
|
5874
|
+
import { jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
5675
5875
|
function getListRelationCount(chips) {
|
|
5676
5876
|
const last = chips[chips.length - 1];
|
|
5677
5877
|
if (typeof last === "string" && last.startsWith("+")) {
|
|
@@ -5696,7 +5896,7 @@ function RelationCellView(props) {
|
|
|
5696
5896
|
}
|
|
5697
5897
|
const chips = cell.data;
|
|
5698
5898
|
const count = getListRelationCount(chips);
|
|
5699
|
-
return /* @__PURE__ */
|
|
5899
|
+
return /* @__PURE__ */ jsxs11(
|
|
5700
5900
|
"div",
|
|
5701
5901
|
{
|
|
5702
5902
|
"data-slot": "relation-cell",
|
|
@@ -5779,7 +5979,7 @@ function parseNumeric(text) {
|
|
|
5779
5979
|
const n = Number(trimmed);
|
|
5780
5980
|
return Number.isFinite(n) ? { ok: true, value: n } : { ok: false, value: null };
|
|
5781
5981
|
}
|
|
5782
|
-
function InlineCellEditor({ value, initialText, numeric, onCommit, onCancel }) {
|
|
5982
|
+
function InlineCellEditor({ ariaLabel, value, initialText, numeric, onCommit, onCancel }) {
|
|
5783
5983
|
const [text, setText] = useState6(() => initialText != null ? initialText : seedText(value));
|
|
5784
5984
|
const inputRef = useRef7(null);
|
|
5785
5985
|
const gridRef = useRef7(null);
|
|
@@ -5823,6 +6023,7 @@ function InlineCellEditor({ value, initialText, numeric, onCommit, onCancel }) {
|
|
|
5823
6023
|
return /* @__PURE__ */ jsx20(
|
|
5824
6024
|
"input",
|
|
5825
6025
|
{
|
|
6026
|
+
"aria-label": ariaLabel,
|
|
5826
6027
|
ref: inputRef,
|
|
5827
6028
|
value: text,
|
|
5828
6029
|
onChange: (e) => setText(e.target.value),
|
|
@@ -5939,15 +6140,15 @@ var SheetsCellHostInner = memo2(
|
|
|
5939
6140
|
draftClasses,
|
|
5940
6141
|
props.className
|
|
5941
6142
|
),
|
|
5942
|
-
children: isDraftActionCell ? /* @__PURE__ */ jsx21(
|
|
6143
|
+
children: isDraftActionCell ? draftAction ? /* @__PURE__ */ jsx21(
|
|
5943
6144
|
DraftActionCellView,
|
|
5944
6145
|
{
|
|
5945
|
-
status: draftAction
|
|
5946
|
-
errored: draftAction
|
|
5947
|
-
disabled: draftAction
|
|
6146
|
+
status: draftAction.status,
|
|
6147
|
+
errored: draftAction.errored,
|
|
6148
|
+
disabled: draftAction.disabled,
|
|
5948
6149
|
onSubmit: submitDraft
|
|
5949
6150
|
}
|
|
5950
|
-
) : props.isEditing ? (
|
|
6151
|
+
) : null : props.isEditing ? (
|
|
5951
6152
|
// Inline (in-cell) edit for the simple text-representable types — a bare <input>
|
|
5952
6153
|
// overlaying the view. `isEditing` is set true ONLY for inline-edit intents (the
|
|
5953
6154
|
// shell short-circuits inline-toggle/overlay/none before here), so the cell kind is
|
|
@@ -5955,6 +6156,7 @@ var SheetsCellHostInner = memo2(
|
|
|
5955
6156
|
/* @__PURE__ */ jsx21(
|
|
5956
6157
|
InlineCellEditor,
|
|
5957
6158
|
{
|
|
6159
|
+
ariaLabel: `Edit ${props.resolution.fieldMeta?.name ?? props.colKey}`,
|
|
5958
6160
|
value: props.value,
|
|
5959
6161
|
initialText: props.inlineInitialText,
|
|
5960
6162
|
numeric: props.resolution.cell.kind === "number",
|
|
@@ -6045,7 +6247,7 @@ import { createPortal } from "react-dom";
|
|
|
6045
6247
|
|
|
6046
6248
|
// src/grid/feedback/editor-error-boundary.tsx
|
|
6047
6249
|
import { Component as Component2 } from "react";
|
|
6048
|
-
import { jsx as jsx22, jsxs as
|
|
6250
|
+
import { jsx as jsx22, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
6049
6251
|
var EditorErrorBoundary = class extends Component2 {
|
|
6050
6252
|
state = { error: null };
|
|
6051
6253
|
static getDerivedStateFromError(error) {
|
|
@@ -6059,7 +6261,7 @@ var EditorErrorBoundary = class extends Component2 {
|
|
|
6059
6261
|
if (this.state.error == null) {
|
|
6060
6262
|
return this.props.children;
|
|
6061
6263
|
}
|
|
6062
|
-
return /* @__PURE__ */
|
|
6264
|
+
return /* @__PURE__ */ jsxs12("div", { className: "bg-popover text-foreground flex flex-col gap-2 rounded-lg border p-3 text-sm shadow-lg", children: [
|
|
6063
6265
|
/* @__PURE__ */ jsx22("span", { className: "text-muted-foreground", children: "Editor failed to load/render" }),
|
|
6064
6266
|
/* @__PURE__ */ jsx22(
|
|
6065
6267
|
"button",
|
|
@@ -6828,7 +7030,7 @@ function resolveKeyCommand(event, keymap = DEFAULT_KEYMAP) {
|
|
|
6828
7030
|
}
|
|
6829
7031
|
|
|
6830
7032
|
// src/grid/sheets.tsx
|
|
6831
|
-
import { Fragment as Fragment3, jsx as jsx24, jsxs as
|
|
7033
|
+
import { Fragment as Fragment3, jsx as jsx24, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
6832
7034
|
var FALLBACK_PAGE_ROWS = 10;
|
|
6833
7035
|
var ESTIMATED_ROW_HEIGHT2 = 34;
|
|
6834
7036
|
function escapeCsvField(value) {
|
|
@@ -6872,10 +7074,6 @@ var Sheets = forwardRef(SheetsInnerComponent);
|
|
|
6872
7074
|
var EMPTY_OBJ = {};
|
|
6873
7075
|
var noop = () => {
|
|
6874
7076
|
};
|
|
6875
|
-
function rowIdAt(rows, index) {
|
|
6876
|
-
const id = rows[index]?.id;
|
|
6877
|
-
return id != null ? String(id) : String(index);
|
|
6878
|
-
}
|
|
6879
7077
|
var OVERLAY_MARGIN_PX = 12;
|
|
6880
7078
|
var OVERLAY_MIN_BELOW_PX = 320;
|
|
6881
7079
|
function SheetsDomInner({
|
|
@@ -6937,6 +7135,7 @@ function SheetsDomInner({
|
|
|
6937
7135
|
[columnSizing, resizeColumn]
|
|
6938
7136
|
);
|
|
6939
7137
|
const combinedRows = shell.combinedRows;
|
|
7138
|
+
const getRowId = shell.getRowId;
|
|
6940
7139
|
const selection = s.selection.gridSelection;
|
|
6941
7140
|
const setSelection = s.selection.setGridSelection;
|
|
6942
7141
|
const activeCell = selection?.current?.cell;
|
|
@@ -6944,15 +7143,15 @@ function SheetsDomInner({
|
|
|
6944
7143
|
if (!selection) return EMPTY_OBJ;
|
|
6945
7144
|
const map = {};
|
|
6946
7145
|
for (const index of selection.rows.toArray()) {
|
|
6947
|
-
map[
|
|
7146
|
+
map[getRowId(combinedRows[index], index)] = true;
|
|
6948
7147
|
}
|
|
6949
7148
|
return map;
|
|
6950
|
-
}, [selection, combinedRows]);
|
|
7149
|
+
}, [selection, combinedRows, getRowId]);
|
|
6951
7150
|
const onRowSelectionChange = useCallback19(
|
|
6952
7151
|
(updater) => {
|
|
6953
7152
|
const next = functionalUpdate(updater, rowSelection);
|
|
6954
7153
|
const indexById = /* @__PURE__ */ new Map();
|
|
6955
|
-
for (let i = 0; i < combinedRows.length; i++) indexById.set(
|
|
7154
|
+
for (let i = 0; i < combinedRows.length; i++) indexById.set(getRowId(combinedRows[i], i), i);
|
|
6956
7155
|
let rows = RangeSet.empty();
|
|
6957
7156
|
let lowest;
|
|
6958
7157
|
for (const id of Object.keys(next)) {
|
|
@@ -6968,7 +7167,7 @@ function SheetsDomInner({
|
|
|
6968
7167
|
}
|
|
6969
7168
|
setSelection({ current: { cell: [0, lowest] }, rows, columns: RangeSet.empty() });
|
|
6970
7169
|
},
|
|
6971
|
-
[rowSelection, combinedRows, setSelection]
|
|
7170
|
+
[rowSelection, combinedRows, getRowId, setSelection]
|
|
6972
7171
|
);
|
|
6973
7172
|
const table = useSheetsTableInstance({
|
|
6974
7173
|
columns,
|
|
@@ -6979,7 +7178,8 @@ function SheetsDomInner({
|
|
|
6979
7178
|
onColumnSizingChange,
|
|
6980
7179
|
// Pinning is shell-derived (frozenCount), never edited from the grid → no writer needed.
|
|
6981
7180
|
onColumnPinningChange: noop,
|
|
6982
|
-
onRowSelectionChange
|
|
7181
|
+
onRowSelectionChange,
|
|
7182
|
+
getRowId
|
|
6983
7183
|
});
|
|
6984
7184
|
const rowCount = combinedRows.length;
|
|
6985
7185
|
const shiftAnchorRef = useRef10(null);
|
|
@@ -7294,7 +7494,7 @@ function SheetsDomInner({
|
|
|
7294
7494
|
value: rowValue,
|
|
7295
7495
|
cell: resolution.cell,
|
|
7296
7496
|
colKey: active.colKey,
|
|
7297
|
-
rowId:
|
|
7497
|
+
rowId: getRowId(combinedRows[active.rowIndex], active.rowIndex),
|
|
7298
7498
|
rowIndex: active.rowIndex,
|
|
7299
7499
|
tableName: props.tableName,
|
|
7300
7500
|
fieldMeta: resolution.fieldMeta,
|
|
@@ -7393,15 +7593,16 @@ function SheetsDomInner({
|
|
|
7393
7593
|
SheetsEmptyState,
|
|
7394
7594
|
{
|
|
7395
7595
|
tableName,
|
|
7396
|
-
|
|
7596
|
+
readOnlyReason: shell.readOnlyReason,
|
|
7597
|
+
onAddRow: shell.canCreate ? () => {
|
|
7397
7598
|
void s.draft.appendRow();
|
|
7398
|
-
}
|
|
7599
|
+
} : void 0
|
|
7399
7600
|
}
|
|
7400
7601
|
);
|
|
7401
7602
|
}
|
|
7402
7603
|
const activeFilterCount = shell.filterTree ? countConditions(shell.filterTree) : 0;
|
|
7403
7604
|
const isFilteredEmpty = shell.serverRowCount === 0 && shell.draftRowCount === 0 && activeFilterCount > 0;
|
|
7404
|
-
return /* @__PURE__ */
|
|
7605
|
+
return /* @__PURE__ */ jsxs13(SheetsErrorBoundary, { onError: config.onError, children: [
|
|
7405
7606
|
/* @__PURE__ */ jsx24("div", { "data-part-id": "sheets-controls-container", children: slots?.toolbar ? /* @__PURE__ */ jsx24(Fragment3, { children: typeof slots.toolbar === "function" ? slots.toolbar({ tableName }) : slots.toolbar }) : /* @__PURE__ */ jsx24(
|
|
7406
7607
|
SheetsControls,
|
|
7407
7608
|
{
|
|
@@ -7417,11 +7618,13 @@ function SheetsDomInner({
|
|
|
7417
7618
|
gridSelection: s.selection.gridSelection ?? null,
|
|
7418
7619
|
setGridSelection: shell.setGridSelectionForControls,
|
|
7419
7620
|
deleteSelected: s.draft.deleteSelected,
|
|
7420
|
-
onAddRow: handleAddRow,
|
|
7621
|
+
onAddRow: shell.canCreate ? handleAddRow : void 0,
|
|
7622
|
+
canDelete: shell.canDelete,
|
|
7623
|
+
readOnlyReason: shell.readOnlyReason,
|
|
7421
7624
|
onExport: handleExport
|
|
7422
7625
|
}
|
|
7423
7626
|
) }),
|
|
7424
|
-
/* @__PURE__ */
|
|
7627
|
+
/* @__PURE__ */ jsxs13(
|
|
7425
7628
|
"div",
|
|
7426
7629
|
{
|
|
7427
7630
|
"data-part-id": "sheets-container",
|
|
@@ -7451,17 +7654,17 @@ function SheetsDomInner({
|
|
|
7451
7654
|
activeDescendantId: activeCell ? `sheets-cell-${activeCell[1]}-${activeCell[0]}` : void 0
|
|
7452
7655
|
}
|
|
7453
7656
|
),
|
|
7454
|
-
isFilteredEmpty && /* @__PURE__ */
|
|
7657
|
+
isFilteredEmpty && /* @__PURE__ */ jsxs13("div", { className: "bg-background/80 absolute inset-0 flex flex-col items-center justify-center gap-3 p-6 text-center", children: [
|
|
7455
7658
|
/* @__PURE__ */ jsx24(RiSearchEyeLine, { className: "text-muted-foreground h-8 w-8" }),
|
|
7456
|
-
/* @__PURE__ */
|
|
7659
|
+
/* @__PURE__ */ jsxs13("div", { className: "space-y-1", children: [
|
|
7457
7660
|
/* @__PURE__ */ jsx24("p", { className: "text-foreground text-sm font-medium", children: "No matching rows" }),
|
|
7458
|
-
/* @__PURE__ */
|
|
7661
|
+
/* @__PURE__ */ jsxs13("p", { className: "text-muted-foreground max-w-md text-sm", children: [
|
|
7459
7662
|
"No rows match the active ",
|
|
7460
7663
|
activeFilterCount === 1 ? "filter" : "filters",
|
|
7461
7664
|
"."
|
|
7462
7665
|
] })
|
|
7463
7666
|
] }),
|
|
7464
|
-
/* @__PURE__ */
|
|
7667
|
+
/* @__PURE__ */ jsxs13(Button6, { variant: "outline", size: "sm", onClick: shell.clearAllFilters, children: [
|
|
7465
7668
|
/* @__PURE__ */ jsx24(RiFilterOffLine, { className: "h-4 w-4" }),
|
|
7466
7669
|
/* @__PURE__ */ jsx24("span", { className: "ms-1", children: "Clear filters" })
|
|
7467
7670
|
] })
|
|
@@ -7500,7 +7703,9 @@ function SheetsDomInner({
|
|
|
7500
7703
|
isEnabled: isCommandEnabled,
|
|
7501
7704
|
onAddRow: handleAddRow,
|
|
7502
7705
|
onDeleteRows: s.draft.deleteSelected,
|
|
7503
|
-
selectedRowCount: selection?.rows.length ?? 0
|
|
7706
|
+
selectedRowCount: selection?.rows.length ?? 0,
|
|
7707
|
+
canAddRows: shell.canCreate,
|
|
7708
|
+
canDeleteRows: shell.canDelete
|
|
7504
7709
|
}
|
|
7505
7710
|
)
|
|
7506
7711
|
] });
|
|
@@ -7537,24 +7742,28 @@ import { Input as Input2 } from "@constructive-io/ui/input";
|
|
|
7537
7742
|
import { ProgressiveBlur } from "@constructive-io/ui/progressive-blur";
|
|
7538
7743
|
import { ScrollArea } from "@constructive-io/ui/scroll-area";
|
|
7539
7744
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@constructive-io/ui/tooltip";
|
|
7540
|
-
import { jsx as jsx25, jsxs as
|
|
7745
|
+
import { jsx as jsx25, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
7541
7746
|
var BLUR_HEIGHT_PERCENT = 0.28;
|
|
7542
7747
|
var BLUR_HEIGHT_MIN_PX = 64;
|
|
7543
7748
|
var BLUR_HEIGHT_MAX_PX = 140;
|
|
7544
7749
|
var TableItem = memo3(function TableItem2({ table, activeTable, onTableSelect, itemRef }) {
|
|
7545
7750
|
const isActive = activeTable === table.value;
|
|
7546
7751
|
return /* @__PURE__ */ jsx25(
|
|
7547
|
-
|
|
7752
|
+
Button7,
|
|
7548
7753
|
{
|
|
7549
7754
|
ref: isActive ? itemRef : void 0,
|
|
7755
|
+
"aria-pressed": isActive,
|
|
7550
7756
|
"data-testid": "table-item",
|
|
7757
|
+
static: true,
|
|
7758
|
+
size: "sm",
|
|
7759
|
+
type: "button",
|
|
7760
|
+
variant: "ghost",
|
|
7551
7761
|
className: cn(
|
|
7552
|
-
|
|
7553
|
-
duration-200`,
|
|
7762
|
+
"group relative my-1 flex h-8 w-full shrink items-center justify-between rounded-lg px-2 text-left text-xs font-normal transition-colors duration-150",
|
|
7554
7763
|
isActive ? "bg-primary/10 text-foreground ring-primary/30 dark:bg-primary/15 dark:ring-primary/40 ring-1" : "text-muted-foreground hover:text-foreground"
|
|
7555
7764
|
),
|
|
7556
7765
|
onClick: () => onTableSelect(table.value),
|
|
7557
|
-
children: /* @__PURE__ */ jsx25("
|
|
7766
|
+
children: /* @__PURE__ */ jsx25("span", { className: "flex min-w-0 flex-1 items-center", children: /* @__PURE__ */ jsxs14(Tooltip, { children: [
|
|
7558
7767
|
/* @__PURE__ */ jsx25(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx25("span", { className: "truncate text-xs", children: table.label }) }),
|
|
7559
7768
|
/* @__PURE__ */ jsx25(TooltipContent, { side: "right", align: "start", children: /* @__PURE__ */ jsx25("span", { className: "text-xs font-medium", children: table.label }) })
|
|
7560
7769
|
] }) })
|
|
@@ -7610,15 +7819,15 @@ var SheetsTableSelector = memo3(function SheetsTableSelector2({
|
|
|
7610
7819
|
}
|
|
7611
7820
|
}, [onNewTable]);
|
|
7612
7821
|
if (isLoading) {
|
|
7613
|
-
return /* @__PURE__ */
|
|
7614
|
-
/* @__PURE__ */
|
|
7822
|
+
return /* @__PURE__ */ jsxs14("div", { "data-part-id": "sheets-table-selector-loading", className: "bg-background flex h-full flex-col", children: [
|
|
7823
|
+
/* @__PURE__ */ jsxs14("div", { className: "border-border/60 flex-shrink-0 border-b p-6", children: [
|
|
7615
7824
|
/* @__PURE__ */ jsx25("div", { className: "bg-muted mb-6 h-8 w-32 animate-pulse rounded" }),
|
|
7616
7825
|
/* @__PURE__ */ jsx25("div", { className: "bg-muted mb-4 h-10 w-full animate-pulse rounded-md" }),
|
|
7617
7826
|
/* @__PURE__ */ jsx25("div", { className: "bg-muted mb-4 h-10 w-full animate-pulse rounded-md" }),
|
|
7618
7827
|
/* @__PURE__ */ jsx25("div", { className: "bg-muted h-10 w-full animate-pulse rounded-md" })
|
|
7619
7828
|
] }),
|
|
7620
|
-
/* @__PURE__ */ jsx25("div", { className: "flex-1 space-y-2 p-6", children: [1, 2, 3, 4, 5].map((i) => /* @__PURE__ */
|
|
7621
|
-
/* @__PURE__ */
|
|
7829
|
+
/* @__PURE__ */ jsx25("div", { className: "flex-1 space-y-2 p-6", children: [1, 2, 3, 4, 5].map((i) => /* @__PURE__ */ jsxs14("div", { className: "flex items-center justify-between rounded-lg border p-3", children: [
|
|
7830
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center gap-3", children: [
|
|
7622
7831
|
/* @__PURE__ */ jsx25("div", { className: "bg-muted h-4 w-4 animate-pulse rounded" }),
|
|
7623
7832
|
/* @__PURE__ */ jsx25("div", { className: "bg-muted h-4 w-24 animate-pulse rounded" })
|
|
7624
7833
|
] }),
|
|
@@ -7626,18 +7835,18 @@ var SheetsTableSelector = memo3(function SheetsTableSelector2({
|
|
|
7626
7835
|
] }, i)) })
|
|
7627
7836
|
] });
|
|
7628
7837
|
}
|
|
7629
|
-
return /* @__PURE__ */ jsx25(TooltipProvider, { delayDuration: 150, children: /* @__PURE__ */
|
|
7838
|
+
return /* @__PURE__ */ jsx25(TooltipProvider, { delayDuration: 150, children: /* @__PURE__ */ jsxs14(
|
|
7630
7839
|
"div",
|
|
7631
7840
|
{
|
|
7632
7841
|
"data-part-id": "sheets-table-selector",
|
|
7633
7842
|
className: "bg-background flex h-full max-h-[calc(100vh-4rem)] flex-col",
|
|
7634
7843
|
children: [
|
|
7635
|
-
/* @__PURE__ */
|
|
7636
|
-
/* @__PURE__ */ jsx25("div", { className: "flex flex-col gap-2 pr-2 pb-2", children: /* @__PURE__ */
|
|
7844
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex-shrink-0 py-4", children: [
|
|
7845
|
+
/* @__PURE__ */ jsx25("div", { className: "flex flex-col gap-2 pr-2 pb-2", children: /* @__PURE__ */ jsxs14(Button7, { onClick: handleNewTable, className: "h-8 w-full justify-start gap-2", variant: "outline", children: [
|
|
7637
7846
|
/* @__PURE__ */ jsx25(RiAddLine4, { size: 16 }),
|
|
7638
7847
|
"New table"
|
|
7639
7848
|
] }) }),
|
|
7640
|
-
/* @__PURE__ */
|
|
7849
|
+
/* @__PURE__ */ jsxs14("div", { className: "relative pr-2", children: [
|
|
7641
7850
|
/* @__PURE__ */ jsx25(
|
|
7642
7851
|
RiSearchLine,
|
|
7643
7852
|
{
|
|
@@ -7663,7 +7872,7 @@ var SheetsTableSelector = memo3(function SheetsTableSelector2({
|
|
|
7663
7872
|
ref: containerRef,
|
|
7664
7873
|
"data-part-id": "table-selector-table-list",
|
|
7665
7874
|
className: "mt-4 flex min-h-0 flex-1 flex-col gap-2 overflow-hidden pr-2",
|
|
7666
|
-
children: filteredTables.length === 0 ? /* @__PURE__ */
|
|
7875
|
+
children: filteredTables.length === 0 ? /* @__PURE__ */ jsxs14("div", { className: "flex flex-col items-center justify-center py-12 text-center", children: [
|
|
7667
7876
|
/* @__PURE__ */ jsx25("div", { className: "bg-muted mb-4 flex h-12 w-12 items-center justify-center rounded-full", children: /* @__PURE__ */ jsx25(RiSearchLine, { size: 20, className: "text-muted-foreground" }) }),
|
|
7668
7877
|
/* @__PURE__ */ jsx25("p", { className: "text-muted-foreground mb-1 text-sm font-medium", children: "No tables found" }),
|
|
7669
7878
|
/* @__PURE__ */ jsx25("p", { className: "text-muted-foreground/80 text-xs", children: searchQuery ? "Try adjusting your search terms" : "No tables available in this schema" })
|
|
@@ -7741,8 +7950,8 @@ function SheetsTableListByCategory({
|
|
|
7741
7950
|
return `${Math.round(clamped)}px`;
|
|
7742
7951
|
}, [scrollAreaHeight]);
|
|
7743
7952
|
const scrollAreaStyle = maxContentHeight !== void 0 ? { maxHeight: `${maxContentHeight}px` } : void 0;
|
|
7744
|
-
return /* @__PURE__ */
|
|
7745
|
-
/* @__PURE__ */
|
|
7953
|
+
return /* @__PURE__ */ jsxs14(Collapsible, { open: isExpanded, onOpenChange: onToggleExpand, className: "flex min-h-0 shrink-0 flex-col", children: [
|
|
7954
|
+
/* @__PURE__ */ jsxs14(
|
|
7746
7955
|
CollapsibleTrigger,
|
|
7747
7956
|
{
|
|
7748
7957
|
className: cn(
|
|
@@ -7761,7 +7970,7 @@ function SheetsTableListByCategory({
|
|
|
7761
7970
|
}
|
|
7762
7971
|
),
|
|
7763
7972
|
/* @__PURE__ */ jsx25("span", { className: "text-muted-foreground text-xs font-medium", children: title }),
|
|
7764
|
-
/* @__PURE__ */
|
|
7973
|
+
/* @__PURE__ */ jsxs14("span", { className: "ml-auto flex items-center gap-1.5", children: [
|
|
7765
7974
|
!isExpanded && hasSelectedItem && /* @__PURE__ */ jsx25("span", { className: "bg-primary/50 h-1.5 w-1.5 rounded-full", "aria-label": "Contains selected item" }),
|
|
7766
7975
|
/* @__PURE__ */ jsx25("span", { className: "text-muted-foreground/70 text-[10px] tabular-nums", children: tables.length })
|
|
7767
7976
|
] })
|
|
@@ -7790,7 +7999,7 @@ function SheetsTableListByCategory({
|
|
|
7790
7999
|
}
|
|
7791
8000
|
},
|
|
7792
8001
|
className: "min-h-0 overflow-hidden",
|
|
7793
|
-
children: tables.length > 0 ? /* @__PURE__ */
|
|
8002
|
+
children: tables.length > 0 ? /* @__PURE__ */ jsxs14("div", { className: "relative mt-2 min-h-0", children: [
|
|
7794
8003
|
/* @__PURE__ */ jsx25(
|
|
7795
8004
|
ScrollArea,
|
|
7796
8005
|
{
|
|
@@ -7811,7 +8020,7 @@ function SheetsTableListByCategory({
|
|
|
7811
8020
|
}
|
|
7812
8021
|
),
|
|
7813
8022
|
showBottomBlur && tables.length > 3 && /* @__PURE__ */ jsx25(ProgressiveBlur, { position: "bottom", height: blurHeight, surface: "background", intensity: 0.22 })
|
|
7814
|
-
] }) : /* @__PURE__ */
|
|
8023
|
+
] }) : /* @__PURE__ */ jsxs14("div", { className: "flex flex-col items-center justify-center py-6 text-center", children: [
|
|
7815
8024
|
/* @__PURE__ */ jsx25("div", { className: "bg-muted mb-2 flex h-10 w-10 items-center justify-center rounded-full", children: hasSearchTerm ? /* @__PURE__ */ jsx25(RiSearchLine, { className: "text-muted-foreground h-5 w-5" }) : /* @__PURE__ */ jsx25(RiDatabaseLine, { className: "text-muted-foreground h-5 w-5" }) }),
|
|
7816
8025
|
/* @__PURE__ */ jsx25("p", { className: "text-muted-foreground text-xs", children: emptyMessage })
|
|
7817
8026
|
] })
|
|
@@ -7918,7 +8127,8 @@ function createScalarFieldSpec(metaField, options, uniqueFields, primaryFields)
|
|
|
7918
8127
|
isArray: metaField.type.isArray,
|
|
7919
8128
|
pgAlias: metaField.type.pgAlias,
|
|
7920
8129
|
pgType: metaField.type.pgType,
|
|
7921
|
-
subtype: metaField.type.subtype ?? void 0
|
|
8130
|
+
subtype: metaField.type.subtype ?? void 0,
|
|
8131
|
+
encoding: metaField.type.encoding
|
|
7922
8132
|
});
|
|
7923
8133
|
if (metaField.type.isArray) {
|
|
7924
8134
|
return null;
|
|
@@ -7946,13 +8156,17 @@ function createScalarFieldSpec(metaField, options, uniqueFields, primaryFields)
|
|
|
7946
8156
|
pgAlias: metaField.type.pgAlias ?? void 0,
|
|
7947
8157
|
pgType: metaField.type.pgType ?? void 0,
|
|
7948
8158
|
subtype: metaField.type.subtype ?? void 0,
|
|
7949
|
-
typmod: metaField.type.typmod ?? void 0
|
|
8159
|
+
typmod: metaField.type.typmod ?? void 0,
|
|
8160
|
+
encoding: metaField.type.encoding ?? void 0
|
|
7950
8161
|
},
|
|
7951
8162
|
constraints: {
|
|
7952
8163
|
isUnique: uniqueFields.has(metaField.name) || void 0,
|
|
7953
8164
|
isPrimaryKey: primaryFields.has(metaField.name) || void 0
|
|
7954
8165
|
}
|
|
7955
8166
|
};
|
|
8167
|
+
if (metaField.enumValues?.values?.length) {
|
|
8168
|
+
spec.enumValues = [...metaField.enumValues.values];
|
|
8169
|
+
}
|
|
7956
8170
|
if (maxLength != null) {
|
|
7957
8171
|
spec.maxLength = maxLength;
|
|
7958
8172
|
}
|
|
@@ -7976,6 +8190,7 @@ function createScalarFieldSpec(metaField, options, uniqueFields, primaryFields)
|
|
|
7976
8190
|
return spec;
|
|
7977
8191
|
}
|
|
7978
8192
|
function buildDescription(metaField) {
|
|
8193
|
+
if (metaField.description) return metaField.description;
|
|
7979
8194
|
const details = [];
|
|
7980
8195
|
const { pgAlias, pgType, subtype } = metaField.type;
|
|
7981
8196
|
if (pgAlias && pgAlias !== pgType) {
|
|
@@ -7993,6 +8208,7 @@ function humanize(name) {
|
|
|
7993
8208
|
return name.replace(HUMAN_CASE_REGEX, "$1 $2").replace(/^./, (str) => str.toUpperCase());
|
|
7994
8209
|
}
|
|
7995
8210
|
function isFieldNullable(metaField) {
|
|
8211
|
+
if (metaField.isNotNull === true || metaField.type.isNotNull === true) return false;
|
|
7996
8212
|
const gqlType = metaField.type.gqlType;
|
|
7997
8213
|
if (gqlType.endsWith("!")) return false;
|
|
7998
8214
|
return true;
|
|
@@ -8407,6 +8623,7 @@ export {
|
|
|
8407
8623
|
buildRelationInfoFromMeta,
|
|
8408
8624
|
buildScalarFormSpec,
|
|
8409
8625
|
buildZodSchema,
|
|
8626
|
+
canRunSheetsMutation,
|
|
8410
8627
|
clear as clearSheetsSelection,
|
|
8411
8628
|
computeDraftMetaSignature,
|
|
8412
8629
|
countConditions,
|
|
@@ -8426,6 +8643,7 @@ export {
|
|
|
8426
8643
|
findTableFormSpec,
|
|
8427
8644
|
getCellsInRange,
|
|
8428
8645
|
getDraftMeta,
|
|
8646
|
+
getSheetsWriteCapability,
|
|
8429
8647
|
isArrayCellType,
|
|
8430
8648
|
isDraftRow,
|
|
8431
8649
|
isImageField,
|
|
@@ -8436,10 +8654,16 @@ export {
|
|
|
8436
8654
|
moveActive,
|
|
8437
8655
|
sheetsTableQueryKeys as queryKeys,
|
|
8438
8656
|
resolveCellType,
|
|
8657
|
+
resolveDownloadUrl,
|
|
8658
|
+
resolveSheetsIdentifier,
|
|
8659
|
+
resolveSheetsRowIdentity,
|
|
8439
8660
|
selectCell,
|
|
8440
8661
|
selectRange,
|
|
8441
8662
|
selectRow,
|
|
8663
|
+
sheetsIdentifierCacheKey,
|
|
8664
|
+
sheetsIdentifierToWhere,
|
|
8442
8665
|
sheetsQueryKeys,
|
|
8666
|
+
sheetsRowKey,
|
|
8443
8667
|
toTSV,
|
|
8444
8668
|
toggleRow,
|
|
8445
8669
|
tokensFromCssVars,
|