@xcelsior/ui-spreadsheets 1.1.7 → 1.1.9
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 +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +30 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/Spreadsheet.stories.tsx +56 -0
- package/src/components/Spreadsheet.tsx +9 -0
- package/src/components/SpreadsheetCell.tsx +3 -3
- package/src/components/SpreadsheetHeader.tsx +1 -1
- package/src/hooks/useSpreadsheetPinning.ts +30 -0
- package/src/types.ts +8 -1
package/dist/index.mjs
CHANGED
|
@@ -377,7 +377,7 @@ var SpreadsheetCell = ({
|
|
|
377
377
|
}
|
|
378
378
|
),
|
|
379
379
|
!isInSelection && !isFocused && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-0.5 shrink-0", children: [
|
|
380
|
-
onHighlight && /* @__PURE__ */ jsx(
|
|
380
|
+
column.highlightable !== false && onHighlight && /* @__PURE__ */ jsx(
|
|
381
381
|
"button",
|
|
382
382
|
{
|
|
383
383
|
type: "button",
|
|
@@ -398,7 +398,7 @@ var SpreadsheetCell = ({
|
|
|
398
398
|
)
|
|
399
399
|
}
|
|
400
400
|
),
|
|
401
|
-
hasComments && onViewComments ? /* @__PURE__ */ jsxs(
|
|
401
|
+
column.commentable !== false && hasComments && onViewComments ? /* @__PURE__ */ jsxs(
|
|
402
402
|
"button",
|
|
403
403
|
{
|
|
404
404
|
type: "button",
|
|
@@ -413,7 +413,7 @@ var SpreadsheetCell = ({
|
|
|
413
413
|
unresolvedCommentCount > 0 && /* @__PURE__ */ jsx("span", { className: "text-[9px] font-medium text-amber-600", children: unresolvedCommentCount > 99 ? "99+" : unresolvedCommentCount })
|
|
414
414
|
]
|
|
415
415
|
}
|
|
416
|
-
) : onAddComment ? /* @__PURE__ */ jsx(
|
|
416
|
+
) : column.commentable !== false && onAddComment ? /* @__PURE__ */ jsx(
|
|
417
417
|
"button",
|
|
418
418
|
{
|
|
419
419
|
type: "button",
|
|
@@ -1216,7 +1216,7 @@ var SpreadsheetHeader = ({
|
|
|
1216
1216
|
ColumnHeaderActions,
|
|
1217
1217
|
{
|
|
1218
1218
|
enableFiltering: column.filterable,
|
|
1219
|
-
enableHighlighting: !!onHighlightClick,
|
|
1219
|
+
enableHighlighting: column.highlightable !== false && !!onHighlightClick,
|
|
1220
1220
|
enablePinning: column.pinnable !== false,
|
|
1221
1221
|
hasActiveFilter,
|
|
1222
1222
|
hasActiveHighlight: !!highlightColor,
|
|
@@ -1242,13 +1242,17 @@ function useSpreadsheetPinning({
|
|
|
1242
1242
|
columns,
|
|
1243
1243
|
columnGroups,
|
|
1244
1244
|
showRowIndex = true,
|
|
1245
|
-
defaultPinnedColumns = []
|
|
1245
|
+
defaultPinnedColumns = [],
|
|
1246
|
+
defaultPinnedRightColumns = []
|
|
1246
1247
|
}) {
|
|
1247
1248
|
const [pinnedColumns, setPinnedColumns] = useState3(() => {
|
|
1248
1249
|
const map = /* @__PURE__ */ new Map();
|
|
1249
1250
|
defaultPinnedColumns.forEach((col) => {
|
|
1250
1251
|
map.set(col, "left");
|
|
1251
1252
|
});
|
|
1253
|
+
defaultPinnedRightColumns.forEach((col) => {
|
|
1254
|
+
map.set(col, "right");
|
|
1255
|
+
});
|
|
1252
1256
|
return map;
|
|
1253
1257
|
});
|
|
1254
1258
|
const [collapsedGroups, setCollapsedGroups] = useState3(/* @__PURE__ */ new Set());
|
|
@@ -1351,6 +1355,20 @@ function useSpreadsheetPinning({
|
|
|
1351
1355
|
},
|
|
1352
1356
|
[pinnedColumns]
|
|
1353
1357
|
);
|
|
1358
|
+
const getColumnRightOffset = useCallback(
|
|
1359
|
+
(columnId) => {
|
|
1360
|
+
const pinnedRight = Array.from(pinnedColumns.entries()).filter(([, side]) => side === "right").map(([id]) => id);
|
|
1361
|
+
const index = pinnedRight.indexOf(columnId);
|
|
1362
|
+
if (index === -1) return 0;
|
|
1363
|
+
let offset = 0;
|
|
1364
|
+
for (let i = pinnedRight.length - 1; i > index; i--) {
|
|
1365
|
+
const col = columns.find((c) => c.id === pinnedRight[i]);
|
|
1366
|
+
offset += col?.minWidth || col?.width || 100;
|
|
1367
|
+
}
|
|
1368
|
+
return offset;
|
|
1369
|
+
},
|
|
1370
|
+
[pinnedColumns, columns]
|
|
1371
|
+
);
|
|
1354
1372
|
return {
|
|
1355
1373
|
pinnedColumns,
|
|
1356
1374
|
isRowIndexPinned,
|
|
@@ -1360,6 +1378,7 @@ function useSpreadsheetPinning({
|
|
|
1360
1378
|
handleToggleGroupCollapse,
|
|
1361
1379
|
setPinnedColumnsFromIds,
|
|
1362
1380
|
getColumnLeftOffset,
|
|
1381
|
+
getColumnRightOffset,
|
|
1363
1382
|
isColumnPinned,
|
|
1364
1383
|
getColumnPinSide
|
|
1365
1384
|
};
|
|
@@ -3454,12 +3473,14 @@ function Spreadsheet({
|
|
|
3454
3473
|
handleToggleGroupCollapse,
|
|
3455
3474
|
setPinnedColumnsFromIds,
|
|
3456
3475
|
getColumnLeftOffset,
|
|
3476
|
+
getColumnRightOffset,
|
|
3457
3477
|
isColumnPinned,
|
|
3458
3478
|
getColumnPinSide
|
|
3459
3479
|
} = useSpreadsheetPinning({
|
|
3460
3480
|
columns,
|
|
3461
3481
|
columnGroups,
|
|
3462
|
-
defaultPinnedColumns: initialSettings?.defaultPinnedColumns
|
|
3482
|
+
defaultPinnedColumns: initialSettings?.defaultPinnedColumns,
|
|
3483
|
+
defaultPinnedRightColumns: initialSettings?.defaultPinnedRightColumns
|
|
3463
3484
|
});
|
|
3464
3485
|
const {
|
|
3465
3486
|
getCellComments,
|
|
@@ -3911,6 +3932,7 @@ function Spreadsheet({
|
|
|
3911
3932
|
),
|
|
3912
3933
|
visibleColumns.map((column) => {
|
|
3913
3934
|
const isPinnedLeft = isColumnPinned(column.id) && getColumnPinSide(column.id) === "left";
|
|
3935
|
+
const isPinnedRight = isColumnPinned(column.id) && getColumnPinSide(column.id) === "right";
|
|
3914
3936
|
return /* @__PURE__ */ jsx12(
|
|
3915
3937
|
SpreadsheetHeader,
|
|
3916
3938
|
{
|
|
@@ -3920,6 +3942,7 @@ function Spreadsheet({
|
|
|
3920
3942
|
isPinned: isColumnPinned(column.id),
|
|
3921
3943
|
pinSide: getColumnPinSide(column.id),
|
|
3922
3944
|
leftOffset: isPinnedLeft ? getColumnLeftOffset(column.id) : 0,
|
|
3945
|
+
rightOffset: isPinnedRight ? getColumnRightOffset(column.id) : 0,
|
|
3923
3946
|
highlightColor: getColumnHighlight(column.id),
|
|
3924
3947
|
compactMode: effectiveCompactMode,
|
|
3925
3948
|
onClick: () => handleSort(column.id),
|
|
@@ -4136,6 +4159,7 @@ function Spreadsheet({
|
|
|
4136
4159
|
isPinned: isColPinned,
|
|
4137
4160
|
pinSide: colPinSide,
|
|
4138
4161
|
leftOffset: getColumnLeftOffset(column.id),
|
|
4162
|
+
rightOffset: getColumnRightOffset(column.id),
|
|
4139
4163
|
onClick: (e) => handleCellClick(rowId, column.id, e),
|
|
4140
4164
|
onConfirm: handleConfirmEdit,
|
|
4141
4165
|
onCancel: handleCancelEdit,
|