@xcelsior/ui-spreadsheets 1.3.1 → 1.3.3
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/.omc/state/idle-notif-cooldown.json +1 -1
- package/dist/index.js +83 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/Spreadsheet.tsx +65 -15
- package/src/components/SpreadsheetCell.tsx +9 -4
- package/src/hooks/useSpreadsheetFiltering.ts +6 -1
- package/src/hooks/useSpreadsheetKeyboardShortcuts.ts +9 -0
- package/src/hooks/useSpreadsheetSummary.ts +2 -2
package/dist/index.js
CHANGED
|
@@ -484,9 +484,10 @@ var SpreadsheetCell = ({
|
|
|
484
484
|
return typeof value === "number" ? value.toLocaleString() : value;
|
|
485
485
|
}
|
|
486
486
|
if (column.type === "autocomplete") {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
487
|
+
const displayVal = localValue ?? value;
|
|
488
|
+
if (column.getOptionLabel) return column.getOptionLabel(displayVal, row);
|
|
489
|
+
const match = column.autocompleteOptions?.find((o) => o.value === displayVal);
|
|
490
|
+
return match ? match.label : displayVal != null && displayVal !== "" ? String(displayVal) : null;
|
|
490
491
|
}
|
|
491
492
|
return String(value);
|
|
492
493
|
};
|
|
@@ -501,7 +502,10 @@ var SpreadsheetCell = ({
|
|
|
501
502
|
value: localValue,
|
|
502
503
|
column,
|
|
503
504
|
compactMode,
|
|
504
|
-
onConfirm
|
|
505
|
+
onConfirm: (newVal) => {
|
|
506
|
+
setLocalValue(newVal);
|
|
507
|
+
onConfirm?.(newVal);
|
|
508
|
+
},
|
|
505
509
|
onCancel
|
|
506
510
|
}
|
|
507
511
|
);
|
|
@@ -3241,7 +3245,8 @@ function useSpreadsheetFiltering({
|
|
|
3241
3245
|
return false;
|
|
3242
3246
|
}
|
|
3243
3247
|
if (filter.textCondition) {
|
|
3244
|
-
|
|
3248
|
+
const filterableValue = column.type === "autocomplete" && column.getOptionLabel ? column.getOptionLabel(value, row) : value;
|
|
3249
|
+
return applyTextCondition(filterableValue, filter.textCondition);
|
|
3245
3250
|
}
|
|
3246
3251
|
if (filter.numberCondition) {
|
|
3247
3252
|
return applyNumberCondition(value, filter.numberCondition);
|
|
@@ -3855,6 +3860,11 @@ function useSpreadsheetKeyboardShortcuts({
|
|
|
3855
3860
|
(0, import_react19.useEffect)(() => {
|
|
3856
3861
|
if (!enabled) return;
|
|
3857
3862
|
const handleKeyDown = (event) => {
|
|
3863
|
+
const activeEl = document.activeElement;
|
|
3864
|
+
const isInFormElement = activeEl instanceof HTMLInputElement || activeEl instanceof HTMLTextAreaElement || activeEl instanceof HTMLSelectElement;
|
|
3865
|
+
if (isInFormElement && event.key !== "Escape") {
|
|
3866
|
+
return;
|
|
3867
|
+
}
|
|
3858
3868
|
if (event.key === "Escape") {
|
|
3859
3869
|
if (showKeyboardShortcuts) {
|
|
3860
3870
|
setShowKeyboardShortcuts(false);
|
|
@@ -4430,7 +4440,7 @@ function useSpreadsheetSummary({
|
|
|
4430
4440
|
const numericValues = [];
|
|
4431
4441
|
for (const { position, value } of selectedCellValues) {
|
|
4432
4442
|
const column = columns.find((c) => c.id === position.columnId);
|
|
4433
|
-
if (column?.type === "number"
|
|
4443
|
+
if (column?.type === "number") {
|
|
4434
4444
|
const num = typeof value === "number" ? value : parseFloat(value);
|
|
4435
4445
|
if (!isNaN(num)) {
|
|
4436
4446
|
numericValues.push(num);
|
|
@@ -4780,7 +4790,7 @@ function Spreadsheet({
|
|
|
4780
4790
|
onToggleCommentResolved
|
|
4781
4791
|
});
|
|
4782
4792
|
const [showSettingsModal, setShowSettingsModal] = (0, import_react23.useState)(false);
|
|
4783
|
-
const [showFiltersPanel, setShowFiltersPanel] = (0, import_react23.useState)(
|
|
4793
|
+
const [showFiltersPanel, setShowFiltersPanel] = (0, import_react23.useState)(true);
|
|
4784
4794
|
const {
|
|
4785
4795
|
canUndo,
|
|
4786
4796
|
canRedo,
|
|
@@ -5133,8 +5143,14 @@ function Spreadsheet({
|
|
|
5133
5143
|
(rowId, columnId, event) => {
|
|
5134
5144
|
event.stopPropagation();
|
|
5135
5145
|
handleCellMouseDown(rowId, columnId, event);
|
|
5146
|
+
if (!event.shiftKey && !event.metaKey && !event.ctrlKey) {
|
|
5147
|
+
const column = columns.find((c) => c.id === columnId);
|
|
5148
|
+
if (column?.editable && enableCellEditing) {
|
|
5149
|
+
setEditingCell({ rowId, columnId });
|
|
5150
|
+
}
|
|
5151
|
+
}
|
|
5136
5152
|
},
|
|
5137
|
-
[handleCellMouseDown]
|
|
5153
|
+
[handleCellMouseDown, columns, enableCellEditing, setEditingCell]
|
|
5138
5154
|
);
|
|
5139
5155
|
const handleCellDoubleClick = (0, import_react23.useCallback)(
|
|
5140
5156
|
(rowId, columnId) => {
|
|
@@ -5400,17 +5416,65 @@ function Spreadsheet({
|
|
|
5400
5416
|
})
|
|
5401
5417
|
] })
|
|
5402
5418
|
] }),
|
|
5403
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("tbody", { children: isLoading ?
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5419
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("tbody", { children: isLoading ? Array.from({ length: Math.min(pageSize, 40) }).map((_, rowIdx) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("tr", { children: [
|
|
5420
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
5421
|
+
"td",
|
|
5422
|
+
{
|
|
5423
|
+
className: cn(
|
|
5424
|
+
"sticky",
|
|
5425
|
+
effectiveCompactMode ? "px-1.5 py-0.5" : "px-2.5 py-1.5"
|
|
5426
|
+
),
|
|
5427
|
+
style: {
|
|
5428
|
+
minWidth: `${ROW_INDEX_COLUMN_WIDTH}px`,
|
|
5429
|
+
width: `${ROW_INDEX_COLUMN_WIDTH}px`,
|
|
5430
|
+
left: 0,
|
|
5431
|
+
zIndex: 40,
|
|
5432
|
+
backgroundColor: rowIdx % 2 !== 0 ? "#f9fafb" : "white"
|
|
5433
|
+
},
|
|
5434
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
5435
|
+
"div",
|
|
5436
|
+
{
|
|
5437
|
+
className: "h-4 bg-gray-200 rounded animate-pulse",
|
|
5438
|
+
style: { width: "60%", animationDelay: `${rowIdx * 50}ms` }
|
|
5439
|
+
}
|
|
5440
|
+
)
|
|
5441
|
+
}
|
|
5442
|
+
),
|
|
5443
|
+
columnRenderItems.map((item, colIdx) => {
|
|
5444
|
+
if (item.type === "collapsed-placeholder") {
|
|
5445
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
5446
|
+
"td",
|
|
5447
|
+
{
|
|
5448
|
+
style: { backgroundColor: rowIdx % 2 !== 0 ? "#f9fafb" : "white" }
|
|
5449
|
+
},
|
|
5450
|
+
`skeleton-${rowIdx}-placeholder-${item.groupId}`
|
|
5451
|
+
);
|
|
5452
|
+
}
|
|
5453
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
5454
|
+
"td",
|
|
5455
|
+
{
|
|
5456
|
+
className: cn(
|
|
5457
|
+
effectiveCompactMode ? "px-1.5 py-0.5" : "px-2.5 py-1.5"
|
|
5458
|
+
),
|
|
5459
|
+
style: {
|
|
5460
|
+
minWidth: item.column.width ?? 120,
|
|
5461
|
+
backgroundColor: rowIdx % 2 !== 0 ? "#f9fafb" : "white"
|
|
5462
|
+
},
|
|
5463
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
5464
|
+
"div",
|
|
5465
|
+
{
|
|
5466
|
+
className: "h-4 bg-gray-200 rounded animate-pulse",
|
|
5467
|
+
style: {
|
|
5468
|
+
width: `${55 + (rowIdx * 7 + colIdx * 13) % 35}%`,
|
|
5469
|
+
animationDelay: `${(rowIdx * columnRenderItems.length + colIdx) * 30}ms`
|
|
5470
|
+
}
|
|
5471
|
+
}
|
|
5472
|
+
)
|
|
5473
|
+
},
|
|
5474
|
+
`skeleton-${rowIdx}-${item.column.id}`
|
|
5475
|
+
);
|
|
5476
|
+
})
|
|
5477
|
+
] }, `skeleton-${rowIdx}`)) : paginatedData.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
5414
5478
|
"td",
|
|
5415
5479
|
{
|
|
5416
5480
|
colSpan: columnRenderItems.length + 1,
|