@particle-academy/fancy-sheets 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +46 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +48 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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);
|
|
@@ -1838,7 +1839,10 @@ var Cell = react.memo(function Cell2({ address, row, col }) {
|
|
|
1838
1839
|
if (cell?.format?.bold) formatStyle.fontWeight = "bold";
|
|
1839
1840
|
if (cell?.format?.italic) formatStyle.fontStyle = "italic";
|
|
1840
1841
|
if (cell?.format?.textAlign) formatStyle.textAlign = cell.format.textAlign;
|
|
1841
|
-
if (cell?.format?.backgroundColor)
|
|
1842
|
+
if (cell?.format?.backgroundColor) {
|
|
1843
|
+
formatStyle.backgroundColor = cell.format.backgroundColor;
|
|
1844
|
+
if (!cell.format.color) formatStyle.color = "#1f2937";
|
|
1845
|
+
}
|
|
1842
1846
|
if (cell?.format?.color) formatStyle.color = cell.format.color;
|
|
1843
1847
|
if (cell?.format?.fontSize) formatStyle.fontSize = cell.format.fontSize;
|
|
1844
1848
|
if (cell?.format?.borderTop) {
|
|
@@ -1853,7 +1857,15 @@ var Cell = react.memo(function Cell2({ address, row, col }) {
|
|
|
1853
1857
|
formatStyle.borderLeftStyle = "solid";
|
|
1854
1858
|
formatStyle.borderLeftColor = cell.format.borderLeft;
|
|
1855
1859
|
}
|
|
1856
|
-
|
|
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(
|
|
1857
1869
|
"div",
|
|
1858
1870
|
{
|
|
1859
1871
|
"data-fancy-sheets-cell": "",
|
|
@@ -1867,10 +1879,40 @@ var Cell = react.memo(function Cell2({ address, row, col }) {
|
|
|
1867
1879
|
),
|
|
1868
1880
|
style: { width, minWidth: width, height: rowHeight, ...formatStyle },
|
|
1869
1881
|
onMouseDown: handleMouseDown,
|
|
1870
|
-
onMouseEnter:
|
|
1882
|
+
onMouseEnter: (e) => {
|
|
1883
|
+
handleMouseEnter();
|
|
1884
|
+
if (comment) setShowComment(true);
|
|
1885
|
+
},
|
|
1871
1886
|
onMouseUp: handleMouseUp,
|
|
1887
|
+
onMouseLeave: () => {
|
|
1888
|
+
if (comment) setShowComment(false);
|
|
1889
|
+
},
|
|
1872
1890
|
onDoubleClick: handleDoubleClick,
|
|
1873
|
-
children:
|
|
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
|
+
]
|
|
1874
1916
|
}
|
|
1875
1917
|
);
|
|
1876
1918
|
});
|