@constructive-io/sheets 0.13.1 → 0.14.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/README.md +10 -1
- package/dist/advanced.cjs +554 -716
- package/dist/advanced.cjs.map +1 -1
- package/dist/advanced.d.cts +2 -2
- package/dist/advanced.d.ts +2 -2
- package/dist/advanced.js +4 -4
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.js +2 -2
- package/dist/{chunk-PZL2BCWF.js → chunk-6Y7CZ5VS.js} +2 -2
- package/dist/chunk-6Y7CZ5VS.js.map +1 -0
- package/dist/{chunk-AYMXT3ME.js → chunk-BGL6EBTE.js} +108 -202
- package/dist/chunk-BGL6EBTE.js.map +1 -0
- package/dist/{chunk-MXVNIKES.js → chunk-BYAYBXVB.js} +2 -2
- package/dist/{chunk-5QPNOKMA.js → chunk-ER3FIDK7.js} +444 -458
- package/dist/chunk-ER3FIDK7.js.map +1 -0
- package/dist/chunk-GZM2CSTR.js +279 -0
- package/dist/chunk-GZM2CSTR.js.map +1 -0
- package/dist/{chunk-H5HR5HUJ.js → chunk-YJZFHL2D.js} +1 -1
- package/dist/chunk-YJZFHL2D.js.map +1 -0
- package/dist/{date-editor-ZFNDKYBD.js → date-editor-G26WKILO.js} +2 -2
- package/dist/{grid-cell-types-Pbe2m2tE.d.ts → grid-cell-types-C2-ocDS7.d.cts} +45 -5
- package/dist/{grid-cell-types-Pbe2m2tE.d.cts → grid-cell-types-C2-ocDS7.d.ts} +45 -5
- package/dist/index.cjs +782 -637
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +106 -112
- package/dist/index.d.ts +106 -112
- package/dist/index.js +234 -134
- package/dist/index.js.map +1 -1
- package/dist/{sheets-context-Cu3Ec_ca.d.ts → sheets-context-CHUVJCff.d.ts} +32 -31
- package/dist/{sheets-context-CY1RmDKL.d.cts → sheets-context-C_MkTxXm.d.cts} +32 -31
- package/dist/testing.cjs +121 -87
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +16 -4
- package/dist/testing.js.map +1 -1
- package/package.json +5 -4
- package/dist/chunk-5QPNOKMA.js.map +0 -1
- package/dist/chunk-AYMXT3ME.js.map +0 -1
- package/dist/chunk-H5HR5HUJ.js.map +0 -1
- package/dist/chunk-PZL2BCWF.js.map +0 -1
- package/dist/chunk-ZKANUG3F.js +0 -123
- package/dist/chunk-ZKANUG3F.js.map +0 -1
- /package/dist/{chunk-MXVNIKES.js.map → chunk-BYAYBXVB.js.map} +0 -0
- /package/dist/{date-editor-ZFNDKYBD.js.map → date-editor-G26WKILO.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
DOM_EDITOR_REGISTRY,
|
|
4
|
+
ImageEditorDom,
|
|
4
5
|
OverlayMeasureContext,
|
|
5
6
|
canRunSheetsMutation,
|
|
6
7
|
computeOverlayGeometry,
|
|
7
8
|
createPostGraphileAdapter,
|
|
8
9
|
createSheetsCell,
|
|
9
10
|
executeFieldUpload,
|
|
11
|
+
formatFileSize,
|
|
10
12
|
getImageMetadata,
|
|
11
13
|
getSheetsWriteCapability,
|
|
12
14
|
resolveRelationFieldMap,
|
|
@@ -19,31 +21,31 @@ import {
|
|
|
19
21
|
transformToPostGraphileVariables,
|
|
20
22
|
useSheetsAdapter,
|
|
21
23
|
useSheetsFieldUpload,
|
|
22
|
-
|
|
24
|
+
useSheetsMediaUrl,
|
|
23
25
|
useSheetsMeta,
|
|
24
26
|
useSheetsTable,
|
|
25
27
|
useSheetsTableCursor,
|
|
26
28
|
validateOrderByVariables
|
|
27
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-ER3FIDK7.js";
|
|
28
30
|
import {
|
|
29
31
|
SheetsAuthGate,
|
|
30
32
|
useSheetsForgotPassword,
|
|
31
33
|
useSheetsLogin,
|
|
32
34
|
useSheetsRegister,
|
|
33
35
|
useSheetsResetPassword
|
|
34
|
-
} from "./chunk-
|
|
35
|
-
import {
|
|
36
|
-
SheetsProvider
|
|
37
|
-
} from "./chunk-ZKANUG3F.js";
|
|
36
|
+
} from "./chunk-BYAYBXVB.js";
|
|
38
37
|
import {
|
|
39
38
|
ConstructiveError,
|
|
39
|
+
SheetsProvider,
|
|
40
40
|
createSheetsExecute,
|
|
41
|
-
createSheetsUpload
|
|
41
|
+
createSheetsUpload
|
|
42
|
+
} from "./chunk-GZM2CSTR.js";
|
|
43
|
+
import {
|
|
42
44
|
isSheetsScopeKey,
|
|
43
45
|
resolveDownloadUrl,
|
|
44
46
|
reuseSheetsPlaceholderData,
|
|
45
47
|
sheetsQueryKeys
|
|
46
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-BGL6EBTE.js";
|
|
47
49
|
import "./chunk-4EZ6A23C.js";
|
|
48
50
|
import {
|
|
49
51
|
SheetsContext,
|
|
@@ -55,7 +57,7 @@ import {
|
|
|
55
57
|
useSheetsContext,
|
|
56
58
|
useSheetsStore,
|
|
57
59
|
useSheetsStoreApi
|
|
58
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-YJZFHL2D.js";
|
|
59
61
|
import {
|
|
60
62
|
BOOLEAN_TYPES,
|
|
61
63
|
BUILTIN_EDITOR_TYPES,
|
|
@@ -70,7 +72,7 @@ import {
|
|
|
70
72
|
TYPED_ARRAY_TYPES,
|
|
71
73
|
VIEWER_ONLY_TYPES,
|
|
72
74
|
isArrayCellType
|
|
73
|
-
} from "./chunk-
|
|
75
|
+
} from "./chunk-6Y7CZ5VS.js";
|
|
74
76
|
import "./chunk-GGECS2BP.js";
|
|
75
77
|
import {
|
|
76
78
|
cn
|
|
@@ -80,13 +82,26 @@ import {
|
|
|
80
82
|
} from "./chunk-X7DHTSOX.js";
|
|
81
83
|
|
|
82
84
|
// src/grid/sheets.tsx
|
|
83
|
-
import { forwardRef, useCallback as
|
|
85
|
+
import { forwardRef, useCallback as useCallback20, useEffect as useEffect6, useImperativeHandle as useImperativeHandle2, useMemo as useMemo17, useRef as useRef10, useState as useState9 } from "react";
|
|
84
86
|
import {
|
|
85
87
|
functionalUpdate
|
|
86
88
|
} from "@tanstack/react-table";
|
|
87
89
|
import { RiFilterOffLine, RiSearchEyeLine } from "@remixicon/react";
|
|
88
90
|
import { Button as Button6 } from "@constructive-io/ui/button";
|
|
89
91
|
|
|
92
|
+
// src/grid/row-model.ts
|
|
93
|
+
var DRAFT_META = /* @__PURE__ */ Symbol("sheets.draftMeta");
|
|
94
|
+
function attachDraftMeta(row, meta) {
|
|
95
|
+
Object.defineProperty(row, DRAFT_META, { value: meta, enumerable: false, configurable: true });
|
|
96
|
+
return row;
|
|
97
|
+
}
|
|
98
|
+
function getDraftMeta(row) {
|
|
99
|
+
return row ? row[DRAFT_META] : void 0;
|
|
100
|
+
}
|
|
101
|
+
function isDraftRow(row) {
|
|
102
|
+
return getDraftMeta(row)?.isDraft === true;
|
|
103
|
+
}
|
|
104
|
+
|
|
90
105
|
// src/grid/sheets.controls.tsx
|
|
91
106
|
import { memo, useCallback, useEffect, useMemo, useState } from "react";
|
|
92
107
|
import {
|
|
@@ -1520,7 +1535,7 @@ function mapToFrontendCellType(metadata) {
|
|
|
1520
1535
|
if (encodedType) return encodedType;
|
|
1521
1536
|
if (pgAlias) {
|
|
1522
1537
|
const aliasType = mapAliasToCellType(pgAlias);
|
|
1523
|
-
if (aliasType !== "unknown") return aliasType;
|
|
1538
|
+
if (aliasType !== "unknown" && !(isArray && aliasType === "attachment")) return aliasType;
|
|
1524
1539
|
}
|
|
1525
1540
|
if (isArray) {
|
|
1526
1541
|
const result = mapGraphQLTypeToCellType(gqlType, isArray, metadata.subtype, null);
|
|
@@ -1573,6 +1588,7 @@ function mapAliasToCellType(alias) {
|
|
|
1573
1588
|
video: "video",
|
|
1574
1589
|
audio: "audio",
|
|
1575
1590
|
upload: "upload",
|
|
1591
|
+
attachment: "attachment",
|
|
1576
1592
|
// Relation types
|
|
1577
1593
|
relation: "relation",
|
|
1578
1594
|
// Special text types
|
|
@@ -1700,6 +1716,7 @@ function mapBackendTypeToCellType(pgType) {
|
|
|
1700
1716
|
url: "url",
|
|
1701
1717
|
image: "image",
|
|
1702
1718
|
upload: "upload",
|
|
1719
|
+
attachment: "attachment",
|
|
1703
1720
|
origin: "origin",
|
|
1704
1721
|
// Arrays are handled by isArray flag
|
|
1705
1722
|
_text: "array",
|
|
@@ -2509,19 +2526,6 @@ function useDataGridColumns(tableName, rows = []) {
|
|
|
2509
2526
|
// src/grid/use-sheets.ts
|
|
2510
2527
|
import { toast } from "@constructive-io/ui/toast";
|
|
2511
2528
|
|
|
2512
|
-
// src/grid/row-model.ts
|
|
2513
|
-
var DRAFT_META = /* @__PURE__ */ Symbol("sheets.draftMeta");
|
|
2514
|
-
function attachDraftMeta(row, meta) {
|
|
2515
|
-
Object.defineProperty(row, DRAFT_META, { value: meta, enumerable: false, configurable: true });
|
|
2516
|
-
return row;
|
|
2517
|
-
}
|
|
2518
|
-
function getDraftMeta(row) {
|
|
2519
|
-
return row ? row[DRAFT_META] : void 0;
|
|
2520
|
-
}
|
|
2521
|
-
function isDraftRow(row) {
|
|
2522
|
-
return getDraftMeta(row)?.isDraft === true;
|
|
2523
|
-
}
|
|
2524
|
-
|
|
2525
2529
|
// src/cell-types/cell-type-registry.ts
|
|
2526
2530
|
function createCellTypeRegistry(cellTypes, builtins) {
|
|
2527
2531
|
const byKey = /* @__PURE__ */ new Map();
|
|
@@ -2728,6 +2732,7 @@ function useBatchCommit({
|
|
|
2728
2732
|
update,
|
|
2729
2733
|
getRowIdentifier = legacyRowIdentifier2,
|
|
2730
2734
|
readOnlyFields,
|
|
2735
|
+
isCellReadOnly,
|
|
2731
2736
|
canUpdate = true,
|
|
2732
2737
|
applyOptimisticPatch,
|
|
2733
2738
|
resyncRow,
|
|
@@ -2744,6 +2749,7 @@ function useBatchCommit({
|
|
|
2744
2749
|
for (const w of writes) {
|
|
2745
2750
|
const rowData = combinedRows[w.rowIndex];
|
|
2746
2751
|
if (!rowData) continue;
|
|
2752
|
+
if (isCellReadOnly?.(w.rowIndex, w.colKey)) continue;
|
|
2747
2753
|
if (getDraftMeta(rowData)) {
|
|
2748
2754
|
draftWrites.push(w);
|
|
2749
2755
|
continue;
|
|
@@ -2810,7 +2816,7 @@ function useBatchCommit({
|
|
|
2810
2816
|
}
|
|
2811
2817
|
return { applied: resolved.length };
|
|
2812
2818
|
},
|
|
2813
|
-
[combinedRows, fieldMetaMap, relationInfoByField, update, getRowIdentifier, readOnlyFields, canUpdate, applyOptimisticPatch, resyncRow, editCell, onCellEdit, record]
|
|
2819
|
+
[combinedRows, fieldMetaMap, relationInfoByField, update, getRowIdentifier, readOnlyFields, isCellReadOnly, canUpdate, applyOptimisticPatch, resyncRow, editCell, onCellEdit, record]
|
|
2814
2820
|
);
|
|
2815
2821
|
commitRef.current = commitCells;
|
|
2816
2822
|
return commitCells;
|
|
@@ -3194,12 +3200,14 @@ function useSheetsContent(args) {
|
|
|
3194
3200
|
serverRowsReadOnly = false,
|
|
3195
3201
|
serverReadOnlyFields,
|
|
3196
3202
|
getRowIdentifier,
|
|
3197
|
-
supportsScalarSelfCommit = true
|
|
3203
|
+
supportsScalarSelfCommit = true,
|
|
3204
|
+
canUpload = true,
|
|
3205
|
+
canCreate = true
|
|
3198
3206
|
} = args;
|
|
3199
3207
|
const relationFieldNamesFromMeta = useMemo7(() => buildRelationFieldNameSet(meta, tableName), [meta, tableName]);
|
|
3200
3208
|
const cache2 = useMemo7(
|
|
3201
3209
|
() => /* @__PURE__ */ new Map(),
|
|
3202
|
-
[data, columnKeys, fieldMetaMap, registry, relationFieldNamesFromMeta, relationInfoByField, options, serverRowsReadOnly, serverReadOnlyFields, getRowIdentifier, supportsScalarSelfCommit]
|
|
3210
|
+
[data, columnKeys, fieldMetaMap, registry, relationFieldNamesFromMeta, relationInfoByField, options, serverRowsReadOnly, serverReadOnlyFields, getRowIdentifier, supportsScalarSelfCommit, canUpload, canCreate]
|
|
3203
3211
|
);
|
|
3204
3212
|
const getSheetsCell = useCallback11(
|
|
3205
3213
|
(rowIndex, colKey) => {
|
|
@@ -3270,9 +3278,11 @@ function useSheetsContent(args) {
|
|
|
3270
3278
|
};
|
|
3271
3279
|
const cellType = registry.resolveTypeKey(matchInput, () => route.cellType);
|
|
3272
3280
|
const rowIdentifier = !isDraftRow2 ? getRowIdentifier?.(rowData) : null;
|
|
3273
|
-
const
|
|
3274
|
-
const lacksScalarEditorIdentity =
|
|
3275
|
-
const
|
|
3281
|
+
const isMedia = MEDIA_TYPES.has(cellType);
|
|
3282
|
+
const lacksScalarEditorIdentity = isRelation && (!supportsScalarSelfCommit || rowIdentifier != null && typeof rowIdentifier === "object");
|
|
3283
|
+
const lacksMediaTarget = isMedia && (isDraftRow2 ? !canCreate || serverRowsReadOnly : rowIdentifier == null);
|
|
3284
|
+
const readOnlyReason = isMedia && !canUpload ? "Uploads need a storage endpoint" : void 0;
|
|
3285
|
+
const forcedReadOnly = tableForcedReadOnly || lacksScalarEditorIdentity || lacksMediaTarget || !!readOnlyReason;
|
|
3276
3286
|
const metadata = {
|
|
3277
3287
|
cellType,
|
|
3278
3288
|
fieldName: colKey,
|
|
@@ -3295,11 +3305,20 @@ function useSheetsContent(args) {
|
|
|
3295
3305
|
const hasCellError = Boolean(draftErrors && colKey in draftErrors);
|
|
3296
3306
|
const styled = isDraftRow2 ? tagDraftStyle(displaySafe, hasCellError) : displaySafe;
|
|
3297
3307
|
const component = registry.getCellComponent(cellType);
|
|
3298
|
-
const resolution = {
|
|
3308
|
+
const resolution = {
|
|
3309
|
+
cell: styled,
|
|
3310
|
+
component,
|
|
3311
|
+
colKey,
|
|
3312
|
+
typeKey: cellType,
|
|
3313
|
+
fieldMeta,
|
|
3314
|
+
relationInfo,
|
|
3315
|
+
rowIdentifier,
|
|
3316
|
+
readOnlyReason
|
|
3317
|
+
};
|
|
3299
3318
|
cache2.set(cacheKey, { value: rawValue, resolution });
|
|
3300
3319
|
return resolution;
|
|
3301
3320
|
},
|
|
3302
|
-
[data, columnKeys, fieldMetaMap, registry, relationFieldNamesFromMeta, relationInfoByField, options, serverRowsReadOnly, serverReadOnlyFields, getRowIdentifier, supportsScalarSelfCommit]
|
|
3321
|
+
[data, columnKeys, fieldMetaMap, registry, relationFieldNamesFromMeta, relationInfoByField, options, serverRowsReadOnly, serverReadOnlyFields, getRowIdentifier, supportsScalarSelfCommit, canUpload, canCreate]
|
|
3303
3322
|
);
|
|
3304
3323
|
return { getSheetsCell };
|
|
3305
3324
|
}
|
|
@@ -4409,7 +4428,7 @@ function useSheets(props) {
|
|
|
4409
4428
|
const emit = useCallback16((type, meta) => {
|
|
4410
4429
|
onEventRef.current?.({ type, tableName, at: Date.now(), meta });
|
|
4411
4430
|
}, [tableName]);
|
|
4412
|
-
const { config } = useSheetsContext();
|
|
4431
|
+
const { config, canUpload } = useSheetsContext();
|
|
4413
4432
|
const cellRegistry = useMemo13(
|
|
4414
4433
|
() => createCellTypeRegistry(
|
|
4415
4434
|
// Compiled cell-component slots go LAST so they win over plugins + cellTypes.
|
|
@@ -4691,7 +4710,9 @@ function useSheets(props) {
|
|
|
4691
4710
|
serverRowsReadOnly: !canUpdate,
|
|
4692
4711
|
serverReadOnlyFields: primaryKeyFields,
|
|
4693
4712
|
getRowIdentifier,
|
|
4694
|
-
supportsScalarSelfCommit
|
|
4713
|
+
supportsScalarSelfCommit,
|
|
4714
|
+
canUpload,
|
|
4715
|
+
canCreate
|
|
4695
4716
|
});
|
|
4696
4717
|
const effectiveColumnOrder = useMemo13(() => {
|
|
4697
4718
|
if (columnKeys.length > 0) return columnKeys;
|
|
@@ -4821,6 +4842,7 @@ function useSheets(props) {
|
|
|
4821
4842
|
update,
|
|
4822
4843
|
getRowIdentifier,
|
|
4823
4844
|
readOnlyFields: primaryKeyFields,
|
|
4845
|
+
isCellReadOnly: canUpload ? void 0 : (rowIndex, colKey) => Boolean(getSheetsCellContent(rowIndex, colKey).readOnlyReason),
|
|
4824
4846
|
canUpdate,
|
|
4825
4847
|
applyOptimisticPatch: applyOptimisticCellPatch,
|
|
4826
4848
|
resyncRow,
|
|
@@ -5782,34 +5804,34 @@ function warmImage(url) {
|
|
|
5782
5804
|
|
|
5783
5805
|
// src/cell-model/views/image-view.tsx
|
|
5784
5806
|
import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
5785
|
-
function readUrl(data) {
|
|
5786
|
-
if (Array.isArray(data) && typeof data[0] === "string") return data[0];
|
|
5787
|
-
return "";
|
|
5788
|
-
}
|
|
5789
5807
|
function basename(url) {
|
|
5790
5808
|
const path = url.split(/[?#]/)[0];
|
|
5791
5809
|
const seg = path.slice(path.lastIndexOf("/") + 1);
|
|
5792
5810
|
return seg || url;
|
|
5793
5811
|
}
|
|
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
|
-
}
|
|
5799
5812
|
function ImageCellView(props) {
|
|
5800
|
-
const
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5813
|
+
const meta = getImageMetadata(props.value);
|
|
5814
|
+
const previewImage = props.column.cellType === "image" || Boolean(meta?.mime.startsWith("image/"));
|
|
5815
|
+
const { url, durableUrl, id, isLoading, onImageError, onImageLoad } = useSheetsMediaUrl(props.value, previewImage);
|
|
5816
|
+
if (!previewImage && (id || durableUrl) || id && !url && !isLoading) {
|
|
5817
|
+
const filename = meta?.filename && meta.filename !== "Unknown" ? meta.filename : durableUrl ? basename(durableUrl) : "File";
|
|
5818
|
+
const details = [
|
|
5819
|
+
filename,
|
|
5820
|
+
meta?.size !== void 0 ? formatFileSize(meta.size) : null,
|
|
5821
|
+
meta?.mime !== "unknown" ? meta?.mime : null
|
|
5822
|
+
].filter(Boolean).join(" \u2022 ");
|
|
5804
5823
|
return /* @__PURE__ */ jsxs10(
|
|
5805
5824
|
"div",
|
|
5806
5825
|
{
|
|
5807
5826
|
"data-slot": "file-cell",
|
|
5808
5827
|
role: "gridcell",
|
|
5828
|
+
"aria-readonly": props.readOnlyReason ? true : void 0,
|
|
5829
|
+
"aria-description": props.readOnlyReason,
|
|
5809
5830
|
className: cn("flex h-full w-full items-center gap-1.5 overflow-hidden px-2"),
|
|
5810
5831
|
children: [
|
|
5811
5832
|
/* @__PURE__ */ jsx14(FileIcon, { className: "size-3.5 shrink-0 text-muted-foreground", "aria-hidden": "true" }),
|
|
5812
|
-
/* @__PURE__ */ jsx14("span", { className: "truncate text-sm", title:
|
|
5833
|
+
/* @__PURE__ */ jsx14("span", { className: "truncate text-sm", title: props.readOnlyReason ? `${details}
|
|
5834
|
+
${props.readOnlyReason}` : details, children: filename })
|
|
5813
5835
|
]
|
|
5814
5836
|
}
|
|
5815
5837
|
);
|
|
@@ -5819,6 +5841,8 @@ function ImageCellView(props) {
|
|
|
5819
5841
|
{
|
|
5820
5842
|
"data-slot": "image-cell",
|
|
5821
5843
|
role: "gridcell",
|
|
5844
|
+
"aria-readonly": props.readOnlyReason ? true : void 0,
|
|
5845
|
+
"aria-description": props.readOnlyReason,
|
|
5822
5846
|
className: cn("flex h-full w-full items-center overflow-hidden p-1"),
|
|
5823
5847
|
children: /* @__PURE__ */ jsx14("div", { className: cn("relative aspect-square h-full max-h-full overflow-hidden rounded-sm bg-muted"), children: url ? /* @__PURE__ */ jsx14(
|
|
5824
5848
|
"img",
|
|
@@ -5826,11 +5850,16 @@ function ImageCellView(props) {
|
|
|
5826
5850
|
src: url,
|
|
5827
5851
|
decoding: "async",
|
|
5828
5852
|
alt: "",
|
|
5829
|
-
|
|
5853
|
+
onError: onImageError,
|
|
5854
|
+
onLoad: () => {
|
|
5855
|
+
onImageLoad();
|
|
5856
|
+
if (durableUrl) warmImage(durableUrl);
|
|
5857
|
+
},
|
|
5830
5858
|
className: cn(
|
|
5831
5859
|
"absolute inset-0 h-full w-full rounded-sm object-cover outline-1 -outline-offset-1 outline-black/10 dark:outline-white/10"
|
|
5832
5860
|
)
|
|
5833
|
-
}
|
|
5861
|
+
},
|
|
5862
|
+
url
|
|
5834
5863
|
) : null })
|
|
5835
5864
|
}
|
|
5836
5865
|
);
|
|
@@ -5941,7 +5970,9 @@ function TextCellView(props) {
|
|
|
5941
5970
|
{
|
|
5942
5971
|
role: "gridcell",
|
|
5943
5972
|
"data-slot": "text-cell",
|
|
5944
|
-
title: text,
|
|
5973
|
+
title: [text, props.readOnlyReason].filter(Boolean).join("\n"),
|
|
5974
|
+
"aria-readonly": props.readOnlyReason ? true : void 0,
|
|
5975
|
+
"aria-description": props.readOnlyReason,
|
|
5945
5976
|
className: cn("flex h-full w-full items-center truncate px-3 text-sm"),
|
|
5946
5977
|
children: /* @__PURE__ */ jsx18("span", { className: "truncate", children: text })
|
|
5947
5978
|
}
|
|
@@ -6090,7 +6121,8 @@ function toCellProps(props, onStartEdit) {
|
|
|
6090
6121
|
column: { key: props.colKey, name: props.colKey, cellType: cell.meta?.cellType ?? "unknown" },
|
|
6091
6122
|
isEditing: props.isEditing,
|
|
6092
6123
|
onStartEdit,
|
|
6093
|
-
disabled: false
|
|
6124
|
+
disabled: false,
|
|
6125
|
+
readOnlyReason: props.resolution.readOnlyReason
|
|
6094
6126
|
};
|
|
6095
6127
|
}
|
|
6096
6128
|
var SheetsCellHostInner = memo2(
|
|
@@ -6133,6 +6165,7 @@ var SheetsCellHostInner = memo2(
|
|
|
6133
6165
|
ref: wrapperRef,
|
|
6134
6166
|
id: `sheets-cell-${props.rowIndex}-${props.columnIndex}`,
|
|
6135
6167
|
"aria-selected": props.isActive || void 0,
|
|
6168
|
+
title: props.resolution.readOnlyReason,
|
|
6136
6169
|
onClick: activate,
|
|
6137
6170
|
onDoubleClick: startEdit,
|
|
6138
6171
|
onContextMenu: contextMenu,
|
|
@@ -6172,7 +6205,7 @@ var SheetsCellHostInner = memo2(
|
|
|
6172
6205
|
},
|
|
6173
6206
|
(prev, next) => prev.rowId === next.rowId && prev.colKey === next.colKey && prev.value === next.value && prev.isEditing === next.isEditing && // initialText seeds the inline editor on open; it only differs for the editing cell.
|
|
6174
6207
|
prev.inlineInitialText === next.inlineInitialText && prev.onInlineCommit === next.onInlineCommit && prev.onInlineCancel === next.onInlineCancel && // isActive must gate the memo or the focus ring will not move between cells.
|
|
6175
|
-
prev.isActive === next.isActive && prev.openEditor === next.openEditor && prev.onActivateCell === next.onActivateCell && prev.onContextMenu === next.onContextMenu && prev.onSubmitDraftRow === next.onSubmitDraftRow && // styleHint.draft/error and the draft-action status can flip while `value` is
|
|
6208
|
+
prev.isActive === next.isActive && prev.openEditor === next.openEditor && prev.onActivateCell === next.onActivateCell && prev.onContextMenu === next.onContextMenu && prev.onSubmitDraftRow === next.onSubmitDraftRow && prev.resolution.cell.readonly === next.resolution.cell.readonly && prev.resolution.readOnlyReason === next.resolution.readOnlyReason && // styleHint.draft/error and the draft-action status can flip while `value` is
|
|
6176
6209
|
// unchanged (validation result arrives, save in flight), so gate on them too.
|
|
6177
6210
|
prev.resolution.cell.styleHint?.draft === next.resolution.cell.styleHint?.draft && prev.resolution.cell.styleHint?.error === next.resolution.cell.styleHint?.error && sameDraftAction(prev.draftAction, next.draftAction)
|
|
6178
6211
|
);
|
|
@@ -6244,7 +6277,7 @@ function useOverlayController() {
|
|
|
6244
6277
|
}
|
|
6245
6278
|
|
|
6246
6279
|
// src/grid-dom/overlay/overlay-manager.tsx
|
|
6247
|
-
import { useEffect as useEffect5, useLayoutEffect as useLayoutEffect2, useMemo as useMemo16, useRef as useRef9, useState as useState8 } from "react";
|
|
6280
|
+
import { useCallback as useCallback19, useEffect as useEffect5, useLayoutEffect as useLayoutEffect2, useMemo as useMemo16, useRef as useRef9, useState as useState8 } from "react";
|
|
6248
6281
|
import { createPortal } from "react-dom";
|
|
6249
6282
|
|
|
6250
6283
|
// src/grid/feedback/editor-error-boundary.tsx
|
|
@@ -6286,10 +6319,43 @@ function EditorErrorGuard({ children, onClose }) {
|
|
|
6286
6319
|
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
6287
6320
|
var MARGIN_PX = 12;
|
|
6288
6321
|
var MIN_BELOW_PX = 320;
|
|
6322
|
+
var DROPDOWN_MOTION = [
|
|
6323
|
+
"opacity-0 pointer-events-none will-change-[transform,opacity]",
|
|
6324
|
+
"[transform:scale(var(--dropdown-pre-scale,0.97))]",
|
|
6325
|
+
"[transition-property:transform,opacity]",
|
|
6326
|
+
"[transition-duration:var(--dropdown-open-dur,250ms)]",
|
|
6327
|
+
"[transition-timing-function:var(--dropdown-ease,cubic-bezier(0.22,1,0.36,1))]",
|
|
6328
|
+
"data-[state=open]:opacity-100 data-[state=open]:pointer-events-auto data-[state=open]:[transform:scale(1)]",
|
|
6329
|
+
"data-[state=closing]:[transform:scale(var(--dropdown-closing-scale,0.99))]",
|
|
6330
|
+
"data-[state=closing]:[transition-duration:var(--dropdown-close-dur,150ms)]",
|
|
6331
|
+
"motion-reduce:transition-none!"
|
|
6332
|
+
].join(" ");
|
|
6333
|
+
function prefersReducedMotion() {
|
|
6334
|
+
return typeof window.matchMedia !== "function" || window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
6335
|
+
}
|
|
6336
|
+
function playCloseTransition(node) {
|
|
6337
|
+
if (node.dataset.state !== "open" || prefersReducedMotion()) return;
|
|
6338
|
+
const host = node.parentNode ?? document.getElementById("portal-root") ?? document.body;
|
|
6339
|
+
const ghost = node.cloneNode(true);
|
|
6340
|
+
for (const el of [ghost, ...ghost.querySelectorAll("[id]")]) el.removeAttribute("id");
|
|
6341
|
+
ghost.setAttribute("aria-hidden", "true");
|
|
6342
|
+
ghost.inert = true;
|
|
6343
|
+
host.insertBefore(ghost, node.parentNode === host ? node : null);
|
|
6344
|
+
void ghost.offsetWidth;
|
|
6345
|
+
ghost.dataset.state = "closing";
|
|
6346
|
+
const closeMs = parseFloat(getComputedStyle(ghost).transitionDuration) * 1e3;
|
|
6347
|
+
window.setTimeout(() => ghost.remove(), (Number.isFinite(closeMs) ? closeMs : 150) + 50);
|
|
6348
|
+
}
|
|
6289
6349
|
var FLOATING_LAYER_SELECTOR = '[role="listbox"],[role="menu"],[role="dialog"],[role="tooltip"],[data-floating-ui-portal],[data-base-ui-positioner],[data-radix-popper-content-wrapper]';
|
|
6290
6350
|
function OverlayManager({ anchorRect, open, presetClass, onCancel, dismissMode = "cancel", children }) {
|
|
6291
6351
|
const containerRef = useRef9(null);
|
|
6352
|
+
const setContainer = useCallback19((node) => {
|
|
6353
|
+
const previous = containerRef.current;
|
|
6354
|
+
containerRef.current = node;
|
|
6355
|
+
if (!node && previous) playCloseTransition(previous);
|
|
6356
|
+
}, []);
|
|
6292
6357
|
const [pos, setPos] = useState8(null);
|
|
6358
|
+
const [entered, setEntered] = useState8(false);
|
|
6293
6359
|
const targetY = anchorRect?.top;
|
|
6294
6360
|
const targetH = anchorRect?.height;
|
|
6295
6361
|
const vh = typeof window !== "undefined" ? window.innerHeight : 800;
|
|
@@ -6298,21 +6364,38 @@ function OverlayManager({ anchorRect, open, presetClass, onCancel, dismissMode =
|
|
|
6298
6364
|
useLayoutEffect2(() => {
|
|
6299
6365
|
if (!open || !anchorRect) {
|
|
6300
6366
|
setPos(null);
|
|
6367
|
+
setEntered(false);
|
|
6301
6368
|
return;
|
|
6302
6369
|
}
|
|
6303
6370
|
const el = containerRef.current;
|
|
6304
6371
|
if (!el) return;
|
|
6305
|
-
const
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6372
|
+
const place = () => {
|
|
6373
|
+
const width = el.offsetWidth;
|
|
6374
|
+
const height = el.offsetHeight;
|
|
6375
|
+
const vw = window.innerWidth;
|
|
6376
|
+
const vhNow = window.innerHeight;
|
|
6377
|
+
let left = anchorRect.left;
|
|
6378
|
+
left = Math.max(MARGIN_PX, Math.min(left, vw - MARGIN_PX - width));
|
|
6379
|
+
if (!Number.isFinite(left)) left = MARGIN_PX;
|
|
6380
|
+
let top = shouldFlip ? anchorRect.top - height : anchorRect.bottom;
|
|
6381
|
+
top = Math.max(MARGIN_PX, Math.min(top, vhNow - MARGIN_PX - height));
|
|
6382
|
+
if (!Number.isFinite(top)) top = MARGIN_PX;
|
|
6383
|
+
const originX = Math.max(0, Math.min(anchorRect.left - left, width));
|
|
6384
|
+
setPos((prev) => prev && prev.left === left && prev.top === top && prev.originX === originX ? prev : { left, top, originX });
|
|
6385
|
+
};
|
|
6386
|
+
place();
|
|
6387
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
6388
|
+
const observer = new ResizeObserver(place);
|
|
6389
|
+
observer.observe(el);
|
|
6390
|
+
return () => observer.disconnect();
|
|
6315
6391
|
}, [open, shouldFlip, anchorRect, maxHeight]);
|
|
6392
|
+
useEffect5(() => {
|
|
6393
|
+
if (!open || pos === null || entered) return;
|
|
6394
|
+
const el = containerRef.current;
|
|
6395
|
+
if (!el) return;
|
|
6396
|
+
void el.offsetWidth;
|
|
6397
|
+
setEntered(true);
|
|
6398
|
+
}, [open, pos, entered]);
|
|
6316
6399
|
useEffect5(() => {
|
|
6317
6400
|
if (!open) return;
|
|
6318
6401
|
const onPointerDown = (e) => {
|
|
@@ -6339,8 +6422,8 @@ function OverlayManager({ anchorRect, open, presetClass, onCancel, dismissMode =
|
|
|
6339
6422
|
// Pre-measure default = the ANCHOR position (below, or above when flipping), NOT a
|
|
6340
6423
|
// screen corner. So an overlay that fits (the common case) renders at its FINAL spot
|
|
6341
6424
|
// with zero left/top change once measured — no travel. It stays hidden until measured
|
|
6342
|
-
// and
|
|
6343
|
-
// never seen sliding to the anchor (the correction happens
|
|
6425
|
+
// and left/top are never transitioned, so the rare off-screen clamp is instant and the
|
|
6426
|
+
// overlay is never seen sliding to the anchor (the correction happens pre-reveal).
|
|
6344
6427
|
left: pos ? pos.left : anchorRect.left,
|
|
6345
6428
|
top: pos ? pos.top : shouldFlip ? anchorRect.top : anchorRect.bottom,
|
|
6346
6429
|
maxHeight,
|
|
@@ -6349,26 +6432,19 @@ function OverlayManager({ anchorRect, open, presetClass, onCancel, dismissMode =
|
|
|
6349
6432
|
// Join the shared design-system overlay layer instead of an
|
|
6350
6433
|
// arbitrary z, so the editor and any popover/tooltip it opens (e.g. the relation
|
|
6351
6434
|
// "Record Data" popover, which portals into #portal-root) stack coherently.
|
|
6352
|
-
zIndex: "var(--z-layer-floating)"
|
|
6435
|
+
zIndex: "var(--z-layer-floating)",
|
|
6436
|
+
transformOrigin: `${pos?.originX ?? 0}px ${shouldFlip ? "100%" : "0"}`
|
|
6353
6437
|
};
|
|
6354
6438
|
const portalHost = document.getElementById("portal-root") ?? document.body;
|
|
6355
6439
|
return createPortal(
|
|
6356
6440
|
/* @__PURE__ */ jsx23(
|
|
6357
6441
|
"div",
|
|
6358
6442
|
{
|
|
6359
|
-
ref:
|
|
6443
|
+
ref: setContainer,
|
|
6444
|
+
"data-slot": "sheets-editor-overlay",
|
|
6445
|
+
"data-state": entered ? "open" : "closed",
|
|
6360
6446
|
style,
|
|
6361
|
-
className:
|
|
6362
|
-
// `transition-none`: the entrance is an ANIMATION (scale + fade); left/top must NEVER
|
|
6363
|
-
// transition, or measuring/clamping the position would visibly slide the overlay across
|
|
6364
|
-
// the screen to its anchor. This keeps the position application instant.
|
|
6365
|
-
"pointer-events-auto transition-none",
|
|
6366
|
-
// Origin-aware entrance (DESIGN_SPEC §10 / Emil standards): subtle scale + fade from the
|
|
6367
|
-
// cell corner, reusing the UI popover's tw-animate utilities for a consistent feel. Gated
|
|
6368
|
-
// on `positioned` so the overlay animates only after its measured position is applied.
|
|
6369
|
-
positioned && "animate-[fade-scale-in_var(--duration-moderate)_ease-out] motion-reduce:animate-none",
|
|
6370
|
-
shouldFlip ? "origin-bottom-left" : "origin-top-left"
|
|
6371
|
-
),
|
|
6447
|
+
className: DROPDOWN_MOTION,
|
|
6372
6448
|
children: /* @__PURE__ */ jsx23(OverlayMeasureContext.Provider, { value: overlayMeasure, children: /* @__PURE__ */ jsx23(EditorErrorGuard, { onClose: onCancel, children: /* @__PURE__ */ jsx23(EditorFocusTrap, { onEscape: onCancel, className: cn("overflow-visible", presetClass), children }) }) })
|
|
6373
6449
|
}
|
|
6374
6450
|
),
|
|
@@ -7093,7 +7169,7 @@ function SheetsDomInner({
|
|
|
7093
7169
|
} = props;
|
|
7094
7170
|
const s = useSheets(props);
|
|
7095
7171
|
const shell = s._shell;
|
|
7096
|
-
const { config } = useSheetsContext();
|
|
7172
|
+
const { config, canUpload, scopeKey } = useSheetsContext();
|
|
7097
7173
|
const viewportRef = useRef10(null);
|
|
7098
7174
|
const { commands, keymap, interceptors, onCommand } = props;
|
|
7099
7175
|
const registry = useMemo17(() => createGridCommandRegistry(commands), [commands]);
|
|
@@ -7107,7 +7183,7 @@ function SheetsDomInner({
|
|
|
7107
7183
|
const ctxRef = useRef10(void 0);
|
|
7108
7184
|
const dispatchRef = useRef10(void 0);
|
|
7109
7185
|
dispatchRef.current = useMemo17(() => makeDispatch(registry, () => ctxRef.current, chain), [registry, chain]);
|
|
7110
|
-
const dispatch =
|
|
7186
|
+
const dispatch = useCallback20((command, native, payload) => dispatchRef.current(command, native, payload), []);
|
|
7111
7187
|
const columns = useMemo17(
|
|
7112
7188
|
() => s.columns.map((col) => ({ key: col.id, name: col.title, size: col.width })),
|
|
7113
7189
|
[s.columns]
|
|
@@ -7127,7 +7203,7 @@ function SheetsDomInner({
|
|
|
7127
7203
|
() => ({ start: frozenCount > 0 && firstColumnKey ? [firstColumnKey] : [], end: [] }),
|
|
7128
7204
|
[frozenCount, firstColumnKey]
|
|
7129
7205
|
);
|
|
7130
|
-
const onColumnSizingChange =
|
|
7206
|
+
const onColumnSizingChange = useCallback20(
|
|
7131
7207
|
(updater) => {
|
|
7132
7208
|
const next = functionalUpdate(updater, columnSizing);
|
|
7133
7209
|
for (const key2 of Object.keys(next)) {
|
|
@@ -7149,7 +7225,7 @@ function SheetsDomInner({
|
|
|
7149
7225
|
}
|
|
7150
7226
|
return map;
|
|
7151
7227
|
}, [selection, combinedRows, getRowId]);
|
|
7152
|
-
const onRowSelectionChange =
|
|
7228
|
+
const onRowSelectionChange = useCallback20(
|
|
7153
7229
|
(updater) => {
|
|
7154
7230
|
const next = functionalUpdate(updater, rowSelection);
|
|
7155
7231
|
const indexById = /* @__PURE__ */ new Map();
|
|
@@ -7189,14 +7265,14 @@ function SheetsDomInner({
|
|
|
7189
7265
|
rowMarkerSelectionRef.current = selection;
|
|
7190
7266
|
const rowCountRef = useRef10(rowCount);
|
|
7191
7267
|
rowCountRef.current = rowCount;
|
|
7192
|
-
const toggleRowImpl =
|
|
7268
|
+
const toggleRowImpl = useCallback20((index, shiftKey) => {
|
|
7193
7269
|
const sel = rowMarkerSelectionRef.current ?? emptySheetsSelection;
|
|
7194
7270
|
const anchor = shiftAnchorRef.current;
|
|
7195
7271
|
const next = shiftKey && anchor !== null ? selectRange(sel, anchor, index) : toggleRow(sel, index);
|
|
7196
7272
|
shiftAnchorRef.current = index;
|
|
7197
7273
|
setSelection(next);
|
|
7198
7274
|
}, [setSelection]);
|
|
7199
|
-
const toggleAllImpl =
|
|
7275
|
+
const toggleAllImpl = useCallback20(() => {
|
|
7200
7276
|
const sel = rowMarkerSelectionRef.current ?? emptySheetsSelection;
|
|
7201
7277
|
const rc = rowCountRef.current;
|
|
7202
7278
|
const allSelected = rc > 0 && sel.rows.length === rc;
|
|
@@ -7220,11 +7296,11 @@ function SheetsDomInner({
|
|
|
7220
7296
|
onToggleAll: () => dispatch("rowmarker.toggleAll")
|
|
7221
7297
|
};
|
|
7222
7298
|
}, [selection, rowCount, dispatch]);
|
|
7223
|
-
const getSelectedRows =
|
|
7299
|
+
const getSelectedRows = useCallback20(
|
|
7224
7300
|
() => (selection?.rows.toArray() ?? []).map((i) => combinedRows[i]).filter(Boolean),
|
|
7225
7301
|
[selection, combinedRows]
|
|
7226
7302
|
);
|
|
7227
|
-
const runCsvExport =
|
|
7303
|
+
const runCsvExport = useCallback20(
|
|
7228
7304
|
(opts) => {
|
|
7229
7305
|
const selected = getSelectedRows();
|
|
7230
7306
|
const rows = selected.length ? selected : shell.combinedRows;
|
|
@@ -7244,12 +7320,12 @@ function SheetsDomInner({
|
|
|
7244
7320
|
[s.draft.submitDrafts, s.refetch, getSelectedRows, runCsvExport]
|
|
7245
7321
|
);
|
|
7246
7322
|
const appendRow = s.draft.appendRow;
|
|
7247
|
-
const handleAddRow =
|
|
7323
|
+
const handleAddRow = useCallback20(() => {
|
|
7248
7324
|
void appendRow().then((index) => {
|
|
7249
7325
|
if (index !== void 0) viewportRef.current?.scrollToIndex(index);
|
|
7250
7326
|
});
|
|
7251
7327
|
}, [appendRow]);
|
|
7252
|
-
const handleExport =
|
|
7328
|
+
const handleExport = useCallback20(() => runCsvExport({ filename: `${tableName}.csv` }), [runCsvExport, tableName]);
|
|
7253
7329
|
const optionsKey = useMemo17(
|
|
7254
7330
|
() => JSON.stringify({ id: shell.sorting.id, desc: shell.sorting.desc, filter: shell.filterTree }),
|
|
7255
7331
|
[shell.sorting.id, shell.sorting.desc, shell.filterTree]
|
|
@@ -7267,6 +7343,11 @@ function SheetsDomInner({
|
|
|
7267
7343
|
const overlayOpen = overlay2.open;
|
|
7268
7344
|
const overlayClose = overlay2.close;
|
|
7269
7345
|
const overlayReanchor = overlay2.reanchor;
|
|
7346
|
+
const mediaDraft = overlay2.active?.mediaDraft;
|
|
7347
|
+
const activeMediaDraft = canUpload && mediaDraft?.scopeKey === scopeKey && mediaDraft?.tableName === tableName ? mediaDraft : void 0;
|
|
7348
|
+
useEffect6(() => {
|
|
7349
|
+
if (mediaDraft && !activeMediaDraft) overlayClose();
|
|
7350
|
+
}, [mediaDraft, activeMediaDraft, overlayClose]);
|
|
7270
7351
|
const getSheetsCellContent = shell.getSheetsCellContent;
|
|
7271
7352
|
const submitDraftRow = shell.submitDraftRow;
|
|
7272
7353
|
const commitCellValue = shell.commitCellValue;
|
|
@@ -7287,7 +7368,7 @@ function SheetsDomInner({
|
|
|
7287
7368
|
commitCellsRef.current = commitCells;
|
|
7288
7369
|
const selectionRef = useRef10(selection);
|
|
7289
7370
|
selectionRef.current = selection;
|
|
7290
|
-
const openEditorImpl =
|
|
7371
|
+
const openEditorImpl = useCallback20(
|
|
7291
7372
|
(rowIndex, colKey, anchorRect, initialText) => {
|
|
7292
7373
|
const resolution = getSheetsCellContentRef.current(rowIndex, colKey);
|
|
7293
7374
|
const intent = resolveEditIntent(
|
|
@@ -7305,17 +7386,32 @@ function SheetsDomInner({
|
|
|
7305
7386
|
overlayOpen({ rowIndex, colKey, anchorRect, initialText, mode: "inline" });
|
|
7306
7387
|
return;
|
|
7307
7388
|
}
|
|
7308
|
-
|
|
7389
|
+
const row = combinedRowsRef.current[rowIndex];
|
|
7390
|
+
const draft = intent.editor === ImageEditorDom ? getDraftMeta(row) : void 0;
|
|
7391
|
+
overlayOpen({
|
|
7392
|
+
rowIndex,
|
|
7393
|
+
colKey,
|
|
7394
|
+
anchorRect,
|
|
7395
|
+
initialText,
|
|
7396
|
+
mode: "overlay",
|
|
7397
|
+
mediaDraft: draft ? {
|
|
7398
|
+
rowId: draft.draftRowId,
|
|
7399
|
+
tableName,
|
|
7400
|
+
scopeKey,
|
|
7401
|
+
value: row[colKey],
|
|
7402
|
+
resolution
|
|
7403
|
+
} : void 0
|
|
7404
|
+
});
|
|
7309
7405
|
},
|
|
7310
|
-
[overlayOpen]
|
|
7406
|
+
[overlayOpen, tableName, scopeKey]
|
|
7311
7407
|
);
|
|
7312
|
-
const openEditor =
|
|
7408
|
+
const openEditor = useCallback20(
|
|
7313
7409
|
(rowIndex, colKey, anchorRect, initialText) => dispatch("editor.open", void 0, { rowIndex, colKey, anchorRect, initialText }),
|
|
7314
7410
|
[dispatch]
|
|
7315
7411
|
);
|
|
7316
7412
|
const columnKeysRef = useRef10(shell.columnKeys);
|
|
7317
7413
|
columnKeysRef.current = shell.columnKeys;
|
|
7318
|
-
const commitBulkOrSingle =
|
|
7414
|
+
const commitBulkOrSingle = useCallback20(
|
|
7319
7415
|
(rowIndex, colKey, value) => {
|
|
7320
7416
|
const range = selectionRef.current?.current?.range;
|
|
7321
7417
|
const keys = columnKeysRef.current;
|
|
@@ -7333,7 +7429,7 @@ function SheetsDomInner({
|
|
|
7333
7429
|
);
|
|
7334
7430
|
const anchorRef = useRef10(null);
|
|
7335
7431
|
const setSelectionRange = s.selection.setGridSelection;
|
|
7336
|
-
const extendToCell =
|
|
7432
|
+
const extendToCell = useCallback20(
|
|
7337
7433
|
(col, row) => {
|
|
7338
7434
|
const sel = selectionRef.current ?? emptySheetsSelection;
|
|
7339
7435
|
const anchor = anchorRef.current ?? sel.current?.cell ?? [col, row];
|
|
@@ -7343,12 +7439,12 @@ function SheetsDomInner({
|
|
|
7343
7439
|
[setSelectionRange]
|
|
7344
7440
|
);
|
|
7345
7441
|
const setActiveCell = s.selection.setActiveCell;
|
|
7346
|
-
const handleActivateCell =
|
|
7442
|
+
const handleActivateCell = useCallback20(
|
|
7347
7443
|
(col, row, shiftKey) => dispatch(shiftKey ? "cell.extendToClicked" : "cell.activate", void 0, { col, row }),
|
|
7348
7444
|
[dispatch]
|
|
7349
7445
|
);
|
|
7350
7446
|
const [contextMenu, setContextMenu] = useState9(null);
|
|
7351
|
-
const handleContextMenu =
|
|
7447
|
+
const handleContextMenu = useCallback20(
|
|
7352
7448
|
(col, row, clientX, clientY) => {
|
|
7353
7449
|
const sel = selectionRef.current;
|
|
7354
7450
|
const active2 = sel?.current?.cell;
|
|
@@ -7360,8 +7456,8 @@ function SheetsDomInner({
|
|
|
7360
7456
|
},
|
|
7361
7457
|
[dispatch]
|
|
7362
7458
|
);
|
|
7363
|
-
const closeContextMenu =
|
|
7364
|
-
const isCommandEnabled =
|
|
7459
|
+
const closeContextMenu = useCallback20(() => setContextMenu(null), []);
|
|
7460
|
+
const isCommandEnabled = useCallback20(
|
|
7365
7461
|
(commandId) => {
|
|
7366
7462
|
const cmd = registry.get(commandId);
|
|
7367
7463
|
return cmd ? cmd.canRun ? cmd.canRun(ctxRef.current, void 0) : true : false;
|
|
@@ -7371,14 +7467,14 @@ function SheetsDomInner({
|
|
|
7371
7467
|
const inlineActive = overlay2.active?.mode === "inline" ? overlay2.active : null;
|
|
7372
7468
|
const inlineKey = inlineActive ? `${inlineActive.rowIndex}:${inlineActive.colKey}` : null;
|
|
7373
7469
|
const inlineInitialText = inlineActive?.initialText;
|
|
7374
|
-
const onInlineCommit =
|
|
7470
|
+
const onInlineCommit = useCallback20(
|
|
7375
7471
|
(rowIndex, colKey, value) => {
|
|
7376
7472
|
commitBulkOrSingle(rowIndex, colKey, value);
|
|
7377
7473
|
overlayClose();
|
|
7378
7474
|
},
|
|
7379
7475
|
[commitBulkOrSingle, overlayClose]
|
|
7380
7476
|
);
|
|
7381
|
-
const renderCell =
|
|
7477
|
+
const renderCell = useCallback20(
|
|
7382
7478
|
(c, ctx) => {
|
|
7383
7479
|
const editingThisCell = inlineKey != null && inlineKey === `${c.row.index}:${c.column.id}`;
|
|
7384
7480
|
return /* @__PURE__ */ jsx24(
|
|
@@ -7402,7 +7498,7 @@ function SheetsDomInner({
|
|
|
7402
7498
|
);
|
|
7403
7499
|
const moveActiveCell = s.selection.moveActive;
|
|
7404
7500
|
const isOverlayOpen = overlay2.isOpen;
|
|
7405
|
-
const openEditorAtActiveCell =
|
|
7501
|
+
const openEditorAtActiveCell = useCallback20(
|
|
7406
7502
|
(initialText) => {
|
|
7407
7503
|
const cell = selectionRef.current?.current?.cell;
|
|
7408
7504
|
if (!cell) return false;
|
|
@@ -7418,7 +7514,7 @@ function SheetsDomInner({
|
|
|
7418
7514
|
},
|
|
7419
7515
|
[columns, openEditorImpl]
|
|
7420
7516
|
);
|
|
7421
|
-
const handleGridKeyDown =
|
|
7517
|
+
const handleGridKeyDown = useCallback20(
|
|
7422
7518
|
(e) => {
|
|
7423
7519
|
if (isOverlayOpen) return;
|
|
7424
7520
|
const cmd = resolveKeyCommand(e.nativeEvent, keymapRef.current);
|
|
@@ -7432,21 +7528,21 @@ function SheetsDomInner({
|
|
|
7432
7528
|
},
|
|
7433
7529
|
[isOverlayOpen, dispatch]
|
|
7434
7530
|
);
|
|
7435
|
-
const handleCopy =
|
|
7531
|
+
const handleCopy = useCallback20(
|
|
7436
7532
|
(e) => {
|
|
7437
7533
|
if (isOverlayOpen) return;
|
|
7438
7534
|
dispatch("clipboard.copy", e.nativeEvent, { clipboard: e.nativeEvent.clipboardData });
|
|
7439
7535
|
},
|
|
7440
7536
|
[isOverlayOpen, dispatch]
|
|
7441
7537
|
);
|
|
7442
|
-
const handleCut =
|
|
7538
|
+
const handleCut = useCallback20(
|
|
7443
7539
|
(e) => {
|
|
7444
7540
|
if (isOverlayOpen) return;
|
|
7445
7541
|
dispatch("clipboard.cut", e.nativeEvent, { clipboard: e.nativeEvent.clipboardData });
|
|
7446
7542
|
},
|
|
7447
7543
|
[isOverlayOpen, dispatch]
|
|
7448
7544
|
);
|
|
7449
|
-
const handlePaste =
|
|
7545
|
+
const handlePaste = useCallback20(
|
|
7450
7546
|
(e) => {
|
|
7451
7547
|
if (isOverlayOpen) return;
|
|
7452
7548
|
dispatch("clipboard.paste", e.nativeEvent, { clipboard: e.nativeEvent.clipboardData });
|
|
@@ -7457,9 +7553,10 @@ function SheetsDomInner({
|
|
|
7457
7553
|
activeRef.current = overlay2.active;
|
|
7458
7554
|
const columnsRef = useRef10(columns);
|
|
7459
7555
|
columnsRef.current = columns;
|
|
7460
|
-
const handleOverlayScroll =
|
|
7556
|
+
const handleOverlayScroll = useCallback20(() => {
|
|
7461
7557
|
const a = activeRef.current;
|
|
7462
7558
|
if (!a) return;
|
|
7559
|
+
if (a.mediaDraft && getDraftMeta(combinedRowsRef.current[a.rowIndex])?.draftRowId !== a.mediaDraft.rowId) return;
|
|
7463
7560
|
const colIndex = columnsRef.current.findIndex((c) => c.key === a.colKey);
|
|
7464
7561
|
const node = colIndex >= 0 ? document.getElementById(`sheets-cell-${a.rowIndex}-${colIndex}`) : null;
|
|
7465
7562
|
if (node) {
|
|
@@ -7472,12 +7569,13 @@ function SheetsDomInner({
|
|
|
7472
7569
|
}, [overlayReanchor, overlayClose]);
|
|
7473
7570
|
const active = overlay2.active;
|
|
7474
7571
|
const editorNode = (() => {
|
|
7475
|
-
if (!active) return null;
|
|
7476
|
-
const resolution = getSheetsCellContent(active.rowIndex, active.colKey);
|
|
7572
|
+
if (!active || mediaDraft && !activeMediaDraft) return null;
|
|
7573
|
+
const resolution = activeMediaDraft?.resolution ?? getSheetsCellContent(active.rowIndex, active.colKey);
|
|
7477
7574
|
const intent = resolveEditIntent(resolution.typeKey, { readonly: resolution.cell.readonly }, getEditorComponent);
|
|
7478
7575
|
if (intent.mode !== "overlay") return null;
|
|
7479
7576
|
const Editor = intent.editor;
|
|
7480
|
-
const
|
|
7577
|
+
const row = combinedRows[active.rowIndex];
|
|
7578
|
+
const rowValue = activeMediaDraft ? activeMediaDraft.value : row?.[active.colKey];
|
|
7481
7579
|
const geom = computeOverlayGeometry(
|
|
7482
7580
|
typeof window !== "undefined" ? window.innerHeight : 800,
|
|
7483
7581
|
active.anchorRect.top,
|
|
@@ -7496,7 +7594,8 @@ function SheetsDomInner({
|
|
|
7496
7594
|
value: rowValue,
|
|
7497
7595
|
cell: resolution.cell,
|
|
7498
7596
|
colKey: active.colKey,
|
|
7499
|
-
rowId: getRowId(
|
|
7597
|
+
rowId: activeMediaDraft?.rowId ?? getRowId(row, active.rowIndex),
|
|
7598
|
+
rowIdentifier: resolution.rowIdentifier,
|
|
7500
7599
|
rowIndex: active.rowIndex,
|
|
7501
7600
|
tableName: props.tableName,
|
|
7502
7601
|
fieldMeta: resolution.fieldMeta,
|
|
@@ -7507,7 +7606,9 @@ function SheetsDomInner({
|
|
|
7507
7606
|
overlayClose();
|
|
7508
7607
|
},
|
|
7509
7608
|
onCommitPatch: (patch) => {
|
|
7510
|
-
|
|
7609
|
+
if (!activeMediaDraft || getDraftMeta(row)?.draftRowId === activeMediaDraft.rowId) {
|
|
7610
|
+
shell.commitCellPatch(active.rowIndex, patch);
|
|
7611
|
+
}
|
|
7511
7612
|
overlayClose();
|
|
7512
7613
|
},
|
|
7513
7614
|
onSubmitDraftRow: shell.submitDraftRow,
|
|
@@ -7519,7 +7620,7 @@ function SheetsDomInner({
|
|
|
7519
7620
|
};
|
|
7520
7621
|
})();
|
|
7521
7622
|
const onVisibleRegionChanged = shell.onVisibleRegionChanged;
|
|
7522
|
-
const onVisibleRangeChange =
|
|
7623
|
+
const onVisibleRangeChange = useCallback20(
|
|
7523
7624
|
(range) => {
|
|
7524
7625
|
onVisibleRegionChanged(range);
|
|
7525
7626
|
},
|
|
@@ -7528,8 +7629,8 @@ function SheetsDomInner({
|
|
|
7528
7629
|
const sorting = shell.sorting;
|
|
7529
7630
|
const onHeaderClicked = shell.onHeaderClicked;
|
|
7530
7631
|
const columnKeys = shell.columnKeys;
|
|
7531
|
-
const onHeaderClick =
|
|
7532
|
-
const handleFillDrag =
|
|
7632
|
+
const onHeaderClick = useCallback20((colKey) => dispatch("header.sortToggle", void 0, { colKey }), [dispatch]);
|
|
7633
|
+
const handleFillDrag = useCallback20(
|
|
7533
7634
|
(sourceRange, target) => dispatch("fill.drag", void 0, { from: sourceRange, to: target }),
|
|
7534
7635
|
[dispatch]
|
|
7535
7636
|
);
|
|
@@ -7576,18 +7677,18 @@ function SheetsDomInner({
|
|
|
7576
7677
|
toTSV: (values) => toTSV(values),
|
|
7577
7678
|
emit
|
|
7578
7679
|
};
|
|
7579
|
-
if (s.dataError && shell.combinedRows.length === 0) {
|
|
7680
|
+
if (!activeMediaDraft && s.dataError && shell.combinedRows.length === 0) {
|
|
7580
7681
|
const retry = () => s.refetch();
|
|
7581
7682
|
if (slots?.error) {
|
|
7582
7683
|
return /* @__PURE__ */ jsx24(Fragment3, { children: slots.error({ error: s.dataError, retry }) });
|
|
7583
7684
|
}
|
|
7584
7685
|
return /* @__PURE__ */ jsx24(SheetsErrorState, { error: s.dataError, onRetry: retry });
|
|
7585
7686
|
}
|
|
7586
|
-
if (s.isInitialLoading) {
|
|
7687
|
+
if (!activeMediaDraft && s.isInitialLoading) {
|
|
7587
7688
|
if (slots?.loading) return /* @__PURE__ */ jsx24(Fragment3, { children: slots.loading });
|
|
7588
7689
|
return /* @__PURE__ */ jsx24(SheetsLoadingState, {});
|
|
7589
7690
|
}
|
|
7590
|
-
if (s.isEmpty) {
|
|
7691
|
+
if (!activeMediaDraft && s.isEmpty) {
|
|
7591
7692
|
if (slots?.empty) {
|
|
7592
7693
|
return /* @__PURE__ */ jsx24(Fragment3, { children: typeof slots.empty === "function" ? slots.empty({ tableName }) : slots.empty });
|
|
7593
7694
|
}
|
|
@@ -7734,7 +7835,7 @@ function tokensFromCssVars(el = typeof document !== "undefined" ? document.docum
|
|
|
7734
7835
|
}
|
|
7735
7836
|
|
|
7736
7837
|
// src/grid/sheets.table-selector.tsx
|
|
7737
|
-
import { memo as memo3, useCallback as
|
|
7838
|
+
import { memo as memo3, useCallback as useCallback21, useEffect as useEffect7, useMemo as useMemo18, useRef as useRef11, useState as useState10 } from "react";
|
|
7738
7839
|
import { RiAddLine as RiAddLine4, RiDatabaseLine, RiSearchLine } from "@remixicon/react";
|
|
7739
7840
|
import { ChevronRight } from "lucide-react";
|
|
7740
7841
|
import { AnimatePresence as AnimatePresence3, motion as motion3 } from "motion/react";
|
|
@@ -7809,13 +7910,13 @@ var SheetsTableSelector = memo3(function SheetsTableSelector2({
|
|
|
7809
7910
|
resizeObserver.observe(container);
|
|
7810
7911
|
return () => resizeObserver.disconnect();
|
|
7811
7912
|
}, []);
|
|
7812
|
-
const handleTableSelect =
|
|
7913
|
+
const handleTableSelect = useCallback21(
|
|
7813
7914
|
(tableName) => {
|
|
7814
7915
|
onTableChange(tableName);
|
|
7815
7916
|
},
|
|
7816
7917
|
[onTableChange]
|
|
7817
7918
|
);
|
|
7818
|
-
const handleNewTable =
|
|
7919
|
+
const handleNewTable = useCallback21(() => {
|
|
7819
7920
|
if (onNewTable) {
|
|
7820
7921
|
onNewTable();
|
|
7821
7922
|
}
|
|
@@ -7925,7 +8026,7 @@ function SheetsTableListByCategory({
|
|
|
7925
8026
|
}, 350);
|
|
7926
8027
|
return () => clearTimeout(timer);
|
|
7927
8028
|
}, [shouldScrollToActive, isExpanded, activeTable]);
|
|
7928
|
-
const handleScroll =
|
|
8029
|
+
const handleScroll = useCallback21((event) => {
|
|
7929
8030
|
const el = event.currentTarget;
|
|
7930
8031
|
const atBottom = el.scrollTop + el.clientHeight >= el.scrollHeight - 1;
|
|
7931
8032
|
setShowBottomBlur(!(atBottom || el.scrollHeight <= el.clientHeight));
|
|
@@ -8444,7 +8545,7 @@ function useDynamicUpdate(tableName, rowId) {
|
|
|
8444
8545
|
}
|
|
8445
8546
|
|
|
8446
8547
|
// src/grid/hooks/use-filter-grid.ts
|
|
8447
|
-
import { useCallback as
|
|
8548
|
+
import { useCallback as useCallback23, useMemo as useMemo19, useState as useState11 } from "react";
|
|
8448
8549
|
function hasActiveNode(node) {
|
|
8449
8550
|
if (node.type === "condition") {
|
|
8450
8551
|
return isValuelessOperator(node.operator) || node.value !== "" && node.value !== null && node.value !== void 0;
|
|
@@ -8458,10 +8559,10 @@ function useDataFiltering({
|
|
|
8458
8559
|
}) {
|
|
8459
8560
|
const [filterTree, setFilterTree] = useState11(initialFilterTree ?? createEmptyGroup());
|
|
8460
8561
|
const [filtersOpen, setFiltersOpen] = useState11(false);
|
|
8461
|
-
const clearAllFilters =
|
|
8562
|
+
const clearAllFilters = useCallback23(() => {
|
|
8462
8563
|
setFilterTree(createEmptyGroup());
|
|
8463
8564
|
}, []);
|
|
8464
|
-
const applyFilters =
|
|
8565
|
+
const applyFilters = useCallback23(() => {
|
|
8465
8566
|
}, []);
|
|
8466
8567
|
const effectiveWhere = useMemo19(
|
|
8467
8568
|
() => buildWhereFromFilters(filterTree, tableMeta),
|
|
@@ -8491,7 +8592,7 @@ function useDataFiltering({
|
|
|
8491
8592
|
}
|
|
8492
8593
|
|
|
8493
8594
|
// src/grid/hooks/use-paginate-grid.ts
|
|
8494
|
-
import { useCallback as
|
|
8595
|
+
import { useCallback as useCallback24, useEffect as useEffect8, useMemo as useMemo20, useState as useState12 } from "react";
|
|
8495
8596
|
function useDataPagination({
|
|
8496
8597
|
initialPageSize = 100,
|
|
8497
8598
|
initialPageIndex = 0,
|
|
@@ -8520,7 +8621,7 @@ function useDataPagination({
|
|
|
8520
8621
|
setPageIndexState(Math.max(0, totalPages - 1));
|
|
8521
8622
|
}
|
|
8522
8623
|
}, [pageIndex, totalPages]);
|
|
8523
|
-
const setPageIndex =
|
|
8624
|
+
const setPageIndex = useCallback24(
|
|
8524
8625
|
(index) => {
|
|
8525
8626
|
const clampedIndex = Math.max(0, Math.min(index, totalPages - 1));
|
|
8526
8627
|
setPageIndexState(clampedIndex);
|
|
@@ -8528,7 +8629,7 @@ function useDataPagination({
|
|
|
8528
8629
|
},
|
|
8529
8630
|
[totalPages, pageSize, onPageChange]
|
|
8530
8631
|
);
|
|
8531
|
-
const setPageSize =
|
|
8632
|
+
const setPageSize = useCallback24(
|
|
8532
8633
|
(size) => {
|
|
8533
8634
|
setPageSizeState(size);
|
|
8534
8635
|
setPageIndexState(0);
|
|
@@ -8536,20 +8637,20 @@ function useDataPagination({
|
|
|
8536
8637
|
},
|
|
8537
8638
|
[onPageChange]
|
|
8538
8639
|
);
|
|
8539
|
-
const goToNextPage =
|
|
8640
|
+
const goToNextPage = useCallback24(() => {
|
|
8540
8641
|
if (hasNextPage) {
|
|
8541
8642
|
setPageIndex(pageIndex + 1);
|
|
8542
8643
|
}
|
|
8543
8644
|
}, [hasNextPage, pageIndex, setPageIndex]);
|
|
8544
|
-
const goToPreviousPage =
|
|
8645
|
+
const goToPreviousPage = useCallback24(() => {
|
|
8545
8646
|
if (hasPreviousPage) {
|
|
8546
8647
|
setPageIndex(pageIndex - 1);
|
|
8547
8648
|
}
|
|
8548
8649
|
}, [hasPreviousPage, pageIndex, setPageIndex]);
|
|
8549
|
-
const goToFirstPage =
|
|
8650
|
+
const goToFirstPage = useCallback24(() => {
|
|
8550
8651
|
setPageIndex(0);
|
|
8551
8652
|
}, [setPageIndex]);
|
|
8552
|
-
const goToLastPage =
|
|
8653
|
+
const goToLastPage = useCallback24(() => {
|
|
8553
8654
|
setPageIndex(totalPages - 1);
|
|
8554
8655
|
}, [totalPages, setPageIndex]);
|
|
8555
8656
|
const contextValue = useMemo20(
|
|
@@ -8682,7 +8783,6 @@ export {
|
|
|
8682
8783
|
useSheetsContext,
|
|
8683
8784
|
useSheetsFieldUpload,
|
|
8684
8785
|
useSheetsForgotPassword,
|
|
8685
|
-
useSheetsImageUpload,
|
|
8686
8786
|
useSheetsInfiniteTable,
|
|
8687
8787
|
useSheetsLogin,
|
|
8688
8788
|
useSheetsMeta,
|