@smallwebco/tinypivot-react 1.0.47 → 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 +57 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +57 -16
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -425,12 +425,11 @@ function usePivotTable(data) {
|
|
|
425
425
|
}, [currentStorageKey, rowFields, columnFields, valueFields, showRowTotals, showColumnTotals, calculatedFields]);
|
|
426
426
|
const addRowField = useCallback3(
|
|
427
427
|
(field) => {
|
|
428
|
-
if (!requirePro("Pivot Table - Row Fields")) return;
|
|
429
428
|
if (!rowFields.includes(field)) {
|
|
430
429
|
setRowFieldsState((prev) => [...prev, field]);
|
|
431
430
|
}
|
|
432
431
|
},
|
|
433
|
-
[rowFields
|
|
432
|
+
[rowFields]
|
|
434
433
|
);
|
|
435
434
|
const removeRowField = useCallback3((field) => {
|
|
436
435
|
setRowFieldsState((prev) => prev.filter((f) => f !== field));
|
|
@@ -440,12 +439,11 @@ function usePivotTable(data) {
|
|
|
440
439
|
}, []);
|
|
441
440
|
const addColumnField = useCallback3(
|
|
442
441
|
(field) => {
|
|
443
|
-
if (!requirePro("Pivot Table - Column Fields")) return;
|
|
444
442
|
if (!columnFields.includes(field)) {
|
|
445
443
|
setColumnFieldsState((prev) => [...prev, field]);
|
|
446
444
|
}
|
|
447
445
|
},
|
|
448
|
-
[columnFields
|
|
446
|
+
[columnFields]
|
|
449
447
|
);
|
|
450
448
|
const removeColumnField = useCallback3((field) => {
|
|
451
449
|
setColumnFieldsState((prev) => prev.filter((f) => f !== field));
|
|
@@ -455,7 +453,9 @@ function usePivotTable(data) {
|
|
|
455
453
|
}, []);
|
|
456
454
|
const addValueField = useCallback3(
|
|
457
455
|
(field, aggregation = "sum") => {
|
|
458
|
-
if (!requirePro(
|
|
456
|
+
if (aggregation !== "sum" && !requirePro(`${aggregation} aggregation`)) {
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
459
|
setValueFields((prev) => {
|
|
460
460
|
if (prev.some((v) => v.field === field && v.aggregation === aggregation)) {
|
|
461
461
|
return prev;
|
|
@@ -1538,6 +1538,9 @@ function CalculatedFieldModal({
|
|
|
1538
1538
|
|
|
1539
1539
|
// src/components/PivotConfig.tsx
|
|
1540
1540
|
import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1541
|
+
function aggregationRequiresPro(agg) {
|
|
1542
|
+
return agg !== "sum";
|
|
1543
|
+
}
|
|
1541
1544
|
function getFieldIcon(type, isCalculated) {
|
|
1542
1545
|
if (isCalculated) return "\u0192";
|
|
1543
1546
|
switch (type) {
|
|
@@ -1577,6 +1580,10 @@ function PivotConfig({
|
|
|
1577
1580
|
const [fieldSearch, setFieldSearch] = useState8("");
|
|
1578
1581
|
const [showCalcModal, setShowCalcModal] = useState8(false);
|
|
1579
1582
|
const [editingCalcField, setEditingCalcField] = useState8(null);
|
|
1583
|
+
const { canUseAdvancedAggregations } = useLicense();
|
|
1584
|
+
const isAggregationAvailable = useCallback8((agg) => {
|
|
1585
|
+
return !aggregationRequiresPro(agg) || canUseAdvancedAggregations;
|
|
1586
|
+
}, [canUseAdvancedAggregations]);
|
|
1580
1587
|
const numericFieldNames = useMemo8(
|
|
1581
1588
|
() => availableFields.filter((f) => f.isNumeric).map((f) => f.field),
|
|
1582
1589
|
[availableFields]
|
|
@@ -1642,9 +1649,13 @@ function PivotConfig({
|
|
|
1642
1649
|
);
|
|
1643
1650
|
const handleAggregationChange = useCallback8(
|
|
1644
1651
|
(field, currentAgg, newAgg) => {
|
|
1652
|
+
if (!isAggregationAvailable(newAgg)) {
|
|
1653
|
+
console.warn(`[TinyPivot] "${newAgg}" aggregation requires a Pro license. Visit https://tiny-pivot.com/#pricing to upgrade.`);
|
|
1654
|
+
return;
|
|
1655
|
+
}
|
|
1645
1656
|
onUpdateAggregation(field, currentAgg, newAgg);
|
|
1646
1657
|
},
|
|
1647
|
-
[onUpdateAggregation]
|
|
1658
|
+
[onUpdateAggregation, isAggregationAvailable]
|
|
1648
1659
|
);
|
|
1649
1660
|
const toggleRowColumn = useCallback8(
|
|
1650
1661
|
(field, currentAssignment) => {
|
|
@@ -1782,11 +1793,20 @@ function PivotConfig({
|
|
|
1782
1793
|
);
|
|
1783
1794
|
},
|
|
1784
1795
|
onClick: (e) => e.stopPropagation(),
|
|
1785
|
-
children: AGGREGATION_OPTIONS.map((agg) => /* @__PURE__ */ jsxs4(
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1796
|
+
children: AGGREGATION_OPTIONS.map((agg) => /* @__PURE__ */ jsxs4(
|
|
1797
|
+
"option",
|
|
1798
|
+
{
|
|
1799
|
+
value: agg.value,
|
|
1800
|
+
disabled: aggregationRequiresPro(agg.value) && !canUseAdvancedAggregations,
|
|
1801
|
+
children: [
|
|
1802
|
+
agg.symbol,
|
|
1803
|
+
" ",
|
|
1804
|
+
agg.label,
|
|
1805
|
+
aggregationRequiresPro(agg.value) && !canUseAdvancedAggregations ? " (Pro)" : ""
|
|
1806
|
+
]
|
|
1807
|
+
},
|
|
1808
|
+
agg.value
|
|
1809
|
+
))
|
|
1790
1810
|
}
|
|
1791
1811
|
),
|
|
1792
1812
|
/* @__PURE__ */ jsx4(
|
|
@@ -2689,7 +2709,7 @@ function DataGrid({
|
|
|
2689
2709
|
onExport,
|
|
2690
2710
|
onCopy
|
|
2691
2711
|
}) {
|
|
2692
|
-
const { showWatermark, canUsePivot, isDemo } = useLicense();
|
|
2712
|
+
const { showWatermark, canUsePivot, isDemo, isPro } = useLicense();
|
|
2693
2713
|
const currentTheme = useMemo10(() => {
|
|
2694
2714
|
if (theme === "auto") {
|
|
2695
2715
|
return window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
@@ -3396,11 +3416,11 @@ function DataGrid({
|
|
|
3396
3416
|
) })
|
|
3397
3417
|
}
|
|
3398
3418
|
),
|
|
3399
|
-
enableExport &&
|
|
3419
|
+
enableExport && viewMode === "grid" && /* @__PURE__ */ jsxs6(
|
|
3400
3420
|
"button",
|
|
3401
3421
|
{
|
|
3402
3422
|
className: "vpg-export-btn",
|
|
3403
|
-
title:
|
|
3423
|
+
title: "Export to CSV",
|
|
3404
3424
|
onClick: handleExport,
|
|
3405
3425
|
children: [
|
|
3406
3426
|
/* @__PURE__ */ jsx6("svg", { className: "vpg-icon", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx6(
|
|
@@ -3412,8 +3432,29 @@ function DataGrid({
|
|
|
3412
3432
|
d: "M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"
|
|
3413
3433
|
}
|
|
3414
3434
|
) }),
|
|
3415
|
-
"Export"
|
|
3416
|
-
|
|
3435
|
+
"Export"
|
|
3436
|
+
]
|
|
3437
|
+
}
|
|
3438
|
+
),
|
|
3439
|
+
enableExport && viewMode === "pivot" && pivotIsConfigured && /* @__PURE__ */ jsxs6(
|
|
3440
|
+
"button",
|
|
3441
|
+
{
|
|
3442
|
+
className: `vpg-export-btn ${!isPro ? "vpg-export-btn-disabled" : ""}`,
|
|
3443
|
+
disabled: !isPro,
|
|
3444
|
+
title: isPro ? "Export Pivot to CSV" : "Export Pivot to CSV (Pro feature)",
|
|
3445
|
+
onClick: () => isPro && handleExport(),
|
|
3446
|
+
children: [
|
|
3447
|
+
/* @__PURE__ */ jsx6("svg", { className: "vpg-icon", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx6(
|
|
3448
|
+
"path",
|
|
3449
|
+
{
|
|
3450
|
+
strokeLinecap: "round",
|
|
3451
|
+
strokeLinejoin: "round",
|
|
3452
|
+
strokeWidth: 2,
|
|
3453
|
+
d: "M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"
|
|
3454
|
+
}
|
|
3455
|
+
) }),
|
|
3456
|
+
"Export Pivot",
|
|
3457
|
+
!isPro ? " (Pro)" : ""
|
|
3417
3458
|
]
|
|
3418
3459
|
}
|
|
3419
3460
|
)
|