@smallwebco/tinypivot-react 1.0.48 → 1.0.49

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
@@ -2320,6 +2320,14 @@ function PivotSkeleton({
2320
2320
  [reorderDropTarget]
2321
2321
  );
2322
2322
  const currentFontSize = fontSize;
2323
+ const rowHeaderWidth = 180;
2324
+ const rowHeaderColWidth = (0, import_react9.useMemo)(() => {
2325
+ const numCols = Math.max(rowFields.length, 1);
2326
+ return Math.max(rowHeaderWidth / numCols, 80);
2327
+ }, [rowFields.length]);
2328
+ const getRowHeaderLeftOffset = (0, import_react9.useCallback)((fieldIdx) => {
2329
+ return fieldIdx * rowHeaderColWidth;
2330
+ }, [rowHeaderColWidth]);
2323
2331
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
2324
2332
  "div",
2325
2333
  {
@@ -2600,18 +2608,20 @@ function PivotSkeleton({
2600
2608
  ] }) }),
2601
2609
  isConfigured && pivotResult && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "vpg-table-container", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("table", { className: "vpg-pivot-table", children: [
2602
2610
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("thead", { children: columnHeaderCells.map((headerRow, levelIdx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("tr", { className: "vpg-column-header-row", children: [
2603
- levelIdx === 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2611
+ levelIdx === 0 && (rowFields.length > 0 ? rowFields : ["Rows"]).map((field, fieldIdx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2604
2612
  "th",
2605
2613
  {
2606
2614
  className: "vpg-row-header-label",
2607
2615
  rowSpan: columnHeaderCells.length,
2616
+ style: { width: `${rowHeaderColWidth}px`, minWidth: "80px", left: `${getRowHeaderLeftOffset(fieldIdx)}px` },
2608
2617
  onClick: () => toggleSort("row"),
2609
2618
  children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "vpg-header-content", children: [
2610
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: rowFields.join(" / ") || "Rows" }),
2611
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: `vpg-sort-indicator ${sortTarget === "row" ? "active" : ""}`, children: sortTarget === "row" ? sortDirection === "asc" ? "\u2191" : "\u2193" : "\u21C5" })
2619
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: field }),
2620
+ (fieldIdx === rowFields.length - 1 || rowFields.length === 0) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: `vpg-sort-indicator ${sortTarget === "row" ? "active" : ""}`, children: sortTarget === "row" ? sortDirection === "asc" ? "\u2191" : "\u2193" : "\u21C5" })
2612
2621
  ] })
2613
- }
2614
- ),
2622
+ },
2623
+ `row-header-${fieldIdx}`
2624
+ )),
2615
2625
  headerRow.map((cell, idx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2616
2626
  "th",
2617
2627
  {
@@ -2629,7 +2639,15 @@ function PivotSkeleton({
2629
2639
  ] }, `header-${levelIdx}`)) }),
2630
2640
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("tbody", { children: [
2631
2641
  sortedRowIndices.map((sortedIdx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("tr", { className: "vpg-data-row", children: [
2632
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("th", { className: "vpg-row-header-cell", children: pivotResult.rowHeaders[sortedIdx].map((val, idx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "vpg-row-value", children: val }, idx)) }),
2642
+ pivotResult.rowHeaders[sortedIdx].map((val, idx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2643
+ "th",
2644
+ {
2645
+ className: "vpg-row-header-cell",
2646
+ style: { width: `${rowHeaderColWidth}px`, minWidth: "80px", left: `${getRowHeaderLeftOffset(idx)}px` },
2647
+ children: val
2648
+ },
2649
+ `row-${sortedIdx}-${idx}`
2650
+ )),
2633
2651
  pivotResult.data[sortedIdx].map((cell, colIdx) => {
2634
2652
  const displayRowIdx = sortedRowIndices.indexOf(sortedIdx);
2635
2653
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
@@ -2646,7 +2664,15 @@ function PivotSkeleton({
2646
2664
  pivotResult.rowTotals[sortedIdx] && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "vpg-data-cell vpg-total-cell", children: pivotResult.rowTotals[sortedIdx].formattedValue })
2647
2665
  ] }, sortedIdx)),
2648
2666
  pivotResult.columnTotals.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("tr", { className: "vpg-totals-row", children: [
2649
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("th", { className: "vpg-row-header-cell vpg-total-label", children: "Total" }),
2667
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2668
+ "th",
2669
+ {
2670
+ className: "vpg-row-header-cell vpg-total-label",
2671
+ colSpan: Math.max(rowFields.length, 1),
2672
+ style: { width: `${rowHeaderWidth}px` },
2673
+ children: "Total"
2674
+ }
2675
+ ),
2650
2676
  pivotResult.columnTotals.map((cell, colIdx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "vpg-data-cell vpg-total-cell", children: cell.formattedValue }, colIdx)),
2651
2677
  pivotResult.rowTotals.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "vpg-data-cell vpg-grand-total-cell", children: pivotResult.grandTotal.formattedValue })
2652
2678
  ] })