@particle-academy/fancy-sheets 0.4.2 → 0.4.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.cjs +31 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +31 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1235,10 +1235,15 @@ function getRecalculationOrder(graph) {
|
|
|
1235
1235
|
|
|
1236
1236
|
// src/hooks/use-spreadsheet-store.ts
|
|
1237
1237
|
function recalculateWorkbook(workbook) {
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
}
|
|
1238
|
+
const recalculated = [];
|
|
1239
|
+
for (const sheet of workbook.sheets) {
|
|
1240
|
+
recalculated.push(recalculateSheet(sheet, recalculated));
|
|
1241
|
+
}
|
|
1242
|
+
const finalSheets = [];
|
|
1243
|
+
for (const sheet of recalculated) {
|
|
1244
|
+
finalSheets.push(recalculateSheet(sheet, recalculated));
|
|
1245
|
+
}
|
|
1246
|
+
return { ...workbook, sheets: finalSheets };
|
|
1242
1247
|
}
|
|
1243
1248
|
function createInitialState(data) {
|
|
1244
1249
|
const workbook = data ?? createEmptyWorkbook();
|
|
@@ -1338,10 +1343,11 @@ function reducer(state, action) {
|
|
|
1338
1343
|
const sheet = getActiveSheet(state);
|
|
1339
1344
|
const existing = sheet.cells[action.address];
|
|
1340
1345
|
if (existing?.format) cellData.format = existing.format;
|
|
1341
|
-
const
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
});
|
|
1346
|
+
const updatedWorkbook = updateActiveSheet(state, (s) => ({
|
|
1347
|
+
...s,
|
|
1348
|
+
cells: { ...s.cells, [action.address]: cellData }
|
|
1349
|
+
}));
|
|
1350
|
+
const workbook = recalculateWorkbook(updatedWorkbook);
|
|
1345
1351
|
return { ...state, workbook, ...history };
|
|
1346
1352
|
}
|
|
1347
1353
|
case "SET_CELL_FORMAT": {
|
|
@@ -2196,7 +2202,18 @@ function DefaultToolbar() {
|
|
|
2196
2202
|
const isItalic = cell?.format?.italic ?? false;
|
|
2197
2203
|
const textAlign = cell?.format?.textAlign ?? "left";
|
|
2198
2204
|
const displayFormat = cell?.format?.displayFormat ?? "auto";
|
|
2199
|
-
const
|
|
2205
|
+
const explicitDecimals = cell?.format?.decimals;
|
|
2206
|
+
const cellValue = cell?.computedValue ?? cell?.value;
|
|
2207
|
+
const inferredDecimals = (() => {
|
|
2208
|
+
if (explicitDecimals !== void 0) return explicitDecimals;
|
|
2209
|
+
if (typeof cellValue === "number") {
|
|
2210
|
+
const str = String(cellValue);
|
|
2211
|
+
const dotIdx = str.indexOf(".");
|
|
2212
|
+
return dotIdx === -1 ? 0 : str.length - dotIdx - 1;
|
|
2213
|
+
}
|
|
2214
|
+
return 0;
|
|
2215
|
+
})();
|
|
2216
|
+
const currentDecimals = explicitDecimals ?? inferredDecimals;
|
|
2200
2217
|
const selectedAddresses = [selection.activeCell];
|
|
2201
2218
|
const handleFormulaBarChange = (e) => {
|
|
2202
2219
|
if (editingCell) {
|
|
@@ -2333,9 +2350,9 @@ function DefaultToolbar() {
|
|
|
2333
2350
|
"button",
|
|
2334
2351
|
{
|
|
2335
2352
|
className: btnClass,
|
|
2336
|
-
onClick: () => setCellFormat(selectedAddresses, { decimals: Math.max(0,
|
|
2337
|
-
disabled: readOnly ||
|
|
2338
|
-
title:
|
|
2353
|
+
onClick: () => setCellFormat(selectedAddresses, { decimals: Math.max(0, currentDecimals - 1) }),
|
|
2354
|
+
disabled: readOnly || currentDecimals <= 0,
|
|
2355
|
+
title: `Decrease decimal places (currently ${currentDecimals})`,
|
|
2339
2356
|
children: [
|
|
2340
2357
|
/* @__PURE__ */ jsx("span", { className: "text-[10px]", children: ".0" }),
|
|
2341
2358
|
/* @__PURE__ */ jsx("span", { className: "text-[8px]", children: "\u2190" })
|
|
@@ -2346,9 +2363,9 @@ function DefaultToolbar() {
|
|
|
2346
2363
|
"button",
|
|
2347
2364
|
{
|
|
2348
2365
|
className: btnClass,
|
|
2349
|
-
onClick: () => setCellFormat(selectedAddresses, { decimals:
|
|
2366
|
+
onClick: () => setCellFormat(selectedAddresses, { decimals: currentDecimals + 1 }),
|
|
2350
2367
|
disabled: readOnly,
|
|
2351
|
-
title:
|
|
2368
|
+
title: `Increase decimal places (currently ${currentDecimals})`,
|
|
2352
2369
|
children: [
|
|
2353
2370
|
/* @__PURE__ */ jsx("span", { className: "text-[10px]", children: ".00" }),
|
|
2354
2371
|
/* @__PURE__ */ jsx("span", { className: "text-[8px]", children: "\u2192" })
|