docblocks-react-ui 0.27.0 → 0.28.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/CHANGELOG.md +6 -0
- package/README.md +15 -3
- package/dist/{Editor-L0Ph4I89.mjs → Editor-IByUG91k.mjs} +653 -199
- package/dist/{index-QtG3mkFQ.d.mts → index-Ccn_x_wU.d.mts} +2 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/mermaid/index.mjs +1 -1
- package/dist/pdf/index.d.mts +1 -1
- package/dist/styles.css +13 -0
- package/package.json +1 -1
|
@@ -516,6 +516,11 @@ const INIT_OPTIONS = {
|
|
|
516
516
|
"moveDown": "Move down",
|
|
517
517
|
"delete": "Delete row"
|
|
518
518
|
},
|
|
519
|
+
range: {
|
|
520
|
+
"options": "Selected range",
|
|
521
|
+
"clear": "Clear range",
|
|
522
|
+
"deleteRows": "Delete rows"
|
|
523
|
+
},
|
|
519
524
|
rows: {
|
|
520
525
|
"loadMore": "Load more rows",
|
|
521
526
|
"none": "No rows.",
|
|
@@ -534,7 +539,26 @@ const INIT_OPTIONS = {
|
|
|
534
539
|
"group": "+ Group",
|
|
535
540
|
"groupHeader": "Group {index}",
|
|
536
541
|
"removeCondition": "Remove condition",
|
|
537
|
-
"valuePlaceholder": "value, value"
|
|
542
|
+
"valuePlaceholder": "value, value",
|
|
543
|
+
"operators": {
|
|
544
|
+
"is": "is",
|
|
545
|
+
"is not": "is not",
|
|
546
|
+
"contains": "contains",
|
|
547
|
+
"not contains": "not contains",
|
|
548
|
+
"starts with": "starts with",
|
|
549
|
+
"ends with": "ends with",
|
|
550
|
+
"empty": "empty",
|
|
551
|
+
"not empty": "not empty",
|
|
552
|
+
"<": "<",
|
|
553
|
+
"<=": "<=",
|
|
554
|
+
">": ">",
|
|
555
|
+
">=": ">=",
|
|
556
|
+
"between": "between",
|
|
557
|
+
"before": "before",
|
|
558
|
+
"after": "after",
|
|
559
|
+
"in": "in",
|
|
560
|
+
"not in": "not in"
|
|
561
|
+
}
|
|
538
562
|
},
|
|
539
563
|
picker: {
|
|
540
564
|
"searchOptions": "Search options",
|
|
@@ -1068,6 +1092,11 @@ const INIT_OPTIONS = {
|
|
|
1068
1092
|
"moveDown": "Переместить вниз",
|
|
1069
1093
|
"delete": "Удалить строку"
|
|
1070
1094
|
},
|
|
1095
|
+
range: {
|
|
1096
|
+
"options": "Выделенный диапазон",
|
|
1097
|
+
"clear": "Очистить диапазон",
|
|
1098
|
+
"deleteRows": "Удалить строки"
|
|
1099
|
+
},
|
|
1071
1100
|
rows: {
|
|
1072
1101
|
"loadMore": "Загрузить ещё строки",
|
|
1073
1102
|
"none": "Нет строк.",
|
|
@@ -1086,7 +1115,26 @@ const INIT_OPTIONS = {
|
|
|
1086
1115
|
"group": "+ Группа",
|
|
1087
1116
|
"groupHeader": "Группа {index}",
|
|
1088
1117
|
"removeCondition": "Удалить условие",
|
|
1089
|
-
"valuePlaceholder": "значение, значение"
|
|
1118
|
+
"valuePlaceholder": "значение, значение",
|
|
1119
|
+
"operators": {
|
|
1120
|
+
"is": "равно",
|
|
1121
|
+
"is not": "не равно",
|
|
1122
|
+
"contains": "содержит",
|
|
1123
|
+
"not contains": "не содержит",
|
|
1124
|
+
"starts with": "начинается с",
|
|
1125
|
+
"ends with": "завершается на",
|
|
1126
|
+
"empty": "не заполнено",
|
|
1127
|
+
"not empty": "заполнено",
|
|
1128
|
+
"<": "меньше",
|
|
1129
|
+
"<=": "меньше или равно",
|
|
1130
|
+
">": "больше",
|
|
1131
|
+
">=": "больше или равно",
|
|
1132
|
+
"between": "между",
|
|
1133
|
+
"before": "ранее",
|
|
1134
|
+
"after": "позднее",
|
|
1135
|
+
"in": "в списке",
|
|
1136
|
+
"not in": "не в списке"
|
|
1137
|
+
}
|
|
1090
1138
|
},
|
|
1091
1139
|
picker: {
|
|
1092
1140
|
"searchOptions": "Поиск вариантов",
|
|
@@ -4185,14 +4233,18 @@ const NUMBER_OPERATORS = [
|
|
|
4185
4233
|
"<=",
|
|
4186
4234
|
">",
|
|
4187
4235
|
">=",
|
|
4188
|
-
"between"
|
|
4236
|
+
"between",
|
|
4237
|
+
"empty",
|
|
4238
|
+
"not empty"
|
|
4189
4239
|
];
|
|
4190
4240
|
/** The date / datetime operators. */
|
|
4191
4241
|
const DATE_OPERATORS = [
|
|
4192
4242
|
"is",
|
|
4193
4243
|
"before",
|
|
4194
4244
|
"after",
|
|
4195
|
-
"between"
|
|
4245
|
+
"between",
|
|
4246
|
+
"empty",
|
|
4247
|
+
"not empty"
|
|
4196
4248
|
];
|
|
4197
4249
|
/** The time-of-day operators. */
|
|
4198
4250
|
const TIME_OPERATORS = [
|
|
@@ -4200,9 +4252,18 @@ const TIME_OPERATORS = [
|
|
|
4200
4252
|
"is not",
|
|
4201
4253
|
"before",
|
|
4202
4254
|
"after",
|
|
4203
|
-
"between"
|
|
4255
|
+
"between",
|
|
4256
|
+
"empty",
|
|
4257
|
+
"not empty"
|
|
4204
4258
|
];
|
|
4205
|
-
/** The
|
|
4259
|
+
/** The boolean operators (the emptiness's checks stand the null's cell). */
|
|
4260
|
+
const BOOLEAN_OPERATORS = [
|
|
4261
|
+
"is",
|
|
4262
|
+
"is not",
|
|
4263
|
+
"empty",
|
|
4264
|
+
"not empty"
|
|
4265
|
+
];
|
|
4266
|
+
/** The equality-only operators (the interval / unknown). */
|
|
4206
4267
|
const EQUALITY_OPERATORS = ["is", "is not"];
|
|
4207
4268
|
/** The standard PostgreSQL type names per operator / input group. The contract
|
|
4208
4269
|
* is type-agnostic — this is the package's DEFAULT catalog; a non-standard
|
|
@@ -4268,7 +4329,8 @@ function operatorCatalog(type) {
|
|
|
4268
4329
|
const base = baseType(type);
|
|
4269
4330
|
if (TEXT_TYPES.has(base)) return TEXT_OPERATORS;
|
|
4270
4331
|
if (NUMBER_TYPES.has(base)) return NUMBER_OPERATORS;
|
|
4271
|
-
if (BOOLEAN_TYPES.has(base)
|
|
4332
|
+
if (BOOLEAN_TYPES.has(base)) return BOOLEAN_OPERATORS;
|
|
4333
|
+
if (INTERVAL_TYPES.has(base)) return EQUALITY_OPERATORS;
|
|
4272
4334
|
if (DATE_TYPES.has(base) || DATETIME_TYPES.has(base)) return DATE_OPERATORS;
|
|
4273
4335
|
if (TIME_TYPES.has(base)) return TIME_OPERATORS;
|
|
4274
4336
|
}
|
|
@@ -4293,12 +4355,12 @@ function valueInputFor(type) {
|
|
|
4293
4355
|
function columnAnnotation(column) {
|
|
4294
4356
|
let operators;
|
|
4295
4357
|
if (column.operators !== void 0) operators = [...column.operators];
|
|
4296
|
-
else if (column.refKind === "enum" || column.refKind === "row") operators =
|
|
4358
|
+
else if (column.refKind === "enum" || column.refKind === "row") operators = [
|
|
4297
4359
|
"is",
|
|
4298
4360
|
"is not",
|
|
4299
4361
|
"empty",
|
|
4300
4362
|
"not empty"
|
|
4301
|
-
]
|
|
4363
|
+
];
|
|
4302
4364
|
else operators = operatorCatalog(column.type) ?? ["is", "is not"];
|
|
4303
4365
|
let valueInput;
|
|
4304
4366
|
if (column.refKind === "enum") valueInput = "enum";
|
|
@@ -6121,6 +6183,57 @@ function Textarea({ className, ...props }) {
|
|
|
6121
6183
|
});
|
|
6122
6184
|
}
|
|
6123
6185
|
//#endregion
|
|
6186
|
+
//#region src/database/filter-builder/FilterOperatorPicker.tsx
|
|
6187
|
+
/**
|
|
6188
|
+
* The filter's operator's picker: the popover's option list over the column
|
|
6189
|
+
* annotation's catalog (the trigger stands the selected operator's localized
|
|
6190
|
+
* label, the list stands the catalog over its declared order with the active
|
|
6191
|
+
* option marked). The pick commits the wire's op — the display label never
|
|
6192
|
+
* reaches the payload (the op's contract), and a consumer's custom operator
|
|
6193
|
+
* (the `operators` override) stands its raw form when the catalog has no
|
|
6194
|
+
* label for it.
|
|
6195
|
+
*/
|
|
6196
|
+
function FilterOperatorPicker({ operators, value, onPick }) {
|
|
6197
|
+
const { t } = useTranslation("database");
|
|
6198
|
+
const [open, setOpen] = useState(false);
|
|
6199
|
+
const label = (operator) => t(`filter.operators.${operator}`, operator);
|
|
6200
|
+
const pick = (operator) => {
|
|
6201
|
+
setOpen(false);
|
|
6202
|
+
onPick(operator);
|
|
6203
|
+
};
|
|
6204
|
+
const pickOption = (operator) => () => pick(operator);
|
|
6205
|
+
return /* @__PURE__ */ jsxs(Popover, {
|
|
6206
|
+
open,
|
|
6207
|
+
onOpenChange: setOpen,
|
|
6208
|
+
children: [/* @__PURE__ */ jsx(PopoverTrigger, {
|
|
6209
|
+
asChild: true,
|
|
6210
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
6211
|
+
type: "button",
|
|
6212
|
+
variant: "outline",
|
|
6213
|
+
size: "sm",
|
|
6214
|
+
"data-slot": "docblocks/filter-operator",
|
|
6215
|
+
"data-operator": value,
|
|
6216
|
+
className: "\n h-8 max-w-45 truncate rounded-md border border-input bg-transparent px-2 text-sm text-foreground\n outline-none\n focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50\n dark:bg-input/30\n ",
|
|
6217
|
+
children: label(value)
|
|
6218
|
+
})
|
|
6219
|
+
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
6220
|
+
align: "start",
|
|
6221
|
+
className: "w-48 gap-0.5 p-1.5",
|
|
6222
|
+
children: operators.map((operator) => /* @__PURE__ */ jsx(Button, {
|
|
6223
|
+
type: "button",
|
|
6224
|
+
variant: "ghost",
|
|
6225
|
+
size: "sm",
|
|
6226
|
+
"data-slot": "docblocks/filter-operator-option",
|
|
6227
|
+
"data-operator": operator,
|
|
6228
|
+
"data-active": operator === value ? "true" : void 0,
|
|
6229
|
+
className: cn("w-full cursor-pointer justify-start rounded-md px-2 py-1.5 font-normal", operator === value && "bg-muted"),
|
|
6230
|
+
onClick: pickOption(operator),
|
|
6231
|
+
children: label(operator)
|
|
6232
|
+
}, operator))
|
|
6233
|
+
})]
|
|
6234
|
+
});
|
|
6235
|
+
}
|
|
6236
|
+
//#endregion
|
|
6124
6237
|
//#region src/database/grid/use-ref-tables.ts
|
|
6125
6238
|
/**
|
|
6126
6239
|
* The ref-table data provider for the grid: one page of the ref table's
|
|
@@ -6595,11 +6708,6 @@ function FilterConditionRow({ condition, columns, onChange, onRemove, refTableDa
|
|
|
6595
6708
|
value: void 0
|
|
6596
6709
|
});
|
|
6597
6710
|
};
|
|
6598
|
-
const onOperatorChange = (event) => onChange({
|
|
6599
|
-
...condition,
|
|
6600
|
-
op: event.target.value,
|
|
6601
|
-
value: void 0
|
|
6602
|
-
});
|
|
6603
6711
|
const onValueChange = (value) => onChange({
|
|
6604
6712
|
...condition,
|
|
6605
6713
|
op: operator,
|
|
@@ -6629,14 +6737,14 @@ function FilterConditionRow({ condition, columns, onChange, onRemove, refTableDa
|
|
|
6629
6737
|
children: entry.name
|
|
6630
6738
|
}, entry.id))
|
|
6631
6739
|
}),
|
|
6632
|
-
/* @__PURE__ */ jsx(
|
|
6633
|
-
|
|
6740
|
+
/* @__PURE__ */ jsx(FilterOperatorPicker, {
|
|
6741
|
+
operators: annotation.operators,
|
|
6634
6742
|
value: operator,
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
6639
|
-
}
|
|
6743
|
+
onPick: (nextOperator) => onChange({
|
|
6744
|
+
...condition,
|
|
6745
|
+
op: nextOperator,
|
|
6746
|
+
value: void 0
|
|
6747
|
+
})
|
|
6640
6748
|
}),
|
|
6641
6749
|
needsValue && /* @__PURE__ */ jsx(ValueInput, {
|
|
6642
6750
|
column,
|
|
@@ -7309,6 +7417,48 @@ function useTableHistory({ bridge, tableId, noteError, clearError, refresh, clea
|
|
|
7309
7417
|
};
|
|
7310
7418
|
}
|
|
7311
7419
|
//#endregion
|
|
7420
|
+
//#region src/database/use-database-table/load-more.ts
|
|
7421
|
+
/** The next page's continuation (the `nextCursor`'s stand over the
|
|
7422
|
+
* cursor's snapshot boundary). */
|
|
7423
|
+
function createLoadMore(ctx) {
|
|
7424
|
+
const { bridge, tableId, nextCursor, loadTokenRef, pageRef, revisionsRef, setRows, setNextCursor } = ctx;
|
|
7425
|
+
const { noteError, refresh } = ctx;
|
|
7426
|
+
return async () => {
|
|
7427
|
+
if (nextCursor === null) return;
|
|
7428
|
+
const token = loadTokenRef.current;
|
|
7429
|
+
const { asOfSeq, fingerprint } = pageRef.current;
|
|
7430
|
+
try {
|
|
7431
|
+
const page = await bridge.queryNextPage(tableId, {
|
|
7432
|
+
cursor: nextCursor,
|
|
7433
|
+
asOfSeq,
|
|
7434
|
+
queryFingerprint: fingerprint
|
|
7435
|
+
});
|
|
7436
|
+
if (token !== loadTokenRef.current) return;
|
|
7437
|
+
pageRef.current = {
|
|
7438
|
+
asOfSeq: page.asOfSeq,
|
|
7439
|
+
fingerprint: page.queryFingerprint
|
|
7440
|
+
};
|
|
7441
|
+
for (const row of page.rows) revisionsRef.current.set(row.id, row.revision);
|
|
7442
|
+
setRows((rows) => {
|
|
7443
|
+
const known = new Set(rows.map((row) => row.rowId));
|
|
7444
|
+
const appended = page.rows.filter((row) => !known.has(row.id)).map((row) => ({
|
|
7445
|
+
rowId: row.id,
|
|
7446
|
+
cells: { ...row.cells }
|
|
7447
|
+
}));
|
|
7448
|
+
return [...rows, ...appended];
|
|
7449
|
+
});
|
|
7450
|
+
setNextCursor(page.nextCursor);
|
|
7451
|
+
} catch (operationError) {
|
|
7452
|
+
if (token !== loadTokenRef.current) return;
|
|
7453
|
+
if (isBridgeError(operationError) && operationError.code === "cursor_expired") {
|
|
7454
|
+
refresh();
|
|
7455
|
+
return;
|
|
7456
|
+
}
|
|
7457
|
+
noteError(operationError);
|
|
7458
|
+
}
|
|
7459
|
+
};
|
|
7460
|
+
}
|
|
7461
|
+
//#endregion
|
|
7312
7462
|
//#region src/database/use-database-table/row-write-ops.ts
|
|
7313
7463
|
/**
|
|
7314
7464
|
* The single-row's cell writes (the insert / the update) over the bridge:
|
|
@@ -7677,40 +7827,45 @@ function restorePatchesOf(before, cleaned) {
|
|
|
7677
7827
|
function createRowStructureOps(ctx) {
|
|
7678
7828
|
const { bridge, tableId, rowsRef, pendingRowRef, capabilitiesRef, setRows, setPendingRow } = ctx;
|
|
7679
7829
|
const { pushUndo, refresh, noteError, casOf, sameIdentity } = ctx;
|
|
7680
|
-
const
|
|
7830
|
+
const removeRows = async (rowIds) => {
|
|
7831
|
+
const ids = [...new Set(rowIds)].filter((rowId) => rowOf(rowsRef, pendingRowRef, rowId) !== void 0);
|
|
7832
|
+
if (ids.length === 0) return;
|
|
7833
|
+
const removed = new Set(ids);
|
|
7681
7834
|
const snapshot = rowsRef.current;
|
|
7682
|
-
const
|
|
7683
|
-
setRows((rows) => rows.filter((entry) => entry.rowId
|
|
7835
|
+
const pendingSnapshot = pendingRowRef.current;
|
|
7836
|
+
setRows((rows) => rows.filter((entry) => !removed.has(entry.rowId)));
|
|
7684
7837
|
try {
|
|
7685
|
-
await bridge.batchRows(tableId, { ops:
|
|
7838
|
+
await bridge.batchRows(tableId, { ops: ids.map((rowId) => ({
|
|
7686
7839
|
op: "delete",
|
|
7687
7840
|
rowId,
|
|
7688
7841
|
...casOf(rowId)
|
|
7689
|
-
}
|
|
7842
|
+
})) }, newMutationContext());
|
|
7690
7843
|
if (!sameIdentity()) return;
|
|
7691
|
-
setPendingRow((current) => current
|
|
7692
|
-
if (
|
|
7693
|
-
label: `remove
|
|
7844
|
+
setPendingRow((current) => current !== null && removed.has(current.rowId) ? null : current);
|
|
7845
|
+
if (capabilitiesRef.current.includes("rowRestore")) pushUndo({
|
|
7846
|
+
label: `remove rows ${ids.join(", ")}`,
|
|
7694
7847
|
forward: async () => {
|
|
7695
|
-
await bridge.batchRows(tableId, { ops:
|
|
7848
|
+
await bridge.batchRows(tableId, { ops: ids.map((rowId) => ({
|
|
7696
7849
|
op: "delete",
|
|
7697
7850
|
rowId
|
|
7698
|
-
}
|
|
7851
|
+
})) }, newMutationContext());
|
|
7699
7852
|
},
|
|
7700
7853
|
inverse: async () => {
|
|
7701
|
-
await bridge.undeleteRows(tableId, { rowIds:
|
|
7854
|
+
await bridge.undeleteRows(tableId, { rowIds: ids }, newMutationContext());
|
|
7702
7855
|
}
|
|
7703
7856
|
}, bridge, tableId);
|
|
7704
7857
|
refresh();
|
|
7705
7858
|
} catch (operationError) {
|
|
7706
7859
|
if (sameIdentity()) {
|
|
7707
7860
|
setRows(snapshot);
|
|
7861
|
+
setPendingRow(pendingSnapshot);
|
|
7708
7862
|
noteError(operationError);
|
|
7709
7863
|
refresh();
|
|
7710
7864
|
}
|
|
7711
7865
|
throw toBridgeError(operationError);
|
|
7712
7866
|
}
|
|
7713
7867
|
};
|
|
7868
|
+
const removeRow = async (rowId) => removeRows([rowId]);
|
|
7714
7869
|
const moveRow = async (rowId, beforeRowId) => {
|
|
7715
7870
|
const snapshot = rowsRef.current.map((row) => ({
|
|
7716
7871
|
rowId: row.rowId,
|
|
@@ -7764,6 +7919,7 @@ function createRowStructureOps(ctx) {
|
|
|
7764
7919
|
};
|
|
7765
7920
|
return {
|
|
7766
7921
|
removeRow,
|
|
7922
|
+
removeRows,
|
|
7767
7923
|
moveRow
|
|
7768
7924
|
};
|
|
7769
7925
|
}
|
|
@@ -7814,9 +7970,19 @@ function applySnapshotState(state, snapshot, clearError = false) {
|
|
|
7814
7970
|
function useTableStream(ctx) {
|
|
7815
7971
|
const { bridge, tableId, filter, filterKey, loadVersion, state, noteError } = ctx;
|
|
7816
7972
|
const { loadTokenRef, subGenRef } = state;
|
|
7973
|
+
const loadedIdentityRef = useRef(null);
|
|
7817
7974
|
const applySnapshot = (snapshot, clearError = false) => applySnapshotState(state, snapshot, clearError);
|
|
7818
7975
|
useEffect(() => {
|
|
7976
|
+
const loadedIdentity = loadedIdentityRef.current;
|
|
7977
|
+
const sameIdentity = loadedIdentity?.bridge === bridge && loadedIdentity.tableId === tableId;
|
|
7819
7978
|
state.setPendingRow(null);
|
|
7979
|
+
state.setNextCursor(null);
|
|
7980
|
+
if (!sameIdentity) {
|
|
7981
|
+
loadedIdentityRef.current = null;
|
|
7982
|
+
state.setTable(null);
|
|
7983
|
+
state.setRows([]);
|
|
7984
|
+
state.revisionsRef.current = /* @__PURE__ */ new Map();
|
|
7985
|
+
}
|
|
7820
7986
|
let disposed = false;
|
|
7821
7987
|
let handle = null;
|
|
7822
7988
|
let lastSeenSeq = null;
|
|
@@ -7827,6 +7993,7 @@ function useTableStream(ctx) {
|
|
|
7827
7993
|
state.setNextCursor(null);
|
|
7828
7994
|
state.revisionsRef.current = /* @__PURE__ */ new Map();
|
|
7829
7995
|
if (handle !== null) handle.unsubscribe();
|
|
7996
|
+
loadedIdentityRef.current = null;
|
|
7830
7997
|
state.setPhase("broken");
|
|
7831
7998
|
noteError(operationError);
|
|
7832
7999
|
};
|
|
@@ -7847,7 +8014,7 @@ function useTableStream(ctx) {
|
|
|
7847
8014
|
const myGen = ++subGenRef.current;
|
|
7848
8015
|
const token = ++loadTokenRef.current;
|
|
7849
8016
|
handle?.unsubscribe();
|
|
7850
|
-
if (!disposed) state.setPhase("loading");
|
|
8017
|
+
if (!disposed && !sameIdentity) state.setPhase("loading");
|
|
7851
8018
|
try {
|
|
7852
8019
|
const descriptor = await bridge.describeProtocol();
|
|
7853
8020
|
if (disposed || token !== loadTokenRef.current) return;
|
|
@@ -7861,6 +8028,10 @@ function useTableStream(ctx) {
|
|
|
7861
8028
|
lastSeenSeq = snapshot.page.asOfSeq;
|
|
7862
8029
|
seenSeqs.clear();
|
|
7863
8030
|
applySnapshot(snapshot, true);
|
|
8031
|
+
loadedIdentityRef.current = {
|
|
8032
|
+
bridge,
|
|
8033
|
+
tableId
|
|
8034
|
+
};
|
|
7864
8035
|
handle = bridge.subscribeTable(tableId, { afterSeq: snapshot.page.asOfSeq }, {
|
|
7865
8036
|
ready: () => void 0,
|
|
7866
8037
|
event: (envelope) => {
|
|
@@ -7916,46 +8087,6 @@ function useTableStream(ctx) {
|
|
|
7916
8087
|
loadVersion
|
|
7917
8088
|
]);
|
|
7918
8089
|
}
|
|
7919
|
-
/** The next page's continuation (the `nextCursor`'s stand over the
|
|
7920
|
-
* cursor's snapshot boundary). */
|
|
7921
|
-
function createLoadMore(ctx) {
|
|
7922
|
-
const { bridge, tableId, nextCursor, loadTokenRef, pageRef, revisionsRef, setRows, setNextCursor } = ctx;
|
|
7923
|
-
const { noteError, refresh } = ctx;
|
|
7924
|
-
return async () => {
|
|
7925
|
-
if (nextCursor === null) return;
|
|
7926
|
-
const token = loadTokenRef.current;
|
|
7927
|
-
const { asOfSeq, fingerprint } = pageRef.current;
|
|
7928
|
-
try {
|
|
7929
|
-
const page = await bridge.queryNextPage(tableId, {
|
|
7930
|
-
cursor: nextCursor,
|
|
7931
|
-
asOfSeq,
|
|
7932
|
-
queryFingerprint: fingerprint
|
|
7933
|
-
});
|
|
7934
|
-
if (token !== loadTokenRef.current) return;
|
|
7935
|
-
pageRef.current = {
|
|
7936
|
-
asOfSeq: page.asOfSeq,
|
|
7937
|
-
fingerprint: page.queryFingerprint
|
|
7938
|
-
};
|
|
7939
|
-
for (const row of page.rows) revisionsRef.current.set(row.id, row.revision);
|
|
7940
|
-
setRows((rows) => {
|
|
7941
|
-
const known = new Set(rows.map((row) => row.rowId));
|
|
7942
|
-
const appended = page.rows.filter((row) => !known.has(row.id)).map((row) => ({
|
|
7943
|
-
rowId: row.id,
|
|
7944
|
-
cells: { ...row.cells }
|
|
7945
|
-
}));
|
|
7946
|
-
return [...rows, ...appended];
|
|
7947
|
-
});
|
|
7948
|
-
setNextCursor(page.nextCursor);
|
|
7949
|
-
} catch (operationError) {
|
|
7950
|
-
if (token !== loadTokenRef.current) return;
|
|
7951
|
-
if (isBridgeError(operationError) && operationError.code === "cursor_expired") {
|
|
7952
|
-
refresh();
|
|
7953
|
-
return;
|
|
7954
|
-
}
|
|
7955
|
-
noteError(operationError);
|
|
7956
|
-
}
|
|
7957
|
-
};
|
|
7958
|
-
}
|
|
7959
8090
|
//#endregion
|
|
7960
8091
|
//#region src/database/use-database-table/use-database-table.ts
|
|
7961
8092
|
/**
|
|
@@ -8156,6 +8287,7 @@ function useDatabaseTable(bridge, tableId, filter) {
|
|
|
8156
8287
|
updateRows: rowBatch.updateRows,
|
|
8157
8288
|
pasteRows: rowBatch.pasteRows,
|
|
8158
8289
|
removeRow: rowStructure.removeRow,
|
|
8290
|
+
removeRows: rowStructure.removeRows,
|
|
8159
8291
|
moveRow: rowStructure.moveRow,
|
|
8160
8292
|
addColumn: column.addColumn,
|
|
8161
8293
|
updateColumn: column.updateColumn,
|
|
@@ -8173,6 +8305,41 @@ function useDatabaseTable(bridge, tableId, filter) {
|
|
|
8173
8305
|
};
|
|
8174
8306
|
}
|
|
8175
8307
|
//#endregion
|
|
8308
|
+
//#region src/database/grid/DatabaseRangeMenu.tsx
|
|
8309
|
+
function DatabaseRangeMenu({ anchor, onOpenChange, onClear, onDelete }) {
|
|
8310
|
+
const { t } = useTranslation("database");
|
|
8311
|
+
return /* @__PURE__ */ jsxs(DropdownMenu, {
|
|
8312
|
+
modal: false,
|
|
8313
|
+
open: anchor !== null,
|
|
8314
|
+
onOpenChange,
|
|
8315
|
+
children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
|
|
8316
|
+
asChild: true,
|
|
8317
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
8318
|
+
"aria-hidden": true,
|
|
8319
|
+
className: "pointer-events-none fixed size-0",
|
|
8320
|
+
style: {
|
|
8321
|
+
left: anchor?.x ?? 0,
|
|
8322
|
+
top: anchor?.y ?? 0
|
|
8323
|
+
}
|
|
8324
|
+
})
|
|
8325
|
+
}), /* @__PURE__ */ jsxs(DropdownMenuContent, {
|
|
8326
|
+
"data-slot": "docblocks/database-context-menu",
|
|
8327
|
+
"aria-label": t("range.options"),
|
|
8328
|
+
sideOffset: 4,
|
|
8329
|
+
children: [/* @__PURE__ */ jsx(DropdownMenuItem, {
|
|
8330
|
+
"data-slot": "docblocks/database-context-clear",
|
|
8331
|
+
onSelect: onClear,
|
|
8332
|
+
children: t("range.clear")
|
|
8333
|
+
}), /* @__PURE__ */ jsx(DropdownMenuItem, {
|
|
8334
|
+
"data-slot": "docblocks/database-context-delete",
|
|
8335
|
+
variant: "destructive",
|
|
8336
|
+
onSelect: onDelete,
|
|
8337
|
+
children: t("range.deleteRows")
|
|
8338
|
+
})]
|
|
8339
|
+
})]
|
|
8340
|
+
});
|
|
8341
|
+
}
|
|
8342
|
+
//#endregion
|
|
8176
8343
|
//#region src/database/grid/DatabaseResizeHandle.tsx
|
|
8177
8344
|
/** The database block's bottom-edge height handle. */
|
|
8178
8345
|
function DatabaseResizeHandle({ height, minHeight, onPointerDown, onPointerMove, onPointerUp, onPointerCancel, onKeyDown }) {
|
|
@@ -9565,7 +9732,7 @@ function useCellEditSession({ editing, isText, isNumber, isDateTime, rawValue, r
|
|
|
9565
9732
|
* placeholder, no trigger chrome): the pickers open on the double press
|
|
9566
9733
|
* over the cell itself.
|
|
9567
9734
|
*/
|
|
9568
|
-
function DatabaseCell({ rowId, column, value, revision, rowIndex, colIndex, first, lastRow, filterPending, dragDx, dragShifted, selected, singleSelected, editing, onChange, onPointerDown, onEditStart, onEditEnd, booleanPress, refTableData }) {
|
|
9735
|
+
function DatabaseCell({ rowId, column, value, revision, rowIndex, colIndex, first, lastRow, filterPending, dragDx, dragShifted, selected, pasteHighlighted, singleSelected, editing, onChange, onPointerDown, onEditStart, onEditEnd, booleanPress, refTableData }) {
|
|
9569
9736
|
const annotation = columnAnnotation(column);
|
|
9570
9737
|
const empty = value === void 0 || value === null || value === "" || Array.isArray(value) && value.length === 0;
|
|
9571
9738
|
const isDate = annotation.valueInput === "date";
|
|
@@ -9644,7 +9811,7 @@ function DatabaseCell({ rowId, column, value, revision, rowIndex, colIndex, firs
|
|
|
9644
9811
|
}
|
|
9645
9812
|
onEditStart();
|
|
9646
9813
|
};
|
|
9647
|
-
const cell = /* @__PURE__ */
|
|
9814
|
+
const cell = /* @__PURE__ */ jsxs("div", {
|
|
9648
9815
|
"data-slot": "docblocks/database-cell",
|
|
9649
9816
|
"data-key": cellKeyOf(rowId, column.id),
|
|
9650
9817
|
"data-row-id": rowId,
|
|
@@ -9656,12 +9823,16 @@ function DatabaseCell({ rowId, column, value, revision, rowIndex, colIndex, firs
|
|
|
9656
9823
|
"data-empty": empty ? "true" : void 0,
|
|
9657
9824
|
"data-selected": selected ? "true" : void 0,
|
|
9658
9825
|
"data-editing": editing ? "true" : void 0,
|
|
9659
|
-
className: cn(CELL_WRAP, !first && "border-l-(length:--docblocks-table-border-width)", !lastRow && "border-b-(length:--docblocks-table-border-width)", first && lastRow && "rounded-bl-(--docblocks-radius)", selected && (singleSelected ? "bg-(--docblocks-selected-background) outline-(length:--docblocks-canvas-selection-border-width) outline-offset-[-1px] outline-(--docblocks-canvas-selection-border-color) outline-solid" : "bg-(--docblocks-canvas-selection-fill)")),
|
|
9826
|
+
className: cn(CELL_WRAP, pasteHighlighted && "relative", !first && "border-l-(length:--docblocks-table-border-width)", !lastRow && "border-b-(length:--docblocks-table-border-width)", first && lastRow && "rounded-bl-(--docblocks-radius)", selected && (singleSelected ? "bg-(--docblocks-selected-background) outline-(length:--docblocks-canvas-selection-border-width) outline-offset-[-1px] outline-(--docblocks-canvas-selection-border-color) outline-solid" : "bg-(--docblocks-canvas-selection-fill)")),
|
|
9660
9827
|
style: dragStyle,
|
|
9661
9828
|
onPointerDown,
|
|
9662
9829
|
onClick: onCellClick,
|
|
9663
9830
|
onDoubleClick: onCellDoubleClick,
|
|
9664
|
-
children: content
|
|
9831
|
+
children: [content, pasteHighlighted && /* @__PURE__ */ jsx("span", {
|
|
9832
|
+
"aria-hidden": true,
|
|
9833
|
+
"data-slot": "docblocks/database-paste-range",
|
|
9834
|
+
className: "pointer-events-none absolute inset-0 outline-(length:--docblocks-database-paste-range-border-width) outline-offset-[-1px] outline-(--docblocks-database-paste-range-border-color) outline-solid"
|
|
9835
|
+
})]
|
|
9665
9836
|
});
|
|
9666
9837
|
if (isText) return /* @__PURE__ */ jsx(DatabaseCellText, {
|
|
9667
9838
|
cell,
|
|
@@ -9740,7 +9911,7 @@ function RowMenuCell({ row, rowMenu, setRowMenu, canMoveUp, canMoveDown, onMoveU
|
|
|
9740
9911
|
* the rejection's no-rethrow (the cell's commit has no caller to handle
|
|
9741
9912
|
* it).
|
|
9742
9913
|
*/
|
|
9743
|
-
function GridRows({ rows, columns, data, selectedCells, editingCell, setEditingCell, onCellPointerDown, booleanPressRef, drag, dragShiftOf, pendingRowId, refTableData, filter, readOnly = false }) {
|
|
9914
|
+
function GridRows({ rows, columns, data, selectedCells, pasteRange, editingCell, setEditingCell, onCellPointerDown, booleanPressRef, drag, dragShiftOf, pendingRowId, refTableData, filter, readOnly = false }) {
|
|
9744
9915
|
const { t } = useTranslation("database");
|
|
9745
9916
|
const [rowMenu, setRowMenu] = useState(null);
|
|
9746
9917
|
const lastRowId = rows.length > 0 ? rows[rows.length - 1].rowId : null;
|
|
@@ -9778,6 +9949,7 @@ function GridRows({ rows, columns, data, selectedCells, editingCell, setEditingC
|
|
|
9778
9949
|
dragDx: drag !== null && drag.id === column.id ? drag.dx : dragShiftOf(index),
|
|
9779
9950
|
dragShifted: drag !== null && drag.id !== column.id,
|
|
9780
9951
|
selected: selectedCells.has(key),
|
|
9952
|
+
pasteHighlighted: pasteRange.has(key),
|
|
9781
9953
|
singleSelected: selectedCells.has(key) && selectedCells.size === 1,
|
|
9782
9954
|
editing: editingCell === key,
|
|
9783
9955
|
onChange: cellChange(row, column),
|
|
@@ -10320,7 +10492,7 @@ function useSingleLineHeaderHeight(tableRef) {
|
|
|
10320
10492
|
* model (the cell / column selection — the native text selection over the
|
|
10321
10493
|
* drag is suppressed).
|
|
10322
10494
|
*/
|
|
10323
|
-
function GridTable({ columns, allColumns, columnOrder, hiddenColumns, columnWidths, onViewChange, data, rows, selectedCells, editingCell, setEditingCell, onCellPointerDown, booleanPressRef, pendingRowId, refTableData, filter, readOnly = false, headerHeight, onHeaderHeightChange, onHeaderHeightReset, tableRef, onTableKeyDown, onTablePaste, onTableBlur, form, OptionsEditor }) {
|
|
10495
|
+
function GridTable({ columns, allColumns, columnOrder, hiddenColumns, columnWidths, onViewChange, data, rows, selectedCells, pasteRange, editingCell, setEditingCell, onCellPointerDown, booleanPressRef, pendingRowId, refTableData, filter, readOnly = false, headerHeight, onHeaderHeightChange, onHeaderHeightReset, tableRef, onTableKeyDown, onTablePaste, onTableContextMenu, onTableBlur, form, OptionsEditor }) {
|
|
10324
10496
|
const [columnMenu, setColumnMenu] = useState(null);
|
|
10325
10497
|
const { resizePreview, onSeamPointerDown, onSeamPointerMove, onSeamPointerUp, onSeamPointerCancel } = useGridSeamResize({
|
|
10326
10498
|
columns,
|
|
@@ -10379,6 +10551,7 @@ function GridTable({ columns, allColumns, columnOrder, hiddenColumns, columnWidt
|
|
|
10379
10551
|
className: cn(GRID_CHROME_FRAME, "grid w-full overflow-hidden outline-none select-none"),
|
|
10380
10552
|
onKeyDown: onTableKeyDown,
|
|
10381
10553
|
onPaste: onTablePaste,
|
|
10554
|
+
onContextMenu: onTableContextMenu,
|
|
10382
10555
|
onBlur: onTableBlur,
|
|
10383
10556
|
style: {
|
|
10384
10557
|
gridTemplateRows: headerRowHeight !== void 0 ? `${headerRowHeight}px` : "auto",
|
|
@@ -10433,6 +10606,7 @@ function GridTable({ columns, allColumns, columnOrder, hiddenColumns, columnWidt
|
|
|
10433
10606
|
columns,
|
|
10434
10607
|
data,
|
|
10435
10608
|
selectedCells,
|
|
10609
|
+
pasteRange,
|
|
10436
10610
|
editingCell,
|
|
10437
10611
|
setEditingCell,
|
|
10438
10612
|
onCellPointerDown,
|
|
@@ -11333,33 +11507,193 @@ function useEnumOptionsMotion() {
|
|
|
11333
11507
|
return useContext(EnumOptionsMotionSlot);
|
|
11334
11508
|
}
|
|
11335
11509
|
//#endregion
|
|
11510
|
+
//#region src/database/grid/grid-cell-actions.ts
|
|
11511
|
+
/** Clears every selected cell in one bridge batch and one history entry. */
|
|
11512
|
+
function clearGridCells(selectedCells, data) {
|
|
11513
|
+
const byRow = /* @__PURE__ */ new Map();
|
|
11514
|
+
selectedCells.forEach((key) => {
|
|
11515
|
+
const [rowId, colId] = key.split("\0");
|
|
11516
|
+
if (rowId === void 0 || colId === void 0) return;
|
|
11517
|
+
const cells = byRow.get(rowId) ?? Object.create(null);
|
|
11518
|
+
cells[colId] = null;
|
|
11519
|
+
byRow.set(rowId, cells);
|
|
11520
|
+
});
|
|
11521
|
+
return data.updateRows([...byRow.entries()].map(([rowId, cells]) => ({
|
|
11522
|
+
rowId,
|
|
11523
|
+
cells
|
|
11524
|
+
})));
|
|
11525
|
+
}
|
|
11526
|
+
/** Returns the selected row ids once, in the selection's row-major order. */
|
|
11527
|
+
function selectedGridRowIds(selectedCells) {
|
|
11528
|
+
const ids = /* @__PURE__ */ new Set();
|
|
11529
|
+
selectedCells.forEach((key) => {
|
|
11530
|
+
const [rowId] = key.split("\0");
|
|
11531
|
+
if (rowId !== void 0) ids.add(rowId);
|
|
11532
|
+
});
|
|
11533
|
+
return [...ids];
|
|
11534
|
+
}
|
|
11535
|
+
//#endregion
|
|
11536
|
+
//#region src/database/grid/grid-cell-clipboard.ts
|
|
11537
|
+
const DATABASE_GRID_MIME = "application/x-docblocks-database-grid";
|
|
11538
|
+
const DATABASE_GRID_PAYLOAD_VERSION = 1;
|
|
11539
|
+
function refDataOf(column, refs) {
|
|
11540
|
+
if (column.refTableId === void 0) return void 0;
|
|
11541
|
+
return refs[refEntryKey({
|
|
11542
|
+
tableId: column.refTableId,
|
|
11543
|
+
displayColumn: column.refDisplayColumn
|
|
11544
|
+
})];
|
|
11545
|
+
}
|
|
11546
|
+
function displayTextOf$1(column, value, refs) {
|
|
11547
|
+
if (column.refKind === void 0) return cellTextOf(value);
|
|
11548
|
+
const data = refDataOf(column, refs);
|
|
11549
|
+
const display = (entry) => {
|
|
11550
|
+
const raw = cellTextOf(entry);
|
|
11551
|
+
return data?.displays[raw] ?? raw;
|
|
11552
|
+
};
|
|
11553
|
+
return Array.isArray(value) ? value.map(display).join(",") : display(value);
|
|
11554
|
+
}
|
|
11555
|
+
/** Builds the standard display TSV and the same-table raw-value payload. */
|
|
11556
|
+
function buildDatabaseGridClipboard(ctx) {
|
|
11557
|
+
const { tableId, rows, columns, selectionFrame, refTableData } = ctx;
|
|
11558
|
+
const rMin = Math.min(selectionFrame.anchorR, selectionFrame.cursorR);
|
|
11559
|
+
const rMax = Math.max(selectionFrame.anchorR, selectionFrame.cursorR);
|
|
11560
|
+
const cMin = Math.min(selectionFrame.anchorC, selectionFrame.cursorC);
|
|
11561
|
+
const cMax = Math.max(selectionFrame.anchorC, selectionFrame.cursorC);
|
|
11562
|
+
const textRows = [];
|
|
11563
|
+
const rawRows = [];
|
|
11564
|
+
for (let r = rMin; r <= rMax; r += 1) {
|
|
11565
|
+
const textCells = [];
|
|
11566
|
+
const rawCells = [];
|
|
11567
|
+
for (let c = cMin; c <= cMax; c += 1) {
|
|
11568
|
+
const row = rows[r];
|
|
11569
|
+
const column = columns[c];
|
|
11570
|
+
const value = row === void 0 || column === void 0 ? null : row.cells[column.id];
|
|
11571
|
+
rawCells.push(value ?? null);
|
|
11572
|
+
textCells.push(column === void 0 ? "" : displayTextOf$1(column, value, refTableData));
|
|
11573
|
+
}
|
|
11574
|
+
textRows.push(textCells.join(" "));
|
|
11575
|
+
rawRows.push(rawCells);
|
|
11576
|
+
}
|
|
11577
|
+
return {
|
|
11578
|
+
mime: DATABASE_GRID_MIME,
|
|
11579
|
+
text: textRows.join("\n"),
|
|
11580
|
+
payload: JSON.stringify({
|
|
11581
|
+
v: DATABASE_GRID_PAYLOAD_VERSION,
|
|
11582
|
+
tableId,
|
|
11583
|
+
cells: rawRows
|
|
11584
|
+
})
|
|
11585
|
+
};
|
|
11586
|
+
}
|
|
11587
|
+
/** Parses only the versioned payload issued for the current table. */
|
|
11588
|
+
function parseDatabaseGridPayload(raw, tableId) {
|
|
11589
|
+
if (raw === "") return null;
|
|
11590
|
+
try {
|
|
11591
|
+
const parsed = JSON.parse(raw);
|
|
11592
|
+
if (typeof parsed !== "object" || parsed === null) return null;
|
|
11593
|
+
const candidate = parsed;
|
|
11594
|
+
if (candidate.v !== DATABASE_GRID_PAYLOAD_VERSION || candidate.tableId !== tableId) return null;
|
|
11595
|
+
if (!Array.isArray(candidate.cells) || !candidate.cells.every((row) => Array.isArray(row))) return null;
|
|
11596
|
+
return candidate.cells;
|
|
11597
|
+
} catch {
|
|
11598
|
+
return null;
|
|
11599
|
+
}
|
|
11600
|
+
}
|
|
11601
|
+
function invalid(error) {
|
|
11602
|
+
return {
|
|
11603
|
+
ok: false,
|
|
11604
|
+
error
|
|
11605
|
+
};
|
|
11606
|
+
}
|
|
11607
|
+
/** Resolves display text against a reference column's loaded catalog. */
|
|
11608
|
+
function resolveReferenceText(column, raw, refs) {
|
|
11609
|
+
if (raw === "") return {
|
|
11610
|
+
ok: true,
|
|
11611
|
+
value: null
|
|
11612
|
+
};
|
|
11613
|
+
if (refs === void 0) return invalid("The reference catalog is unavailable");
|
|
11614
|
+
const labels = column.refMany === true ? raw.split(",").map((entry) => entry.trim()) : [raw.trim()];
|
|
11615
|
+
const values = [];
|
|
11616
|
+
for (const label of labels) {
|
|
11617
|
+
const matches = refs.rowIds.filter((rowId) => refs.displays[rowId] === label);
|
|
11618
|
+
if (matches.length === 0 || column.refKind === "row" && matches.length !== 1) return invalid("The reference label is unknown or ambiguous");
|
|
11619
|
+
values.push(matches[0]);
|
|
11620
|
+
}
|
|
11621
|
+
return {
|
|
11622
|
+
ok: true,
|
|
11623
|
+
value: column.refMany === true ? values : values[0]
|
|
11624
|
+
};
|
|
11625
|
+
}
|
|
11626
|
+
/** Resolves external TSV text into one target cell. */
|
|
11627
|
+
function resolveTextGridCell(column, raw, refs) {
|
|
11628
|
+
const input = columnAnnotation(column).valueInput;
|
|
11629
|
+
if (input === "none") return invalid("The column does not accept values");
|
|
11630
|
+
if (input === "enum" || input === "row-link") return resolveReferenceText(column, raw, refs);
|
|
11631
|
+
return parseCellValue(input, raw);
|
|
11632
|
+
}
|
|
11633
|
+
/** Validates raw structured clipboard values against the target column. */
|
|
11634
|
+
function resolveStructuredGridCell(column, raw) {
|
|
11635
|
+
const input = columnAnnotation(column).valueInput;
|
|
11636
|
+
if (input === "none") return invalid("The column does not accept values");
|
|
11637
|
+
if (raw === null) return {
|
|
11638
|
+
ok: true,
|
|
11639
|
+
value: null
|
|
11640
|
+
};
|
|
11641
|
+
if (input === "enum" || input === "row-link") {
|
|
11642
|
+
if (column.refMany === true) return Array.isArray(raw) && raw.every((entry) => typeof entry === "string") ? {
|
|
11643
|
+
ok: true,
|
|
11644
|
+
value: [...raw]
|
|
11645
|
+
} : invalid("The reference list is invalid");
|
|
11646
|
+
return typeof raw === "string" ? {
|
|
11647
|
+
ok: true,
|
|
11648
|
+
value: raw
|
|
11649
|
+
} : invalid("The reference is invalid");
|
|
11650
|
+
}
|
|
11651
|
+
if (input === "number") return typeof raw === "number" && Number.isFinite(raw) ? {
|
|
11652
|
+
ok: true,
|
|
11653
|
+
value: raw
|
|
11654
|
+
} : invalid("The number is invalid");
|
|
11655
|
+
if (input === "boolean") return typeof raw === "boolean" ? {
|
|
11656
|
+
ok: true,
|
|
11657
|
+
value: raw
|
|
11658
|
+
} : invalid("The boolean is invalid");
|
|
11659
|
+
if (typeof raw !== "string") return invalid("The text value is invalid");
|
|
11660
|
+
return parseCellValue(input, raw);
|
|
11661
|
+
}
|
|
11662
|
+
/** Writes both clipboard flavors, retaining TSV when custom MIME is unavailable. */
|
|
11663
|
+
async function writeDatabaseGridClipboard(clipboard) {
|
|
11664
|
+
if (typeof navigator === "undefined" || navigator.clipboard === void 0) return;
|
|
11665
|
+
if (typeof navigator.clipboard.write === "function" && typeof ClipboardItem !== "undefined") try {
|
|
11666
|
+
const item = new ClipboardItem({
|
|
11667
|
+
"text/plain": new Blob([clipboard.text], { type: "text/plain" }),
|
|
11668
|
+
[clipboard.mime]: new Blob([clipboard.payload], { type: clipboard.mime })
|
|
11669
|
+
});
|
|
11670
|
+
await navigator.clipboard.write([item]);
|
|
11671
|
+
return;
|
|
11672
|
+
} catch {}
|
|
11673
|
+
try {
|
|
11674
|
+
await navigator.clipboard.writeText(clipboard.text);
|
|
11675
|
+
} catch {}
|
|
11676
|
+
}
|
|
11677
|
+
//#endregion
|
|
11336
11678
|
//#region src/database/grid/grid-cell-keyboard.ts
|
|
11337
11679
|
/** The table's keydown stand (the grid's own gestures over the table's
|
|
11338
11680
|
* focus — the editor root's blocks-selection gestures must not fire). */
|
|
11339
11681
|
function handleGridCellKeyDown(event, ctx) {
|
|
11340
|
-
const { readOnly, rows, columns, data, selectionFrame, editingCell, selectedCells, setSelectionFrame, setEditingCell } = ctx;
|
|
11682
|
+
const { tableId, refTableData, readOnly, rows, columns, data, selectionFrame, editingCell, selectedCells, setSelectionFrame, setEditingCell } = ctx;
|
|
11341
11683
|
if (readOnly) return;
|
|
11342
11684
|
if ((event.metaKey || event.ctrlKey) && !event.shiftKey && event.key.toLowerCase() === "c") {
|
|
11343
11685
|
if (event.target instanceof HTMLInputElement || event.target instanceof HTMLTextAreaElement) return;
|
|
11344
11686
|
if (selectionFrame === null) return;
|
|
11345
11687
|
event.preventDefault();
|
|
11346
11688
|
event.stopPropagation();
|
|
11347
|
-
const
|
|
11348
|
-
|
|
11349
|
-
|
|
11350
|
-
|
|
11351
|
-
|
|
11352
|
-
|
|
11353
|
-
|
|
11354
|
-
|
|
11355
|
-
const row = rows[r];
|
|
11356
|
-
const column = columns[c];
|
|
11357
|
-
cells.push(row === void 0 || column === void 0 ? "" : cellTextOf(row.cells[column.id]));
|
|
11358
|
-
}
|
|
11359
|
-
lines.push(cells.join(" "));
|
|
11360
|
-
}
|
|
11361
|
-
const tsv = lines.join("\n");
|
|
11362
|
-
if (typeof navigator !== "undefined" && navigator.clipboard !== void 0) navigator.clipboard.writeText(tsv).catch(() => void 0);
|
|
11689
|
+
const clipboard = buildDatabaseGridClipboard({
|
|
11690
|
+
tableId,
|
|
11691
|
+
rows,
|
|
11692
|
+
columns,
|
|
11693
|
+
selectionFrame,
|
|
11694
|
+
refTableData
|
|
11695
|
+
});
|
|
11696
|
+
if (clipboard !== null) writeDatabaseGridClipboard(clipboard);
|
|
11363
11697
|
return;
|
|
11364
11698
|
}
|
|
11365
11699
|
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "z") {
|
|
@@ -11421,34 +11755,24 @@ function handleGridCellKeyDown(event, ctx) {
|
|
|
11421
11755
|
if (selectedCells.size === 0) return;
|
|
11422
11756
|
event.preventDefault();
|
|
11423
11757
|
event.stopPropagation();
|
|
11424
|
-
|
|
11425
|
-
selectedCells.forEach((key) => {
|
|
11426
|
-
const [rowId, colId] = key.split("\0");
|
|
11427
|
-
const cells = byRow.get(rowId) ?? Object.create(null);
|
|
11428
|
-
cells[colId] = null;
|
|
11429
|
-
byRow.set(rowId, cells);
|
|
11430
|
-
});
|
|
11431
|
-
data.updateRows([...byRow.entries()].map(([rowId, cells]) => ({
|
|
11432
|
-
rowId,
|
|
11433
|
-
cells
|
|
11434
|
-
}))).catch(() => void 0);
|
|
11758
|
+
clearGridCells(selectedCells, data).catch(() => void 0);
|
|
11435
11759
|
}
|
|
11436
11760
|
//#endregion
|
|
11437
11761
|
//#region src/database/grid/grid-cell-paste.ts
|
|
11438
|
-
/**
|
|
11439
|
-
function handleGridCellPaste(event, ctx) {
|
|
11440
|
-
const { readOnly, rows, columns, data, selectionFrame } = ctx;
|
|
11441
|
-
if (readOnly) return;
|
|
11442
|
-
if (event.target instanceof HTMLInputElement || event.target instanceof HTMLTextAreaElement) return;
|
|
11443
|
-
|
|
11444
|
-
|
|
11762
|
+
/** Commits one paste and returns its changed cells for the transient frame. */
|
|
11763
|
+
async function handleGridCellPaste(event, ctx) {
|
|
11764
|
+
const { readOnly, tableId, rows, columns, data, selectionFrame, refTableData } = ctx;
|
|
11765
|
+
if (readOnly) return null;
|
|
11766
|
+
if (event.target instanceof HTMLInputElement || event.target instanceof HTMLTextAreaElement) return null;
|
|
11767
|
+
if (selectionFrame === null) return null;
|
|
11768
|
+
const structured = parseDatabaseGridPayload(event.clipboardData.getData(DATABASE_GRID_MIME), tableId);
|
|
11445
11769
|
const text = event.clipboardData.getData("text/plain");
|
|
11446
|
-
if (text === "") return;
|
|
11770
|
+
if (structured === null && text === "") return null;
|
|
11447
11771
|
event.preventDefault();
|
|
11448
|
-
const grid = parseClipboardTsv(text);
|
|
11449
|
-
if (grid.length === 0 || rows.length === 0 || columns.length === 0) return;
|
|
11450
|
-
const r0 =
|
|
11451
|
-
const c0 =
|
|
11772
|
+
const grid = structured ?? parseClipboardTsv(text);
|
|
11773
|
+
if (grid.length === 0 || rows.length === 0 || columns.length === 0) return null;
|
|
11774
|
+
const r0 = selectionFrame.anchorR;
|
|
11775
|
+
const c0 = selectionFrame.anchorC;
|
|
11452
11776
|
const updates = [];
|
|
11453
11777
|
const creates = [];
|
|
11454
11778
|
for (let i = 0; i < grid.length; i += 1) {
|
|
@@ -11457,29 +11781,110 @@ function handleGridCellPaste(event, ctx) {
|
|
|
11457
11781
|
const cells = Object.create(null);
|
|
11458
11782
|
for (let j = 0; j < line.length; j += 1) {
|
|
11459
11783
|
const column = columns[c0 + j];
|
|
11460
|
-
if (column === void 0) continue;
|
|
11461
|
-
const input = columnAnnotation(column).valueInput;
|
|
11462
|
-
if (input === "enum" || input === "row-link" || input === "none") continue;
|
|
11463
11784
|
const raw = line[j];
|
|
11464
|
-
if (raw === void 0) continue;
|
|
11465
|
-
const
|
|
11466
|
-
if (
|
|
11467
|
-
cells[column.id] = parsed.value;
|
|
11785
|
+
if (column === void 0 || raw === void 0) continue;
|
|
11786
|
+
const resolved = structured !== null ? resolveStructuredGridCell(column, raw) : resolveTextGridCell(column, String(raw), refDataOf(column, refTableData));
|
|
11787
|
+
if (resolved.ok) cells[column.id] = resolved.value;
|
|
11468
11788
|
}
|
|
11469
11789
|
const rowAt = rows[r0 + i];
|
|
11790
|
+
if (rowAt !== void 0) {
|
|
11791
|
+
for (const [columnId, value] of Object.entries(cells)) if (cellValueEqual(rowAt.cells[columnId], value)) delete cells[columnId];
|
|
11792
|
+
}
|
|
11793
|
+
if (Object.keys(cells).length === 0) continue;
|
|
11470
11794
|
if (rowAt !== void 0) updates.push({
|
|
11471
11795
|
rowId: rowAt.rowId,
|
|
11472
11796
|
cells
|
|
11473
11797
|
});
|
|
11474
11798
|
else creates.push(cells);
|
|
11475
11799
|
}
|
|
11476
|
-
if (updates.length === 0 && creates.length === 0) return;
|
|
11477
|
-
const
|
|
11478
|
-
|
|
11800
|
+
if (updates.length === 0 && creates.length === 0) return null;
|
|
11801
|
+
const lastUpdated = updates.at(-1);
|
|
11802
|
+
const successor = rows[(lastUpdated === void 0 ? -1 : rows.findIndex((row) => row.rowId === lastUpdated.rowId)) + 1];
|
|
11803
|
+
const createdRowIds = await data.pasteRows({
|
|
11479
11804
|
updates,
|
|
11480
11805
|
creates,
|
|
11481
11806
|
beforeRowId: successor?.rowId ?? null
|
|
11482
|
-
})
|
|
11807
|
+
});
|
|
11808
|
+
const updatedHighlights = updates.map(({ rowId, cells }) => ({
|
|
11809
|
+
rowId,
|
|
11810
|
+
columnIds: Object.keys(cells)
|
|
11811
|
+
}));
|
|
11812
|
+
const createdHighlights = createdRowIds.flatMap((rowId, index) => {
|
|
11813
|
+
const cells = creates[index];
|
|
11814
|
+
return cells === void 0 ? [] : [{
|
|
11815
|
+
rowId,
|
|
11816
|
+
columnIds: Object.keys(cells)
|
|
11817
|
+
}];
|
|
11818
|
+
});
|
|
11819
|
+
return [...updatedHighlights, ...createdHighlights];
|
|
11820
|
+
}
|
|
11821
|
+
//#endregion
|
|
11822
|
+
//#region src/database/grid/use-grid-range-menu.ts
|
|
11823
|
+
/** Opens the selected range's menu at the right-click release point. */
|
|
11824
|
+
function useGridRangeMenu({ selectedCells, data, readOnly, onAction }) {
|
|
11825
|
+
const [anchor, setAnchor] = useState(null);
|
|
11826
|
+
const pendingOpenRef = useRef(null);
|
|
11827
|
+
const onTableContextMenu = (event) => {
|
|
11828
|
+
if (readOnly || selectedCells.size <= 1) return;
|
|
11829
|
+
const cell = (event.target instanceof Element ? event.target : null)?.closest("[data-slot='docblocks/database-cell'][data-key]");
|
|
11830
|
+
if (cell == null || !selectedCells.has(cell.dataset.key ?? "")) return;
|
|
11831
|
+
event.preventDefault();
|
|
11832
|
+
pendingOpenRef.current?.();
|
|
11833
|
+
const open = (x, y) => setAnchor({
|
|
11834
|
+
x,
|
|
11835
|
+
y
|
|
11836
|
+
});
|
|
11837
|
+
if (event.buttons === 0) {
|
|
11838
|
+
const task = window.setTimeout(() => {
|
|
11839
|
+
pendingOpenRef.current = null;
|
|
11840
|
+
open(event.clientX, event.clientY);
|
|
11841
|
+
}, 0);
|
|
11842
|
+
pendingOpenRef.current = () => window.clearTimeout(task);
|
|
11843
|
+
return;
|
|
11844
|
+
}
|
|
11845
|
+
const onUp = (up) => {
|
|
11846
|
+
if (up.button !== 2) {
|
|
11847
|
+
window.addEventListener("pointerup", onUp, { once: true });
|
|
11848
|
+
return;
|
|
11849
|
+
}
|
|
11850
|
+
pendingOpenRef.current = null;
|
|
11851
|
+
open(up.clientX, up.clientY);
|
|
11852
|
+
};
|
|
11853
|
+
window.addEventListener("pointerup", onUp, { once: true });
|
|
11854
|
+
window.addEventListener("pointercancel", onUp, { once: true });
|
|
11855
|
+
pendingOpenRef.current = () => {
|
|
11856
|
+
window.removeEventListener("pointerup", onUp);
|
|
11857
|
+
window.removeEventListener("pointercancel", onUp);
|
|
11858
|
+
};
|
|
11859
|
+
};
|
|
11860
|
+
const clearRange = () => {
|
|
11861
|
+
onAction?.();
|
|
11862
|
+
clearGridCells(selectedCells, data).catch(() => void 0);
|
|
11863
|
+
};
|
|
11864
|
+
const deleteRows = () => {
|
|
11865
|
+
onAction?.();
|
|
11866
|
+
data.removeRows(selectedGridRowIds(selectedCells)).catch(() => void 0);
|
|
11867
|
+
};
|
|
11868
|
+
const onOpenChange = (open) => {
|
|
11869
|
+
if (!open) setAnchor(null);
|
|
11870
|
+
};
|
|
11871
|
+
useEffect(() => {
|
|
11872
|
+
if (selectedCells.size > 1) return;
|
|
11873
|
+
pendingOpenRef.current?.();
|
|
11874
|
+
pendingOpenRef.current = null;
|
|
11875
|
+
setAnchor(null);
|
|
11876
|
+
}, [selectedCells]);
|
|
11877
|
+
useEffect(() => () => {
|
|
11878
|
+
pendingOpenRef.current?.();
|
|
11879
|
+
pendingOpenRef.current = null;
|
|
11880
|
+
}, []);
|
|
11881
|
+
return {
|
|
11882
|
+
anchor,
|
|
11883
|
+
clearRange,
|
|
11884
|
+
deleteRows,
|
|
11885
|
+
onOpenChange,
|
|
11886
|
+
onTableContextMenu
|
|
11887
|
+
};
|
|
11483
11888
|
}
|
|
11484
11889
|
//#endregion
|
|
11485
11890
|
//#region src/database/grid/use-grid-cell-interaction.ts
|
|
@@ -11493,9 +11898,21 @@ function handleGridCellPaste(event, ctx) {
|
|
|
11493
11898
|
* and the press-outside's teardown (the view state resets, the edit session
|
|
11494
11899
|
* closes). The selection's set + the frame's state + the editing cell's
|
|
11495
11900
|
* state + the boolean press's stand stand in the hook. */
|
|
11496
|
-
function useGridCellInteraction({ rows, columns, data, tableRef, readOnly = false }) {
|
|
11901
|
+
function useGridCellInteraction({ tableId, refTableData, rows, columns, data, tableRef, readOnly = false }) {
|
|
11497
11902
|
const [selectionFrame, setSelectionFrame] = useState(null);
|
|
11498
11903
|
const [editingCell, setEditingCell] = useState(null);
|
|
11904
|
+
const [pasteRange, setPasteRange] = useState(/* @__PURE__ */ new Set());
|
|
11905
|
+
const clearPasteRange = useCallback(() => {
|
|
11906
|
+
setPasteRange((current) => current.size === 0 ? current : /* @__PURE__ */ new Set());
|
|
11907
|
+
}, []);
|
|
11908
|
+
const updateSelectionFrame = useCallback((value) => {
|
|
11909
|
+
clearPasteRange();
|
|
11910
|
+
setSelectionFrame(value);
|
|
11911
|
+
}, [clearPasteRange]);
|
|
11912
|
+
const updateEditingCell = useCallback((value) => {
|
|
11913
|
+
if (value !== null) clearPasteRange();
|
|
11914
|
+
setEditingCell(value);
|
|
11915
|
+
}, [clearPasteRange]);
|
|
11499
11916
|
const selectedCells = useMemo(() => {
|
|
11500
11917
|
const keys = /* @__PURE__ */ new Set();
|
|
11501
11918
|
if (selectionFrame === null) return keys;
|
|
@@ -11529,6 +11946,7 @@ function useGridCellInteraction({ rows, columns, data, tableRef, readOnly = fals
|
|
|
11529
11946
|
const onCellPointerDown = (rowId, colId, r, c) => (event) => {
|
|
11530
11947
|
if (readOnly) return;
|
|
11531
11948
|
if (event.button !== 0) return;
|
|
11949
|
+
clearPasteRange();
|
|
11532
11950
|
if (event.target instanceof HTMLInputElement || event.target instanceof HTMLTextAreaElement) return;
|
|
11533
11951
|
if (event.target instanceof Element && event.target.closest("[data-radix-popper-content-wrapper]") !== null) return;
|
|
11534
11952
|
const key = cellKeyOf(rowId, colId);
|
|
@@ -11587,29 +12005,44 @@ function useGridCellInteraction({ rows, columns, data, tableRef, readOnly = fals
|
|
|
11587
12005
|
* focus — the editor root's blocks-selection gestures must not fire
|
|
11588
12006
|
* over the stand). */
|
|
11589
12007
|
const onTableKeyDown = (event) => {
|
|
12008
|
+
clearPasteRange();
|
|
11590
12009
|
handleGridCellKeyDown(event, {
|
|
11591
12010
|
readOnly,
|
|
11592
12011
|
rows,
|
|
11593
12012
|
columns,
|
|
11594
12013
|
data,
|
|
12014
|
+
tableId,
|
|
12015
|
+
refTableData,
|
|
11595
12016
|
selectionFrame,
|
|
11596
12017
|
editingCell,
|
|
11597
12018
|
selectedCells,
|
|
11598
|
-
setSelectionFrame,
|
|
11599
|
-
setEditingCell
|
|
12019
|
+
setSelectionFrame: updateSelectionFrame,
|
|
12020
|
+
setEditingCell: updateEditingCell
|
|
11600
12021
|
});
|
|
11601
12022
|
};
|
|
11602
12023
|
/** The clipboard's paste (the mixed batch: the TSV's grid stands from
|
|
11603
12024
|
* the selection's anchor cell over the grid's own columns — the
|
|
11604
12025
|
* updates + the creates over one `batchRows`). */
|
|
12026
|
+
const commitPaste = async (event) => {
|
|
12027
|
+
try {
|
|
12028
|
+
const highlights = await handleGridCellPaste(event, {
|
|
12029
|
+
readOnly,
|
|
12030
|
+
tableId,
|
|
12031
|
+
rows,
|
|
12032
|
+
columns,
|
|
12033
|
+
data,
|
|
12034
|
+
selectionFrame,
|
|
12035
|
+
refTableData
|
|
12036
|
+
});
|
|
12037
|
+
if (highlights === null) return;
|
|
12038
|
+
const keys = /* @__PURE__ */ new Set();
|
|
12039
|
+
for (const highlight of highlights) for (const columnId of highlight.columnIds) keys.add(cellKeyOf(highlight.rowId, columnId));
|
|
12040
|
+
setPasteRange(keys);
|
|
12041
|
+
} catch {}
|
|
12042
|
+
};
|
|
11605
12043
|
const onTablePaste = (event) => {
|
|
11606
|
-
|
|
11607
|
-
|
|
11608
|
-
rows,
|
|
11609
|
-
columns,
|
|
11610
|
-
data,
|
|
11611
|
-
selectionFrame
|
|
11612
|
-
});
|
|
12044
|
+
clearPasteRange();
|
|
12045
|
+
commitPaste(event);
|
|
11613
12046
|
};
|
|
11614
12047
|
useEffect(() => {
|
|
11615
12048
|
if (selectionFrame === null) return;
|
|
@@ -11619,6 +12052,7 @@ function useGridCellInteraction({ rows, columns, data, tableRef, readOnly = fals
|
|
|
11619
12052
|
if (tableRef.current === null || !tableRef.current.contains(event.target)) {
|
|
11620
12053
|
setSelectionFrame(null);
|
|
11621
12054
|
setEditingCell(null);
|
|
12055
|
+
clearPasteRange();
|
|
11622
12056
|
}
|
|
11623
12057
|
};
|
|
11624
12058
|
document.addEventListener("pointerdown", onDown, true);
|
|
@@ -11626,12 +12060,19 @@ function useGridCellInteraction({ rows, columns, data, tableRef, readOnly = fals
|
|
|
11626
12060
|
}, [selectionFrame]);
|
|
11627
12061
|
return {
|
|
11628
12062
|
editingCell,
|
|
11629
|
-
setEditingCell,
|
|
12063
|
+
setEditingCell: updateEditingCell,
|
|
12064
|
+
pasteRange,
|
|
11630
12065
|
selectedCells,
|
|
11631
12066
|
booleanPressRef,
|
|
11632
12067
|
onCellPointerDown,
|
|
11633
12068
|
onTableKeyDown,
|
|
11634
|
-
onTablePaste
|
|
12069
|
+
onTablePaste,
|
|
12070
|
+
rangeMenu: useGridRangeMenu({
|
|
12071
|
+
selectedCells,
|
|
12072
|
+
data,
|
|
12073
|
+
readOnly,
|
|
12074
|
+
onAction: clearPasteRange
|
|
12075
|
+
})
|
|
11635
12076
|
};
|
|
11636
12077
|
}
|
|
11637
12078
|
//#endregion
|
|
@@ -11750,7 +12191,9 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
|
|
|
11750
12191
|
};
|
|
11751
12192
|
const pendingRow = data.pendingRow !== null && !data.rows.some((row) => row.rowId === data.pendingRow?.rowId) ? data.pendingRow : null;
|
|
11752
12193
|
const rows = pendingRow === null ? data.rows : [...data.rows, pendingRow];
|
|
11753
|
-
const { editingCell, setEditingCell, selectedCells, booleanPressRef, onCellPointerDown, onTableKeyDown, onTablePaste } = useGridCellInteraction({
|
|
12194
|
+
const { editingCell, setEditingCell, pasteRange, selectedCells, booleanPressRef, onCellPointerDown, onTableKeyDown, onTablePaste, rangeMenu } = useGridCellInteraction({
|
|
12195
|
+
tableId,
|
|
12196
|
+
refTableData,
|
|
11754
12197
|
rows,
|
|
11755
12198
|
columns,
|
|
11756
12199
|
data,
|
|
@@ -11780,68 +12223,79 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
|
|
|
11780
12223
|
contentEditable: false,
|
|
11781
12224
|
style: blockHeight.style,
|
|
11782
12225
|
className: "\n group relative my-(--docblocks-block-spacing) flex min-h-0 flex-1 flex-col rounded-(--docblocks-radius)\n border-(length:--docblocks-table-border-width) border-(--docblocks-table-border-color) outline-none\n ",
|
|
11783
|
-
children: [
|
|
11784
|
-
|
|
11785
|
-
|
|
11786
|
-
|
|
11787
|
-
|
|
11788
|
-
|
|
11789
|
-
|
|
11790
|
-
|
|
11791
|
-
|
|
11792
|
-
|
|
11793
|
-
hiddenColumns,
|
|
11794
|
-
columnWidths,
|
|
11795
|
-
onViewChange: updateView,
|
|
11796
|
-
refTableData,
|
|
11797
|
-
showName: blockId !== void 0,
|
|
11798
|
-
readOnly
|
|
11799
|
-
}), data.table.columns.length === 0 ? /* @__PURE__ */ jsx(GridEmptyState, {
|
|
11800
|
-
form,
|
|
11801
|
-
OptionsEditor,
|
|
11802
|
-
readOnly
|
|
11803
|
-
}) : /* @__PURE__ */ jsx(ScrollArea, {
|
|
11804
|
-
ref: scrollerRef,
|
|
11805
|
-
"data-slot": "docblocks/database-grid",
|
|
11806
|
-
className: "min-h-0 flex-1",
|
|
11807
|
-
children: /* @__PURE__ */ jsx(GridTable, {
|
|
11808
|
-
columns,
|
|
11809
|
-
allColumns: data.table.columns,
|
|
12226
|
+
children: [
|
|
12227
|
+
/* @__PURE__ */ jsxs(CardContent, {
|
|
12228
|
+
"data-slot": "docblocks/database",
|
|
12229
|
+
className: "flex min-h-0 flex-1 flex-col gap-(--docblocks-block-spacing) p-(--docblocks-block-spacing)",
|
|
12230
|
+
children: [/* @__PURE__ */ jsx(GridToolbar, {
|
|
12231
|
+
tableId,
|
|
12232
|
+
table: data.table,
|
|
12233
|
+
data,
|
|
12234
|
+
totalRows: sectionRowCount,
|
|
12235
|
+
filter,
|
|
11810
12236
|
columnOrder,
|
|
11811
12237
|
hiddenColumns,
|
|
11812
12238
|
columnWidths,
|
|
11813
12239
|
onViewChange: updateView,
|
|
11814
|
-
data,
|
|
11815
|
-
rows,
|
|
11816
|
-
selectedCells,
|
|
11817
|
-
editingCell,
|
|
11818
|
-
setEditingCell,
|
|
11819
|
-
onCellPointerDown,
|
|
11820
|
-
booleanPressRef,
|
|
11821
|
-
pendingRowId,
|
|
11822
12240
|
refTableData,
|
|
11823
|
-
|
|
11824
|
-
readOnly
|
|
11825
|
-
|
|
11826
|
-
onHeaderHeightChange,
|
|
11827
|
-
onHeaderHeightReset,
|
|
11828
|
-
tableRef,
|
|
11829
|
-
onTableKeyDown,
|
|
11830
|
-
onTablePaste,
|
|
11831
|
-
onTableBlur,
|
|
12241
|
+
showName: blockId !== void 0,
|
|
12242
|
+
readOnly
|
|
12243
|
+
}), data.table.columns.length === 0 ? /* @__PURE__ */ jsx(GridEmptyState, {
|
|
11832
12244
|
form,
|
|
11833
|
-
OptionsEditor
|
|
11834
|
-
|
|
11835
|
-
|
|
11836
|
-
|
|
11837
|
-
|
|
11838
|
-
|
|
11839
|
-
|
|
11840
|
-
|
|
11841
|
-
|
|
11842
|
-
|
|
11843
|
-
|
|
11844
|
-
|
|
12245
|
+
OptionsEditor,
|
|
12246
|
+
readOnly
|
|
12247
|
+
}) : /* @__PURE__ */ jsx(ScrollArea, {
|
|
12248
|
+
ref: scrollerRef,
|
|
12249
|
+
"data-slot": "docblocks/database-grid",
|
|
12250
|
+
className: "min-h-0 flex-1",
|
|
12251
|
+
children: /* @__PURE__ */ jsx(GridTable, {
|
|
12252
|
+
columns,
|
|
12253
|
+
allColumns: data.table.columns,
|
|
12254
|
+
columnOrder,
|
|
12255
|
+
hiddenColumns,
|
|
12256
|
+
columnWidths,
|
|
12257
|
+
onViewChange: updateView,
|
|
12258
|
+
data,
|
|
12259
|
+
rows,
|
|
12260
|
+
selectedCells,
|
|
12261
|
+
pasteRange,
|
|
12262
|
+
editingCell,
|
|
12263
|
+
setEditingCell,
|
|
12264
|
+
onCellPointerDown,
|
|
12265
|
+
booleanPressRef,
|
|
12266
|
+
pendingRowId,
|
|
12267
|
+
refTableData,
|
|
12268
|
+
filter,
|
|
12269
|
+
readOnly,
|
|
12270
|
+
headerHeight: resolvedHeaderHeight,
|
|
12271
|
+
onHeaderHeightChange,
|
|
12272
|
+
onHeaderHeightReset,
|
|
12273
|
+
tableRef,
|
|
12274
|
+
onTableKeyDown,
|
|
12275
|
+
onTablePaste,
|
|
12276
|
+
onTableContextMenu: rangeMenu.onTableContextMenu,
|
|
12277
|
+
onTableBlur,
|
|
12278
|
+
form,
|
|
12279
|
+
OptionsEditor
|
|
12280
|
+
})
|
|
12281
|
+
})]
|
|
12282
|
+
}),
|
|
12283
|
+
/* @__PURE__ */ jsx(DatabaseRangeMenu, {
|
|
12284
|
+
anchor: rangeMenu.anchor,
|
|
12285
|
+
onOpenChange: rangeMenu.onOpenChange,
|
|
12286
|
+
onClear: rangeMenu.clearRange,
|
|
12287
|
+
onDelete: rangeMenu.deleteRows
|
|
12288
|
+
}),
|
|
12289
|
+
blockId !== void 0 && onHeightChange !== void 0 && !readOnly && /* @__PURE__ */ jsx(DatabaseResizeHandle, {
|
|
12290
|
+
height: blockHeight.currentHeight,
|
|
12291
|
+
minHeight: blockHeight.minHeight,
|
|
12292
|
+
onPointerDown: blockHeight.onPointerDown,
|
|
12293
|
+
onPointerMove: blockHeight.onPointerMove,
|
|
12294
|
+
onPointerUp: blockHeight.onPointerUp,
|
|
12295
|
+
onPointerCancel: blockHeight.onPointerCancel,
|
|
12296
|
+
onKeyDown: blockHeight.onKeyDown
|
|
12297
|
+
})
|
|
12298
|
+
]
|
|
11845
12299
|
});
|
|
11846
12300
|
}
|
|
11847
12301
|
//#endregion
|