@xcelsior/ui-spreadsheets 1.1.3 → 1.1.5
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/.turbo/turbo-build.log +18 -18
- package/CHANGELOG.md +8 -0
- package/dist/index.d.mts +61 -6
- package/dist/index.d.ts +61 -6
- package/dist/index.js +292 -229
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +192 -130
- package/dist/index.mjs.map +1 -1
- package/dist/styles/globals.css +29 -7
- package/dist/styles/globals.css.map +1 -1
- package/package.json +4 -4
- package/src/components/RowContextMenu.tsx +82 -0
- package/src/components/Spreadsheet.stories.tsx +294 -33
- package/src/components/Spreadsheet.tsx +30 -53
- package/src/hooks/useSpreadsheetComments.ts +17 -5
- package/src/hooks/useSpreadsheetFiltering.ts +1 -1
- package/src/hooks/useSpreadsheetHighlighting.ts +67 -34
- package/src/index.ts +2 -0
- package/src/types.ts +39 -4
- package/.turbo/turbo-lint.log +0 -196
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
RowContextMenu: () => RowContextMenu,
|
|
33
34
|
Spreadsheet: () => Spreadsheet,
|
|
34
35
|
SpreadsheetCell: () => MemoizedSpreadsheetCell,
|
|
35
36
|
SpreadsheetFilterDropdown: () => SpreadsheetFilterDropdown,
|
|
@@ -40,7 +41,7 @@ __export(index_exports, {
|
|
|
40
41
|
module.exports = __toCommonJS(index_exports);
|
|
41
42
|
|
|
42
43
|
// src/components/Spreadsheet.tsx
|
|
43
|
-
var
|
|
44
|
+
var import_react17 = require("react");
|
|
44
45
|
|
|
45
46
|
// ../../../node_modules/.pnpm/react-icons@4.12.0_react@18.3.1/node_modules/react-icons/lib/esm/iconBase.js
|
|
46
47
|
var import_react2 = __toESM(require("react"));
|
|
@@ -134,9 +135,6 @@ function HiCog(props) {
|
|
|
134
135
|
function HiDotsVertical(props) {
|
|
135
136
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 20 20", "fill": "currentColor", "aria-hidden": "true" }, "child": [{ "tag": "path", "attr": { "d": "M10 6a2 2 0 110-4 2 2 0 010 4zM10 12a2 2 0 110-4 2 2 0 010 4zM10 18a2 2 0 110-4 2 2 0 010 4z" } }] })(props);
|
|
136
137
|
}
|
|
137
|
-
function HiDuplicate(props) {
|
|
138
|
-
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 20 20", "fill": "currentColor", "aria-hidden": "true" }, "child": [{ "tag": "path", "attr": { "d": "M7 9a2 2 0 012-2h6a2 2 0 012 2v6a2 2 0 01-2 2H9a2 2 0 01-2-2V9z" } }, { "tag": "path", "attr": { "d": "M5 3a2 2 0 00-2 2v6a2 2 0 002 2V5h8a2 2 0 00-2-2H5z" } }] })(props);
|
|
139
|
-
}
|
|
140
138
|
function HiEye(props) {
|
|
141
139
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 20 20", "fill": "currentColor", "aria-hidden": "true" }, "child": [{ "tag": "path", "attr": { "d": "M10 12a2 2 0 100-4 2 2 0 000 4z" } }, { "tag": "path", "attr": { "fillRule": "evenodd", "d": "M.458 10C1.732 5.943 5.522 3 10 3s8.268 2.943 9.542 7c-1.274 4.057-5.064 7-9.542 7S1.732 14.057.458 10zM14 10a4 4 0 11-8 0 4 4 0 018 0z", "clipRule": "evenodd" } }] })(props);
|
|
142
140
|
}
|
|
@@ -149,9 +147,6 @@ function HiReply(props) {
|
|
|
149
147
|
function HiSortAscending(props) {
|
|
150
148
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 20 20", "fill": "currentColor", "aria-hidden": "true" }, "child": [{ "tag": "path", "attr": { "d": "M3 3a1 1 0 000 2h11a1 1 0 100-2H3zM3 7a1 1 0 000 2h5a1 1 0 000-2H3zM3 11a1 1 0 100 2h4a1 1 0 100-2H3zM13 16a1 1 0 102 0v-5.586l1.293 1.293a1 1 0 001.414-1.414l-3-3a1 1 0 00-1.414 0l-3 3a1 1 0 101.414 1.414L13 10.414V16z" } }] })(props);
|
|
151
149
|
}
|
|
152
|
-
function HiTrash(props) {
|
|
153
|
-
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 20 20", "fill": "currentColor", "aria-hidden": "true" }, "child": [{ "tag": "path", "attr": { "fillRule": "evenodd", "d": "M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z", "clipRule": "evenodd" } }] })(props);
|
|
154
|
-
}
|
|
155
150
|
function HiViewBoards(props) {
|
|
156
151
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 20 20", "fill": "currentColor", "aria-hidden": "true" }, "child": [{ "tag": "path", "attr": { "d": "M2 4a1 1 0 011-1h2a1 1 0 011 1v12a1 1 0 01-1 1H3a1 1 0 01-1-1V4zM8 4a1 1 0 011-1h2a1 1 0 011 1v12a1 1 0 01-1 1H9a1 1 0 01-1-1V4zM15 3a1 1 0 00-1 1v12a1 1 0 001 1h2a1 1 0 001-1V4a1 1 0 00-1-1h-2z" } }] })(props);
|
|
157
152
|
}
|
|
@@ -1492,15 +1487,21 @@ var HIGHLIGHT_COLORS = {
|
|
|
1492
1487
|
};
|
|
1493
1488
|
function useSpreadsheetHighlighting({
|
|
1494
1489
|
externalRowHighlights,
|
|
1495
|
-
onRowHighlight
|
|
1490
|
+
onRowHighlight,
|
|
1491
|
+
externalColumnHighlights,
|
|
1492
|
+
onColumnHighlight,
|
|
1493
|
+
externalCellHighlights,
|
|
1494
|
+
onCellHighlight
|
|
1496
1495
|
} = {}) {
|
|
1497
|
-
const [
|
|
1496
|
+
const [cellHighlightsInternal, setCellHighlightsInternal] = (0, import_react7.useState)([]);
|
|
1498
1497
|
const [rowHighlightsInternal, setRowHighlightsInternal] = (0, import_react7.useState)([]);
|
|
1499
|
-
const [
|
|
1498
|
+
const [columnHighlightsInternal, setColumnHighlightsInternal] = (0, import_react7.useState)({});
|
|
1500
1499
|
const [highlightPickerRow, setHighlightPickerRow] = (0, import_react7.useState)(null);
|
|
1501
1500
|
const [highlightPickerColumn, setHighlightPickerColumn] = (0, import_react7.useState)(null);
|
|
1502
1501
|
const [highlightPickerCell, setHighlightPickerCell] = (0, import_react7.useState)(null);
|
|
1502
|
+
const cellHighlights = externalCellHighlights || cellHighlightsInternal;
|
|
1503
1503
|
const rowHighlights = externalRowHighlights || rowHighlightsInternal;
|
|
1504
|
+
const columnHighlights = externalColumnHighlights || columnHighlightsInternal;
|
|
1504
1505
|
const getCellHighlight = (0, import_react7.useCallback)(
|
|
1505
1506
|
(rowId, columnId) => {
|
|
1506
1507
|
return cellHighlights.find((h) => h.rowId === rowId && h.columnId === columnId)?.color;
|
|
@@ -1509,24 +1510,30 @@ function useSpreadsheetHighlighting({
|
|
|
1509
1510
|
);
|
|
1510
1511
|
const handleCellHighlightToggle = (0, import_react7.useCallback)(
|
|
1511
1512
|
(rowId, columnId, color = "#fef08a") => {
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1513
|
+
if (onCellHighlight) {
|
|
1514
|
+
onCellHighlight(rowId, columnId, color);
|
|
1515
|
+
} else {
|
|
1516
|
+
setCellHighlightsInternal((prev) => {
|
|
1517
|
+
const existing = prev.find((h) => h.rowId === rowId && h.columnId === columnId);
|
|
1518
|
+
if (existing) {
|
|
1519
|
+
if (color === null) {
|
|
1520
|
+
return prev.filter(
|
|
1521
|
+
(h) => !(h.rowId === rowId && h.columnId === columnId)
|
|
1522
|
+
);
|
|
1523
|
+
}
|
|
1524
|
+
return prev.map(
|
|
1525
|
+
(h) => h.rowId === rowId && h.columnId === columnId ? { ...h, color } : h
|
|
1526
|
+
);
|
|
1517
1527
|
}
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
}
|
|
1525
|
-
return prev;
|
|
1526
|
-
});
|
|
1528
|
+
if (color) {
|
|
1529
|
+
return [...prev, { rowId, columnId, color }];
|
|
1530
|
+
}
|
|
1531
|
+
return prev;
|
|
1532
|
+
});
|
|
1533
|
+
}
|
|
1527
1534
|
setHighlightPickerCell(null);
|
|
1528
1535
|
},
|
|
1529
|
-
[]
|
|
1536
|
+
[onCellHighlight]
|
|
1530
1537
|
);
|
|
1531
1538
|
const getRowHighlight = (0, import_react7.useCallback)(
|
|
1532
1539
|
(rowId) => {
|
|
@@ -1565,22 +1572,29 @@ function useSpreadsheetHighlighting({
|
|
|
1565
1572
|
},
|
|
1566
1573
|
[columnHighlights]
|
|
1567
1574
|
);
|
|
1568
|
-
const handleColumnHighlightToggle = (0, import_react7.useCallback)(
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
delete newHighlights[columnId];
|
|
1575
|
+
const handleColumnHighlightToggle = (0, import_react7.useCallback)(
|
|
1576
|
+
(columnId, color) => {
|
|
1577
|
+
if (onColumnHighlight) {
|
|
1578
|
+
onColumnHighlight(columnId, color);
|
|
1573
1579
|
} else {
|
|
1574
|
-
|
|
1580
|
+
setColumnHighlightsInternal((prev) => {
|
|
1581
|
+
const newHighlights = { ...prev };
|
|
1582
|
+
if (color === null) {
|
|
1583
|
+
delete newHighlights[columnId];
|
|
1584
|
+
} else {
|
|
1585
|
+
newHighlights[columnId] = color;
|
|
1586
|
+
}
|
|
1587
|
+
return newHighlights;
|
|
1588
|
+
});
|
|
1575
1589
|
}
|
|
1576
|
-
|
|
1577
|
-
}
|
|
1578
|
-
|
|
1579
|
-
|
|
1590
|
+
setHighlightPickerColumn(null);
|
|
1591
|
+
},
|
|
1592
|
+
[onColumnHighlight]
|
|
1593
|
+
);
|
|
1580
1594
|
const clearAllHighlights = (0, import_react7.useCallback)(() => {
|
|
1581
|
-
|
|
1595
|
+
setCellHighlightsInternal([]);
|
|
1582
1596
|
setRowHighlightsInternal([]);
|
|
1583
|
-
|
|
1597
|
+
setColumnHighlightsInternal({});
|
|
1584
1598
|
}, []);
|
|
1585
1599
|
return {
|
|
1586
1600
|
// Cell highlights
|
|
@@ -2202,12 +2216,72 @@ function ShortcutRow({ label, keys }) {
|
|
|
2202
2216
|
}
|
|
2203
2217
|
KeyboardShortcutsModal.displayName = "KeyboardShortcutsModal";
|
|
2204
2218
|
|
|
2205
|
-
// src/components/
|
|
2219
|
+
// src/components/RowContextMenu.tsx
|
|
2220
|
+
var import_react11 = require("react");
|
|
2206
2221
|
var import_design_system = require("@xcelsior/design-system");
|
|
2222
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2223
|
+
function RowContextMenu({
|
|
2224
|
+
row,
|
|
2225
|
+
rowId,
|
|
2226
|
+
items,
|
|
2227
|
+
compactMode = false,
|
|
2228
|
+
className
|
|
2229
|
+
}) {
|
|
2230
|
+
const visibleItems = (0, import_react11.useMemo)(() => {
|
|
2231
|
+
return items.filter((item) => !item.visible || item.visible(row));
|
|
2232
|
+
}, [items, row]);
|
|
2233
|
+
if (visibleItems.length === 0) {
|
|
2234
|
+
return null;
|
|
2235
|
+
}
|
|
2236
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2237
|
+
import_design_system.ContextMenu,
|
|
2238
|
+
{
|
|
2239
|
+
trigger: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2240
|
+
"button",
|
|
2241
|
+
{
|
|
2242
|
+
type: "button",
|
|
2243
|
+
className: cn(
|
|
2244
|
+
"opacity-0 group-hover:opacity-100 transition-opacity p-0.5 bg-gray-100 hover:bg-gray-200 rounded",
|
|
2245
|
+
className
|
|
2246
|
+
),
|
|
2247
|
+
title: "More actions",
|
|
2248
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2249
|
+
HiDotsVertical,
|
|
2250
|
+
{
|
|
2251
|
+
className: cn("text-gray-500", compactMode ? "h-2.5 w-2.5" : "h-3 w-3")
|
|
2252
|
+
}
|
|
2253
|
+
)
|
|
2254
|
+
}
|
|
2255
|
+
),
|
|
2256
|
+
placement: "bottom",
|
|
2257
|
+
children: visibleItems.map((item) => {
|
|
2258
|
+
const isDisabled = item.disabled?.(row);
|
|
2259
|
+
const variantClass = item.variant === "destructive" ? "text-red-600 hover:bg-red-50" : "";
|
|
2260
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
2261
|
+
import_design_system.ContextMenuItem,
|
|
2262
|
+
{
|
|
2263
|
+
onClick: () => item.onClick(row, rowId),
|
|
2264
|
+
disabled: isDisabled,
|
|
2265
|
+
className: `${variantClass} ${item.className || ""}`,
|
|
2266
|
+
children: [
|
|
2267
|
+
item.icon && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "mr-2", children: item.icon }),
|
|
2268
|
+
item.label
|
|
2269
|
+
]
|
|
2270
|
+
},
|
|
2271
|
+
item.id
|
|
2272
|
+
);
|
|
2273
|
+
})
|
|
2274
|
+
}
|
|
2275
|
+
);
|
|
2276
|
+
}
|
|
2277
|
+
RowContextMenu.displayName = "RowContextMenu";
|
|
2278
|
+
|
|
2279
|
+
// src/components/Spreadsheet.tsx
|
|
2280
|
+
var import_design_system2 = require("@xcelsior/design-system");
|
|
2207
2281
|
|
|
2208
2282
|
// src/hooks/useSpreadsheetFiltering.ts
|
|
2209
|
-
var
|
|
2210
|
-
var
|
|
2283
|
+
var import_react12 = require("react");
|
|
2284
|
+
var import_utils10 = require("@xcelsior/utils");
|
|
2211
2285
|
function useSpreadsheetFiltering({
|
|
2212
2286
|
data,
|
|
2213
2287
|
columns,
|
|
@@ -2218,16 +2292,16 @@ function useSpreadsheetFiltering({
|
|
|
2218
2292
|
controlledSortConfig,
|
|
2219
2293
|
defaultSortConfig
|
|
2220
2294
|
}) {
|
|
2221
|
-
const [internalFilters, setInternalFilters] = (0,
|
|
2295
|
+
const [internalFilters, setInternalFilters] = (0, import_react12.useState)(
|
|
2222
2296
|
{}
|
|
2223
2297
|
);
|
|
2224
|
-
const [internalSortConfig, setInternalSortConfig] = (0,
|
|
2298
|
+
const [internalSortConfig, setInternalSortConfig] = (0, import_react12.useState)(
|
|
2225
2299
|
defaultSortConfig ?? null
|
|
2226
2300
|
);
|
|
2227
|
-
const [activeFilterColumn, setActiveFilterColumn] = (0,
|
|
2301
|
+
const [activeFilterColumn, setActiveFilterColumn] = (0, import_react12.useState)(null);
|
|
2228
2302
|
const filters = controlledFilters ?? internalFilters;
|
|
2229
2303
|
const sortConfig = controlledSortConfig !== void 0 ? controlledSortConfig : internalSortConfig;
|
|
2230
|
-
const applyTextCondition = (0,
|
|
2304
|
+
const applyTextCondition = (0, import_react12.useCallback)(
|
|
2231
2305
|
(value, condition) => {
|
|
2232
2306
|
const strValue = String(value ?? "").toLowerCase();
|
|
2233
2307
|
const filterValue = (condition.value ?? "").toLowerCase();
|
|
@@ -2254,7 +2328,7 @@ function useSpreadsheetFiltering({
|
|
|
2254
2328
|
},
|
|
2255
2329
|
[]
|
|
2256
2330
|
);
|
|
2257
|
-
const applyNumberCondition = (0,
|
|
2331
|
+
const applyNumberCondition = (0, import_react12.useCallback)(
|
|
2258
2332
|
(value, condition) => {
|
|
2259
2333
|
if (condition.operator === "isEmpty") return isBlankValue(value);
|
|
2260
2334
|
if (condition.operator === "isNotEmpty") return !isBlankValue(value);
|
|
@@ -2283,7 +2357,7 @@ function useSpreadsheetFiltering({
|
|
|
2283
2357
|
},
|
|
2284
2358
|
[]
|
|
2285
2359
|
);
|
|
2286
|
-
const applyDateCondition = (0,
|
|
2360
|
+
const applyDateCondition = (0, import_react12.useCallback)(
|
|
2287
2361
|
(value, condition) => {
|
|
2288
2362
|
if (condition.operator === "isEmpty") return isBlankValue(value);
|
|
2289
2363
|
if (condition.operator === "isNotEmpty") return !isBlankValue(value);
|
|
@@ -2355,7 +2429,7 @@ function useSpreadsheetFiltering({
|
|
|
2355
2429
|
},
|
|
2356
2430
|
[]
|
|
2357
2431
|
);
|
|
2358
|
-
const buildFilterPredicate = (0,
|
|
2432
|
+
const buildFilterPredicate = (0, import_react12.useCallback)(
|
|
2359
2433
|
(column, filter) => {
|
|
2360
2434
|
return (row) => {
|
|
2361
2435
|
const value = column.getValue ? column.getValue(row) : row[column.id];
|
|
@@ -2389,7 +2463,7 @@ function useSpreadsheetFiltering({
|
|
|
2389
2463
|
},
|
|
2390
2464
|
[applyTextCondition, applyNumberCondition, applyDateCondition]
|
|
2391
2465
|
);
|
|
2392
|
-
const buildSortComparator = (0,
|
|
2466
|
+
const buildSortComparator = (0, import_react12.useCallback)(
|
|
2393
2467
|
(column, direction) => {
|
|
2394
2468
|
return (a, b) => {
|
|
2395
2469
|
const aValue = column?.getValue ? column.getValue(a) : a[sortConfig?.columnId];
|
|
@@ -2404,14 +2478,14 @@ function useSpreadsheetFiltering({
|
|
|
2404
2478
|
},
|
|
2405
2479
|
[sortConfig?.columnId]
|
|
2406
2480
|
);
|
|
2407
|
-
const filteredData = (0,
|
|
2408
|
-
if (!data || !Array.isArray(data)) return
|
|
2481
|
+
const filteredData = (0, import_react12.useMemo)(() => {
|
|
2482
|
+
if (!data || !Array.isArray(data)) return import_utils10.LazyArray.empty();
|
|
2409
2483
|
if (serverSide) {
|
|
2410
|
-
return
|
|
2484
|
+
return import_utils10.LazyArray.from(data);
|
|
2411
2485
|
}
|
|
2412
|
-
if (!columns || !Array.isArray(columns)) return
|
|
2413
|
-
let lazyResult =
|
|
2414
|
-
const filterChain = new
|
|
2486
|
+
if (!columns || !Array.isArray(columns)) return import_utils10.LazyArray.from(data);
|
|
2487
|
+
let lazyResult = import_utils10.LazyArray.from(data);
|
|
2488
|
+
const filterChain = new import_utils10.FilterChain();
|
|
2415
2489
|
for (const [columnId, filter] of Object.entries(filters)) {
|
|
2416
2490
|
if (!filter) continue;
|
|
2417
2491
|
const column = columns.find((c) => c.id === columnId);
|
|
@@ -2427,7 +2501,7 @@ function useSpreadsheetFiltering({
|
|
|
2427
2501
|
}
|
|
2428
2502
|
return lazyResult;
|
|
2429
2503
|
}, [data, filters, sortConfig, columns, serverSide, buildFilterPredicate, buildSortComparator]);
|
|
2430
|
-
const handleFilterChange = (0,
|
|
2504
|
+
const handleFilterChange = (0, import_react12.useCallback)(
|
|
2431
2505
|
(columnId, filter) => {
|
|
2432
2506
|
const newFilters = { ...filters };
|
|
2433
2507
|
if (filter) {
|
|
@@ -2442,7 +2516,7 @@ function useSpreadsheetFiltering({
|
|
|
2442
2516
|
},
|
|
2443
2517
|
[filters, onFilterChange, controlledFilters]
|
|
2444
2518
|
);
|
|
2445
|
-
const handleSort = (0,
|
|
2519
|
+
const handleSort = (0, import_react12.useCallback)(
|
|
2446
2520
|
(columnId) => {
|
|
2447
2521
|
let newSortConfig;
|
|
2448
2522
|
if (sortConfig?.columnId === columnId) {
|
|
@@ -2461,13 +2535,13 @@ function useSpreadsheetFiltering({
|
|
|
2461
2535
|
},
|
|
2462
2536
|
[sortConfig, onSortChange, controlledSortConfig]
|
|
2463
2537
|
);
|
|
2464
|
-
const clearSort = (0,
|
|
2538
|
+
const clearSort = (0, import_react12.useCallback)(() => {
|
|
2465
2539
|
if (controlledSortConfig === void 0) {
|
|
2466
2540
|
setInternalSortConfig(null);
|
|
2467
2541
|
}
|
|
2468
2542
|
onSortChange?.(null);
|
|
2469
2543
|
}, [onSortChange, controlledSortConfig]);
|
|
2470
|
-
const setSortConfig = (0,
|
|
2544
|
+
const setSortConfig = (0, import_react12.useCallback)(
|
|
2471
2545
|
(config) => {
|
|
2472
2546
|
if (controlledSortConfig === void 0) {
|
|
2473
2547
|
setInternalSortConfig(config);
|
|
@@ -2476,7 +2550,7 @@ function useSpreadsheetFiltering({
|
|
|
2476
2550
|
},
|
|
2477
2551
|
[onSortChange, controlledSortConfig]
|
|
2478
2552
|
);
|
|
2479
|
-
const clearAllFilters = (0,
|
|
2553
|
+
const clearAllFilters = (0, import_react12.useCallback)(() => {
|
|
2480
2554
|
if (controlledFilters === void 0) {
|
|
2481
2555
|
setInternalFilters({});
|
|
2482
2556
|
}
|
|
@@ -2499,22 +2573,23 @@ function useSpreadsheetFiltering({
|
|
|
2499
2573
|
}
|
|
2500
2574
|
|
|
2501
2575
|
// src/hooks/useSpreadsheetComments.ts
|
|
2502
|
-
var
|
|
2576
|
+
var import_react13 = require("react");
|
|
2503
2577
|
function useSpreadsheetComments({
|
|
2504
2578
|
externalCellComments,
|
|
2505
|
-
onAddCellComment
|
|
2579
|
+
onAddCellComment,
|
|
2580
|
+
onToggleCommentResolved
|
|
2506
2581
|
} = {}) {
|
|
2507
|
-
const [cellCommentsInternal, setCellCommentsInternal] = (0,
|
|
2508
|
-
const [commentModalCell, setCommentModalCell] = (0,
|
|
2509
|
-
const [viewCommentsCell, setViewCommentsCell] = (0,
|
|
2582
|
+
const [cellCommentsInternal, setCellCommentsInternal] = (0, import_react13.useState)([]);
|
|
2583
|
+
const [commentModalCell, setCommentModalCell] = (0, import_react13.useState)(null);
|
|
2584
|
+
const [viewCommentsCell, setViewCommentsCell] = (0, import_react13.useState)(null);
|
|
2510
2585
|
const cellComments = externalCellComments || cellCommentsInternal;
|
|
2511
|
-
const getCellComments = (0,
|
|
2586
|
+
const getCellComments = (0, import_react13.useCallback)(
|
|
2512
2587
|
(rowId, columnId) => {
|
|
2513
2588
|
return cellComments.filter((c) => c.rowId === rowId && c.columnId === columnId);
|
|
2514
2589
|
},
|
|
2515
2590
|
[cellComments]
|
|
2516
2591
|
);
|
|
2517
|
-
const getCellUnresolvedCommentCount = (0,
|
|
2592
|
+
const getCellUnresolvedCommentCount = (0, import_react13.useCallback)(
|
|
2518
2593
|
(rowId, columnId) => {
|
|
2519
2594
|
return cellComments.filter(
|
|
2520
2595
|
(c) => c.rowId === rowId && c.columnId === columnId && !c.resolved
|
|
@@ -2522,13 +2597,13 @@ function useSpreadsheetComments({
|
|
|
2522
2597
|
},
|
|
2523
2598
|
[cellComments]
|
|
2524
2599
|
);
|
|
2525
|
-
const cellHasComments = (0,
|
|
2600
|
+
const cellHasComments = (0, import_react13.useCallback)(
|
|
2526
2601
|
(rowId, columnId) => {
|
|
2527
2602
|
return cellComments.some((c) => c.rowId === rowId && c.columnId === columnId);
|
|
2528
2603
|
},
|
|
2529
2604
|
[cellComments]
|
|
2530
2605
|
);
|
|
2531
|
-
const handleAddCellComment = (0,
|
|
2606
|
+
const handleAddCellComment = (0, import_react13.useCallback)(
|
|
2532
2607
|
(rowId, columnId, text) => {
|
|
2533
2608
|
if (!text.trim()) return;
|
|
2534
2609
|
if (onAddCellComment) {
|
|
@@ -2550,11 +2625,18 @@ function useSpreadsheetComments({
|
|
|
2550
2625
|
},
|
|
2551
2626
|
[onAddCellComment]
|
|
2552
2627
|
);
|
|
2553
|
-
const handleToggleCommentResolved = (0,
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2628
|
+
const handleToggleCommentResolved = (0, import_react13.useCallback)(
|
|
2629
|
+
(commentId) => {
|
|
2630
|
+
if (onToggleCommentResolved) {
|
|
2631
|
+
onToggleCommentResolved(commentId);
|
|
2632
|
+
} else {
|
|
2633
|
+
setCellCommentsInternal(
|
|
2634
|
+
(prev) => prev.map((c) => c.id === commentId ? { ...c, resolved: !c.resolved } : c)
|
|
2635
|
+
);
|
|
2636
|
+
}
|
|
2637
|
+
},
|
|
2638
|
+
[onToggleCommentResolved]
|
|
2639
|
+
);
|
|
2558
2640
|
return {
|
|
2559
2641
|
// Comments data
|
|
2560
2642
|
cellComments,
|
|
@@ -2575,20 +2657,20 @@ function useSpreadsheetComments({
|
|
|
2575
2657
|
}
|
|
2576
2658
|
|
|
2577
2659
|
// src/hooks/useSpreadsheetUndoRedo.ts
|
|
2578
|
-
var
|
|
2660
|
+
var import_react14 = require("react");
|
|
2579
2661
|
function useSpreadsheetUndoRedo({
|
|
2580
2662
|
enabled = true,
|
|
2581
2663
|
maxStackSize = 50,
|
|
2582
2664
|
autoSave = true,
|
|
2583
2665
|
onSave
|
|
2584
2666
|
}) {
|
|
2585
|
-
const [undoStack, setUndoStack] = (0,
|
|
2586
|
-
const [redoStack, setRedoStack] = (0,
|
|
2587
|
-
const [hasUnsavedChanges, setHasUnsavedChanges] = (0,
|
|
2588
|
-
const [saveStatus, setSaveStatus] = (0,
|
|
2589
|
-
const onSaveRef = (0,
|
|
2667
|
+
const [undoStack, setUndoStack] = (0, import_react14.useState)([]);
|
|
2668
|
+
const [redoStack, setRedoStack] = (0, import_react14.useState)([]);
|
|
2669
|
+
const [hasUnsavedChanges, setHasUnsavedChanges] = (0, import_react14.useState)(false);
|
|
2670
|
+
const [saveStatus, setSaveStatus] = (0, import_react14.useState)("saved");
|
|
2671
|
+
const onSaveRef = (0, import_react14.useRef)(onSave);
|
|
2590
2672
|
onSaveRef.current = onSave;
|
|
2591
|
-
const pushToUndoStack = (0,
|
|
2673
|
+
const pushToUndoStack = (0, import_react14.useCallback)(
|
|
2592
2674
|
(snapshot) => {
|
|
2593
2675
|
if (!enabled) return;
|
|
2594
2676
|
setUndoStack((prev) => {
|
|
@@ -2602,7 +2684,7 @@ function useSpreadsheetUndoRedo({
|
|
|
2602
2684
|
},
|
|
2603
2685
|
[enabled, maxStackSize]
|
|
2604
2686
|
);
|
|
2605
|
-
const handleUndo = (0,
|
|
2687
|
+
const handleUndo = (0, import_react14.useCallback)(() => {
|
|
2606
2688
|
if (!enabled || undoStack.length === 0) return null;
|
|
2607
2689
|
const previousSnapshot = undoStack[undoStack.length - 1];
|
|
2608
2690
|
setUndoStack((prev) => prev.slice(0, -1));
|
|
@@ -2615,7 +2697,7 @@ function useSpreadsheetUndoRedo({
|
|
|
2615
2697
|
});
|
|
2616
2698
|
return previousSnapshot;
|
|
2617
2699
|
}, [enabled, undoStack, maxStackSize]);
|
|
2618
|
-
const handleRedo = (0,
|
|
2700
|
+
const handleRedo = (0, import_react14.useCallback)(() => {
|
|
2619
2701
|
if (!enabled || redoStack.length === 0) return null;
|
|
2620
2702
|
const nextSnapshot = redoStack[redoStack.length - 1];
|
|
2621
2703
|
setRedoStack((prev) => prev.slice(0, -1));
|
|
@@ -2628,7 +2710,7 @@ function useSpreadsheetUndoRedo({
|
|
|
2628
2710
|
});
|
|
2629
2711
|
return nextSnapshot;
|
|
2630
2712
|
}, [enabled, redoStack, maxStackSize]);
|
|
2631
|
-
const handleSave = (0,
|
|
2713
|
+
const handleSave = (0, import_react14.useCallback)(async () => {
|
|
2632
2714
|
if (!hasUnsavedChanges && !autoSave) return;
|
|
2633
2715
|
setSaveStatus("saving");
|
|
2634
2716
|
try {
|
|
@@ -2641,7 +2723,7 @@ function useSpreadsheetUndoRedo({
|
|
|
2641
2723
|
setSaveStatus("error");
|
|
2642
2724
|
}
|
|
2643
2725
|
}, [hasUnsavedChanges, autoSave]);
|
|
2644
|
-
const markAsChanged = (0,
|
|
2726
|
+
const markAsChanged = (0, import_react14.useCallback)(() => {
|
|
2645
2727
|
setHasUnsavedChanges(true);
|
|
2646
2728
|
if (autoSave) {
|
|
2647
2729
|
setSaveStatus("saving");
|
|
@@ -2662,11 +2744,11 @@ function useSpreadsheetUndoRedo({
|
|
|
2662
2744
|
setSaveStatus("unsaved");
|
|
2663
2745
|
}
|
|
2664
2746
|
}, [autoSave]);
|
|
2665
|
-
const markAsSaved = (0,
|
|
2747
|
+
const markAsSaved = (0, import_react14.useCallback)(() => {
|
|
2666
2748
|
setHasUnsavedChanges(false);
|
|
2667
2749
|
setSaveStatus("saved");
|
|
2668
2750
|
}, []);
|
|
2669
|
-
const clearStacks = (0,
|
|
2751
|
+
const clearStacks = (0, import_react14.useCallback)(() => {
|
|
2670
2752
|
setUndoStack([]);
|
|
2671
2753
|
setRedoStack([]);
|
|
2672
2754
|
}, []);
|
|
@@ -2694,7 +2776,7 @@ function useSpreadsheetUndoRedo({
|
|
|
2694
2776
|
}
|
|
2695
2777
|
|
|
2696
2778
|
// src/hooks/useSpreadsheetKeyboardShortcuts.ts
|
|
2697
|
-
var
|
|
2779
|
+
var import_react15 = require("react");
|
|
2698
2780
|
function useSpreadsheetKeyboardShortcuts({
|
|
2699
2781
|
onUndo,
|
|
2700
2782
|
onRedo,
|
|
@@ -2709,10 +2791,10 @@ function useSpreadsheetKeyboardShortcuts({
|
|
|
2709
2791
|
customShortcuts = [],
|
|
2710
2792
|
enabled = true
|
|
2711
2793
|
} = {}) {
|
|
2712
|
-
const [showKeyboardShortcuts, setShowKeyboardShortcuts] = (0,
|
|
2794
|
+
const [showKeyboardShortcuts, setShowKeyboardShortcuts] = (0, import_react15.useState)(false);
|
|
2713
2795
|
const isMac = typeof navigator !== "undefined" && /Mac|iPhone|iPod|iPad/.test(navigator.platform);
|
|
2714
2796
|
const modifierKey = isMac ? "\u2318" : "Ctrl";
|
|
2715
|
-
(0,
|
|
2797
|
+
(0, import_react15.useEffect)(() => {
|
|
2716
2798
|
if (!enabled) return;
|
|
2717
2799
|
const handleKeyDown = (event) => {
|
|
2718
2800
|
if (event.key === "Escape") {
|
|
@@ -2853,7 +2935,7 @@ function useSpreadsheetKeyboardShortcuts({
|
|
|
2853
2935
|
}
|
|
2854
2936
|
|
|
2855
2937
|
// src/hooks/useSpreadsheetSelection.ts
|
|
2856
|
-
var
|
|
2938
|
+
var import_react16 = require("react");
|
|
2857
2939
|
function useSpreadsheetSelection({
|
|
2858
2940
|
data,
|
|
2859
2941
|
columns,
|
|
@@ -2861,34 +2943,34 @@ function useSpreadsheetSelection({
|
|
|
2861
2943
|
onCellRangeSelectionChange,
|
|
2862
2944
|
enableCellEditing = true
|
|
2863
2945
|
}) {
|
|
2864
|
-
const [focusedCell, setFocusedCell] = (0,
|
|
2865
|
-
const [editingCell, setEditingCell] = (0,
|
|
2866
|
-
const [selectedCellRange, setSelectedCellRangeState] = (0,
|
|
2867
|
-
const [isDragging, setIsDragging] = (0,
|
|
2868
|
-
const [clipboardData, setClipboardData] = (0,
|
|
2869
|
-
const anchorCell = (0,
|
|
2870
|
-
const rowIndexMap = (0,
|
|
2946
|
+
const [focusedCell, setFocusedCell] = (0, import_react16.useState)(null);
|
|
2947
|
+
const [editingCell, setEditingCell] = (0, import_react16.useState)(null);
|
|
2948
|
+
const [selectedCellRange, setSelectedCellRangeState] = (0, import_react16.useState)(null);
|
|
2949
|
+
const [isDragging, setIsDragging] = (0, import_react16.useState)(false);
|
|
2950
|
+
const [clipboardData, setClipboardData] = (0, import_react16.useState)(null);
|
|
2951
|
+
const anchorCell = (0, import_react16.useRef)(null);
|
|
2952
|
+
const rowIndexMap = (0, import_react16.useMemo)(() => {
|
|
2871
2953
|
const map = /* @__PURE__ */ new Map();
|
|
2872
2954
|
data.forEach((row, index) => {
|
|
2873
2955
|
map.set(getRowId(row), index);
|
|
2874
2956
|
});
|
|
2875
2957
|
return map;
|
|
2876
2958
|
}, [data, getRowId]);
|
|
2877
|
-
const columnIndexMap = (0,
|
|
2959
|
+
const columnIndexMap = (0, import_react16.useMemo)(() => {
|
|
2878
2960
|
const map = /* @__PURE__ */ new Map();
|
|
2879
2961
|
columns.forEach((col, index) => {
|
|
2880
2962
|
map.set(col.id, index);
|
|
2881
2963
|
});
|
|
2882
2964
|
return map;
|
|
2883
2965
|
}, [columns]);
|
|
2884
|
-
const setSelectedCellRange = (0,
|
|
2966
|
+
const setSelectedCellRange = (0, import_react16.useCallback)(
|
|
2885
2967
|
(range) => {
|
|
2886
2968
|
setSelectedCellRangeState(range);
|
|
2887
2969
|
onCellRangeSelectionChange?.(range);
|
|
2888
2970
|
},
|
|
2889
2971
|
[onCellRangeSelectionChange]
|
|
2890
2972
|
);
|
|
2891
|
-
const getNormalizedRange = (0,
|
|
2973
|
+
const getNormalizedRange = (0, import_react16.useCallback)(
|
|
2892
2974
|
(range) => {
|
|
2893
2975
|
if (!range) return null;
|
|
2894
2976
|
const startRowIdx = rowIndexMap.get(range.start.rowId);
|
|
@@ -2907,7 +2989,7 @@ function useSpreadsheetSelection({
|
|
|
2907
2989
|
},
|
|
2908
2990
|
[rowIndexMap, columnIndexMap]
|
|
2909
2991
|
);
|
|
2910
|
-
const isCellInSelection = (0,
|
|
2992
|
+
const isCellInSelection = (0, import_react16.useCallback)(
|
|
2911
2993
|
(rowId, columnId) => {
|
|
2912
2994
|
const normalizedRange = getNormalizedRange(selectedCellRange);
|
|
2913
2995
|
if (!normalizedRange) return false;
|
|
@@ -2918,7 +3000,7 @@ function useSpreadsheetSelection({
|
|
|
2918
3000
|
},
|
|
2919
3001
|
[selectedCellRange, rowIndexMap, columnIndexMap, getNormalizedRange]
|
|
2920
3002
|
);
|
|
2921
|
-
const getCellSelectionEdge = (0,
|
|
3003
|
+
const getCellSelectionEdge = (0, import_react16.useCallback)(
|
|
2922
3004
|
(rowId, columnId) => {
|
|
2923
3005
|
if (!isCellInSelection(rowId, columnId)) return void 0;
|
|
2924
3006
|
const normalizedRange = getNormalizedRange(selectedCellRange);
|
|
@@ -2935,7 +3017,7 @@ function useSpreadsheetSelection({
|
|
|
2935
3017
|
},
|
|
2936
3018
|
[isCellInSelection, selectedCellRange, rowIndexMap, columnIndexMap, getNormalizedRange]
|
|
2937
3019
|
);
|
|
2938
|
-
const getSelectedCells = (0,
|
|
3020
|
+
const getSelectedCells = (0, import_react16.useCallback)(() => {
|
|
2939
3021
|
const normalizedRange = getNormalizedRange(selectedCellRange);
|
|
2940
3022
|
if (!normalizedRange) {
|
|
2941
3023
|
return focusedCell ? [focusedCell] : [];
|
|
@@ -2953,7 +3035,7 @@ function useSpreadsheetSelection({
|
|
|
2953
3035
|
}
|
|
2954
3036
|
return cells;
|
|
2955
3037
|
}, [selectedCellRange, focusedCell, data, columns, getRowId, getNormalizedRange]);
|
|
2956
|
-
const getSelectedCellValues = (0,
|
|
3038
|
+
const getSelectedCellValues = (0, import_react16.useCallback)(() => {
|
|
2957
3039
|
const cells = getSelectedCells();
|
|
2958
3040
|
return cells.map((cell) => {
|
|
2959
3041
|
const row = data.find((r) => getRowId(r) === cell.rowId);
|
|
@@ -2962,7 +3044,7 @@ function useSpreadsheetSelection({
|
|
|
2962
3044
|
return { position: cell, value };
|
|
2963
3045
|
});
|
|
2964
3046
|
}, [getSelectedCells, data, columns, getRowId]);
|
|
2965
|
-
const handleCellClick = (0,
|
|
3047
|
+
const handleCellClick = (0, import_react16.useCallback)(
|
|
2966
3048
|
(rowId, columnId, event) => {
|
|
2967
3049
|
event.stopPropagation();
|
|
2968
3050
|
const newCell = { rowId, columnId };
|
|
@@ -2984,7 +3066,7 @@ function useSpreadsheetSelection({
|
|
|
2984
3066
|
},
|
|
2985
3067
|
[columns, enableCellEditing, setSelectedCellRange]
|
|
2986
3068
|
);
|
|
2987
|
-
const handleCellMouseDown = (0,
|
|
3069
|
+
const handleCellMouseDown = (0, import_react16.useCallback)(
|
|
2988
3070
|
(rowId, columnId, event) => {
|
|
2989
3071
|
if (event.button !== 0) return;
|
|
2990
3072
|
const newCell = { rowId, columnId };
|
|
@@ -3010,18 +3092,18 @@ function useSpreadsheetSelection({
|
|
|
3010
3092
|
},
|
|
3011
3093
|
[columns, enableCellEditing, setSelectedCellRange]
|
|
3012
3094
|
);
|
|
3013
|
-
const handleCellMouseEnter = (0,
|
|
3095
|
+
const handleCellMouseEnter = (0, import_react16.useCallback)((_rowId, _columnId) => {
|
|
3014
3096
|
}, []);
|
|
3015
|
-
const handleMouseUp = (0,
|
|
3097
|
+
const handleMouseUp = (0, import_react16.useCallback)(() => {
|
|
3016
3098
|
setIsDragging(false);
|
|
3017
3099
|
}, []);
|
|
3018
|
-
const clearSelection = (0,
|
|
3100
|
+
const clearSelection = (0, import_react16.useCallback)(() => {
|
|
3019
3101
|
setFocusedCell(null);
|
|
3020
3102
|
setEditingCell(null);
|
|
3021
3103
|
setSelectedCellRange(null);
|
|
3022
3104
|
anchorCell.current = null;
|
|
3023
3105
|
}, [setSelectedCellRange]);
|
|
3024
|
-
const navigateCell = (0,
|
|
3106
|
+
const navigateCell = (0, import_react16.useCallback)(
|
|
3025
3107
|
(direction, extendSelection = false) => {
|
|
3026
3108
|
const currentCell = focusedCell;
|
|
3027
3109
|
if (!currentCell) return;
|
|
@@ -3068,7 +3150,7 @@ function useSpreadsheetSelection({
|
|
|
3068
3150
|
},
|
|
3069
3151
|
[focusedCell, data, columns, getRowId, rowIndexMap, columnIndexMap, setSelectedCellRange]
|
|
3070
3152
|
);
|
|
3071
|
-
const handleTabNavigation = (0,
|
|
3153
|
+
const handleTabNavigation = (0, import_react16.useCallback)(
|
|
3072
3154
|
(shiftKey) => {
|
|
3073
3155
|
const currentCell = focusedCell;
|
|
3074
3156
|
if (!currentCell) return;
|
|
@@ -3109,17 +3191,17 @@ function useSpreadsheetSelection({
|
|
|
3109
3191
|
},
|
|
3110
3192
|
[focusedCell, data, columns, getRowId, rowIndexMap, columnIndexMap, setSelectedCellRange]
|
|
3111
3193
|
);
|
|
3112
|
-
const enterEditMode = (0,
|
|
3194
|
+
const enterEditMode = (0, import_react16.useCallback)(() => {
|
|
3113
3195
|
if (!focusedCell || !enableCellEditing) return;
|
|
3114
3196
|
const column = columns.find((c) => c.id === focusedCell.columnId);
|
|
3115
3197
|
if (column?.editable) {
|
|
3116
3198
|
setEditingCell(focusedCell);
|
|
3117
3199
|
}
|
|
3118
3200
|
}, [focusedCell, columns, enableCellEditing]);
|
|
3119
|
-
const exitEditMode = (0,
|
|
3201
|
+
const exitEditMode = (0, import_react16.useCallback)(() => {
|
|
3120
3202
|
setEditingCell(null);
|
|
3121
3203
|
}, []);
|
|
3122
|
-
const copySelectedCells = (0,
|
|
3204
|
+
const copySelectedCells = (0, import_react16.useCallback)(() => {
|
|
3123
3205
|
const normalizedRange = getNormalizedRange(selectedCellRange);
|
|
3124
3206
|
if (!normalizedRange && !focusedCell) return;
|
|
3125
3207
|
const startRowIdx = normalizedRange?.startRowIdx ?? rowIndexMap.get(focusedCell.rowId) ?? 0;
|
|
@@ -3168,14 +3250,14 @@ function useSpreadsheetSelection({
|
|
|
3168
3250
|
rowIndexMap,
|
|
3169
3251
|
columnIndexMap
|
|
3170
3252
|
]);
|
|
3171
|
-
const parseClipboardText = (0,
|
|
3253
|
+
const parseClipboardText = (0, import_react16.useCallback)((text) => {
|
|
3172
3254
|
const lines = text.split(/\r?\n/);
|
|
3173
3255
|
if (lines.length > 0 && lines[lines.length - 1] === "") {
|
|
3174
3256
|
lines.pop();
|
|
3175
3257
|
}
|
|
3176
3258
|
return lines.map((line) => line.split(" "));
|
|
3177
3259
|
}, []);
|
|
3178
|
-
const createEditsFromValues = (0,
|
|
3260
|
+
const createEditsFromValues = (0, import_react16.useCallback)(
|
|
3179
3261
|
(values) => {
|
|
3180
3262
|
if (!focusedCell) return [];
|
|
3181
3263
|
const edits = [];
|
|
@@ -3235,11 +3317,11 @@ function useSpreadsheetSelection({
|
|
|
3235
3317
|
getNormalizedRange
|
|
3236
3318
|
]
|
|
3237
3319
|
);
|
|
3238
|
-
const pasteClipboard = (0,
|
|
3320
|
+
const pasteClipboard = (0, import_react16.useCallback)(() => {
|
|
3239
3321
|
if (!clipboardData?.values) return [];
|
|
3240
3322
|
return createEditsFromValues(clipboardData.values);
|
|
3241
3323
|
}, [clipboardData, createEditsFromValues]);
|
|
3242
|
-
const pasteFromSystemClipboard = (0,
|
|
3324
|
+
const pasteFromSystemClipboard = (0, import_react16.useCallback)(async () => {
|
|
3243
3325
|
if (!focusedCell) return [];
|
|
3244
3326
|
try {
|
|
3245
3327
|
const text = await navigator.clipboard.readText();
|
|
@@ -3281,7 +3363,7 @@ function useSpreadsheetSelection({
|
|
|
3281
3363
|
}
|
|
3282
3364
|
|
|
3283
3365
|
// src/components/Spreadsheet.tsx
|
|
3284
|
-
var
|
|
3366
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
3285
3367
|
function Spreadsheet({
|
|
3286
3368
|
data,
|
|
3287
3369
|
columns,
|
|
@@ -3293,10 +3375,11 @@ function Spreadsheet({
|
|
|
3293
3375
|
onFilterChange,
|
|
3294
3376
|
onRowClick,
|
|
3295
3377
|
onRowDoubleClick,
|
|
3296
|
-
onRowClone,
|
|
3297
|
-
onRowDelete,
|
|
3298
3378
|
onAddCellComment,
|
|
3379
|
+
onToggleCommentResolved,
|
|
3299
3380
|
onRowHighlight,
|
|
3381
|
+
onColumnHighlight,
|
|
3382
|
+
onCellHighlight,
|
|
3300
3383
|
showToolbar = true,
|
|
3301
3384
|
showPagination = true,
|
|
3302
3385
|
enableRowSelection = true,
|
|
@@ -3312,8 +3395,11 @@ function Spreadsheet({
|
|
|
3312
3395
|
className,
|
|
3313
3396
|
emptyMessage = "No data available",
|
|
3314
3397
|
rowHighlights: externalRowHighlights,
|
|
3398
|
+
columnHighlights: externalColumnHighlights,
|
|
3399
|
+
cellHighlights: externalCellHighlights,
|
|
3315
3400
|
cellComments: externalCellComments,
|
|
3316
3401
|
rowActions,
|
|
3402
|
+
rowContextMenuItems,
|
|
3317
3403
|
toolbarMenuItems,
|
|
3318
3404
|
// Server-side mode props
|
|
3319
3405
|
serverSide = false,
|
|
@@ -3324,7 +3410,7 @@ function Spreadsheet({
|
|
|
3324
3410
|
onPageChange,
|
|
3325
3411
|
filters: controlledFilters
|
|
3326
3412
|
}) {
|
|
3327
|
-
const [spreadsheetSettings, setSpreadsheetSettings] = (0,
|
|
3413
|
+
const [spreadsheetSettings, setSpreadsheetSettings] = (0, import_react17.useState)({
|
|
3328
3414
|
defaultPinnedColumns: initialSettings?.defaultPinnedColumns ?? [],
|
|
3329
3415
|
defaultSort: initialSettings?.defaultSort ?? null,
|
|
3330
3416
|
defaultPageSize: initialSettings?.defaultPageSize ?? 25,
|
|
@@ -3368,7 +3454,11 @@ function Spreadsheet({
|
|
|
3368
3454
|
setHighlightPickerCell
|
|
3369
3455
|
} = useSpreadsheetHighlighting({
|
|
3370
3456
|
externalRowHighlights,
|
|
3371
|
-
onRowHighlight
|
|
3457
|
+
onRowHighlight,
|
|
3458
|
+
externalColumnHighlights,
|
|
3459
|
+
onColumnHighlight,
|
|
3460
|
+
externalCellHighlights,
|
|
3461
|
+
onCellHighlight
|
|
3372
3462
|
});
|
|
3373
3463
|
const {
|
|
3374
3464
|
pinnedColumns,
|
|
@@ -3398,9 +3488,10 @@ function Spreadsheet({
|
|
|
3398
3488
|
handleToggleCommentResolved
|
|
3399
3489
|
} = useSpreadsheetComments({
|
|
3400
3490
|
externalCellComments,
|
|
3401
|
-
onAddCellComment
|
|
3491
|
+
onAddCellComment,
|
|
3492
|
+
onToggleCommentResolved
|
|
3402
3493
|
});
|
|
3403
|
-
const [showSettingsModal, setShowSettingsModal] = (0,
|
|
3494
|
+
const [showSettingsModal, setShowSettingsModal] = (0, import_react17.useState)(false);
|
|
3404
3495
|
const {
|
|
3405
3496
|
canUndo,
|
|
3406
3497
|
canRedo,
|
|
@@ -3418,15 +3509,15 @@ function Spreadsheet({
|
|
|
3418
3509
|
autoSave: spreadsheetSettings.autoSave,
|
|
3419
3510
|
onSave
|
|
3420
3511
|
});
|
|
3421
|
-
const [selectedRows, setSelectedRows] = (0,
|
|
3422
|
-
const [lastSelectedRow, setLastSelectedRow] = (0,
|
|
3423
|
-
const [hoveredRow, setHoveredRow] = (0,
|
|
3424
|
-
const [internalCurrentPage, setInternalCurrentPage] = (0,
|
|
3425
|
-
const [internalPageSize, setInternalPageSize] = (0,
|
|
3426
|
-
const [zoom, setZoom] = (0,
|
|
3512
|
+
const [selectedRows, setSelectedRows] = (0, import_react17.useState)(/* @__PURE__ */ new Set());
|
|
3513
|
+
const [lastSelectedRow, setLastSelectedRow] = (0, import_react17.useState)(null);
|
|
3514
|
+
const [hoveredRow, setHoveredRow] = (0, import_react17.useState)(null);
|
|
3515
|
+
const [internalCurrentPage, setInternalCurrentPage] = (0, import_react17.useState)(1);
|
|
3516
|
+
const [internalPageSize, setInternalPageSize] = (0, import_react17.useState)(spreadsheetSettings.defaultPageSize);
|
|
3517
|
+
const [zoom, setZoom] = (0, import_react17.useState)(spreadsheetSettings.defaultZoom);
|
|
3427
3518
|
const currentPage = controlledCurrentPage ?? internalCurrentPage;
|
|
3428
3519
|
const pageSize = controlledPageSize ?? internalPageSize;
|
|
3429
|
-
const handlePageChange = (0,
|
|
3520
|
+
const handlePageChange = (0, import_react17.useCallback)(
|
|
3430
3521
|
(newPage) => {
|
|
3431
3522
|
if (controlledCurrentPage === void 0) {
|
|
3432
3523
|
setInternalCurrentPage(newPage);
|
|
@@ -3435,7 +3526,7 @@ function Spreadsheet({
|
|
|
3435
3526
|
},
|
|
3436
3527
|
[controlledCurrentPage, onPageChange, pageSize]
|
|
3437
3528
|
);
|
|
3438
|
-
const handlePageSizeChange = (0,
|
|
3529
|
+
const handlePageSizeChange = (0, import_react17.useCallback)(
|
|
3439
3530
|
(newPageSize) => {
|
|
3440
3531
|
if (controlledPageSize === void 0) {
|
|
3441
3532
|
setInternalPageSize(newPageSize);
|
|
@@ -3447,13 +3538,13 @@ function Spreadsheet({
|
|
|
3447
3538
|
},
|
|
3448
3539
|
[controlledPageSize, controlledCurrentPage, onPageChange]
|
|
3449
3540
|
);
|
|
3450
|
-
(0,
|
|
3541
|
+
(0, import_react17.useEffect)(() => {
|
|
3451
3542
|
setSpreadsheetSettings((prev) => ({
|
|
3452
3543
|
...prev,
|
|
3453
3544
|
defaultSort: sortConfig
|
|
3454
3545
|
}));
|
|
3455
3546
|
}, [sortConfig]);
|
|
3456
|
-
(0,
|
|
3547
|
+
(0, import_react17.useEffect)(() => {
|
|
3457
3548
|
const pinnedColumnIds = Array.from(pinnedColumns.keys());
|
|
3458
3549
|
setSpreadsheetSettings((prev) => {
|
|
3459
3550
|
const prevIds = prev.defaultPinnedColumns;
|
|
@@ -3466,15 +3557,15 @@ function Spreadsheet({
|
|
|
3466
3557
|
};
|
|
3467
3558
|
});
|
|
3468
3559
|
}, [pinnedColumns]);
|
|
3469
|
-
const isInitialMount = (0,
|
|
3470
|
-
(0,
|
|
3560
|
+
const isInitialMount = (0, import_react17.useRef)(true);
|
|
3561
|
+
(0, import_react17.useEffect)(() => {
|
|
3471
3562
|
if (isInitialMount.current) {
|
|
3472
3563
|
isInitialMount.current = false;
|
|
3473
3564
|
return;
|
|
3474
3565
|
}
|
|
3475
3566
|
onSettingsChange?.(spreadsheetSettings);
|
|
3476
3567
|
}, [spreadsheetSettings, onSettingsChange]);
|
|
3477
|
-
const applyUndo = (0,
|
|
3568
|
+
const applyUndo = (0, import_react17.useCallback)(() => {
|
|
3478
3569
|
const entry = popUndoEntry();
|
|
3479
3570
|
if (!entry || !onCellsEdit) return;
|
|
3480
3571
|
if (entry.type === "cell-edit") {
|
|
@@ -3492,7 +3583,7 @@ function Spreadsheet({
|
|
|
3492
3583
|
}
|
|
3493
3584
|
markAsChanged();
|
|
3494
3585
|
}, [popUndoEntry, onCellsEdit, markAsChanged]);
|
|
3495
|
-
const applyRedo = (0,
|
|
3586
|
+
const applyRedo = (0, import_react17.useCallback)(() => {
|
|
3496
3587
|
const entry = popRedoEntry();
|
|
3497
3588
|
if (!entry || !onCellsEdit) return;
|
|
3498
3589
|
if (entry.type === "cell-edit") {
|
|
@@ -3508,7 +3599,7 @@ function Spreadsheet({
|
|
|
3508
3599
|
}
|
|
3509
3600
|
markAsChanged();
|
|
3510
3601
|
}, [popRedoEntry, onCellsEdit, markAsChanged]);
|
|
3511
|
-
const paginatedData = (0,
|
|
3602
|
+
const paginatedData = (0, import_react17.useMemo)(() => {
|
|
3512
3603
|
if (serverSide) {
|
|
3513
3604
|
return filteredData;
|
|
3514
3605
|
}
|
|
@@ -3534,7 +3625,7 @@ function Spreadsheet({
|
|
|
3534
3625
|
getRowId,
|
|
3535
3626
|
enableCellEditing
|
|
3536
3627
|
});
|
|
3537
|
-
const handleEscapeCallback = (0,
|
|
3628
|
+
const handleEscapeCallback = (0, import_react17.useCallback)(() => {
|
|
3538
3629
|
if (commentModalCell !== null) {
|
|
3539
3630
|
setCommentModalCell(null);
|
|
3540
3631
|
} else if (viewCommentsCell !== null) {
|
|
@@ -3563,7 +3654,7 @@ function Spreadsheet({
|
|
|
3563
3654
|
setHighlightPickerCell,
|
|
3564
3655
|
clearSelection
|
|
3565
3656
|
]);
|
|
3566
|
-
const handleNavigate = (0,
|
|
3657
|
+
const handleNavigate = (0, import_react17.useCallback)(
|
|
3567
3658
|
(direction, event) => {
|
|
3568
3659
|
const extendSelection = event?.shiftKey ?? false;
|
|
3569
3660
|
navigateCell(direction, extendSelection);
|
|
@@ -3584,10 +3675,10 @@ function Spreadsheet({
|
|
|
3584
3675
|
},
|
|
3585
3676
|
[navigateCell, focusedCell]
|
|
3586
3677
|
);
|
|
3587
|
-
const handleEnterEditMode = (0,
|
|
3678
|
+
const handleEnterEditMode = (0, import_react17.useCallback)(() => {
|
|
3588
3679
|
enterEditMode();
|
|
3589
3680
|
}, [enterEditMode]);
|
|
3590
|
-
const handlePaste = (0,
|
|
3681
|
+
const handlePaste = (0, import_react17.useCallback)(async () => {
|
|
3591
3682
|
const edits = await pasteFromSystemClipboard();
|
|
3592
3683
|
if (edits.length > 0 && onCellsEdit) {
|
|
3593
3684
|
if (enableUndoRedo) {
|
|
@@ -3633,15 +3724,15 @@ function Spreadsheet({
|
|
|
3633
3724
|
});
|
|
3634
3725
|
const effectiveCompactMode = spreadsheetSettings.compactView ?? false;
|
|
3635
3726
|
const rowIndexHighlightColor = getColumnHighlight(ROW_INDEX_COLUMN_ID);
|
|
3636
|
-
const tableRef = (0,
|
|
3727
|
+
const tableRef = (0, import_react17.useRef)(null);
|
|
3637
3728
|
const effectiveTotalItems = serverSide ? totalItems ?? data.length : filteredData.length;
|
|
3638
3729
|
const totalPages = Math.max(1, Math.ceil(effectiveTotalItems / pageSize));
|
|
3639
|
-
(0,
|
|
3730
|
+
(0, import_react17.useEffect)(() => {
|
|
3640
3731
|
if (!serverSide && currentPage > totalPages) {
|
|
3641
3732
|
setInternalCurrentPage(1);
|
|
3642
3733
|
}
|
|
3643
3734
|
}, [totalPages, currentPage, serverSide]);
|
|
3644
|
-
const handleRowSelect = (0,
|
|
3735
|
+
const handleRowSelect = (0, import_react17.useCallback)(
|
|
3645
3736
|
(rowId, event) => {
|
|
3646
3737
|
if (!enableRowSelection) return;
|
|
3647
3738
|
event.stopPropagation();
|
|
@@ -3690,14 +3781,14 @@ function Spreadsheet({
|
|
|
3690
3781
|
onSelectionChange
|
|
3691
3782
|
]
|
|
3692
3783
|
);
|
|
3693
|
-
const handleCellClick = (0,
|
|
3784
|
+
const handleCellClick = (0, import_react17.useCallback)(
|
|
3694
3785
|
(rowId, columnId, event) => {
|
|
3695
3786
|
event.stopPropagation();
|
|
3696
3787
|
handleCellMouseDown(rowId, columnId, event);
|
|
3697
3788
|
},
|
|
3698
3789
|
[handleCellMouseDown]
|
|
3699
3790
|
);
|
|
3700
|
-
const handleCellChange = (0,
|
|
3791
|
+
const handleCellChange = (0, import_react17.useCallback)(
|
|
3701
3792
|
(rowId, columnId, newValue) => {
|
|
3702
3793
|
const row = data.find((r) => getRowId(r) === rowId);
|
|
3703
3794
|
const previousValue = row ? row[columnId] : void 0;
|
|
@@ -3720,7 +3811,7 @@ function Spreadsheet({
|
|
|
3720
3811
|
},
|
|
3721
3812
|
[data, getRowId, enableUndoRedo, onCellsEdit, pushToUndoStack, markAsChanged]
|
|
3722
3813
|
);
|
|
3723
|
-
const handleConfirmEdit = (0,
|
|
3814
|
+
const handleConfirmEdit = (0, import_react17.useCallback)(
|
|
3724
3815
|
(finalValue) => {
|
|
3725
3816
|
if (editingCell && finalValue !== void 0) {
|
|
3726
3817
|
handleCellChange(editingCell.rowId, editingCell.columnId, finalValue);
|
|
@@ -3729,26 +3820,14 @@ function Spreadsheet({
|
|
|
3729
3820
|
},
|
|
3730
3821
|
[editingCell, handleCellChange, setEditingCell]
|
|
3731
3822
|
);
|
|
3732
|
-
const handleCancelEdit = (0,
|
|
3823
|
+
const handleCancelEdit = (0, import_react17.useCallback)(() => {
|
|
3733
3824
|
setEditingCell(null);
|
|
3734
3825
|
}, [setEditingCell]);
|
|
3735
|
-
const
|
|
3736
|
-
(row, rowId) => {
|
|
3737
|
-
onRowClone?.(row, rowId);
|
|
3738
|
-
},
|
|
3739
|
-
[onRowClone]
|
|
3740
|
-
);
|
|
3741
|
-
const handleRowDelete = (0, import_react16.useCallback)(
|
|
3742
|
-
(row, rowId) => {
|
|
3743
|
-
onRowDelete?.(row, rowId);
|
|
3744
|
-
},
|
|
3745
|
-
[onRowDelete]
|
|
3746
|
-
);
|
|
3747
|
-
const handleRowIndexHighlightClick = (0, import_react16.useCallback)(() => {
|
|
3826
|
+
const handleRowIndexHighlightClick = (0, import_react17.useCallback)(() => {
|
|
3748
3827
|
setHighlightPickerColumn(ROW_INDEX_COLUMN_ID);
|
|
3749
3828
|
}, [setHighlightPickerColumn]);
|
|
3750
|
-
return /* @__PURE__ */ (0,
|
|
3751
|
-
showToolbar && /* @__PURE__ */ (0,
|
|
3829
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: cn("flex flex-col h-full bg-white", className), children: [
|
|
3830
|
+
showToolbar && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3752
3831
|
SpreadsheetToolbar,
|
|
3753
3832
|
{
|
|
3754
3833
|
zoom,
|
|
@@ -3778,7 +3857,7 @@ function Spreadsheet({
|
|
|
3778
3857
|
menuItems: toolbarMenuItems
|
|
3779
3858
|
}
|
|
3780
3859
|
),
|
|
3781
|
-
/* @__PURE__ */ (0,
|
|
3860
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { ref: tableRef, className: "flex-1 overflow-auto border border-gray-200 rounded", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3782
3861
|
"div",
|
|
3783
3862
|
{
|
|
3784
3863
|
style: {
|
|
@@ -3786,10 +3865,10 @@ function Spreadsheet({
|
|
|
3786
3865
|
transformOrigin: "top left",
|
|
3787
3866
|
width: `${100 / (zoom / 100)}%`
|
|
3788
3867
|
},
|
|
3789
|
-
children: /* @__PURE__ */ (0,
|
|
3790
|
-
/* @__PURE__ */ (0,
|
|
3791
|
-
columnGroups && /* @__PURE__ */ (0,
|
|
3792
|
-
/* @__PURE__ */ (0,
|
|
3868
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("table", { className: "w-full border-separate border-spacing-0 text-xs select-none", children: [
|
|
3869
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("thead", { children: [
|
|
3870
|
+
columnGroups && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("tr", { children: [
|
|
3871
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3793
3872
|
RowIndexColumnHeader,
|
|
3794
3873
|
{
|
|
3795
3874
|
enableHighlighting,
|
|
@@ -3811,7 +3890,7 @@ function Spreadsheet({
|
|
|
3811
3890
|
1,
|
|
3812
3891
|
visibleGroupColumns.length + (isCollapsed ? 1 : 0)
|
|
3813
3892
|
);
|
|
3814
|
-
return /* @__PURE__ */ (0,
|
|
3893
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3815
3894
|
"th",
|
|
3816
3895
|
{
|
|
3817
3896
|
colSpan,
|
|
@@ -3823,17 +3902,17 @@ function Spreadsheet({
|
|
|
3823
3902
|
backgroundColor: group.headerColor || "rgb(243 244 246)"
|
|
3824
3903
|
},
|
|
3825
3904
|
onClick: () => group.collapsible && handleToggleGroupCollapse(group.id),
|
|
3826
|
-
children: /* @__PURE__ */ (0,
|
|
3827
|
-
group.collapsible && (isCollapsed ? /* @__PURE__ */ (0,
|
|
3828
|
-
/* @__PURE__ */ (0,
|
|
3905
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center justify-center gap-1", children: [
|
|
3906
|
+
group.collapsible && (isCollapsed ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(HiChevronRight, { className: "h-3 w-3" }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(HiChevronDown, { className: "h-3 w-3" })),
|
|
3907
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: group.label })
|
|
3829
3908
|
] })
|
|
3830
3909
|
},
|
|
3831
3910
|
group.id
|
|
3832
3911
|
);
|
|
3833
3912
|
})
|
|
3834
3913
|
] }),
|
|
3835
|
-
/* @__PURE__ */ (0,
|
|
3836
|
-
!columnGroups && /* @__PURE__ */ (0,
|
|
3914
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("tr", { children: [
|
|
3915
|
+
!columnGroups && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3837
3916
|
RowIndexColumnHeader,
|
|
3838
3917
|
{
|
|
3839
3918
|
enableHighlighting,
|
|
@@ -3847,7 +3926,7 @@ function Spreadsheet({
|
|
|
3847
3926
|
),
|
|
3848
3927
|
visibleColumns.map((column) => {
|
|
3849
3928
|
const isPinnedLeft = isColumnPinned(column.id) && getColumnPinSide(column.id) === "left";
|
|
3850
|
-
return /* @__PURE__ */ (0,
|
|
3929
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3851
3930
|
SpreadsheetHeader,
|
|
3852
3931
|
{
|
|
3853
3932
|
column,
|
|
@@ -3864,7 +3943,7 @@ function Spreadsheet({
|
|
|
3864
3943
|
),
|
|
3865
3944
|
onPinClick: () => handleTogglePin(column.id),
|
|
3866
3945
|
onHighlightClick: enableHighlighting ? () => setHighlightPickerColumn(column.id) : void 0,
|
|
3867
|
-
children: activeFilterColumn === column.id && /* @__PURE__ */ (0,
|
|
3946
|
+
children: activeFilterColumn === column.id && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3868
3947
|
SpreadsheetFilterDropdown,
|
|
3869
3948
|
{
|
|
3870
3949
|
column,
|
|
@@ -3879,17 +3958,17 @@ function Spreadsheet({
|
|
|
3879
3958
|
})
|
|
3880
3959
|
] })
|
|
3881
3960
|
] }),
|
|
3882
|
-
/* @__PURE__ */ (0,
|
|
3961
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tbody", { children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3883
3962
|
"td",
|
|
3884
3963
|
{
|
|
3885
3964
|
colSpan: visibleColumns.length + 1,
|
|
3886
3965
|
className: "text-center py-8 text-gray-500",
|
|
3887
|
-
children: /* @__PURE__ */ (0,
|
|
3888
|
-
/* @__PURE__ */ (0,
|
|
3966
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center justify-center gap-2", children: [
|
|
3967
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w-4 h-4 border-2 border-blue-600 border-t-transparent rounded-full animate-spin" }),
|
|
3889
3968
|
"Loading..."
|
|
3890
3969
|
] })
|
|
3891
3970
|
}
|
|
3892
|
-
) }) : paginatedData.length === 0 ? /* @__PURE__ */ (0,
|
|
3971
|
+
) }) : paginatedData.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3893
3972
|
"td",
|
|
3894
3973
|
{
|
|
3895
3974
|
colSpan: visibleColumns.length + 1,
|
|
@@ -3902,7 +3981,7 @@ function Spreadsheet({
|
|
|
3902
3981
|
const isRowHovered = hoveredRow === rowId;
|
|
3903
3982
|
const rowHighlight = getRowHighlight(rowId);
|
|
3904
3983
|
const displayIndex = rowIndex + 1 + (currentPage - 1) * pageSize;
|
|
3905
|
-
return /* @__PURE__ */ (0,
|
|
3984
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
3906
3985
|
"tr",
|
|
3907
3986
|
{
|
|
3908
3987
|
onMouseEnter: () => setHoveredRow(rowId),
|
|
@@ -3912,7 +3991,7 @@ function Spreadsheet({
|
|
|
3912
3991
|
},
|
|
3913
3992
|
onDoubleClick: () => onRowDoubleClick?.(row, rowIndex),
|
|
3914
3993
|
children: [
|
|
3915
|
-
/* @__PURE__ */ (0,
|
|
3994
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3916
3995
|
"td",
|
|
3917
3996
|
{
|
|
3918
3997
|
onClick: (e) => handleRowSelect(rowId, e),
|
|
@@ -3933,36 +4012,19 @@ function Spreadsheet({
|
|
|
3933
4012
|
left: 0
|
|
3934
4013
|
}
|
|
3935
4014
|
},
|
|
3936
|
-
children: /* @__PURE__ */ (0,
|
|
3937
|
-
/* @__PURE__ */ (0,
|
|
3938
|
-
/* @__PURE__ */ (0,
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
{
|
|
3942
|
-
type: "button",
|
|
3943
|
-
onClick: (e) => {
|
|
3944
|
-
e.stopPropagation();
|
|
3945
|
-
handleRowClone(row, rowId);
|
|
3946
|
-
},
|
|
3947
|
-
className: "opacity-0 group-hover:opacity-100 transition-opacity p-0.5 bg-gray-100 hover:bg-gray-200 rounded",
|
|
3948
|
-
title: "Duplicate row",
|
|
3949
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(HiDuplicate, { className: "h-2.5 w-2.5 text-gray-500" })
|
|
3950
|
-
}
|
|
3951
|
-
),
|
|
3952
|
-
onRowDelete && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3953
|
-
"button",
|
|
4015
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "relative flex items-center justify-center w-full h-full", children: [
|
|
4016
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: displayIndex }),
|
|
4017
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "absolute inset-0 flex items-center justify-evenly", children: [
|
|
4018
|
+
rowContextMenuItems && rowContextMenuItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4019
|
+
RowContextMenu,
|
|
3954
4020
|
{
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
},
|
|
3960
|
-
className: "opacity-0 group-hover:opacity-100 transition-opacity p-0.5 bg-gray-100 hover:bg-red-100 rounded",
|
|
3961
|
-
title: "Delete row",
|
|
3962
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(HiTrash, { className: "h-2.5 w-2.5 text-gray-500 hover:text-red-500" })
|
|
4021
|
+
row,
|
|
4022
|
+
rowId,
|
|
4023
|
+
items: rowContextMenuItems,
|
|
4024
|
+
compactMode: effectiveCompactMode
|
|
3963
4025
|
}
|
|
3964
4026
|
),
|
|
3965
|
-
enableHighlighting && /* @__PURE__ */ (0,
|
|
4027
|
+
enableHighlighting && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3966
4028
|
"button",
|
|
3967
4029
|
{
|
|
3968
4030
|
type: "button",
|
|
@@ -3972,7 +4034,7 @@ function Spreadsheet({
|
|
|
3972
4034
|
},
|
|
3973
4035
|
className: "opacity-0 group-hover:opacity-100 transition-opacity p-0.5 bg-gray-100 hover:bg-gray-200 rounded",
|
|
3974
4036
|
title: "Highlight row",
|
|
3975
|
-
children: /* @__PURE__ */ (0,
|
|
4037
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3976
4038
|
AiFillHighlight,
|
|
3977
4039
|
{
|
|
3978
4040
|
className: cn(
|
|
@@ -3986,7 +4048,7 @@ function Spreadsheet({
|
|
|
3986
4048
|
enableComments && (cellHasComments(
|
|
3987
4049
|
rowId,
|
|
3988
4050
|
ROW_INDEX_COLUMN_ID
|
|
3989
|
-
) ? /* @__PURE__ */ (0,
|
|
4051
|
+
) ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
3990
4052
|
"button",
|
|
3991
4053
|
{
|
|
3992
4054
|
type: "button",
|
|
@@ -4000,11 +4062,11 @@ function Spreadsheet({
|
|
|
4000
4062
|
className: "p-0.5 bg-amber-100 hover:bg-amber-200 rounded transition-colors flex items-center gap-0.5",
|
|
4001
4063
|
title: `${getCellUnresolvedCommentCount(rowId, ROW_INDEX_COLUMN_ID)} comment(s) - click to view`,
|
|
4002
4064
|
children: [
|
|
4003
|
-
/* @__PURE__ */ (0,
|
|
4065
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(FaComment, { className: "h-2.5 w-2.5 text-amber-500" }),
|
|
4004
4066
|
getCellUnresolvedCommentCount(
|
|
4005
4067
|
rowId,
|
|
4006
4068
|
ROW_INDEX_COLUMN_ID
|
|
4007
|
-
) > 0 && /* @__PURE__ */ (0,
|
|
4069
|
+
) > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-[9px] font-medium text-amber-600", children: getCellUnresolvedCommentCount(
|
|
4008
4070
|
rowId,
|
|
4009
4071
|
ROW_INDEX_COLUMN_ID
|
|
4010
4072
|
) > 99 ? "99+" : getCellUnresolvedCommentCount(
|
|
@@ -4013,7 +4075,7 @@ function Spreadsheet({
|
|
|
4013
4075
|
) })
|
|
4014
4076
|
]
|
|
4015
4077
|
}
|
|
4016
|
-
) : /* @__PURE__ */ (0,
|
|
4078
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4017
4079
|
"button",
|
|
4018
4080
|
{
|
|
4019
4081
|
type: "button",
|
|
@@ -4026,13 +4088,13 @@ function Spreadsheet({
|
|
|
4026
4088
|
},
|
|
4027
4089
|
className: "opacity-0 group-hover:opacity-100 transition-opacity p-0.5 bg-gray-100 hover:bg-gray-200 rounded",
|
|
4028
4090
|
title: "Add comment",
|
|
4029
|
-
children: /* @__PURE__ */ (0,
|
|
4091
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(FaRegComment, { className: "h-2.5 w-2.5 text-gray-500" })
|
|
4030
4092
|
}
|
|
4031
4093
|
)),
|
|
4032
4094
|
rowActions?.map((action) => {
|
|
4033
4095
|
if (action.visible && !action.visible(row))
|
|
4034
4096
|
return null;
|
|
4035
|
-
return /* @__PURE__ */ (0,
|
|
4097
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4036
4098
|
"button",
|
|
4037
4099
|
{
|
|
4038
4100
|
type: "button",
|
|
@@ -4069,7 +4131,7 @@ function Spreadsheet({
|
|
|
4069
4131
|
const cellOrRowOrColumnHighlight = getCellHighlight(rowId, column.id) || rowHighlight?.color || getColumnHighlight(column.id);
|
|
4070
4132
|
const isColPinned = isColumnPinned(column.id);
|
|
4071
4133
|
const colPinSide = getColumnPinSide(column.id);
|
|
4072
|
-
return /* @__PURE__ */ (0,
|
|
4134
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4073
4135
|
MemoizedSpreadsheetCell,
|
|
4074
4136
|
{
|
|
4075
4137
|
value,
|
|
@@ -4126,8 +4188,8 @@ function Spreadsheet({
|
|
|
4126
4188
|
] })
|
|
4127
4189
|
}
|
|
4128
4190
|
) }),
|
|
4129
|
-
showPagination && effectiveTotalItems > 0 && /* @__PURE__ */ (0,
|
|
4130
|
-
|
|
4191
|
+
showPagination && effectiveTotalItems > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4192
|
+
import_design_system2.Pagination,
|
|
4131
4193
|
{
|
|
4132
4194
|
currentPage,
|
|
4133
4195
|
totalPages,
|
|
@@ -4141,7 +4203,7 @@ function Spreadsheet({
|
|
|
4141
4203
|
onPageSizeChange: handlePageSizeChange
|
|
4142
4204
|
}
|
|
4143
4205
|
),
|
|
4144
|
-
/* @__PURE__ */ (0,
|
|
4206
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4145
4207
|
AddCommentModal,
|
|
4146
4208
|
{
|
|
4147
4209
|
isOpen: commentModalCell !== null,
|
|
@@ -4152,7 +4214,7 @@ function Spreadsheet({
|
|
|
4152
4214
|
}
|
|
4153
4215
|
}
|
|
4154
4216
|
),
|
|
4155
|
-
/* @__PURE__ */ (0,
|
|
4217
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4156
4218
|
ViewCommentsModal,
|
|
4157
4219
|
{
|
|
4158
4220
|
isOpen: viewCommentsCell !== null,
|
|
@@ -4167,7 +4229,7 @@ function Spreadsheet({
|
|
|
4167
4229
|
onClose: () => setViewCommentsCell(null)
|
|
4168
4230
|
}
|
|
4169
4231
|
),
|
|
4170
|
-
highlightPickerRow !== null && /* @__PURE__ */ (0,
|
|
4232
|
+
highlightPickerRow !== null && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4171
4233
|
ColorPickerPopover,
|
|
4172
4234
|
{
|
|
4173
4235
|
title: "Highlight Row",
|
|
@@ -4176,7 +4238,7 @@ function Spreadsheet({
|
|
|
4176
4238
|
onClose: () => setHighlightPickerRow(null)
|
|
4177
4239
|
}
|
|
4178
4240
|
),
|
|
4179
|
-
highlightPickerColumn !== null && /* @__PURE__ */ (0,
|
|
4241
|
+
highlightPickerColumn !== null && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4180
4242
|
ColorPickerPopover,
|
|
4181
4243
|
{
|
|
4182
4244
|
title: highlightPickerColumn === ROW_INDEX_COLUMN_ID ? "Highlight Row Index Column" : `Highlight Column: ${columns.find((c) => c.id === highlightPickerColumn)?.label || ""}`,
|
|
@@ -4185,7 +4247,7 @@ function Spreadsheet({
|
|
|
4185
4247
|
onClose: () => setHighlightPickerColumn(null)
|
|
4186
4248
|
}
|
|
4187
4249
|
),
|
|
4188
|
-
highlightPickerCell !== null && /* @__PURE__ */ (0,
|
|
4250
|
+
highlightPickerCell !== null && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4189
4251
|
ColorPickerPopover,
|
|
4190
4252
|
{
|
|
4191
4253
|
title: "Highlight Cell",
|
|
@@ -4198,7 +4260,7 @@ function Spreadsheet({
|
|
|
4198
4260
|
onClose: () => setHighlightPickerCell(null)
|
|
4199
4261
|
}
|
|
4200
4262
|
),
|
|
4201
|
-
/* @__PURE__ */ (0,
|
|
4263
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4202
4264
|
KeyboardShortcutsModal,
|
|
4203
4265
|
{
|
|
4204
4266
|
isOpen: showKeyboardShortcuts,
|
|
@@ -4206,7 +4268,7 @@ function Spreadsheet({
|
|
|
4206
4268
|
shortcuts
|
|
4207
4269
|
}
|
|
4208
4270
|
),
|
|
4209
|
-
/* @__PURE__ */ (0,
|
|
4271
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4210
4272
|
SpreadsheetSettingsModal,
|
|
4211
4273
|
{
|
|
4212
4274
|
isOpen: showSettingsModal,
|
|
@@ -4234,6 +4296,7 @@ function Spreadsheet({
|
|
|
4234
4296
|
Spreadsheet.displayName = "Spreadsheet";
|
|
4235
4297
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4236
4298
|
0 && (module.exports = {
|
|
4299
|
+
RowContextMenu,
|
|
4237
4300
|
Spreadsheet,
|
|
4238
4301
|
SpreadsheetCell,
|
|
4239
4302
|
SpreadsheetFilterDropdown,
|