@smallwebco/tinypivot-react 1.0.27 → 1.0.28
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 +22 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +22 -29
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -98,6 +98,7 @@ interface PivotSkeletonProps {
|
|
|
98
98
|
rowFields: string[];
|
|
99
99
|
columnFields: string[];
|
|
100
100
|
valueFields: PivotValueField[];
|
|
101
|
+
calculatedFields?: CalculatedField[];
|
|
101
102
|
isConfigured: boolean;
|
|
102
103
|
draggingField: string | null;
|
|
103
104
|
pivotResult: PivotResult | null;
|
|
@@ -115,7 +116,7 @@ interface PivotSkeletonProps {
|
|
|
115
116
|
onReorderRowFields: (fields: string[]) => void;
|
|
116
117
|
onReorderColumnFields: (fields: string[]) => void;
|
|
117
118
|
}
|
|
118
|
-
declare function PivotSkeleton({ rowFields, columnFields, valueFields, isConfigured, draggingField, pivotResult, fontSize, activeFilters, totalRowCount, filteredRowCount, onAddRowField, onRemoveRowField, onAddColumnField, onRemoveColumnField, onAddValueField, onRemoveValueField, onReorderRowFields, onReorderColumnFields, }: PivotSkeletonProps): react_jsx_runtime.JSX.Element;
|
|
119
|
+
declare function PivotSkeleton({ rowFields, columnFields, valueFields, calculatedFields, isConfigured, draggingField, pivotResult, fontSize, activeFilters, totalRowCount, filteredRowCount, onAddRowField, onRemoveRowField, onAddColumnField, onRemoveColumnField, onAddValueField, onRemoveValueField, onReorderRowFields, onReorderColumnFields, }: PivotSkeletonProps): react_jsx_runtime.JSX.Element;
|
|
119
120
|
|
|
120
121
|
interface ExcelGridOptions<T> {
|
|
121
122
|
data: T[];
|
package/dist/index.d.ts
CHANGED
|
@@ -98,6 +98,7 @@ interface PivotSkeletonProps {
|
|
|
98
98
|
rowFields: string[];
|
|
99
99
|
columnFields: string[];
|
|
100
100
|
valueFields: PivotValueField[];
|
|
101
|
+
calculatedFields?: CalculatedField[];
|
|
101
102
|
isConfigured: boolean;
|
|
102
103
|
draggingField: string | null;
|
|
103
104
|
pivotResult: PivotResult | null;
|
|
@@ -115,7 +116,7 @@ interface PivotSkeletonProps {
|
|
|
115
116
|
onReorderRowFields: (fields: string[]) => void;
|
|
116
117
|
onReorderColumnFields: (fields: string[]) => void;
|
|
117
118
|
}
|
|
118
|
-
declare function PivotSkeleton({ rowFields, columnFields, valueFields, isConfigured, draggingField, pivotResult, fontSize, activeFilters, totalRowCount, filteredRowCount, onAddRowField, onRemoveRowField, onAddColumnField, onRemoveColumnField, onAddValueField, onRemoveValueField, onReorderRowFields, onReorderColumnFields, }: PivotSkeletonProps): react_jsx_runtime.JSX.Element;
|
|
119
|
+
declare function PivotSkeleton({ rowFields, columnFields, valueFields, calculatedFields, isConfigured, draggingField, pivotResult, fontSize, activeFilters, totalRowCount, filteredRowCount, onAddRowField, onRemoveRowField, onAddColumnField, onRemoveColumnField, onAddValueField, onRemoveValueField, onReorderRowFields, onReorderColumnFields, }: PivotSkeletonProps): react_jsx_runtime.JSX.Element;
|
|
119
120
|
|
|
120
121
|
interface ExcelGridOptions<T> {
|
|
121
122
|
data: T[];
|
package/dist/index.js
CHANGED
|
@@ -444,9 +444,7 @@ function usePivotTable(data) {
|
|
|
444
444
|
}
|
|
445
445
|
}, [availableFields, requirePro]);
|
|
446
446
|
const addCalculatedField = useCallback3((field) => {
|
|
447
|
-
console.log("[usePivotTable] addCalculatedField called with:", field);
|
|
448
447
|
setCalculatedFields((prev) => {
|
|
449
|
-
console.log("[usePivotTable] Previous calculatedFields:", prev);
|
|
450
448
|
const existing = prev.findIndex((f) => f.id === field.id);
|
|
451
449
|
let updated;
|
|
452
450
|
if (existing >= 0) {
|
|
@@ -454,7 +452,6 @@ function usePivotTable(data) {
|
|
|
454
452
|
} else {
|
|
455
453
|
updated = [...prev, field];
|
|
456
454
|
}
|
|
457
|
-
console.log("[usePivotTable] Updated calculatedFields:", updated);
|
|
458
455
|
saveCalculatedFields(updated);
|
|
459
456
|
return updated;
|
|
460
457
|
});
|
|
@@ -1029,15 +1026,11 @@ function CalculatedFieldModal({
|
|
|
1029
1026
|
});
|
|
1030
1027
|
}, []);
|
|
1031
1028
|
const handleSave = useCallback6(() => {
|
|
1032
|
-
console.log("[CalculatedFieldModal] handleSave called");
|
|
1033
|
-
console.log("[CalculatedFieldModal] name:", name, "formula:", formula);
|
|
1034
|
-
console.log("[CalculatedFieldModal] availableFields:", availableFields);
|
|
1035
1029
|
if (!name.trim()) {
|
|
1036
1030
|
setError("Name is required");
|
|
1037
1031
|
return;
|
|
1038
1032
|
}
|
|
1039
1033
|
const validationResult = validateSimpleFormula(formula, availableFields);
|
|
1040
|
-
console.log("[CalculatedFieldModal] validationResult:", validationResult);
|
|
1041
1034
|
if (validationResult) {
|
|
1042
1035
|
setError(validationResult);
|
|
1043
1036
|
return;
|
|
@@ -1049,7 +1042,6 @@ function CalculatedFieldModal({
|
|
|
1049
1042
|
formatAs,
|
|
1050
1043
|
decimals
|
|
1051
1044
|
};
|
|
1052
|
-
console.log("[CalculatedFieldModal] Calling onSave with:", field);
|
|
1053
1045
|
onSave(field);
|
|
1054
1046
|
onClose();
|
|
1055
1047
|
}, [name, formula, formatAs, decimals, existingField, availableFields, onSave, onClose]);
|
|
@@ -1210,9 +1202,8 @@ function PivotConfig({
|
|
|
1210
1202
|
[availableFields]
|
|
1211
1203
|
);
|
|
1212
1204
|
const calculatedFieldsAsStats = useMemo7(() => {
|
|
1213
|
-
console.log("[PivotConfig] calculatedFields prop:", calculatedFields);
|
|
1214
1205
|
if (!calculatedFields) return [];
|
|
1215
|
-
|
|
1206
|
+
return calculatedFields.map((calc) => ({
|
|
1216
1207
|
field: `calc:${calc.id}`,
|
|
1217
1208
|
type: "number",
|
|
1218
1209
|
uniqueCount: 0,
|
|
@@ -1222,17 +1213,11 @@ function PivotConfig({
|
|
|
1222
1213
|
calcName: calc.name,
|
|
1223
1214
|
calcFormula: calc.formula
|
|
1224
1215
|
}));
|
|
1225
|
-
console.log("[PivotConfig] calculatedFieldsAsStats:", stats);
|
|
1226
|
-
return stats;
|
|
1227
1216
|
}, [calculatedFields]);
|
|
1228
|
-
const allAvailableFields = useMemo7(() =>
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
];
|
|
1233
|
-
console.log("[PivotConfig] allAvailableFields:", all.length, "items, calc fields:", calculatedFieldsAsStats.length);
|
|
1234
|
-
return all;
|
|
1235
|
-
}, [availableFields, calculatedFieldsAsStats]);
|
|
1217
|
+
const allAvailableFields = useMemo7(() => [
|
|
1218
|
+
...availableFields.map((f) => ({ ...f, isCalculated: false })),
|
|
1219
|
+
...calculatedFieldsAsStats
|
|
1220
|
+
], [availableFields, calculatedFieldsAsStats]);
|
|
1236
1221
|
const assignedFields = useMemo7(() => {
|
|
1237
1222
|
const rowSet = new Set(rowFields);
|
|
1238
1223
|
const colSet = new Set(columnFields);
|
|
@@ -1314,14 +1299,9 @@ function PivotConfig({
|
|
|
1314
1299
|
setShowCalcModal(true);
|
|
1315
1300
|
}, []);
|
|
1316
1301
|
const handleSaveCalcField = useCallback7((field) => {
|
|
1317
|
-
console.log("[PivotConfig] handleSaveCalcField called with:", field);
|
|
1318
|
-
console.log("[PivotConfig] editingCalcField:", editingCalcField);
|
|
1319
|
-
console.log("[PivotConfig] onAddCalculatedField exists:", !!onAddCalculatedField);
|
|
1320
1302
|
if (editingCalcField && onUpdateCalculatedField) {
|
|
1321
|
-
console.log("[PivotConfig] Calling onUpdateCalculatedField");
|
|
1322
1303
|
onUpdateCalculatedField(field);
|
|
1323
1304
|
} else if (onAddCalculatedField) {
|
|
1324
|
-
console.log("[PivotConfig] Calling onAddCalculatedField");
|
|
1325
1305
|
onAddCalculatedField(field);
|
|
1326
1306
|
}
|
|
1327
1307
|
setShowCalcModal(false);
|
|
@@ -1573,6 +1553,7 @@ function PivotSkeleton({
|
|
|
1573
1553
|
rowFields,
|
|
1574
1554
|
columnFields,
|
|
1575
1555
|
valueFields,
|
|
1556
|
+
calculatedFields,
|
|
1576
1557
|
isConfigured,
|
|
1577
1558
|
draggingField,
|
|
1578
1559
|
pivotResult,
|
|
@@ -1590,6 +1571,17 @@ function PivotSkeleton({
|
|
|
1590
1571
|
onReorderColumnFields
|
|
1591
1572
|
}) {
|
|
1592
1573
|
const { showWatermark, canUsePivot, isDemo } = useLicense();
|
|
1574
|
+
const getValueFieldDisplayName = useCallback8((field) => {
|
|
1575
|
+
if (field.startsWith("calc:")) {
|
|
1576
|
+
const calcId = field.replace("calc:", "");
|
|
1577
|
+
const calcField = calculatedFields?.find((c) => c.id === calcId);
|
|
1578
|
+
return calcField?.name || field;
|
|
1579
|
+
}
|
|
1580
|
+
return field;
|
|
1581
|
+
}, [calculatedFields]);
|
|
1582
|
+
const isCalculatedField = useCallback8((field) => {
|
|
1583
|
+
return field.startsWith("calc:");
|
|
1584
|
+
}, []);
|
|
1593
1585
|
const [dragOverArea, setDragOverArea] = useState8(null);
|
|
1594
1586
|
const [reorderDragSource, setReorderDragSource] = useState8(null);
|
|
1595
1587
|
const [reorderDropTarget, setReorderDropTarget] = useState8(null);
|
|
@@ -1631,7 +1623,7 @@ function PivotSkeleton({
|
|
|
1631
1623
|
if (!pivotResult || pivotResult.headers.length === 0) {
|
|
1632
1624
|
return [
|
|
1633
1625
|
valueFields.map((vf) => ({
|
|
1634
|
-
label: `${vf.field} (${getAggregationLabel2(vf.aggregation)})`,
|
|
1626
|
+
label: `${getValueFieldDisplayName(vf.field)} (${getAggregationLabel2(vf.aggregation)})`,
|
|
1635
1627
|
colspan: 1
|
|
1636
1628
|
}))
|
|
1637
1629
|
];
|
|
@@ -1999,10 +1991,10 @@ function PivotSkeleton({
|
|
|
1999
1991
|
valueFields.map((vf) => /* @__PURE__ */ jsxs4(
|
|
2000
1992
|
"div",
|
|
2001
1993
|
{
|
|
2002
|
-
className:
|
|
1994
|
+
className: `vpg-mini-chip vpg-value-chip${isCalculatedField(vf.field) ? " vpg-calc-chip" : ""}`,
|
|
2003
1995
|
children: [
|
|
2004
|
-
/* @__PURE__ */ jsx4("span", { className: "vpg-agg-symbol", children: getAggregationSymbol2(vf.aggregation) }),
|
|
2005
|
-
/* @__PURE__ */ jsx4("span", { className: "vpg-mini-name", children: vf.field }),
|
|
1996
|
+
/* @__PURE__ */ jsx4("span", { className: "vpg-agg-symbol", children: isCalculatedField(vf.field) ? "\u0192" : getAggregationSymbol2(vf.aggregation) }),
|
|
1997
|
+
/* @__PURE__ */ jsx4("span", { className: "vpg-mini-name", children: getValueFieldDisplayName(vf.field) }),
|
|
2006
1998
|
/* @__PURE__ */ jsx4(
|
|
2007
1999
|
"button",
|
|
2008
2000
|
{
|
|
@@ -3039,6 +3031,7 @@ function DataGrid({
|
|
|
3039
3031
|
rowFields: pivotRowFields,
|
|
3040
3032
|
columnFields: pivotColumnFields,
|
|
3041
3033
|
valueFields: pivotValueFields,
|
|
3034
|
+
calculatedFields: pivotCalculatedFields,
|
|
3042
3035
|
isConfigured: pivotIsConfigured,
|
|
3043
3036
|
draggingField,
|
|
3044
3037
|
pivotResult,
|