@particle-academy/fancy-sheets 0.4.3 → 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 CHANGED
@@ -2204,7 +2204,18 @@ function DefaultToolbar() {
2204
2204
  const isItalic = cell?.format?.italic ?? false;
2205
2205
  const textAlign = cell?.format?.textAlign ?? "left";
2206
2206
  const displayFormat = cell?.format?.displayFormat ?? "auto";
2207
- const decimals = cell?.format?.decimals;
2207
+ const explicitDecimals = cell?.format?.decimals;
2208
+ const cellValue = cell?.computedValue ?? cell?.value;
2209
+ const inferredDecimals = (() => {
2210
+ if (explicitDecimals !== void 0) return explicitDecimals;
2211
+ if (typeof cellValue === "number") {
2212
+ const str = String(cellValue);
2213
+ const dotIdx = str.indexOf(".");
2214
+ return dotIdx === -1 ? 0 : str.length - dotIdx - 1;
2215
+ }
2216
+ return 0;
2217
+ })();
2218
+ const currentDecimals = explicitDecimals ?? inferredDecimals;
2208
2219
  const selectedAddresses = [selection.activeCell];
2209
2220
  const handleFormulaBarChange = (e) => {
2210
2221
  if (editingCell) {
@@ -2341,9 +2352,9 @@ function DefaultToolbar() {
2341
2352
  "button",
2342
2353
  {
2343
2354
  className: btnClass,
2344
- onClick: () => setCellFormat(selectedAddresses, { decimals: Math.max(0, (decimals ?? 0) - 1) }),
2345
- disabled: readOnly || (decimals ?? 0) <= 0,
2346
- title: "Decrease decimal places",
2355
+ onClick: () => setCellFormat(selectedAddresses, { decimals: Math.max(0, currentDecimals - 1) }),
2356
+ disabled: readOnly || currentDecimals <= 0,
2357
+ title: `Decrease decimal places (currently ${currentDecimals})`,
2347
2358
  children: [
2348
2359
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px]", children: ".0" }),
2349
2360
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[8px]", children: "\u2190" })
@@ -2354,9 +2365,9 @@ function DefaultToolbar() {
2354
2365
  "button",
2355
2366
  {
2356
2367
  className: btnClass,
2357
- onClick: () => setCellFormat(selectedAddresses, { decimals: (decimals ?? 0) + 1 }),
2368
+ onClick: () => setCellFormat(selectedAddresses, { decimals: currentDecimals + 1 }),
2358
2369
  disabled: readOnly,
2359
- title: "Increase decimal places",
2370
+ title: `Increase decimal places (currently ${currentDecimals})`,
2360
2371
  children: [
2361
2372
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px]", children: ".00" }),
2362
2373
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[8px]", children: "\u2192" })