@particle-academy/fancy-sheets 0.4.3 → 0.4.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/dist/index.cjs +37 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1605,7 +1605,7 @@ function ColumnResizeHandle({ colIndex }) {
|
|
|
1605
1605
|
}
|
|
1606
1606
|
ColumnResizeHandle.displayName = "ColumnResizeHandle";
|
|
1607
1607
|
function ColumnHeaders() {
|
|
1608
|
-
const { columnCount, rowCount, rowHeight, getColumnWidth, selection, selectRange, _isDragging
|
|
1608
|
+
const { columnCount, rowCount, rowHeight, getColumnWidth, selection, selectRange, _isDragging } = useSpreadsheet();
|
|
1609
1609
|
const handleColumnMouseDown = useCallback(
|
|
1610
1610
|
(colIdx, e) => {
|
|
1611
1611
|
if (e.button !== 0) return;
|
|
@@ -1650,7 +1650,15 @@ function ColumnHeaders() {
|
|
|
1650
1650
|
}
|
|
1651
1651
|
),
|
|
1652
1652
|
Array.from({ length: columnCount }, (_, i) => {
|
|
1653
|
-
const isColSelected =
|
|
1653
|
+
const isColSelected = selection.ranges.some((range) => {
|
|
1654
|
+
const s = parseAddress(range.start);
|
|
1655
|
+
const e = parseAddress(range.end);
|
|
1656
|
+
const minCol = Math.min(s.col, e.col);
|
|
1657
|
+
const maxCol = Math.max(s.col, e.col);
|
|
1658
|
+
const minRow = Math.min(s.row, e.row);
|
|
1659
|
+
const maxRow = Math.max(s.row, e.row);
|
|
1660
|
+
return i >= minCol && i <= maxCol && minRow === 0 && maxRow >= rowCount - 1;
|
|
1661
|
+
});
|
|
1654
1662
|
return /* @__PURE__ */ jsxs(
|
|
1655
1663
|
"div",
|
|
1656
1664
|
{
|
|
@@ -1676,8 +1684,16 @@ function ColumnHeaders() {
|
|
|
1676
1684
|
}
|
|
1677
1685
|
ColumnHeaders.displayName = "ColumnHeaders";
|
|
1678
1686
|
function RowHeader({ rowIndex }) {
|
|
1679
|
-
const { rowHeight, columnCount, selection, selectRange, _isDragging
|
|
1680
|
-
const isRowSelected =
|
|
1687
|
+
const { rowHeight, columnCount, selection, selectRange, _isDragging } = useSpreadsheet();
|
|
1688
|
+
const isRowSelected = selection.ranges.some((range) => {
|
|
1689
|
+
const s = parseAddress(range.start);
|
|
1690
|
+
const e = parseAddress(range.end);
|
|
1691
|
+
const minRow = Math.min(s.row, e.row);
|
|
1692
|
+
const maxRow = Math.max(s.row, e.row);
|
|
1693
|
+
const minCol = Math.min(s.col, e.col);
|
|
1694
|
+
const maxCol = Math.max(s.col, e.col);
|
|
1695
|
+
return rowIndex >= minRow && rowIndex <= maxRow && minCol === 0 && maxCol >= columnCount - 1;
|
|
1696
|
+
});
|
|
1681
1697
|
const handleMouseDown = useCallback(
|
|
1682
1698
|
(e) => {
|
|
1683
1699
|
if (e.button !== 0) return;
|
|
@@ -2202,7 +2218,18 @@ function DefaultToolbar() {
|
|
|
2202
2218
|
const isItalic = cell?.format?.italic ?? false;
|
|
2203
2219
|
const textAlign = cell?.format?.textAlign ?? "left";
|
|
2204
2220
|
const displayFormat = cell?.format?.displayFormat ?? "auto";
|
|
2205
|
-
const
|
|
2221
|
+
const explicitDecimals = cell?.format?.decimals;
|
|
2222
|
+
const cellValue = cell?.computedValue ?? cell?.value;
|
|
2223
|
+
const inferredDecimals = (() => {
|
|
2224
|
+
if (explicitDecimals !== void 0) return explicitDecimals;
|
|
2225
|
+
if (typeof cellValue === "number") {
|
|
2226
|
+
const str = String(cellValue);
|
|
2227
|
+
const dotIdx = str.indexOf(".");
|
|
2228
|
+
return dotIdx === -1 ? 0 : str.length - dotIdx - 1;
|
|
2229
|
+
}
|
|
2230
|
+
return 0;
|
|
2231
|
+
})();
|
|
2232
|
+
const currentDecimals = explicitDecimals ?? inferredDecimals;
|
|
2206
2233
|
const selectedAddresses = [selection.activeCell];
|
|
2207
2234
|
const handleFormulaBarChange = (e) => {
|
|
2208
2235
|
if (editingCell) {
|
|
@@ -2339,9 +2366,9 @@ function DefaultToolbar() {
|
|
|
2339
2366
|
"button",
|
|
2340
2367
|
{
|
|
2341
2368
|
className: btnClass,
|
|
2342
|
-
onClick: () => setCellFormat(selectedAddresses, { decimals: Math.max(0,
|
|
2343
|
-
disabled: readOnly ||
|
|
2344
|
-
title:
|
|
2369
|
+
onClick: () => setCellFormat(selectedAddresses, { decimals: Math.max(0, currentDecimals - 1) }),
|
|
2370
|
+
disabled: readOnly || currentDecimals <= 0,
|
|
2371
|
+
title: `Decrease decimal places (currently ${currentDecimals})`,
|
|
2345
2372
|
children: [
|
|
2346
2373
|
/* @__PURE__ */ jsx("span", { className: "text-[10px]", children: ".0" }),
|
|
2347
2374
|
/* @__PURE__ */ jsx("span", { className: "text-[8px]", children: "\u2190" })
|
|
@@ -2352,9 +2379,9 @@ function DefaultToolbar() {
|
|
|
2352
2379
|
"button",
|
|
2353
2380
|
{
|
|
2354
2381
|
className: btnClass,
|
|
2355
|
-
onClick: () => setCellFormat(selectedAddresses, { decimals:
|
|
2382
|
+
onClick: () => setCellFormat(selectedAddresses, { decimals: currentDecimals + 1 }),
|
|
2356
2383
|
disabled: readOnly,
|
|
2357
|
-
title:
|
|
2384
|
+
title: `Increase decimal places (currently ${currentDecimals})`,
|
|
2358
2385
|
children: [
|
|
2359
2386
|
/* @__PURE__ */ jsx("span", { className: "text-[10px]", children: ".00" }),
|
|
2360
2387
|
/* @__PURE__ */ jsx("span", { className: "text-[8px]", children: "\u2192" })
|