@smallwebco/tinypivot-react 1.0.26 → 1.0.27

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.js CHANGED
@@ -444,7 +444,9 @@ function usePivotTable(data) {
444
444
  }
445
445
  }, [availableFields, requirePro]);
446
446
  const addCalculatedField = useCallback3((field) => {
447
+ console.log("[usePivotTable] addCalculatedField called with:", field);
447
448
  setCalculatedFields((prev) => {
449
+ console.log("[usePivotTable] Previous calculatedFields:", prev);
448
450
  const existing = prev.findIndex((f) => f.id === field.id);
449
451
  let updated;
450
452
  if (existing >= 0) {
@@ -452,6 +454,7 @@ function usePivotTable(data) {
452
454
  } else {
453
455
  updated = [...prev, field];
454
456
  }
457
+ console.log("[usePivotTable] Updated calculatedFields:", updated);
455
458
  saveCalculatedFields(updated);
456
459
  return updated;
457
460
  });
@@ -1026,11 +1029,15 @@ function CalculatedFieldModal({
1026
1029
  });
1027
1030
  }, []);
1028
1031
  const handleSave = useCallback6(() => {
1032
+ console.log("[CalculatedFieldModal] handleSave called");
1033
+ console.log("[CalculatedFieldModal] name:", name, "formula:", formula);
1034
+ console.log("[CalculatedFieldModal] availableFields:", availableFields);
1029
1035
  if (!name.trim()) {
1030
1036
  setError("Name is required");
1031
1037
  return;
1032
1038
  }
1033
1039
  const validationResult = validateSimpleFormula(formula, availableFields);
1040
+ console.log("[CalculatedFieldModal] validationResult:", validationResult);
1034
1041
  if (validationResult) {
1035
1042
  setError(validationResult);
1036
1043
  return;
@@ -1042,6 +1049,7 @@ function CalculatedFieldModal({
1042
1049
  formatAs,
1043
1050
  decimals
1044
1051
  };
1052
+ console.log("[CalculatedFieldModal] Calling onSave with:", field);
1045
1053
  onSave(field);
1046
1054
  onClose();
1047
1055
  }, [name, formula, formatAs, decimals, existingField, availableFields, onSave, onClose]);
@@ -1202,8 +1210,9 @@ function PivotConfig({
1202
1210
  [availableFields]
1203
1211
  );
1204
1212
  const calculatedFieldsAsStats = useMemo7(() => {
1213
+ console.log("[PivotConfig] calculatedFields prop:", calculatedFields);
1205
1214
  if (!calculatedFields) return [];
1206
- return calculatedFields.map((calc) => ({
1215
+ const stats = calculatedFields.map((calc) => ({
1207
1216
  field: `calc:${calc.id}`,
1208
1217
  type: "number",
1209
1218
  uniqueCount: 0,
@@ -1213,11 +1222,17 @@ function PivotConfig({
1213
1222
  calcName: calc.name,
1214
1223
  calcFormula: calc.formula
1215
1224
  }));
1225
+ console.log("[PivotConfig] calculatedFieldsAsStats:", stats);
1226
+ return stats;
1216
1227
  }, [calculatedFields]);
1217
- const allAvailableFields = useMemo7(() => [
1218
- ...availableFields.map((f) => ({ ...f, isCalculated: false })),
1219
- ...calculatedFieldsAsStats
1220
- ], [availableFields, calculatedFieldsAsStats]);
1228
+ const allAvailableFields = useMemo7(() => {
1229
+ const all = [
1230
+ ...availableFields.map((f) => ({ ...f, isCalculated: false })),
1231
+ ...calculatedFieldsAsStats
1232
+ ];
1233
+ console.log("[PivotConfig] allAvailableFields:", all.length, "items, calc fields:", calculatedFieldsAsStats.length);
1234
+ return all;
1235
+ }, [availableFields, calculatedFieldsAsStats]);
1221
1236
  const assignedFields = useMemo7(() => {
1222
1237
  const rowSet = new Set(rowFields);
1223
1238
  const colSet = new Set(columnFields);
@@ -1299,9 +1314,14 @@ function PivotConfig({
1299
1314
  setShowCalcModal(true);
1300
1315
  }, []);
1301
1316
  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);
1302
1320
  if (editingCalcField && onUpdateCalculatedField) {
1321
+ console.log("[PivotConfig] Calling onUpdateCalculatedField");
1303
1322
  onUpdateCalculatedField(field);
1304
1323
  } else if (onAddCalculatedField) {
1324
+ console.log("[PivotConfig] Calling onAddCalculatedField");
1305
1325
  onAddCalculatedField(field);
1306
1326
  }
1307
1327
  setShowCalcModal(false);