@xcelsior/ui-spreadsheets 1.1.7 → 1.1.8

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 CHANGED
@@ -323,8 +323,10 @@ interface SpreadsheetProps<T = any> {
323
323
  onSave?: () => void | Promise<void>;
324
324
  /** Initial settings (optional). All settings can be changed by user in the settings modal. */
325
325
  settings?: {
326
- /** Default pinned column IDs */
326
+ /** Default pinned column IDs (pinned to left) */
327
327
  defaultPinnedColumns?: string[];
328
+ /** Default pinned column IDs (pinned to right) */
329
+ defaultPinnedRightColumns?: string[];
328
330
  /** Default sort configuration */
329
331
  defaultSort?: SpreadsheetSortConfig | null;
330
332
  /** Default page size */
@@ -343,6 +345,7 @@ interface SpreadsheetProps<T = any> {
343
345
  defaultPageSize?: number;
344
346
  defaultZoom?: number;
345
347
  defaultPinnedColumns?: string[];
348
+ defaultPinnedRightColumns?: string[];
346
349
  defaultSort?: SpreadsheetSortConfig | null;
347
350
  }) => void;
348
351
  /** Loading state */
package/dist/index.d.ts CHANGED
@@ -323,8 +323,10 @@ interface SpreadsheetProps<T = any> {
323
323
  onSave?: () => void | Promise<void>;
324
324
  /** Initial settings (optional). All settings can be changed by user in the settings modal. */
325
325
  settings?: {
326
- /** Default pinned column IDs */
326
+ /** Default pinned column IDs (pinned to left) */
327
327
  defaultPinnedColumns?: string[];
328
+ /** Default pinned column IDs (pinned to right) */
329
+ defaultPinnedRightColumns?: string[];
328
330
  /** Default sort configuration */
329
331
  defaultSort?: SpreadsheetSortConfig | null;
330
332
  /** Default page size */
@@ -343,6 +345,7 @@ interface SpreadsheetProps<T = any> {
343
345
  defaultPageSize?: number;
344
346
  defaultZoom?: number;
345
347
  defaultPinnedColumns?: string[];
348
+ defaultPinnedRightColumns?: string[];
346
349
  defaultSort?: SpreadsheetSortConfig | null;
347
350
  }) => void;
348
351
  /** Loading state */
package/dist/index.js CHANGED
@@ -1284,13 +1284,17 @@ function useSpreadsheetPinning({
1284
1284
  columns,
1285
1285
  columnGroups,
1286
1286
  showRowIndex = true,
1287
- defaultPinnedColumns = []
1287
+ defaultPinnedColumns = [],
1288
+ defaultPinnedRightColumns = []
1288
1289
  }) {
1289
1290
  const [pinnedColumns, setPinnedColumns] = (0, import_react6.useState)(() => {
1290
1291
  const map = /* @__PURE__ */ new Map();
1291
1292
  defaultPinnedColumns.forEach((col) => {
1292
1293
  map.set(col, "left");
1293
1294
  });
1295
+ defaultPinnedRightColumns.forEach((col) => {
1296
+ map.set(col, "right");
1297
+ });
1294
1298
  return map;
1295
1299
  });
1296
1300
  const [collapsedGroups, setCollapsedGroups] = (0, import_react6.useState)(/* @__PURE__ */ new Set());
@@ -1393,6 +1397,20 @@ function useSpreadsheetPinning({
1393
1397
  },
1394
1398
  [pinnedColumns]
1395
1399
  );
1400
+ const getColumnRightOffset = (0, import_react6.useCallback)(
1401
+ (columnId) => {
1402
+ const pinnedRight = Array.from(pinnedColumns.entries()).filter(([, side]) => side === "right").map(([id]) => id);
1403
+ const index = pinnedRight.indexOf(columnId);
1404
+ if (index === -1) return 0;
1405
+ let offset = 0;
1406
+ for (let i = pinnedRight.length - 1; i > index; i--) {
1407
+ const col = columns.find((c) => c.id === pinnedRight[i]);
1408
+ offset += col?.minWidth || col?.width || 100;
1409
+ }
1410
+ return offset;
1411
+ },
1412
+ [pinnedColumns, columns]
1413
+ );
1396
1414
  return {
1397
1415
  pinnedColumns,
1398
1416
  isRowIndexPinned,
@@ -1402,6 +1420,7 @@ function useSpreadsheetPinning({
1402
1420
  handleToggleGroupCollapse,
1403
1421
  setPinnedColumnsFromIds,
1404
1422
  getColumnLeftOffset,
1423
+ getColumnRightOffset,
1405
1424
  isColumnPinned,
1406
1425
  getColumnPinSide
1407
1426
  };
@@ -3496,12 +3515,14 @@ function Spreadsheet({
3496
3515
  handleToggleGroupCollapse,
3497
3516
  setPinnedColumnsFromIds,
3498
3517
  getColumnLeftOffset,
3518
+ getColumnRightOffset,
3499
3519
  isColumnPinned,
3500
3520
  getColumnPinSide
3501
3521
  } = useSpreadsheetPinning({
3502
3522
  columns,
3503
3523
  columnGroups,
3504
- defaultPinnedColumns: initialSettings?.defaultPinnedColumns
3524
+ defaultPinnedColumns: initialSettings?.defaultPinnedColumns,
3525
+ defaultPinnedRightColumns: initialSettings?.defaultPinnedRightColumns
3505
3526
  });
3506
3527
  const {
3507
3528
  getCellComments,
@@ -3953,6 +3974,7 @@ function Spreadsheet({
3953
3974
  ),
3954
3975
  visibleColumns.map((column) => {
3955
3976
  const isPinnedLeft = isColumnPinned(column.id) && getColumnPinSide(column.id) === "left";
3977
+ const isPinnedRight = isColumnPinned(column.id) && getColumnPinSide(column.id) === "right";
3956
3978
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3957
3979
  SpreadsheetHeader,
3958
3980
  {
@@ -3962,6 +3984,7 @@ function Spreadsheet({
3962
3984
  isPinned: isColumnPinned(column.id),
3963
3985
  pinSide: getColumnPinSide(column.id),
3964
3986
  leftOffset: isPinnedLeft ? getColumnLeftOffset(column.id) : 0,
3987
+ rightOffset: isPinnedRight ? getColumnRightOffset(column.id) : 0,
3965
3988
  highlightColor: getColumnHighlight(column.id),
3966
3989
  compactMode: effectiveCompactMode,
3967
3990
  onClick: () => handleSort(column.id),
@@ -4178,6 +4201,7 @@ function Spreadsheet({
4178
4201
  isPinned: isColPinned,
4179
4202
  pinSide: colPinSide,
4180
4203
  leftOffset: getColumnLeftOffset(column.id),
4204
+ rightOffset: getColumnRightOffset(column.id),
4181
4205
  onClick: (e) => handleCellClick(rowId, column.id, e),
4182
4206
  onConfirm: handleConfirmEdit,
4183
4207
  onCancel: handleCancelEdit,