@xcelsior/ui-spreadsheets 1.0.18 → 1.1.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/dist/index.d.mts +25 -17
- package/dist/index.d.ts +25 -17
- package/dist/index.js +62 -124
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -124
- package/dist/index.mjs.map +1 -1
- package/dist/styles/globals.css +14 -49
- package/dist/styles/globals.css.map +1 -1
- package/package.json +1 -1
- package/src/components/Spreadsheet.stories.tsx +0 -26
- package/src/components/Spreadsheet.tsx +190 -210
- package/src/components/SpreadsheetCell.tsx +7 -7
- package/src/components/SpreadsheetSettingsModal.tsx +3 -110
- package/src/hooks/index.ts +0 -2
- package/src/hooks/useSpreadsheetHighlighting.ts +0 -3
- package/src/hooks/useSpreadsheetPinning.ts +31 -4
- package/src/types.ts +24 -10
package/dist/index.d.mts
CHANGED
|
@@ -283,8 +283,6 @@ interface SpreadsheetProps<T = any> {
|
|
|
283
283
|
showToolbar?: boolean;
|
|
284
284
|
/** Whether to show pagination */
|
|
285
285
|
showPagination?: boolean;
|
|
286
|
-
/** Whether to show row index column (#) */
|
|
287
|
-
showRowIndex?: boolean;
|
|
288
286
|
/** Whether to enable row selection */
|
|
289
287
|
enableRowSelection?: boolean;
|
|
290
288
|
/** Whether to enable cell editing */
|
|
@@ -295,18 +293,34 @@ interface SpreadsheetProps<T = any> {
|
|
|
295
293
|
enableHighlighting?: boolean;
|
|
296
294
|
/** Whether to enable undo/redo */
|
|
297
295
|
enableUndoRedo?: boolean;
|
|
298
|
-
/** Initial page size */
|
|
299
|
-
defaultPageSize?: number;
|
|
300
296
|
/** Available page size options */
|
|
301
297
|
pageSizeOptions?: number[];
|
|
302
|
-
/** Initial zoom level */
|
|
303
|
-
defaultZoom?: number;
|
|
304
|
-
/** Whether to auto-save changes */
|
|
305
|
-
autoSave?: boolean;
|
|
306
298
|
/** Callback when changes are saved (called for both auto-save and manual save) */
|
|
307
299
|
onSave?: () => void | Promise<void>;
|
|
308
|
-
/**
|
|
309
|
-
|
|
300
|
+
/** Initial settings (optional). All settings can be changed by user in the settings modal. */
|
|
301
|
+
settings?: {
|
|
302
|
+
/** Default pinned column IDs */
|
|
303
|
+
defaultPinnedColumns?: string[];
|
|
304
|
+
/** Default sort configuration */
|
|
305
|
+
defaultSort?: SpreadsheetSortConfig | null;
|
|
306
|
+
/** Default page size */
|
|
307
|
+
defaultPageSize?: number;
|
|
308
|
+
/** Default zoom level */
|
|
309
|
+
defaultZoom?: number;
|
|
310
|
+
/** Whether auto-save is enabled */
|
|
311
|
+
autoSave?: boolean;
|
|
312
|
+
/** Whether compact view is enabled */
|
|
313
|
+
compactView?: boolean;
|
|
314
|
+
};
|
|
315
|
+
/** Callback when spreadsheet settings are changed by the user */
|
|
316
|
+
onSettingsChange?: (settings: {
|
|
317
|
+
compactView?: boolean;
|
|
318
|
+
autoSave?: boolean;
|
|
319
|
+
defaultPageSize?: number;
|
|
320
|
+
defaultZoom?: number;
|
|
321
|
+
defaultPinnedColumns?: string[];
|
|
322
|
+
defaultSort?: SpreadsheetSortConfig | null;
|
|
323
|
+
}) => void;
|
|
310
324
|
/** Loading state */
|
|
311
325
|
isLoading?: boolean;
|
|
312
326
|
/** Custom className */
|
|
@@ -606,7 +620,7 @@ interface SpreadsheetColumnGroupHeaderProps {
|
|
|
606
620
|
* />
|
|
607
621
|
* ```
|
|
608
622
|
*/
|
|
609
|
-
declare function Spreadsheet<T extends Record<string, any>>({ data, columns, columnGroups, getRowId, onCellsEdit, onSelectionChange, onSortChange, onFilterChange, onRowClick, onRowDoubleClick, onRowClone, onRowDelete, onAddCellComment, onRowHighlight, showToolbar, showPagination,
|
|
623
|
+
declare function Spreadsheet<T extends Record<string, any>>({ data, columns, columnGroups, getRowId, onCellsEdit, onSelectionChange, onSortChange, onFilterChange, onRowClick, onRowDoubleClick, onRowClone, onRowDelete, onAddCellComment, onRowHighlight, showToolbar, showPagination, enableRowSelection, enableCellEditing, enableComments, enableHighlighting, enableUndoRedo, pageSizeOptions, onSave, settings: initialSettings, onSettingsChange, isLoading, className, emptyMessage, rowHighlights: externalRowHighlights, cellComments: externalCellComments, rowActions, toolbarMenuItems, serverSide, totalItems, currentPage: controlledCurrentPage, pageSize: controlledPageSize, onPageChange, filters: controlledFilters, }: SpreadsheetProps<T>): react_jsx_runtime.JSX.Element;
|
|
610
624
|
declare namespace Spreadsheet {
|
|
611
625
|
var displayName: string;
|
|
612
626
|
}
|
|
@@ -682,12 +696,6 @@ interface SpreadsheetSettings {
|
|
|
682
696
|
autoSave?: boolean;
|
|
683
697
|
/** Whether compact view is enabled */
|
|
684
698
|
compactView?: boolean;
|
|
685
|
-
/** Whether to show row index column */
|
|
686
|
-
showRowIndex?: boolean;
|
|
687
|
-
/** Whether row index column is pinned */
|
|
688
|
-
pinRowIndex?: boolean;
|
|
689
|
-
/** Row index column highlight color */
|
|
690
|
-
rowIndexHighlightColor?: string;
|
|
691
699
|
}
|
|
692
700
|
interface SpreadsheetSettingsModalProps {
|
|
693
701
|
/** Whether the modal is open */
|
package/dist/index.d.ts
CHANGED
|
@@ -283,8 +283,6 @@ interface SpreadsheetProps<T = any> {
|
|
|
283
283
|
showToolbar?: boolean;
|
|
284
284
|
/** Whether to show pagination */
|
|
285
285
|
showPagination?: boolean;
|
|
286
|
-
/** Whether to show row index column (#) */
|
|
287
|
-
showRowIndex?: boolean;
|
|
288
286
|
/** Whether to enable row selection */
|
|
289
287
|
enableRowSelection?: boolean;
|
|
290
288
|
/** Whether to enable cell editing */
|
|
@@ -295,18 +293,34 @@ interface SpreadsheetProps<T = any> {
|
|
|
295
293
|
enableHighlighting?: boolean;
|
|
296
294
|
/** Whether to enable undo/redo */
|
|
297
295
|
enableUndoRedo?: boolean;
|
|
298
|
-
/** Initial page size */
|
|
299
|
-
defaultPageSize?: number;
|
|
300
296
|
/** Available page size options */
|
|
301
297
|
pageSizeOptions?: number[];
|
|
302
|
-
/** Initial zoom level */
|
|
303
|
-
defaultZoom?: number;
|
|
304
|
-
/** Whether to auto-save changes */
|
|
305
|
-
autoSave?: boolean;
|
|
306
298
|
/** Callback when changes are saved (called for both auto-save and manual save) */
|
|
307
299
|
onSave?: () => void | Promise<void>;
|
|
308
|
-
/**
|
|
309
|
-
|
|
300
|
+
/** Initial settings (optional). All settings can be changed by user in the settings modal. */
|
|
301
|
+
settings?: {
|
|
302
|
+
/** Default pinned column IDs */
|
|
303
|
+
defaultPinnedColumns?: string[];
|
|
304
|
+
/** Default sort configuration */
|
|
305
|
+
defaultSort?: SpreadsheetSortConfig | null;
|
|
306
|
+
/** Default page size */
|
|
307
|
+
defaultPageSize?: number;
|
|
308
|
+
/** Default zoom level */
|
|
309
|
+
defaultZoom?: number;
|
|
310
|
+
/** Whether auto-save is enabled */
|
|
311
|
+
autoSave?: boolean;
|
|
312
|
+
/** Whether compact view is enabled */
|
|
313
|
+
compactView?: boolean;
|
|
314
|
+
};
|
|
315
|
+
/** Callback when spreadsheet settings are changed by the user */
|
|
316
|
+
onSettingsChange?: (settings: {
|
|
317
|
+
compactView?: boolean;
|
|
318
|
+
autoSave?: boolean;
|
|
319
|
+
defaultPageSize?: number;
|
|
320
|
+
defaultZoom?: number;
|
|
321
|
+
defaultPinnedColumns?: string[];
|
|
322
|
+
defaultSort?: SpreadsheetSortConfig | null;
|
|
323
|
+
}) => void;
|
|
310
324
|
/** Loading state */
|
|
311
325
|
isLoading?: boolean;
|
|
312
326
|
/** Custom className */
|
|
@@ -606,7 +620,7 @@ interface SpreadsheetColumnGroupHeaderProps {
|
|
|
606
620
|
* />
|
|
607
621
|
* ```
|
|
608
622
|
*/
|
|
609
|
-
declare function Spreadsheet<T extends Record<string, any>>({ data, columns, columnGroups, getRowId, onCellsEdit, onSelectionChange, onSortChange, onFilterChange, onRowClick, onRowDoubleClick, onRowClone, onRowDelete, onAddCellComment, onRowHighlight, showToolbar, showPagination,
|
|
623
|
+
declare function Spreadsheet<T extends Record<string, any>>({ data, columns, columnGroups, getRowId, onCellsEdit, onSelectionChange, onSortChange, onFilterChange, onRowClick, onRowDoubleClick, onRowClone, onRowDelete, onAddCellComment, onRowHighlight, showToolbar, showPagination, enableRowSelection, enableCellEditing, enableComments, enableHighlighting, enableUndoRedo, pageSizeOptions, onSave, settings: initialSettings, onSettingsChange, isLoading, className, emptyMessage, rowHighlights: externalRowHighlights, cellComments: externalCellComments, rowActions, toolbarMenuItems, serverSide, totalItems, currentPage: controlledCurrentPage, pageSize: controlledPageSize, onPageChange, filters: controlledFilters, }: SpreadsheetProps<T>): react_jsx_runtime.JSX.Element;
|
|
610
624
|
declare namespace Spreadsheet {
|
|
611
625
|
var displayName: string;
|
|
612
626
|
}
|
|
@@ -682,12 +696,6 @@ interface SpreadsheetSettings {
|
|
|
682
696
|
autoSave?: boolean;
|
|
683
697
|
/** Whether compact view is enabled */
|
|
684
698
|
compactView?: boolean;
|
|
685
|
-
/** Whether to show row index column */
|
|
686
|
-
showRowIndex?: boolean;
|
|
687
|
-
/** Whether row index column is pinned */
|
|
688
|
-
pinRowIndex?: boolean;
|
|
689
|
-
/** Row index column highlight color */
|
|
690
|
-
rowIndexHighlightColor?: string;
|
|
691
699
|
}
|
|
692
700
|
interface SpreadsheetSettingsModalProps {
|
|
693
701
|
/** Whether the modal is open */
|
package/dist/index.js
CHANGED
|
@@ -292,8 +292,8 @@ var SpreadsheetCell = ({
|
|
|
292
292
|
onKeyDown: handleKeyDown,
|
|
293
293
|
onBlur: () => onConfirm?.(localValue),
|
|
294
294
|
className: cn(
|
|
295
|
-
"w-full border
|
|
296
|
-
compactMode ? "
|
|
295
|
+
"w-full border-0 bg-blue-50 focus:outline-none focus:ring-1 focus:ring-blue-500 rounded-sm",
|
|
296
|
+
compactMode ? "text-[10px]" : "text-xs"
|
|
297
297
|
),
|
|
298
298
|
children: column.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: option, children: option }, option))
|
|
299
299
|
}
|
|
@@ -317,8 +317,8 @@ var SpreadsheetCell = ({
|
|
|
317
317
|
autoCapitalize: "off",
|
|
318
318
|
spellCheck: false,
|
|
319
319
|
className: cn(
|
|
320
|
-
"w-full border
|
|
321
|
-
compactMode ? "
|
|
320
|
+
"w-full border-0 bg-blue-50 focus:outline-none focus:ring-1 focus:ring-blue-500 rounded-sm",
|
|
321
|
+
compactMode ? "text-[10px]" : "text-xs"
|
|
322
322
|
)
|
|
323
323
|
}
|
|
324
324
|
);
|
|
@@ -370,7 +370,7 @@ var SpreadsheetCell = ({
|
|
|
370
370
|
onKeyDown: handleCellKeyDown,
|
|
371
371
|
"data-cell-id": `${rowId}-${column.id}`,
|
|
372
372
|
className: cn(
|
|
373
|
-
"border border-gray-200 group cursor-pointer
|
|
373
|
+
"border border-gray-200 group cursor-pointer select-none",
|
|
374
374
|
compactMode ? "text-[10px]" : "text-xs",
|
|
375
375
|
cellPadding,
|
|
376
376
|
column.align === "right" && "text-right",
|
|
@@ -393,7 +393,7 @@ var SpreadsheetCell = ({
|
|
|
393
393
|
{
|
|
394
394
|
className: cn(
|
|
395
395
|
"flex-1 truncate",
|
|
396
|
-
isEditable && "cursor-text
|
|
396
|
+
isEditable && "cursor-text bg-blue-50/50 rounded"
|
|
397
397
|
),
|
|
398
398
|
title: String(value ?? ""),
|
|
399
399
|
children: renderContent()
|
|
@@ -469,6 +469,7 @@ var MemoizedSpreadsheetCell = (0, import_react3.memo)(SpreadsheetCell, (prevProp
|
|
|
469
469
|
if (prevProps.isPinned !== nextProps.isPinned) return false;
|
|
470
470
|
if (prevProps.leftOffset !== nextProps.leftOffset) return false;
|
|
471
471
|
if (prevProps.rightOffset !== nextProps.rightOffset) return false;
|
|
472
|
+
if (prevProps.compactMode !== nextProps.compactMode) return false;
|
|
472
473
|
const prevEdge = prevProps.selectionEdge;
|
|
473
474
|
const nextEdge = nextProps.selectionEdge;
|
|
474
475
|
if (prevEdge !== nextEdge) {
|
|
@@ -1273,7 +1274,8 @@ SpreadsheetHeader.displayName = "SpreadsheetHeader";
|
|
|
1273
1274
|
|
|
1274
1275
|
// src/hooks/useSpreadsheetPinning.ts
|
|
1275
1276
|
var import_react6 = require("react");
|
|
1276
|
-
var
|
|
1277
|
+
var ROW_INDEX_COLUMN_ID = "__row_index__";
|
|
1278
|
+
var ROW_INDEX_COLUMN_WIDTH = 80;
|
|
1277
1279
|
function useSpreadsheetPinning({
|
|
1278
1280
|
columns,
|
|
1279
1281
|
columnGroups,
|
|
@@ -1284,11 +1286,15 @@ function useSpreadsheetPinning({
|
|
|
1284
1286
|
const [pinnedColumns, setPinnedColumns] = (0, import_react6.useState)(() => {
|
|
1285
1287
|
const map = /* @__PURE__ */ new Map();
|
|
1286
1288
|
defaultPinnedColumns.forEach((col) => {
|
|
1287
|
-
|
|
1289
|
+
if (col !== ROW_INDEX_COLUMN_ID) {
|
|
1290
|
+
map.set(col, "left");
|
|
1291
|
+
}
|
|
1288
1292
|
});
|
|
1289
1293
|
return map;
|
|
1290
1294
|
});
|
|
1291
|
-
const [isRowIndexPinned, setIsRowIndexPinned] = (0, import_react6.useState)(
|
|
1295
|
+
const [isRowIndexPinned, setIsRowIndexPinned] = (0, import_react6.useState)(
|
|
1296
|
+
defaultPinRowIndex || defaultPinnedColumns.includes(ROW_INDEX_COLUMN_ID)
|
|
1297
|
+
);
|
|
1292
1298
|
const [collapsedGroups, setCollapsedGroups] = (0, import_react6.useState)(/* @__PURE__ */ new Set());
|
|
1293
1299
|
const handleTogglePin = (0, import_react6.useCallback)((columnId) => {
|
|
1294
1300
|
setPinnedColumns((prev) => {
|
|
@@ -1304,6 +1310,19 @@ function useSpreadsheetPinning({
|
|
|
1304
1310
|
const handleToggleRowIndexPin = (0, import_react6.useCallback)(() => {
|
|
1305
1311
|
setIsRowIndexPinned((prev) => !prev);
|
|
1306
1312
|
}, []);
|
|
1313
|
+
const setPinnedColumnsFromIds = (0, import_react6.useCallback)((columnIds) => {
|
|
1314
|
+
const map = /* @__PURE__ */ new Map();
|
|
1315
|
+
columnIds.forEach((col) => {
|
|
1316
|
+
if (col !== ROW_INDEX_COLUMN_ID) {
|
|
1317
|
+
map.set(col, "left");
|
|
1318
|
+
}
|
|
1319
|
+
});
|
|
1320
|
+
setPinnedColumns(map);
|
|
1321
|
+
setIsRowIndexPinned(columnIds.includes(ROW_INDEX_COLUMN_ID));
|
|
1322
|
+
}, []);
|
|
1323
|
+
const setRowIndexPinned = (0, import_react6.useCallback)((pinned) => {
|
|
1324
|
+
setIsRowIndexPinned(pinned);
|
|
1325
|
+
}, []);
|
|
1307
1326
|
const handleToggleGroupCollapse = (0, import_react6.useCallback)((groupId) => {
|
|
1308
1327
|
setCollapsedGroups((prev) => {
|
|
1309
1328
|
const newSet = new Set(prev);
|
|
@@ -1388,6 +1407,8 @@ function useSpreadsheetPinning({
|
|
|
1388
1407
|
handleTogglePin,
|
|
1389
1408
|
handleToggleRowIndexPin,
|
|
1390
1409
|
handleToggleGroupCollapse,
|
|
1410
|
+
setPinnedColumnsFromIds,
|
|
1411
|
+
setRowIndexPinned,
|
|
1391
1412
|
getColumnLeftOffset,
|
|
1392
1413
|
getRowIndexLeftOffset,
|
|
1393
1414
|
isColumnPinned,
|
|
@@ -1497,7 +1518,6 @@ var HIGHLIGHT_COLORS = {
|
|
|
1497
1518
|
// gray-200
|
|
1498
1519
|
]
|
|
1499
1520
|
};
|
|
1500
|
-
var ROW_INDEX_COLUMN_ID = "__row_index__";
|
|
1501
1521
|
function useSpreadsheetHighlighting({
|
|
1502
1522
|
externalRowHighlights,
|
|
1503
1523
|
onRowHighlight
|
|
@@ -1665,10 +1685,7 @@ var DEFAULT_SETTINGS = {
|
|
|
1665
1685
|
defaultPageSize: 25,
|
|
1666
1686
|
defaultZoom: 100,
|
|
1667
1687
|
autoSave: true,
|
|
1668
|
-
compactView: false
|
|
1669
|
-
showRowIndex: true,
|
|
1670
|
-
pinRowIndex: false,
|
|
1671
|
-
rowIndexHighlightColor: void 0
|
|
1688
|
+
compactView: false
|
|
1672
1689
|
};
|
|
1673
1690
|
var SpreadsheetSettingsModal = ({
|
|
1674
1691
|
isOpen,
|
|
@@ -1798,11 +1815,8 @@ var SpreadsheetSettingsModal = ({
|
|
|
1798
1815
|
"button",
|
|
1799
1816
|
{
|
|
1800
1817
|
type: "button",
|
|
1801
|
-
onClick: () =>
|
|
1802
|
-
|
|
1803
|
-
pinRowIndex: !localSettings.pinRowIndex
|
|
1804
|
-
}),
|
|
1805
|
-
className: `flex items-center gap-2 p-3 rounded-lg border transition-colors text-left ${localSettings.pinRowIndex !== false ? "bg-blue-50 border-blue-300 text-blue-700" : "bg-gray-50 border-gray-200 text-gray-700 hover:border-blue-300"}`,
|
|
1818
|
+
onClick: () => togglePinnedColumn("__row_index__"),
|
|
1819
|
+
className: `flex items-center gap-2 p-3 rounded-lg border transition-colors text-left ${localSettings.defaultPinnedColumns.includes("__row_index__") ? "bg-blue-50 border-blue-300 text-blue-700" : "bg-gray-50 border-gray-200 text-gray-700 hover:border-blue-300"}`,
|
|
1806
1820
|
children: [
|
|
1807
1821
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(HiViewBoards, { className: "h-4 w-4 shrink-0" }),
|
|
1808
1822
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "text-sm flex-1 truncate", children: "# (Row Index)" })
|
|
@@ -1827,47 +1841,6 @@ var SpreadsheetSettingsModal = ({
|
|
|
1827
1841
|
column.id
|
|
1828
1842
|
);
|
|
1829
1843
|
})
|
|
1830
|
-
] }),
|
|
1831
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "mt-6 p-4 bg-amber-50 border border-amber-200 rounded-lg", children: [
|
|
1832
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-sm font-semibold text-gray-900 mb-3", children: "Row Index Column Highlight" }),
|
|
1833
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-sm text-gray-600 mb-3", children: "Apply a highlight color to the # (row index) column to make it stand out." }),
|
|
1834
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex items-center gap-2 flex-wrap", children: [
|
|
1835
|
-
[
|
|
1836
|
-
"#fef3c7",
|
|
1837
|
-
"#dbeafe",
|
|
1838
|
-
"#dcfce7",
|
|
1839
|
-
"#fce7f3",
|
|
1840
|
-
"#f3e8ff",
|
|
1841
|
-
"#e0e7ff",
|
|
1842
|
-
"#fed7d7",
|
|
1843
|
-
"#c6f6d5"
|
|
1844
|
-
].map((color) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1845
|
-
"button",
|
|
1846
|
-
{
|
|
1847
|
-
type: "button",
|
|
1848
|
-
onClick: () => setLocalSettings({
|
|
1849
|
-
...localSettings,
|
|
1850
|
-
rowIndexHighlightColor: localSettings.rowIndexHighlightColor === color ? void 0 : color
|
|
1851
|
-
}),
|
|
1852
|
-
className: `w-8 h-8 rounded-lg border-2 transition-all ${localSettings.rowIndexHighlightColor === color ? "border-blue-600 scale-110 ring-2 ring-blue-300" : "border-gray-300 hover:border-gray-400"}`,
|
|
1853
|
-
style: { backgroundColor: color },
|
|
1854
|
-
title: localSettings.rowIndexHighlightColor === color ? "Remove highlight" : "Apply highlight"
|
|
1855
|
-
},
|
|
1856
|
-
color
|
|
1857
|
-
)),
|
|
1858
|
-
localSettings.rowIndexHighlightColor && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1859
|
-
"button",
|
|
1860
|
-
{
|
|
1861
|
-
type: "button",
|
|
1862
|
-
onClick: () => setLocalSettings({
|
|
1863
|
-
...localSettings,
|
|
1864
|
-
rowIndexHighlightColor: void 0
|
|
1865
|
-
}),
|
|
1866
|
-
className: "text-sm text-red-600 hover:text-red-700 ml-2 px-2 py-1 rounded hover:bg-red-50",
|
|
1867
|
-
children: "Clear"
|
|
1868
|
-
}
|
|
1869
|
-
)
|
|
1870
|
-
] })
|
|
1871
1844
|
] })
|
|
1872
1845
|
] }),
|
|
1873
1846
|
activeTab === "sorting" && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
|
|
@@ -1913,27 +1886,6 @@ var SpreadsheetSettingsModal = ({
|
|
|
1913
1886
|
] }),
|
|
1914
1887
|
activeTab === "display" && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "space-y-5", children: [
|
|
1915
1888
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-sm text-gray-600", children: "Customize the display and behavior of the spreadsheet." }),
|
|
1916
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "p-4 bg-blue-50 border border-blue-200 rounded-lg", children: [
|
|
1917
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-sm font-semibold text-gray-900 mb-3", children: "Row Index Column" }),
|
|
1918
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "space-y-3", children: [
|
|
1919
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("label", { className: "flex items-center gap-3 cursor-pointer", children: [
|
|
1920
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1921
|
-
"input",
|
|
1922
|
-
{
|
|
1923
|
-
type: "checkbox",
|
|
1924
|
-
checked: localSettings.showRowIndex !== false,
|
|
1925
|
-
onChange: (e) => setLocalSettings({
|
|
1926
|
-
...localSettings,
|
|
1927
|
-
showRowIndex: e.target.checked
|
|
1928
|
-
}),
|
|
1929
|
-
className: "w-4 h-4 cursor-pointer rounded border-gray-300 text-blue-600 focus:ring-blue-500"
|
|
1930
|
-
}
|
|
1931
|
-
),
|
|
1932
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "text-sm text-gray-700", children: "Show row index (#) column" })
|
|
1933
|
-
] }),
|
|
1934
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-xs text-gray-500 ml-7", children: 'Tip: Use the "Pinned Columns" tab to pin and highlight the row index column.' })
|
|
1935
|
-
] })
|
|
1936
|
-
] }),
|
|
1937
1889
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
|
|
1938
1890
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { className: "block text-sm font-medium text-gray-900 mb-2", children: "Default Page Size" }),
|
|
1939
1891
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
@@ -3374,18 +3326,15 @@ function Spreadsheet({
|
|
|
3374
3326
|
onRowHighlight,
|
|
3375
3327
|
showToolbar = true,
|
|
3376
3328
|
showPagination = true,
|
|
3377
|
-
showRowIndex = true,
|
|
3378
3329
|
enableRowSelection = true,
|
|
3379
3330
|
enableCellEditing = true,
|
|
3380
3331
|
enableComments = true,
|
|
3381
3332
|
enableHighlighting = true,
|
|
3382
3333
|
enableUndoRedo = true,
|
|
3383
|
-
defaultPageSize = 25,
|
|
3384
3334
|
pageSizeOptions = [25, 50, 100, 200],
|
|
3385
|
-
defaultZoom = 100,
|
|
3386
|
-
autoSave,
|
|
3387
3335
|
onSave,
|
|
3388
|
-
|
|
3336
|
+
settings: initialSettings,
|
|
3337
|
+
onSettingsChange,
|
|
3389
3338
|
isLoading = false,
|
|
3390
3339
|
className,
|
|
3391
3340
|
emptyMessage = "No data available",
|
|
@@ -3399,9 +3348,16 @@ function Spreadsheet({
|
|
|
3399
3348
|
currentPage: controlledCurrentPage,
|
|
3400
3349
|
pageSize: controlledPageSize,
|
|
3401
3350
|
onPageChange,
|
|
3402
|
-
sortConfig: controlledSortConfig,
|
|
3403
3351
|
filters: controlledFilters
|
|
3404
3352
|
}) {
|
|
3353
|
+
const [spreadsheetSettings, setSpreadsheetSettings] = (0, import_react16.useState)({
|
|
3354
|
+
defaultPinnedColumns: initialSettings?.defaultPinnedColumns ?? [],
|
|
3355
|
+
defaultSort: initialSettings?.defaultSort ?? null,
|
|
3356
|
+
defaultPageSize: initialSettings?.defaultPageSize ?? 25,
|
|
3357
|
+
defaultZoom: initialSettings?.defaultZoom ?? 100,
|
|
3358
|
+
autoSave: initialSettings?.autoSave ?? true,
|
|
3359
|
+
compactView: initialSettings?.compactView ?? false
|
|
3360
|
+
});
|
|
3405
3361
|
const {
|
|
3406
3362
|
filters,
|
|
3407
3363
|
sortConfig,
|
|
@@ -3420,7 +3376,7 @@ function Spreadsheet({
|
|
|
3420
3376
|
onSortChange,
|
|
3421
3377
|
serverSide,
|
|
3422
3378
|
controlledFilters,
|
|
3423
|
-
controlledSortConfig
|
|
3379
|
+
controlledSortConfig: spreadsheetSettings?.defaultSort
|
|
3424
3380
|
});
|
|
3425
3381
|
const {
|
|
3426
3382
|
getCellHighlight,
|
|
@@ -3445,15 +3401,14 @@ function Spreadsheet({
|
|
|
3445
3401
|
collapsedGroups,
|
|
3446
3402
|
visibleColumns,
|
|
3447
3403
|
handleTogglePin,
|
|
3448
|
-
handleToggleRowIndexPin,
|
|
3449
3404
|
handleToggleGroupCollapse,
|
|
3405
|
+
setPinnedColumnsFromIds,
|
|
3450
3406
|
getColumnLeftOffset,
|
|
3451
3407
|
isColumnPinned,
|
|
3452
3408
|
getColumnPinSide
|
|
3453
3409
|
} = useSpreadsheetPinning({
|
|
3454
3410
|
columns,
|
|
3455
|
-
columnGroups
|
|
3456
|
-
showRowIndex
|
|
3411
|
+
columnGroups
|
|
3457
3412
|
});
|
|
3458
3413
|
const {
|
|
3459
3414
|
getCellComments,
|
|
@@ -3470,18 +3425,6 @@ function Spreadsheet({
|
|
|
3470
3425
|
onAddCellComment
|
|
3471
3426
|
});
|
|
3472
3427
|
const [showSettingsModal, setShowSettingsModal] = (0, import_react16.useState)(false);
|
|
3473
|
-
const [spreadsheetSettings, setSpreadsheetSettings] = (0, import_react16.useState)({
|
|
3474
|
-
defaultPinnedColumns: [],
|
|
3475
|
-
defaultSort: null,
|
|
3476
|
-
defaultPageSize,
|
|
3477
|
-
defaultZoom,
|
|
3478
|
-
autoSave: autoSave ?? true,
|
|
3479
|
-
compactView: compactMode ?? false,
|
|
3480
|
-
showRowIndex,
|
|
3481
|
-
pinRowIndex: false,
|
|
3482
|
-
rowIndexHighlightColor: void 0
|
|
3483
|
-
});
|
|
3484
|
-
const effectiveAutoSave = autoSave ?? spreadsheetSettings.autoSave;
|
|
3485
3428
|
const {
|
|
3486
3429
|
canUndo,
|
|
3487
3430
|
canRedo,
|
|
@@ -3496,15 +3439,15 @@ function Spreadsheet({
|
|
|
3496
3439
|
markAsChanged
|
|
3497
3440
|
} = useSpreadsheetUndoRedo({
|
|
3498
3441
|
enabled: enableUndoRedo,
|
|
3499
|
-
autoSave:
|
|
3442
|
+
autoSave: spreadsheetSettings.autoSave,
|
|
3500
3443
|
onSave
|
|
3501
3444
|
});
|
|
3502
3445
|
const [selectedRows, setSelectedRows] = (0, import_react16.useState)(/* @__PURE__ */ new Set());
|
|
3503
3446
|
const [lastSelectedRow, setLastSelectedRow] = (0, import_react16.useState)(null);
|
|
3504
3447
|
const [hoveredRow, setHoveredRow] = (0, import_react16.useState)(null);
|
|
3505
3448
|
const [internalCurrentPage, setInternalCurrentPage] = (0, import_react16.useState)(1);
|
|
3506
|
-
const [internalPageSize, setInternalPageSize] = (0, import_react16.useState)(defaultPageSize);
|
|
3507
|
-
const [zoom, setZoom] = (0, import_react16.useState)(defaultZoom);
|
|
3449
|
+
const [internalPageSize, setInternalPageSize] = (0, import_react16.useState)(spreadsheetSettings.defaultPageSize);
|
|
3450
|
+
const [zoom, setZoom] = (0, import_react16.useState)(spreadsheetSettings.defaultZoom);
|
|
3508
3451
|
const currentPage = controlledCurrentPage ?? internalCurrentPage;
|
|
3509
3452
|
const pageSize = controlledPageSize ?? internalPageSize;
|
|
3510
3453
|
const handlePageChange = (0, import_react16.useCallback)(
|
|
@@ -3691,8 +3634,7 @@ function Spreadsheet({
|
|
|
3691
3634
|
isEditing: editingCell !== null,
|
|
3692
3635
|
enabled: true
|
|
3693
3636
|
});
|
|
3694
|
-
const
|
|
3695
|
-
const effectiveCompactMode = compactMode ?? spreadsheetSettings.compactView;
|
|
3637
|
+
const effectiveCompactMode = spreadsheetSettings.compactView ?? false;
|
|
3696
3638
|
const rowIndexHighlightColor = getColumnHighlight(ROW_INDEX_COLUMN_ID);
|
|
3697
3639
|
const tableRef = (0, import_react16.useRef)(null);
|
|
3698
3640
|
const effectiveTotalItems = serverSide ? totalItems ?? data.length : filteredData.length;
|
|
@@ -3820,7 +3762,7 @@ function Spreadsheet({
|
|
|
3820
3762
|
selectedRowCount: selectedRows.size,
|
|
3821
3763
|
hasUnsavedChanges,
|
|
3822
3764
|
saveStatus,
|
|
3823
|
-
autoSave:
|
|
3765
|
+
autoSave: spreadsheetSettings.autoSave,
|
|
3824
3766
|
hasActiveFilters,
|
|
3825
3767
|
onClearFilters: clearAllFilters,
|
|
3826
3768
|
onZoomIn: () => setZoom((z) => Math.min(z + 10, 200)),
|
|
@@ -3850,14 +3792,14 @@ function Spreadsheet({
|
|
|
3850
3792
|
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("table", { className: "w-full border-separate border-spacing-0 text-xs select-none", children: [
|
|
3851
3793
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("thead", { children: [
|
|
3852
3794
|
columnGroups && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("tr", { children: [
|
|
3853
|
-
|
|
3795
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3854
3796
|
RowIndexColumnHeader,
|
|
3855
3797
|
{
|
|
3856
3798
|
enableHighlighting,
|
|
3857
3799
|
highlightColor: rowIndexHighlightColor,
|
|
3858
3800
|
isPinned: isRowIndexPinned,
|
|
3859
3801
|
onHighlightClick: handleRowIndexHighlightClick,
|
|
3860
|
-
onPinClick:
|
|
3802
|
+
onPinClick: () => handleTogglePin(ROW_INDEX_COLUMN_ID),
|
|
3861
3803
|
hasColumnGroups: true,
|
|
3862
3804
|
compactMode: effectiveCompactMode
|
|
3863
3805
|
}
|
|
@@ -3894,14 +3836,14 @@ function Spreadsheet({
|
|
|
3894
3836
|
})
|
|
3895
3837
|
] }),
|
|
3896
3838
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("tr", { children: [
|
|
3897
|
-
|
|
3839
|
+
!columnGroups && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3898
3840
|
RowIndexColumnHeader,
|
|
3899
3841
|
{
|
|
3900
3842
|
enableHighlighting,
|
|
3901
3843
|
highlightColor: rowIndexHighlightColor,
|
|
3902
3844
|
isPinned: isRowIndexPinned,
|
|
3903
3845
|
onHighlightClick: handleRowIndexHighlightClick,
|
|
3904
|
-
onPinClick:
|
|
3846
|
+
onPinClick: () => handleTogglePin(ROW_INDEX_COLUMN_ID),
|
|
3905
3847
|
hasColumnGroups: false,
|
|
3906
3848
|
compactMode: effectiveCompactMode
|
|
3907
3849
|
}
|
|
@@ -3943,7 +3885,7 @@ function Spreadsheet({
|
|
|
3943
3885
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("tbody", { children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3944
3886
|
"td",
|
|
3945
3887
|
{
|
|
3946
|
-
colSpan: visibleColumns.length +
|
|
3888
|
+
colSpan: visibleColumns.length + 1,
|
|
3947
3889
|
className: "text-center py-8 text-gray-500",
|
|
3948
3890
|
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center justify-center gap-2", children: [
|
|
3949
3891
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "w-4 h-4 border-2 border-blue-600 border-t-transparent rounded-full animate-spin" }),
|
|
@@ -3953,7 +3895,7 @@ function Spreadsheet({
|
|
|
3953
3895
|
) }) : paginatedData.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3954
3896
|
"td",
|
|
3955
3897
|
{
|
|
3956
|
-
colSpan: visibleColumns.length +
|
|
3898
|
+
colSpan: visibleColumns.length + 1,
|
|
3957
3899
|
className: "text-center py-8 text-gray-500",
|
|
3958
3900
|
children: emptyMessage
|
|
3959
3901
|
}
|
|
@@ -3972,9 +3914,8 @@ function Spreadsheet({
|
|
|
3972
3914
|
onRowClick?.(row, rowIndex);
|
|
3973
3915
|
},
|
|
3974
3916
|
onDoubleClick: () => onRowDoubleClick?.(row, rowIndex),
|
|
3975
|
-
className: "transition-colors",
|
|
3976
3917
|
children: [
|
|
3977
|
-
|
|
3918
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3978
3919
|
"td",
|
|
3979
3920
|
{
|
|
3980
3921
|
onClick: (e) => handleRowSelect(rowId, e),
|
|
@@ -4030,9 +3971,7 @@ function Spreadsheet({
|
|
|
4030
3971
|
type: "button",
|
|
4031
3972
|
onClick: (e) => {
|
|
4032
3973
|
e.stopPropagation();
|
|
4033
|
-
setHighlightPickerRow(
|
|
4034
|
-
rowId
|
|
4035
|
-
);
|
|
3974
|
+
setHighlightPickerRow(rowId);
|
|
4036
3975
|
},
|
|
4037
3976
|
className: "opacity-0 group-hover:opacity-100 transition-opacity p-0.5 bg-gray-100 hover:bg-gray-200 rounded",
|
|
4038
3977
|
title: "Highlight row",
|
|
@@ -4102,10 +4041,7 @@ function Spreadsheet({
|
|
|
4102
4041
|
type: "button",
|
|
4103
4042
|
onClick: (e) => {
|
|
4104
4043
|
e.stopPropagation();
|
|
4105
|
-
action.onClick(
|
|
4106
|
-
row,
|
|
4107
|
-
rowId
|
|
4108
|
-
);
|
|
4044
|
+
action.onClick(row, rowId);
|
|
4109
4045
|
},
|
|
4110
4046
|
className: cn(
|
|
4111
4047
|
"opacity-0 group-hover:opacity-100 transition-opacity p-0.5 hover:bg-gray-200 rounded",
|
|
@@ -4288,6 +4224,8 @@ function Spreadsheet({
|
|
|
4288
4224
|
if (newSettings.defaultSort?.columnId !== sortConfig?.columnId || newSettings.defaultSort?.direction !== sortConfig?.direction) {
|
|
4289
4225
|
setSortConfig(newSettings.defaultSort);
|
|
4290
4226
|
}
|
|
4227
|
+
setPinnedColumnsFromIds(newSettings.defaultPinnedColumns);
|
|
4228
|
+
onSettingsChange?.(newSettings);
|
|
4291
4229
|
},
|
|
4292
4230
|
columns: columns || [],
|
|
4293
4231
|
title: "Spreadsheet Settings",
|