@smallwebco/tinypivot-react 1.0.38 → 1.0.48
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 +60 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +60 -17
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -445,12 +445,11 @@ function usePivotTable(data) {
|
|
|
445
445
|
}, [currentStorageKey, rowFields, columnFields, valueFields, showRowTotals, showColumnTotals, calculatedFields]);
|
|
446
446
|
const addRowField = (0, import_react3.useCallback)(
|
|
447
447
|
(field) => {
|
|
448
|
-
if (!requirePro("Pivot Table - Row Fields")) return;
|
|
449
448
|
if (!rowFields.includes(field)) {
|
|
450
449
|
setRowFieldsState((prev) => [...prev, field]);
|
|
451
450
|
}
|
|
452
451
|
},
|
|
453
|
-
[rowFields
|
|
452
|
+
[rowFields]
|
|
454
453
|
);
|
|
455
454
|
const removeRowField = (0, import_react3.useCallback)((field) => {
|
|
456
455
|
setRowFieldsState((prev) => prev.filter((f) => f !== field));
|
|
@@ -460,12 +459,11 @@ function usePivotTable(data) {
|
|
|
460
459
|
}, []);
|
|
461
460
|
const addColumnField = (0, import_react3.useCallback)(
|
|
462
461
|
(field) => {
|
|
463
|
-
if (!requirePro("Pivot Table - Column Fields")) return;
|
|
464
462
|
if (!columnFields.includes(field)) {
|
|
465
463
|
setColumnFieldsState((prev) => [...prev, field]);
|
|
466
464
|
}
|
|
467
465
|
},
|
|
468
|
-
[columnFields
|
|
466
|
+
[columnFields]
|
|
469
467
|
);
|
|
470
468
|
const removeColumnField = (0, import_react3.useCallback)((field) => {
|
|
471
469
|
setColumnFieldsState((prev) => prev.filter((f) => f !== field));
|
|
@@ -475,7 +473,9 @@ function usePivotTable(data) {
|
|
|
475
473
|
}, []);
|
|
476
474
|
const addValueField = (0, import_react3.useCallback)(
|
|
477
475
|
(field, aggregation = "sum") => {
|
|
478
|
-
if (!requirePro(
|
|
476
|
+
if (aggregation !== "sum" && !requirePro(`${aggregation} aggregation`)) {
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
479
|
setValueFields((prev) => {
|
|
480
480
|
if (prev.some((v) => v.field === field && v.aggregation === aggregation)) {
|
|
481
481
|
return prev;
|
|
@@ -1547,11 +1547,15 @@ function CalculatedFieldModal({
|
|
|
1547
1547
|
] })
|
|
1548
1548
|
] })
|
|
1549
1549
|
] }) });
|
|
1550
|
+
if (typeof document === "undefined") return null;
|
|
1550
1551
|
return (0, import_react_dom.createPortal)(modalContent, document.body);
|
|
1551
1552
|
}
|
|
1552
1553
|
|
|
1553
1554
|
// src/components/PivotConfig.tsx
|
|
1554
1555
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1556
|
+
function aggregationRequiresPro(agg) {
|
|
1557
|
+
return agg !== "sum";
|
|
1558
|
+
}
|
|
1555
1559
|
function getFieldIcon(type, isCalculated) {
|
|
1556
1560
|
if (isCalculated) return "\u0192";
|
|
1557
1561
|
switch (type) {
|
|
@@ -1591,6 +1595,10 @@ function PivotConfig({
|
|
|
1591
1595
|
const [fieldSearch, setFieldSearch] = (0, import_react8.useState)("");
|
|
1592
1596
|
const [showCalcModal, setShowCalcModal] = (0, import_react8.useState)(false);
|
|
1593
1597
|
const [editingCalcField, setEditingCalcField] = (0, import_react8.useState)(null);
|
|
1598
|
+
const { canUseAdvancedAggregations } = useLicense();
|
|
1599
|
+
const isAggregationAvailable = (0, import_react8.useCallback)((agg) => {
|
|
1600
|
+
return !aggregationRequiresPro(agg) || canUseAdvancedAggregations;
|
|
1601
|
+
}, [canUseAdvancedAggregations]);
|
|
1594
1602
|
const numericFieldNames = (0, import_react8.useMemo)(
|
|
1595
1603
|
() => availableFields.filter((f) => f.isNumeric).map((f) => f.field),
|
|
1596
1604
|
[availableFields]
|
|
@@ -1656,9 +1664,13 @@ function PivotConfig({
|
|
|
1656
1664
|
);
|
|
1657
1665
|
const handleAggregationChange = (0, import_react8.useCallback)(
|
|
1658
1666
|
(field, currentAgg, newAgg) => {
|
|
1667
|
+
if (!isAggregationAvailable(newAgg)) {
|
|
1668
|
+
console.warn(`[TinyPivot] "${newAgg}" aggregation requires a Pro license. Visit https://tiny-pivot.com/#pricing to upgrade.`);
|
|
1669
|
+
return;
|
|
1670
|
+
}
|
|
1659
1671
|
onUpdateAggregation(field, currentAgg, newAgg);
|
|
1660
1672
|
},
|
|
1661
|
-
[onUpdateAggregation]
|
|
1673
|
+
[onUpdateAggregation, isAggregationAvailable]
|
|
1662
1674
|
);
|
|
1663
1675
|
const toggleRowColumn = (0, import_react8.useCallback)(
|
|
1664
1676
|
(field, currentAssignment) => {
|
|
@@ -1796,11 +1808,20 @@ function PivotConfig({
|
|
|
1796
1808
|
);
|
|
1797
1809
|
},
|
|
1798
1810
|
onClick: (e) => e.stopPropagation(),
|
|
1799
|
-
children: import_tinypivot_core6.AGGREGATION_OPTIONS.map((agg) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1811
|
+
children: import_tinypivot_core6.AGGREGATION_OPTIONS.map((agg) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1812
|
+
"option",
|
|
1813
|
+
{
|
|
1814
|
+
value: agg.value,
|
|
1815
|
+
disabled: aggregationRequiresPro(agg.value) && !canUseAdvancedAggregations,
|
|
1816
|
+
children: [
|
|
1817
|
+
agg.symbol,
|
|
1818
|
+
" ",
|
|
1819
|
+
agg.label,
|
|
1820
|
+
aggregationRequiresPro(agg.value) && !canUseAdvancedAggregations ? " (Pro)" : ""
|
|
1821
|
+
]
|
|
1822
|
+
},
|
|
1823
|
+
agg.value
|
|
1824
|
+
))
|
|
1804
1825
|
}
|
|
1805
1826
|
),
|
|
1806
1827
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
@@ -2703,7 +2724,7 @@ function DataGrid({
|
|
|
2703
2724
|
onExport,
|
|
2704
2725
|
onCopy
|
|
2705
2726
|
}) {
|
|
2706
|
-
const { showWatermark, canUsePivot, isDemo } = useLicense();
|
|
2727
|
+
const { showWatermark, canUsePivot, isDemo, isPro } = useLicense();
|
|
2707
2728
|
const currentTheme = (0, import_react10.useMemo)(() => {
|
|
2708
2729
|
if (theme === "auto") {
|
|
2709
2730
|
return window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
@@ -2877,6 +2898,7 @@ function DataGrid({
|
|
|
2877
2898
|
return { count, sum, avg, numericCount: values.length };
|
|
2878
2899
|
}, [selectionBounds, rows, columnKeys]);
|
|
2879
2900
|
(0, import_react10.useEffect)(() => {
|
|
2901
|
+
if (typeof document === "undefined") return;
|
|
2880
2902
|
if (data.length === 0) return;
|
|
2881
2903
|
const widths = {};
|
|
2882
2904
|
const sampleSize = Math.min(100, data.length);
|
|
@@ -3409,11 +3431,11 @@ function DataGrid({
|
|
|
3409
3431
|
) })
|
|
3410
3432
|
}
|
|
3411
3433
|
),
|
|
3412
|
-
enableExport &&
|
|
3434
|
+
enableExport && viewMode === "grid" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
3413
3435
|
"button",
|
|
3414
3436
|
{
|
|
3415
3437
|
className: "vpg-export-btn",
|
|
3416
|
-
title:
|
|
3438
|
+
title: "Export to CSV",
|
|
3417
3439
|
onClick: handleExport,
|
|
3418
3440
|
children: [
|
|
3419
3441
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("svg", { className: "vpg-icon", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
@@ -3425,8 +3447,29 @@ function DataGrid({
|
|
|
3425
3447
|
d: "M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"
|
|
3426
3448
|
}
|
|
3427
3449
|
) }),
|
|
3428
|
-
"Export"
|
|
3429
|
-
|
|
3450
|
+
"Export"
|
|
3451
|
+
]
|
|
3452
|
+
}
|
|
3453
|
+
),
|
|
3454
|
+
enableExport && viewMode === "pivot" && pivotIsConfigured && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
3455
|
+
"button",
|
|
3456
|
+
{
|
|
3457
|
+
className: `vpg-export-btn ${!isPro ? "vpg-export-btn-disabled" : ""}`,
|
|
3458
|
+
disabled: !isPro,
|
|
3459
|
+
title: isPro ? "Export Pivot to CSV" : "Export Pivot to CSV (Pro feature)",
|
|
3460
|
+
onClick: () => isPro && handleExport(),
|
|
3461
|
+
children: [
|
|
3462
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("svg", { className: "vpg-icon", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3463
|
+
"path",
|
|
3464
|
+
{
|
|
3465
|
+
strokeLinecap: "round",
|
|
3466
|
+
strokeLinejoin: "round",
|
|
3467
|
+
strokeWidth: 2,
|
|
3468
|
+
d: "M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"
|
|
3469
|
+
}
|
|
3470
|
+
) }),
|
|
3471
|
+
"Export Pivot",
|
|
3472
|
+
!isPro ? " (Pro)" : ""
|
|
3430
3473
|
]
|
|
3431
3474
|
}
|
|
3432
3475
|
)
|
|
@@ -3775,7 +3818,7 @@ function DataGrid({
|
|
|
3775
3818
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", {}),
|
|
3776
3819
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", {})
|
|
3777
3820
|
] }) }),
|
|
3778
|
-
activeFilterColumn && (0, import_react_dom2.createPortal)(
|
|
3821
|
+
activeFilterColumn && typeof document !== "undefined" && (0, import_react_dom2.createPortal)(
|
|
3779
3822
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3780
3823
|
"div",
|
|
3781
3824
|
{
|