@xcelsior/ui-spreadsheets 1.0.2 → 1.0.4

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.js CHANGED
@@ -116,12 +116,6 @@ function IconBase(props) {
116
116
  }
117
117
 
118
118
  // ../../../node_modules/.pnpm/react-icons@4.12.0_react@18.3.1/node_modules/react-icons/hi/index.esm.js
119
- function HiAnnotation(props) {
120
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 20 20", "fill": "currentColor", "aria-hidden": "true" }, "child": [{ "tag": "path", "attr": { "fillRule": "evenodd", "d": "M18 13V5a2 2 0 00-2-2H4a2 2 0 00-2 2v8a2 2 0 002 2h3l3 3 3-3h3a2 2 0 002-2zM5 7a1 1 0 011-1h8a1 1 0 110 2H6a1 1 0 01-1-1zm1 3a1 1 0 100 2h3a1 1 0 100-2H6z", "clipRule": "evenodd" } }] })(props);
121
- }
122
- function HiChatAlt2(props) {
123
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 20 20", "fill": "currentColor", "aria-hidden": "true" }, "child": [{ "tag": "path", "attr": { "d": "M2 5a2 2 0 012-2h7a2 2 0 012 2v4a2 2 0 01-2 2H9l-3 3v-3H4a2 2 0 01-2-2V5z" } }, { "tag": "path", "attr": { "d": "M15 7v2a4 4 0 01-4 4H9.828l-1.766 1.767c.28.149.599.233.938.233h2l3 3v-3h2a2 2 0 002-2V9a2 2 0 00-2-2h-1z" } }] })(props);
124
- }
125
119
  function HiCheck(props) {
126
120
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 20 20", "fill": "currentColor", "aria-hidden": "true" }, "child": [{ "tag": "path", "attr": { "fillRule": "evenodd", "d": "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z", "clipRule": "evenodd" } }] })(props);
127
121
  }
@@ -137,9 +131,6 @@ function HiChevronUp(props) {
137
131
  function HiCog(props) {
138
132
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 20 20", "fill": "currentColor", "aria-hidden": "true" }, "child": [{ "tag": "path", "attr": { "fillRule": "evenodd", "d": "M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 01-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.061 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 01.947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 012.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 012.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 01.947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 01-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 01-2.287-.947zM10 13a3 3 0 100-6 3 3 0 000 6z", "clipRule": "evenodd" } }] })(props);
139
133
  }
140
- function HiColorSwatch(props) {
141
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 20 20", "fill": "currentColor", "aria-hidden": "true" }, "child": [{ "tag": "path", "attr": { "fillRule": "evenodd", "d": "M4 2a2 2 0 00-2 2v11a3 3 0 106 0V4a2 2 0 00-2-2H4zm1 14a1 1 0 100-2 1 1 0 000 2zm5-1.757l4.9-4.9a2 2 0 000-2.828L13.485 5.1a2 2 0 00-2.828 0L10 5.757v8.486zM16 18H9.071l6-6H16a2 2 0 012 2v2a2 2 0 01-2 2z", "clipRule": "evenodd" } }] })(props);
142
- }
143
134
  function HiDotsVertical(props) {
144
135
  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);
145
136
  }
@@ -173,25 +164,29 @@ function HiZoomIn(props) {
173
164
  function HiZoomOut(props) {
174
165
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 20 20", "fill": "currentColor", "aria-hidden": "true" }, "child": [{ "tag": "path", "attr": { "fillRule": "evenodd", "d": "M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z", "clipRule": "evenodd" } }, { "tag": "path", "attr": { "fillRule": "evenodd", "d": "M5 8a1 1 0 011-1h4a1 1 0 110 2H6a1 1 0 01-1-1z", "clipRule": "evenodd" } }] })(props);
175
166
  }
176
- function HiOutlineAnnotation(props) {
177
- return GenIcon({ "tag": "svg", "attr": { "fill": "none", "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "aria-hidden": "true" }, "child": [{ "tag": "path", "attr": { "strokeLinecap": "round", "strokeLinejoin": "round", "d": "M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z" } }] })(props);
178
- }
179
- function HiOutlineChatAlt(props) {
180
- return GenIcon({ "tag": "svg", "attr": { "fill": "none", "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "aria-hidden": "true" }, "child": [{ "tag": "path", "attr": { "strokeLinecap": "round", "strokeLinejoin": "round", "d": "M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z" } }] })(props);
181
- }
182
167
  function HiOutlineClipboardCheck(props) {
183
168
  return GenIcon({ "tag": "svg", "attr": { "fill": "none", "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "aria-hidden": "true" }, "child": [{ "tag": "path", "attr": { "strokeLinecap": "round", "strokeLinejoin": "round", "d": "M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4" } }] })(props);
184
169
  }
185
170
  function HiOutlineClipboardCopy(props) {
186
171
  return GenIcon({ "tag": "svg", "attr": { "fill": "none", "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "aria-hidden": "true" }, "child": [{ "tag": "path", "attr": { "strokeLinecap": "round", "strokeLinejoin": "round", "d": "M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3" } }] })(props);
187
172
  }
188
- function HiOutlinePencil(props) {
189
- return GenIcon({ "tag": "svg", "attr": { "fill": "none", "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "aria-hidden": "true" }, "child": [{ "tag": "path", "attr": { "strokeLinecap": "round", "strokeLinejoin": "round", "d": "M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z" } }] })(props);
190
- }
191
173
  function HiOutlineQuestionMarkCircle(props) {
192
174
  return GenIcon({ "tag": "svg", "attr": { "fill": "none", "viewBox": "0 0 24 24", "strokeWidth": "2", "stroke": "currentColor", "aria-hidden": "true" }, "child": [{ "tag": "path", "attr": { "strokeLinecap": "round", "strokeLinejoin": "round", "d": "M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" } }] })(props);
193
175
  }
194
176
 
177
+ // ../../../node_modules/.pnpm/react-icons@4.12.0_react@18.3.1/node_modules/react-icons/ai/index.esm.js
178
+ function AiFillHighlight(props) {
179
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 1024 1024" }, "child": [{ "tag": "path", "attr": { "d": "M957.6 507.4L603.2 158.2a7.9 7.9 0 0 0-11.2 0L353.3 393.4a8.03 8.03 0 0 0-.1 11.3l.1.1 40 39.4-117.2 115.3a8.03 8.03 0 0 0-.1 11.3l.1.1 39.5 38.9-189.1 187H72.1c-4.4 0-8.1 3.6-8.1 8V860c0 4.4 3.6 8 8 8h344.9c2.1 0 4.1-.8 5.6-2.3l76.1-75.6 40.4 39.8a7.9 7.9 0 0 0 11.2 0l117.1-115.6 40.1 39.5a7.9 7.9 0 0 0 11.2 0l238.7-235.2c3.4-3 3.4-8 .3-11.2z" } }] })(props);
180
+ }
181
+
182
+ // ../../../node_modules/.pnpm/react-icons@4.12.0_react@18.3.1/node_modules/react-icons/fa/index.esm.js
183
+ function FaComment(props) {
184
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 512 512" }, "child": [{ "tag": "path", "attr": { "d": "M256 32C114.6 32 0 125.1 0 240c0 49.6 21.4 95 57 130.7C44.5 421.1 2.7 466 2.2 466.5c-2.2 2.3-2.8 5.7-1.5 8.7S4.8 480 8 480c66.3 0 116-31.8 140.6-51.4 32.7 12.3 69 19.4 107.4 19.4 141.4 0 256-93.1 256-208S397.4 32 256 32z" } }] })(props);
185
+ }
186
+ function FaRegComment(props) {
187
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 512 512" }, "child": [{ "tag": "path", "attr": { "d": "M256 32C114.6 32 0 125.1 0 240c0 47.6 19.9 91.2 52.9 126.3C38 405.7 7 439.1 6.5 439.5c-6.6 7-8.4 17.2-4.6 26S14.4 480 24 480c61.5 0 110-25.7 139.1-46.3C192 442.8 223.2 448 256 448c141.4 0 256-93.1 256-208S397.4 32 256 32zm0 368c-26.7 0-53.1-4.1-78.4-12.1l-22.7-7.2-19.5 13.8c-14.3 10.1-33.9 21.4-57.5 29 7.3-12.1 14.4-25.7 19.9-40.2l10.6-28.1-20.6-21.8C69.7 314.1 48 282.2 48 240c0-88.2 93.3-160 208-160s208 71.8 208 160-93.3 160-208 160z" } }] })(props);
188
+ }
189
+
195
190
  // src/utils.ts
196
191
  var import_clsx = require("clsx");
197
192
  var import_tailwind_merge = require("tailwind-merge");
@@ -369,7 +364,7 @@ var SpreadsheetCell = ({
369
364
  minWidth: column.minWidth || column.width,
370
365
  ...positionStyles
371
366
  },
372
- children: isEditing ? renderEditInput() : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-1", children: [
367
+ children: isEditing ? renderEditInput() : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-1 relative", children: [
373
368
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
374
369
  "div",
375
370
  {
@@ -389,19 +384,19 @@ var SpreadsheetCell = ({
389
384
  e.stopPropagation();
390
385
  onViewComments?.();
391
386
  },
392
- className: "p-0.5 hover:bg-gray-100 rounded relative shrink-0",
387
+ className: "absolute -right-1 p-0.5 hover:bg-gray-100 rounded z-10",
393
388
  title: `${unresolvedCommentCount} unresolved comment(s)`,
394
389
  children: [
395
390
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
396
- HiOutlineChatAlt,
391
+ FaComment,
397
392
  {
398
393
  className: cn(
399
- "h-3 w-3",
394
+ "h-2.5 w-2.5",
400
395
  unresolvedCommentCount > 0 ? "text-amber-500" : "text-gray-400"
401
396
  )
402
397
  }
403
398
  ),
404
- unresolvedCommentCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "absolute -top-1 -right-1 bg-amber-500 text-white text-[8px] rounded-full w-3 h-3 flex items-center justify-center", children: unresolvedCommentCount })
399
+ unresolvedCommentCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "absolute -top-1 -right-1 bg-amber-500 text-white text-[6px] rounded-full w-2.5 h-2.5 flex items-center justify-center", children: unresolvedCommentCount })
405
400
  ]
406
401
  }
407
402
  ),
@@ -443,7 +438,7 @@ var SpreadsheetCell = ({
443
438
  className: "p-0.5 hover:bg-gray-100 rounded",
444
439
  title: "Highlight cell",
445
440
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
446
- HiOutlinePencil,
441
+ AiFillHighlight,
447
442
  {
448
443
  className: cn(
449
444
  "h-2.5 w-2.5",
@@ -463,7 +458,7 @@ var SpreadsheetCell = ({
463
458
  },
464
459
  className: "p-0.5 hover:bg-gray-100 rounded",
465
460
  title: "Add comment",
466
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(HiOutlineAnnotation, { className: "h-2.5 w-2.5 text-gray-400" })
461
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FaRegComment, { className: "h-2.5 w-2.5 text-gray-400" })
467
462
  }
468
463
  )
469
464
  ] })
@@ -1149,7 +1144,7 @@ function ColumnHeaderActions({
1149
1144
  hasActiveHighlight ? "text-amber-500 opacity-100" : "text-gray-400 opacity-0 group-hover:opacity-100"
1150
1145
  ),
1151
1146
  title: highlightTitle,
1152
- children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(HiColorSwatch, { className: "h-3 w-3" })
1147
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(AiFillHighlight, { className: "h-3 w-3" })
1153
1148
  }
1154
1149
  ),
1155
1150
  enablePinning && onPinClick && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
@@ -1486,6 +1481,7 @@ function useSpreadsheetHighlighting({
1486
1481
  const [columnHighlights, setColumnHighlights] = (0, import_react7.useState)({});
1487
1482
  const [highlightPickerRow, setHighlightPickerRow] = (0, import_react7.useState)(null);
1488
1483
  const [highlightPickerColumn, setHighlightPickerColumn] = (0, import_react7.useState)(null);
1484
+ const [highlightPickerCell, setHighlightPickerCell] = (0, import_react7.useState)(null);
1489
1485
  const rowHighlights = externalRowHighlights || rowHighlightsInternal;
1490
1486
  const getCellHighlight = (0, import_react7.useCallback)(
1491
1487
  (rowId, columnId) => {
@@ -1498,10 +1494,19 @@ function useSpreadsheetHighlighting({
1498
1494
  setCellHighlights((prev) => {
1499
1495
  const existing = prev.find((h) => h.rowId === rowId && h.columnId === columnId);
1500
1496
  if (existing) {
1501
- return prev.filter((h) => !(h.rowId === rowId && h.columnId === columnId));
1497
+ if (color === null) {
1498
+ return prev.filter((h) => !(h.rowId === rowId && h.columnId === columnId));
1499
+ }
1500
+ return prev.map(
1501
+ (h) => h.rowId === rowId && h.columnId === columnId ? { ...h, color } : h
1502
+ );
1503
+ }
1504
+ if (color) {
1505
+ return [...prev, { rowId, columnId, color }];
1502
1506
  }
1503
- return [...prev, { rowId, columnId, color }];
1507
+ return prev;
1504
1508
  });
1509
+ setHighlightPickerCell(null);
1505
1510
  },
1506
1511
  []
1507
1512
  );
@@ -1577,6 +1582,8 @@ function useSpreadsheetHighlighting({
1577
1582
  setHighlightPickerRow,
1578
1583
  highlightPickerColumn,
1579
1584
  setHighlightPickerColumn,
1585
+ highlightPickerCell,
1586
+ setHighlightPickerCell,
1580
1587
  // Utility
1581
1588
  clearAllHighlights
1582
1589
  };
@@ -2025,13 +2032,17 @@ var import_jsx_runtime9 = require("react/jsx-runtime");
2025
2032
  function AddCommentModal({
2026
2033
  isOpen,
2027
2034
  commentText,
2035
+ columnLabel,
2028
2036
  onCommentTextChange,
2029
2037
  onAdd,
2030
2038
  onClose
2031
2039
  }) {
2032
2040
  if (!isOpen) return null;
2033
2041
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "bg-white rounded-lg shadow-xl p-6 w-96 max-w-full mx-4", children: [
2034
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h3", { className: "text-lg font-semibold mb-4", children: "Add Row Comment" }),
2042
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("h3", { className: "text-lg font-semibold mb-4", children: [
2043
+ "Add Comment",
2044
+ columnLabel ? ` - ${columnLabel}` : ""
2045
+ ] }),
2035
2046
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2036
2047
  "textarea",
2037
2048
  {
@@ -2068,13 +2079,17 @@ AddCommentModal.displayName = "AddCommentModal";
2068
2079
  function ViewCommentsModal({
2069
2080
  isOpen,
2070
2081
  comments,
2082
+ columnLabel,
2071
2083
  onToggleResolved,
2072
2084
  onClose
2073
2085
  }) {
2074
2086
  if (!isOpen) return null;
2075
2087
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "bg-white rounded-lg shadow-xl p-6 w-[480px] max-w-full mx-4 max-h-[80vh] flex flex-col", children: [
2076
2088
  /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center justify-between mb-4", children: [
2077
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h3", { className: "text-lg font-semibold", children: "Row Comments" }),
2089
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("h3", { className: "text-lg font-semibold", children: [
2090
+ "Comments",
2091
+ columnLabel ? ` - ${columnLabel}` : ""
2092
+ ] }),
2078
2093
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2079
2094
  "button",
2080
2095
  {
@@ -2117,7 +2132,7 @@ function ViewCommentsModal({
2117
2132
  },
2118
2133
  comment.id
2119
2134
  )),
2120
- comments.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-center text-gray-500 py-8", children: "No comments for this row." })
2135
+ comments.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-center text-gray-500 py-8", children: "No comments for this cell." })
2121
2136
  ] })
2122
2137
  ] }) });
2123
2138
  }
@@ -2179,6 +2194,7 @@ var import_design_system = require("@xcelsior/design-system");
2179
2194
 
2180
2195
  // src/hooks/useSpreadsheetFiltering.ts
2181
2196
  var import_react10 = require("react");
2197
+ var import_utils9 = require("@xcelsior/utils");
2182
2198
  function useSpreadsheetFiltering({
2183
2199
  data,
2184
2200
  columns,
@@ -2325,19 +2341,10 @@ function useSpreadsheetFiltering({
2325
2341
  },
2326
2342
  []
2327
2343
  );
2328
- const filteredData = (0, import_react10.useMemo)(() => {
2329
- if (!data || !Array.isArray(data)) return [];
2330
- if (serverSide) {
2331
- return data;
2332
- }
2333
- if (!columns || !Array.isArray(columns)) return data;
2334
- let result = [...data];
2335
- for (const [columnId, filter] of Object.entries(filters)) {
2336
- if (!filter) continue;
2337
- const column = columns.find((c) => c.id === columnId);
2338
- if (!column) continue;
2339
- result = result.filter((row) => {
2340
- const value = column.getValue ? column.getValue(row) : row[columnId];
2344
+ const buildFilterPredicate = (0, import_react10.useCallback)(
2345
+ (column, filter) => {
2346
+ return (row) => {
2347
+ const value = column.getValue ? column.getValue(row) : row[column.id];
2341
2348
  if (filter.includeBlanks && isBlankValue(value)) {
2342
2349
  return true;
2343
2350
  }
@@ -2364,32 +2371,48 @@ function useSpreadsheetFiltering({
2364
2371
  if (filter.max !== void 0 && numValue > Number(filter.max)) return false;
2365
2372
  }
2366
2373
  return true;
2367
- });
2368
- }
2369
- if (sortConfig) {
2370
- const column = columns.find((c) => c.id === sortConfig.columnId);
2371
- result.sort((a, b) => {
2372
- const aValue = column?.getValue ? column.getValue(a) : a[sortConfig.columnId];
2373
- const bValue = column?.getValue ? column.getValue(b) : b[sortConfig.columnId];
2374
+ };
2375
+ },
2376
+ [applyTextCondition, applyNumberCondition, applyDateCondition]
2377
+ );
2378
+ const buildSortComparator = (0, import_react10.useCallback)(
2379
+ (column, direction) => {
2380
+ return (a, b) => {
2381
+ const aValue = column?.getValue ? column.getValue(a) : a[sortConfig?.columnId];
2382
+ const bValue = column?.getValue ? column.getValue(b) : b[sortConfig?.columnId];
2374
2383
  if (aValue === null || aValue === void 0) return 1;
2375
2384
  if (bValue === null || bValue === void 0) return -1;
2376
2385
  if (typeof aValue === "string" && typeof bValue === "string") {
2377
- return sortConfig.direction === "asc" ? aValue.localeCompare(bValue) : bValue.localeCompare(aValue);
2386
+ return direction === "asc" ? aValue.localeCompare(bValue) : bValue.localeCompare(aValue);
2378
2387
  }
2379
- return sortConfig.direction === "asc" ? aValue < bValue ? -1 : aValue > bValue ? 1 : 0 : aValue > bValue ? -1 : aValue < bValue ? 1 : 0;
2380
- });
2388
+ return direction === "asc" ? aValue < bValue ? -1 : aValue > bValue ? 1 : 0 : aValue > bValue ? -1 : aValue < bValue ? 1 : 0;
2389
+ };
2390
+ },
2391
+ [sortConfig?.columnId]
2392
+ );
2393
+ const filteredData = (0, import_react10.useMemo)(() => {
2394
+ if (!data || !Array.isArray(data)) return import_utils9.LazyArray.empty();
2395
+ if (serverSide) {
2396
+ return import_utils9.LazyArray.from(data);
2381
2397
  }
2382
- return result;
2383
- }, [
2384
- data,
2385
- filters,
2386
- sortConfig,
2387
- columns,
2388
- serverSide,
2389
- applyDateCondition,
2390
- applyNumberCondition,
2391
- applyTextCondition
2392
- ]);
2398
+ if (!columns || !Array.isArray(columns)) return import_utils9.LazyArray.from(data);
2399
+ let lazyResult = import_utils9.LazyArray.from(data);
2400
+ const filterChain = new import_utils9.FilterChain();
2401
+ for (const [columnId, filter] of Object.entries(filters)) {
2402
+ if (!filter) continue;
2403
+ const column = columns.find((c) => c.id === columnId);
2404
+ if (!column) continue;
2405
+ filterChain.add(buildFilterPredicate(column, filter));
2406
+ }
2407
+ if (!filterChain.isEmpty) {
2408
+ lazyResult = filterChain.applyTo(lazyResult);
2409
+ }
2410
+ if (sortConfig) {
2411
+ const column = columns.find((c) => c.id === sortConfig.columnId);
2412
+ lazyResult = lazyResult.sort(buildSortComparator(column, sortConfig.direction));
2413
+ }
2414
+ return lazyResult;
2415
+ }, [data, filters, sortConfig, columns, serverSide, buildFilterPredicate, buildSortComparator]);
2393
2416
  const handleFilterChange = (0, import_react10.useCallback)(
2394
2417
  (columnId, filter) => {
2395
2418
  const newFilters = { ...filters };
@@ -2407,7 +2430,16 @@ function useSpreadsheetFiltering({
2407
2430
  );
2408
2431
  const handleSort = (0, import_react10.useCallback)(
2409
2432
  (columnId) => {
2410
- const newSortConfig = sortConfig?.columnId === columnId ? { columnId, direction: sortConfig.direction === "asc" ? "desc" : "asc" } : { columnId, direction: "asc" };
2433
+ let newSortConfig;
2434
+ if (sortConfig?.columnId === columnId) {
2435
+ if (sortConfig.direction === "asc") {
2436
+ newSortConfig = { columnId, direction: "desc" };
2437
+ } else {
2438
+ newSortConfig = null;
2439
+ }
2440
+ } else {
2441
+ newSortConfig = { columnId, direction: "asc" };
2442
+ }
2411
2443
  if (controlledSortConfig === void 0) {
2412
2444
  setInternalSortConfig(newSortConfig);
2413
2445
  }
@@ -2415,6 +2447,21 @@ function useSpreadsheetFiltering({
2415
2447
  },
2416
2448
  [sortConfig, onSortChange, controlledSortConfig]
2417
2449
  );
2450
+ const clearSort = (0, import_react10.useCallback)(() => {
2451
+ if (controlledSortConfig === void 0) {
2452
+ setInternalSortConfig(null);
2453
+ }
2454
+ onSortChange?.(null);
2455
+ }, [onSortChange, controlledSortConfig]);
2456
+ const setSortConfig = (0, import_react10.useCallback)(
2457
+ (config) => {
2458
+ if (controlledSortConfig === void 0) {
2459
+ setInternalSortConfig(config);
2460
+ }
2461
+ onSortChange?.(config);
2462
+ },
2463
+ [onSortChange, controlledSortConfig]
2464
+ );
2418
2465
  const clearAllFilters = (0, import_react10.useCallback)(() => {
2419
2466
  if (controlledFilters === void 0) {
2420
2467
  setInternalFilters({});
@@ -2430,6 +2477,8 @@ function useSpreadsheetFiltering({
2430
2477
  setActiveFilterColumn,
2431
2478
  handleFilterChange,
2432
2479
  handleSort,
2480
+ setSortConfig,
2481
+ clearSort,
2433
2482
  clearAllFilters,
2434
2483
  hasActiveFilters
2435
2484
  };
@@ -2438,43 +2487,46 @@ function useSpreadsheetFiltering({
2438
2487
  // src/hooks/useSpreadsheetComments.ts
2439
2488
  var import_react11 = require("react");
2440
2489
  function useSpreadsheetComments({
2441
- externalRowComments,
2442
- onAddRowComment
2490
+ externalCellComments,
2491
+ onAddCellComment
2443
2492
  } = {}) {
2444
- const [rowCommentsInternal, setRowCommentsInternal] = (0, import_react11.useState)([]);
2445
- const [commentModalRow, setCommentModalRow] = (0, import_react11.useState)(null);
2493
+ const [cellCommentsInternal, setCellCommentsInternal] = (0, import_react11.useState)([]);
2494
+ const [commentModalCell, setCommentModalCell] = (0, import_react11.useState)(null);
2446
2495
  const [commentText, setCommentText] = (0, import_react11.useState)("");
2447
- const [viewCommentsRow, setViewCommentsRow] = (0, import_react11.useState)(null);
2448
- const rowComments = externalRowComments || rowCommentsInternal;
2449
- const getRowComments = (0, import_react11.useCallback)(
2450
- (rowId) => {
2451
- return rowComments.filter((c) => c.rowId === rowId && !c.columnId);
2496
+ const [viewCommentsCell, setViewCommentsCell] = (0, import_react11.useState)(null);
2497
+ const cellComments = externalCellComments || cellCommentsInternal;
2498
+ const getCellComments = (0, import_react11.useCallback)(
2499
+ (rowId, columnId) => {
2500
+ return cellComments.filter((c) => c.rowId === rowId && c.columnId === columnId);
2452
2501
  },
2453
- [rowComments]
2502
+ [cellComments]
2454
2503
  );
2455
- const getUnresolvedCommentCount = (0, import_react11.useCallback)(
2456
- (rowId) => {
2457
- return rowComments.filter((c) => c.rowId === rowId && !c.columnId && !c.resolved).length;
2504
+ const getCellUnresolvedCommentCount = (0, import_react11.useCallback)(
2505
+ (rowId, columnId) => {
2506
+ return cellComments.filter(
2507
+ (c) => c.rowId === rowId && c.columnId === columnId && !c.resolved
2508
+ ).length;
2458
2509
  },
2459
- [rowComments]
2510
+ [cellComments]
2460
2511
  );
2461
- const hasComments = (0, import_react11.useCallback)(
2462
- (rowId) => {
2463
- return rowComments.some((c) => c.rowId === rowId && !c.columnId);
2512
+ const cellHasComments = (0, import_react11.useCallback)(
2513
+ (rowId, columnId) => {
2514
+ return cellComments.some((c) => c.rowId === rowId && c.columnId === columnId);
2464
2515
  },
2465
- [rowComments]
2516
+ [cellComments]
2466
2517
  );
2467
- const handleAddRowComment = (0, import_react11.useCallback)(
2468
- (rowId) => {
2518
+ const handleAddCellComment = (0, import_react11.useCallback)(
2519
+ (rowId, columnId) => {
2469
2520
  if (!commentText.trim()) return;
2470
- if (onAddRowComment) {
2471
- onAddRowComment(rowId, commentText);
2521
+ if (onAddCellComment) {
2522
+ onAddCellComment(rowId, columnId, commentText);
2472
2523
  } else {
2473
- setRowCommentsInternal((prev) => [
2524
+ setCellCommentsInternal((prev) => [
2474
2525
  ...prev,
2475
2526
  {
2476
2527
  id: `comment-${Date.now()}`,
2477
2528
  rowId,
2529
+ columnId,
2478
2530
  text: commentText,
2479
2531
  timestamp: /* @__PURE__ */ new Date(),
2480
2532
  resolved: false
@@ -2482,33 +2534,33 @@ function useSpreadsheetComments({
2482
2534
  ]);
2483
2535
  }
2484
2536
  setCommentText("");
2485
- setCommentModalRow(null);
2537
+ setCommentModalCell(null);
2486
2538
  },
2487
- [commentText, onAddRowComment]
2539
+ [commentText, onAddCellComment]
2488
2540
  );
2489
2541
  const handleToggleCommentResolved = (0, import_react11.useCallback)((commentId) => {
2490
- setRowCommentsInternal(
2542
+ setCellCommentsInternal(
2491
2543
  (prev) => prev.map((c) => c.id === commentId ? { ...c, resolved: !c.resolved } : c)
2492
2544
  );
2493
2545
  }, []);
2494
2546
  return {
2495
2547
  // Comments data
2496
- rowComments,
2497
- getRowComments,
2498
- getUnresolvedCommentCount,
2548
+ cellComments,
2549
+ getCellComments,
2550
+ getCellUnresolvedCommentCount,
2499
2551
  // Add comment modal state
2500
- commentModalRow,
2501
- setCommentModalRow,
2552
+ commentModalCell,
2553
+ setCommentModalCell,
2502
2554
  commentText,
2503
2555
  setCommentText,
2504
2556
  // View comments modal state
2505
- viewCommentsRow,
2506
- setViewCommentsRow,
2557
+ viewCommentsCell,
2558
+ setViewCommentsCell,
2507
2559
  // Actions
2508
- handleAddRowComment,
2560
+ handleAddCellComment,
2509
2561
  handleToggleCommentResolved,
2510
2562
  // Utility
2511
- hasComments
2563
+ cellHasComments
2512
2564
  };
2513
2565
  }
2514
2566
 
@@ -2755,7 +2807,7 @@ function Spreadsheet({
2755
2807
  onRowClick,
2756
2808
  onRowDoubleClick,
2757
2809
  onRowClone,
2758
- onAddRowComment,
2810
+ onAddCellComment,
2759
2811
  onRowHighlight,
2760
2812
  showToolbar = true,
2761
2813
  showPagination = true,
@@ -2774,7 +2826,7 @@ function Spreadsheet({
2774
2826
  className,
2775
2827
  emptyMessage = "No data available",
2776
2828
  rowHighlights: externalRowHighlights,
2777
- rowComments: externalRowComments,
2829
+ cellComments: externalCellComments,
2778
2830
  rowActions,
2779
2831
  // Server-side mode props
2780
2832
  serverSide = false,
@@ -2793,6 +2845,7 @@ function Spreadsheet({
2793
2845
  setActiveFilterColumn,
2794
2846
  handleFilterChange,
2795
2847
  handleSort,
2848
+ setSortConfig,
2796
2849
  clearAllFilters,
2797
2850
  hasActiveFilters
2798
2851
  } = useSpreadsheetFiltering({
@@ -2814,7 +2867,9 @@ function Spreadsheet({
2814
2867
  highlightPickerRow,
2815
2868
  setHighlightPickerRow,
2816
2869
  highlightPickerColumn,
2817
- setHighlightPickerColumn
2870
+ setHighlightPickerColumn,
2871
+ highlightPickerCell,
2872
+ setHighlightPickerCell
2818
2873
  } = useSpreadsheetHighlighting({
2819
2874
  externalRowHighlights,
2820
2875
  onRowHighlight
@@ -2836,20 +2891,20 @@ function Spreadsheet({
2836
2891
  showRowIndex
2837
2892
  });
2838
2893
  const {
2839
- getRowComments,
2840
- getUnresolvedCommentCount,
2841
- hasComments,
2842
- commentModalRow,
2843
- setCommentModalRow,
2894
+ getCellComments,
2895
+ getCellUnresolvedCommentCount,
2896
+ cellHasComments,
2897
+ commentModalCell,
2898
+ setCommentModalCell,
2844
2899
  commentText,
2845
2900
  setCommentText,
2846
- viewCommentsRow,
2847
- setViewCommentsRow,
2848
- handleAddRowComment,
2901
+ viewCommentsCell,
2902
+ setViewCommentsCell,
2903
+ handleAddCellComment,
2849
2904
  handleToggleCommentResolved
2850
2905
  } = useSpreadsheetComments({
2851
- externalRowComments,
2852
- onAddRowComment
2906
+ externalCellComments,
2907
+ onAddCellComment
2853
2908
  });
2854
2909
  const {
2855
2910
  canUndo,
@@ -2911,15 +2966,23 @@ function Spreadsheet({
2911
2966
  pinRowIndex: false,
2912
2967
  rowIndexHighlightColor: void 0
2913
2968
  });
2969
+ (0, import_react14.useEffect)(() => {
2970
+ setSpreadsheetSettings((prev) => ({
2971
+ ...prev,
2972
+ defaultSort: sortConfig
2973
+ }));
2974
+ }, [sortConfig]);
2914
2975
  const handleEscapeCallback = (0, import_react14.useCallback)(() => {
2915
- if (commentModalRow !== null) {
2916
- setCommentModalRow(null);
2917
- } else if (viewCommentsRow !== null) {
2918
- setViewCommentsRow(null);
2976
+ if (commentModalCell !== null) {
2977
+ setCommentModalCell(null);
2978
+ } else if (viewCommentsCell !== null) {
2979
+ setViewCommentsCell(null);
2919
2980
  } else if (highlightPickerRow !== null) {
2920
2981
  setHighlightPickerRow(null);
2921
2982
  } else if (highlightPickerColumn !== null) {
2922
2983
  setHighlightPickerColumn(null);
2984
+ } else if (highlightPickerCell !== null) {
2985
+ setHighlightPickerCell(null);
2923
2986
  } else {
2924
2987
  setSelectedRows(/* @__PURE__ */ new Set());
2925
2988
  setLastSelectedRow(null);
@@ -2927,14 +2990,16 @@ function Spreadsheet({
2927
2990
  setEditingCell(null);
2928
2991
  }
2929
2992
  }, [
2930
- commentModalRow,
2931
- setCommentModalRow,
2932
- viewCommentsRow,
2933
- setViewCommentsRow,
2993
+ commentModalCell,
2994
+ setCommentModalCell,
2995
+ viewCommentsCell,
2996
+ setViewCommentsCell,
2934
2997
  highlightPickerRow,
2935
2998
  setHighlightPickerRow,
2936
2999
  highlightPickerColumn,
2937
- setHighlightPickerColumn
3000
+ setHighlightPickerColumn,
3001
+ highlightPickerCell,
3002
+ setHighlightPickerCell
2938
3003
  ]);
2939
3004
  const applyUndo = (0, import_react14.useCallback)(() => {
2940
3005
  const entry = popUndoEntry();
@@ -3290,9 +3355,6 @@ function Spreadsheet({
3290
3355
  const isRowSelected = selectedRows.has(rowId);
3291
3356
  const isRowHovered = hoveredRow === rowId;
3292
3357
  const rowHighlight = getRowHighlight(rowId);
3293
- const rowCommentsList = getRowComments(rowId);
3294
- const hasRowComments = hasComments(rowId);
3295
- const unresolvedCount = getUnresolvedCommentCount(rowId);
3296
3358
  const displayIndex = rowIndex + 1 + (currentPage - 1) * pageSize;
3297
3359
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
3298
3360
  "tr",
@@ -3305,12 +3367,12 @@ function Spreadsheet({
3305
3367
  onDoubleClick: () => onRowDoubleClick?.(row, rowIndex),
3306
3368
  className: "transition-colors",
3307
3369
  children: [
3308
- effectiveShowRowIndex && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
3370
+ effectiveShowRowIndex && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3309
3371
  "td",
3310
3372
  {
3311
3373
  onClick: (e) => handleRowSelect(rowId, e),
3312
3374
  className: cn(
3313
- "border border-gray-200 text-center font-semibold cursor-pointer group relative",
3375
+ "border border-gray-200 text-center font-semibold cursor-pointer group",
3314
3376
  isRowIndexPinned ? "z-20" : "z-0",
3315
3377
  isRowSelected && "bg-blue-100",
3316
3378
  !isRowSelected && rowHighlight && "",
@@ -3325,29 +3387,48 @@ function Spreadsheet({
3325
3387
  left: 0
3326
3388
  }
3327
3389
  },
3328
- children: [
3390
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "relative", children: [
3329
3391
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "py-1 px-1", children: displayIndex }),
3330
- hasRowComments && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
3392
+ cellHasComments(
3393
+ rowId,
3394
+ ROW_INDEX_COLUMN_ID
3395
+ ) && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
3331
3396
  "button",
3332
3397
  {
3333
3398
  type: "button",
3334
3399
  onClick: (e) => {
3335
3400
  e.stopPropagation();
3336
- setViewCommentsRow(rowId);
3401
+ setViewCommentsCell({
3402
+ rowId,
3403
+ columnId: ROW_INDEX_COLUMN_ID
3404
+ });
3337
3405
  },
3338
- className: "absolute top-0 right-0 p-0.5 hover:bg-gray-200/80 rounded-bl",
3339
- title: `${rowCommentsList.length} row comment(s) - ${unresolvedCount} unresolved`,
3406
+ style: {
3407
+ top: "5px",
3408
+ right: "5px"
3409
+ },
3410
+ className: "absolute p-0.5 hover:bg-gray-100 rounded z-10",
3411
+ title: `${getCellUnresolvedCommentCount(rowId, ROW_INDEX_COLUMN_ID)} unresolved comment(s)`,
3340
3412
  children: [
3341
3413
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3342
- HiChatAlt2,
3414
+ FaComment,
3343
3415
  {
3344
3416
  className: cn(
3345
3417
  "h-2.5 w-2.5",
3346
- unresolvedCount > 0 ? "text-amber-500" : "text-gray-400"
3418
+ getCellUnresolvedCommentCount(
3419
+ rowId,
3420
+ ROW_INDEX_COLUMN_ID
3421
+ ) > 0 ? "text-amber-500" : "text-gray-400"
3347
3422
  )
3348
3423
  }
3349
3424
  ),
3350
- unresolvedCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "absolute -top-0.5 -right-0.5 bg-amber-500 text-white text-[6px] rounded-full w-2 h-2 flex items-center justify-center", children: unresolvedCount })
3425
+ getCellUnresolvedCommentCount(
3426
+ rowId,
3427
+ ROW_INDEX_COLUMN_ID
3428
+ ) > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "absolute -top-1 -right-1 bg-amber-500 text-white text-[6px] rounded-full w-2.5 h-2.5 flex items-center justify-center", children: getCellUnresolvedCommentCount(
3429
+ rowId,
3430
+ ROW_INDEX_COLUMN_ID
3431
+ ) })
3351
3432
  ]
3352
3433
  }
3353
3434
  ),
@@ -3371,12 +3452,14 @@ function Spreadsheet({
3371
3452
  type: "button",
3372
3453
  onClick: (e) => {
3373
3454
  e.stopPropagation();
3374
- setHighlightPickerRow(rowId);
3455
+ setHighlightPickerRow(
3456
+ rowId
3457
+ );
3375
3458
  },
3376
3459
  className: "p-0.5 hover:bg-gray-200 rounded",
3377
3460
  title: "Highlight row",
3378
3461
  children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3379
- HiColorSwatch,
3462
+ AiFillHighlight,
3380
3463
  {
3381
3464
  className: cn(
3382
3465
  "h-2.5 w-2.5",
@@ -3392,11 +3475,14 @@ function Spreadsheet({
3392
3475
  type: "button",
3393
3476
  onClick: (e) => {
3394
3477
  e.stopPropagation();
3395
- setCommentModalRow(rowId);
3478
+ setCommentModalCell({
3479
+ rowId,
3480
+ columnId: ROW_INDEX_COLUMN_ID
3481
+ });
3396
3482
  },
3397
3483
  className: "p-0.5 hover:bg-gray-200 rounded",
3398
- title: "Add row comment",
3399
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(HiAnnotation, { className: "h-2.5 w-2.5 text-gray-500" })
3484
+ title: "Add comment",
3485
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FaRegComment, { className: "h-2.5 w-2.5 text-gray-500" })
3400
3486
  }
3401
3487
  ),
3402
3488
  rowActions?.map((action) => {
@@ -3408,7 +3494,10 @@ function Spreadsheet({
3408
3494
  type: "button",
3409
3495
  onClick: (e) => {
3410
3496
  e.stopPropagation();
3411
- action.onClick(row, rowId);
3497
+ action.onClick(
3498
+ row,
3499
+ rowId
3500
+ );
3412
3501
  },
3413
3502
  className: cn(
3414
3503
  "p-0.5 hover:bg-gray-200 rounded",
@@ -3421,7 +3510,7 @@ function Spreadsheet({
3421
3510
  );
3422
3511
  })
3423
3512
  ] })
3424
- ]
3513
+ ] })
3425
3514
  }
3426
3515
  ),
3427
3516
  visibleColumns.map((column) => {
@@ -3455,11 +3544,27 @@ function Spreadsheet({
3455
3544
  onConfirm: handleConfirmEdit,
3456
3545
  onCancel: handleCancelEdit,
3457
3546
  onHighlight: enableHighlighting ? () => {
3458
- handleCellHighlightToggle(
3547
+ setHighlightPickerCell({
3459
3548
  rowId,
3460
- column.id
3461
- );
3462
- } : void 0
3549
+ columnId: column.id
3550
+ });
3551
+ } : void 0,
3552
+ hasComments: cellHasComments(
3553
+ rowId,
3554
+ column.id
3555
+ ),
3556
+ unresolvedCommentCount: getCellUnresolvedCommentCount(
3557
+ rowId,
3558
+ column.id
3559
+ ),
3560
+ onAddComment: enableComments ? () => setCommentModalCell({
3561
+ rowId,
3562
+ columnId: column.id
3563
+ }) : void 0,
3564
+ onViewComments: enableComments && cellHasComments(rowId, column.id) ? () => setViewCommentsCell({
3565
+ rowId,
3566
+ columnId: column.id
3567
+ }) : void 0
3463
3568
  },
3464
3569
  column.id
3465
3570
  );
@@ -3490,23 +3595,25 @@ function Spreadsheet({
3490
3595
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3491
3596
  AddCommentModal,
3492
3597
  {
3493
- isOpen: commentModalRow !== null,
3598
+ isOpen: commentModalCell !== null,
3494
3599
  commentText,
3600
+ columnLabel: commentModalCell ? commentModalCell.columnId === ROW_INDEX_COLUMN_ID ? "Row #" : columns.find((c) => c.id === commentModalCell.columnId)?.label : void 0,
3495
3601
  onCommentTextChange: setCommentText,
3496
- onAdd: () => commentModalRow !== null && handleAddRowComment(commentModalRow),
3602
+ onAdd: () => commentModalCell !== null && handleAddCellComment(commentModalCell.rowId, commentModalCell.columnId),
3497
3603
  onClose: () => {
3498
3604
  setCommentText("");
3499
- setCommentModalRow(null);
3605
+ setCommentModalCell(null);
3500
3606
  }
3501
3607
  }
3502
3608
  ),
3503
3609
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3504
3610
  ViewCommentsModal,
3505
3611
  {
3506
- isOpen: viewCommentsRow !== null,
3507
- comments: viewCommentsRow !== null ? getRowComments(viewCommentsRow) : [],
3612
+ isOpen: viewCommentsCell !== null,
3613
+ comments: viewCommentsCell !== null ? getCellComments(viewCommentsCell.rowId, viewCommentsCell.columnId) : [],
3614
+ columnLabel: viewCommentsCell ? viewCommentsCell.columnId === ROW_INDEX_COLUMN_ID ? "Row #" : columns.find((c) => c.id === viewCommentsCell.columnId)?.label : void 0,
3508
3615
  onToggleResolved: handleToggleCommentResolved,
3509
- onClose: () => setViewCommentsRow(null)
3616
+ onClose: () => setViewCommentsCell(null)
3510
3617
  }
3511
3618
  ),
3512
3619
  highlightPickerRow !== null && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
@@ -3527,6 +3634,19 @@ function Spreadsheet({
3527
3634
  onClose: () => setHighlightPickerColumn(null)
3528
3635
  }
3529
3636
  ),
3637
+ highlightPickerCell !== null && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3638
+ ColorPickerPopover,
3639
+ {
3640
+ title: "Highlight Cell",
3641
+ paletteType: "row",
3642
+ onSelectColor: (color) => handleCellHighlightToggle(
3643
+ highlightPickerCell.rowId,
3644
+ highlightPickerCell.columnId,
3645
+ color
3646
+ ),
3647
+ onClose: () => setHighlightPickerCell(null)
3648
+ }
3649
+ ),
3530
3650
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3531
3651
  KeyboardShortcutsModal,
3532
3652
  {
@@ -3547,7 +3667,8 @@ function Spreadsheet({
3547
3667
  if (newSettings.defaultPageSize !== pageSize) {
3548
3668
  handlePageSizeChange(newSettings.defaultPageSize);
3549
3669
  }
3550
- if (newSettings.defaultSort) {
3670
+ if (newSettings.defaultSort?.columnId !== sortConfig?.columnId || newSettings.defaultSort?.direction !== sortConfig?.direction) {
3671
+ setSortConfig(newSettings.defaultSort);
3551
3672
  }
3552
3673
  },
3553
3674
  columns: columns || [],