@particle-academy/fancy-sheets 0.5.1 → 0.6.1

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.cjs CHANGED
@@ -1739,6 +1739,7 @@ function RowHeader({ rowIndex }) {
1739
1739
  );
1740
1740
  }
1741
1741
  RowHeader.displayName = "RowHeader";
1742
+ var DEFAULT_COMMENT_COLOR = "#f59e0b";
1742
1743
  var EXCEL_EPOCH2 = new Date(1899, 11, 30).getTime();
1743
1744
  function serialToDateStr(serial) {
1744
1745
  const d = new Date(EXCEL_EPOCH2 + Math.floor(serial) * 864e5);
@@ -1856,7 +1857,15 @@ var Cell = react.memo(function Cell2({ address, row, col }) {
1856
1857
  formatStyle.borderLeftStyle = "solid";
1857
1858
  formatStyle.borderLeftColor = cell.format.borderLeft;
1858
1859
  }
1859
- return /* @__PURE__ */ jsxRuntime.jsx(
1860
+ const comment = cell?.comment;
1861
+ const commentColor = comment?.color ?? DEFAULT_COMMENT_COLOR;
1862
+ if (comment) {
1863
+ formatStyle.borderColor = commentColor;
1864
+ formatStyle.borderWidth = 1;
1865
+ formatStyle.borderStyle = "solid";
1866
+ }
1867
+ const [showComment, setShowComment] = react.useState(false);
1868
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1860
1869
  "div",
1861
1870
  {
1862
1871
  "data-fancy-sheets-cell": "",
@@ -1870,10 +1879,40 @@ var Cell = react.memo(function Cell2({ address, row, col }) {
1870
1879
  ),
1871
1880
  style: { width, minWidth: width, height: rowHeight, ...formatStyle },
1872
1881
  onMouseDown: handleMouseDown,
1873
- onMouseEnter: handleMouseEnter,
1882
+ onMouseEnter: (e) => {
1883
+ handleMouseEnter();
1884
+ if (comment) setShowComment(true);
1885
+ },
1874
1886
  onMouseUp: handleMouseUp,
1887
+ onMouseLeave: () => {
1888
+ if (comment) setShowComment(false);
1889
+ },
1875
1890
  onDoubleClick: handleDoubleClick,
1876
- children: !isEditing && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: displayValue })
1891
+ children: [
1892
+ !isEditing && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: displayValue }),
1893
+ comment && /* @__PURE__ */ jsxRuntime.jsx(
1894
+ "div",
1895
+ {
1896
+ className: "absolute top-0 right-0 h-0 w-0",
1897
+ style: {
1898
+ borderTop: `6px solid ${commentColor}`,
1899
+ borderLeft: "6px solid transparent"
1900
+ },
1901
+ "aria-hidden": true
1902
+ }
1903
+ ),
1904
+ comment && showComment && /* @__PURE__ */ jsxRuntime.jsxs(
1905
+ "div",
1906
+ {
1907
+ className: "absolute top-full left-0 z-50 mt-0.5 max-w-[200px] rounded border bg-white px-2 py-1.5 text-[11px] leading-tight shadow-lg dark:bg-zinc-800",
1908
+ style: { borderColor: commentColor },
1909
+ children: [
1910
+ comment.author && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-0.5 font-semibold", style: { color: commentColor }, children: comment.author }),
1911
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-zinc-700 dark:text-zinc-200 whitespace-pre-wrap", children: comment.text })
1912
+ ]
1913
+ }
1914
+ )
1915
+ ]
1877
1916
  }
1878
1917
  );
1879
1918
  });