@xcelsior/ui-spreadsheets 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +22 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/CommentModals.tsx +5 -6
- package/src/components/Spreadsheet.tsx +10 -16
- package/src/components/SpreadsheetCell.tsx +196 -197
- package/src/types.ts +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -377,10 +377,10 @@ interface SpreadsheetCellProps {
|
|
|
377
377
|
rightOffset?: number;
|
|
378
378
|
/** Callback when cell is clicked */
|
|
379
379
|
onClick?: (event: React$1.MouseEvent) => void;
|
|
380
|
-
/** Callback when cell value changes */
|
|
380
|
+
/** Callback when cell value changes (only called on blur/confirm, not during typing) */
|
|
381
381
|
onChange?: (newValue: any) => void;
|
|
382
|
-
/** Callback when editing is confirmed */
|
|
383
|
-
onConfirm?: () => void;
|
|
382
|
+
/** Callback when editing is confirmed, receives the final value */
|
|
383
|
+
onConfirm?: (finalValue?: any) => void;
|
|
384
384
|
/** Callback when editing is cancelled */
|
|
385
385
|
onCancel?: () => void;
|
|
386
386
|
/** Callback to copy value down */
|
package/dist/index.d.ts
CHANGED
|
@@ -377,10 +377,10 @@ interface SpreadsheetCellProps {
|
|
|
377
377
|
rightOffset?: number;
|
|
378
378
|
/** Callback when cell is clicked */
|
|
379
379
|
onClick?: (event: React$1.MouseEvent) => void;
|
|
380
|
-
/** Callback when cell value changes */
|
|
380
|
+
/** Callback when cell value changes (only called on blur/confirm, not during typing) */
|
|
381
381
|
onChange?: (newValue: any) => void;
|
|
382
|
-
/** Callback when editing is confirmed */
|
|
383
|
-
onConfirm?: () => void;
|
|
382
|
+
/** Callback when editing is confirmed, receives the final value */
|
|
383
|
+
onConfirm?: (finalValue?: any) => void;
|
|
384
384
|
/** Callback when editing is cancelled */
|
|
385
385
|
onCancel?: () => void;
|
|
386
386
|
/** Callback to copy value down */
|
package/dist/index.js
CHANGED
|
@@ -253,12 +253,11 @@ var SpreadsheetCell = ({
|
|
|
253
253
|
const handleKeyDown = (e) => {
|
|
254
254
|
if (e.key === "Enter") {
|
|
255
255
|
e.preventDefault();
|
|
256
|
-
onConfirm?.();
|
|
256
|
+
onConfirm?.(localValue);
|
|
257
257
|
} else if (e.key === "Escape") {
|
|
258
258
|
e.preventDefault();
|
|
259
259
|
e.stopPropagation();
|
|
260
260
|
setLocalValue(value);
|
|
261
|
-
onChange?.(value);
|
|
262
261
|
onCancel?.();
|
|
263
262
|
}
|
|
264
263
|
};
|
|
@@ -291,12 +290,12 @@ var SpreadsheetCell = ({
|
|
|
291
290
|
ref: selectRef,
|
|
292
291
|
value: localValue ?? "",
|
|
293
292
|
onChange: (e) => {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
onConfirm?.();
|
|
293
|
+
const newValue = e.target.value;
|
|
294
|
+
setLocalValue(newValue);
|
|
295
|
+
onConfirm?.(newValue);
|
|
297
296
|
},
|
|
298
297
|
onKeyDown: handleKeyDown,
|
|
299
|
-
onBlur: () => onConfirm?.(),
|
|
298
|
+
onBlur: () => onConfirm?.(localValue),
|
|
300
299
|
className: cn(
|
|
301
300
|
"w-full border border-gray-300 rounded text-xs focus:outline-none focus:ring-1 focus:ring-blue-500",
|
|
302
301
|
compactMode ? "px-1 py-0.5" : "px-2 py-1"
|
|
@@ -315,10 +314,9 @@ var SpreadsheetCell = ({
|
|
|
315
314
|
onChange: (e) => {
|
|
316
315
|
const newValue = column.type === "number" ? e.target.value === "" ? "" : parseFloat(e.target.value) : e.target.value;
|
|
317
316
|
setLocalValue(newValue);
|
|
318
|
-
onChange?.(newValue);
|
|
319
317
|
},
|
|
320
318
|
onKeyDown: handleKeyDown,
|
|
321
|
-
onBlur: () => onConfirm?.(),
|
|
319
|
+
onBlur: () => onConfirm?.(localValue),
|
|
322
320
|
className: cn(
|
|
323
321
|
"w-full border border-gray-300 rounded text-xs focus:outline-none focus:ring-1 focus:ring-blue-500 bg-yellow-50",
|
|
324
322
|
compactMode ? "px-1 py-0.5" : "px-2 py-1"
|
|
@@ -328,7 +326,7 @@ var SpreadsheetCell = ({
|
|
|
328
326
|
};
|
|
329
327
|
const cellPadding = compactMode ? cellPaddingCompact : cellPaddingNormal;
|
|
330
328
|
const handleCellKeyDown = (e) => {
|
|
331
|
-
if (e.key === " ") {
|
|
329
|
+
if (e.key === " " && !isEditing) {
|
|
332
330
|
e.preventDefault();
|
|
333
331
|
onClick?.(e);
|
|
334
332
|
}
|
|
@@ -2037,12 +2035,7 @@ SpreadsheetSettingsModal.displayName = "SpreadsheetSettingsModal";
|
|
|
2037
2035
|
// src/components/CommentModals.tsx
|
|
2038
2036
|
var import_react9 = require("react");
|
|
2039
2037
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
2040
|
-
function AddCommentModal({
|
|
2041
|
-
isOpen,
|
|
2042
|
-
columnLabel,
|
|
2043
|
-
onAdd,
|
|
2044
|
-
onClose
|
|
2045
|
-
}) {
|
|
2038
|
+
function AddCommentModal({ isOpen, columnLabel, onAdd, onClose }) {
|
|
2046
2039
|
const [commentText, setCommentText] = (0, import_react9.useState)("");
|
|
2047
2040
|
(0, import_react9.useEffect)(() => {
|
|
2048
2041
|
if (!isOpen) {
|
|
@@ -2070,6 +2063,10 @@ function AddCommentModal({
|
|
|
2070
2063
|
{
|
|
2071
2064
|
value: commentText,
|
|
2072
2065
|
onChange: (e) => setCommentText(e.target.value),
|
|
2066
|
+
onKeyDown: (e) => {
|
|
2067
|
+
e.stopPropagation();
|
|
2068
|
+
e.nativeEvent.stopImmediatePropagation();
|
|
2069
|
+
},
|
|
2073
2070
|
placeholder: "Enter your comment...",
|
|
2074
2071
|
className: "w-full h-24 p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 resize-none",
|
|
2075
2072
|
autoFocus: true
|
|
@@ -2953,7 +2950,6 @@ function Spreadsheet({
|
|
|
2953
2950
|
const [lastSelectedRow, setLastSelectedRow] = (0, import_react15.useState)(null);
|
|
2954
2951
|
const [focusedCell, setFocusedCell] = (0, import_react15.useState)(null);
|
|
2955
2952
|
const [editingCell, setEditingCell] = (0, import_react15.useState)(null);
|
|
2956
|
-
const [editValue, setEditValue] = (0, import_react15.useState)("");
|
|
2957
2953
|
const [hoveredRow, setHoveredRow] = (0, import_react15.useState)(null);
|
|
2958
2954
|
const [internalCurrentPage, setInternalCurrentPage] = (0, import_react15.useState)(1);
|
|
2959
2955
|
const [internalPageSize, setInternalPageSize] = (0, import_react15.useState)(defaultPageSize);
|
|
@@ -3100,9 +3096,7 @@ function Spreadsheet({
|
|
|
3100
3096
|
if (column?.editable && enableCellEditing) {
|
|
3101
3097
|
const row = (data || []).find((r) => getRowId(r) === focusedCell.rowId);
|
|
3102
3098
|
if (row) {
|
|
3103
|
-
const value = column.getValue ? column.getValue(row) : row[focusedCell.columnId];
|
|
3104
3099
|
setEditingCell({ rowId: focusedCell.rowId, columnId: focusedCell.columnId });
|
|
3105
|
-
setEditValue(value);
|
|
3106
3100
|
}
|
|
3107
3101
|
}
|
|
3108
3102
|
}, [focusedCell, columns, data, getRowId, enableCellEditing]);
|
|
@@ -3182,9 +3176,7 @@ function Spreadsheet({
|
|
|
3182
3176
|
if (column?.editable && enableCellEditing) {
|
|
3183
3177
|
const row = (data || []).find((r) => getRowId(r) === rowId);
|
|
3184
3178
|
if (row) {
|
|
3185
|
-
const value = column.getValue ? column.getValue(row) : row[columnId];
|
|
3186
3179
|
setEditingCell({ rowId, columnId });
|
|
3187
|
-
setEditValue(value);
|
|
3188
3180
|
}
|
|
3189
3181
|
}
|
|
3190
3182
|
},
|
|
@@ -3211,15 +3203,17 @@ function Spreadsheet({
|
|
|
3211
3203
|
},
|
|
3212
3204
|
[data, getRowId, enableUndoRedo, onCellEdit, pushToUndoStack, markAsChanged]
|
|
3213
3205
|
);
|
|
3214
|
-
const handleConfirmEdit = (0, import_react15.useCallback)(
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3206
|
+
const handleConfirmEdit = (0, import_react15.useCallback)(
|
|
3207
|
+
(finalValue) => {
|
|
3208
|
+
if (editingCell && finalValue !== void 0) {
|
|
3209
|
+
handleCellChange(editingCell.rowId, editingCell.columnId, finalValue);
|
|
3210
|
+
setEditingCell(null);
|
|
3211
|
+
}
|
|
3212
|
+
},
|
|
3213
|
+
[editingCell, handleCellChange]
|
|
3214
|
+
);
|
|
3220
3215
|
const handleCancelEdit = (0, import_react15.useCallback)(() => {
|
|
3221
3216
|
setEditingCell(null);
|
|
3222
|
-
setEditValue("");
|
|
3223
3217
|
}, []);
|
|
3224
3218
|
const handleRowClone = (0, import_react15.useCallback)(
|
|
3225
3219
|
(row, rowId) => {
|
|
@@ -3537,7 +3531,7 @@ function Spreadsheet({
|
|
|
3537
3531
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3538
3532
|
MemoizedSpreadsheetCell,
|
|
3539
3533
|
{
|
|
3540
|
-
value
|
|
3534
|
+
value,
|
|
3541
3535
|
column,
|
|
3542
3536
|
row,
|
|
3543
3537
|
rowIndex,
|
|
@@ -3554,7 +3548,6 @@ function Spreadsheet({
|
|
|
3554
3548
|
pinSide: colPinSide,
|
|
3555
3549
|
leftOffset: getColumnLeftOffset(column.id),
|
|
3556
3550
|
onClick: (e) => handleCellClick(rowId, column.id, e),
|
|
3557
|
-
onChange: (newValue) => setEditValue(newValue),
|
|
3558
3551
|
onConfirm: handleConfirmEdit,
|
|
3559
3552
|
onCancel: handleCancelEdit,
|
|
3560
3553
|
onHighlight: enableHighlighting ? () => {
|