@quillsql/react 2.16.98 → 2.16.100

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
@@ -62437,14 +62437,48 @@ function createUseFormInitialLoadQueryKey(input) {
62437
62437
  ];
62438
62438
  }
62439
62439
  var DASHBOARD_REPORT_STALE_TIME_MS = 5 * 60 * 1e3;
62440
+ var DASHBOARD_REPORT_RESULT_FIELDS = [
62441
+ "rows",
62442
+ "compareRows",
62443
+ "pivotRows",
62444
+ "pivotColumns",
62445
+ "pivotRowCount"
62446
+ ];
62447
+ function dashboardReportQueryKey(reportId) {
62448
+ return ["quill", "dashboard-report", reportId];
62449
+ }
62450
+ function mergeSavedReportIntoDashboardQueryData(previous, saved) {
62451
+ const previousReport = previous?.report && typeof previous.report === "object" ? previous.report : void 0;
62452
+ const savedId = String(saved.id ?? saved._id ?? "").trim();
62453
+ const merged = {
62454
+ ...previousReport,
62455
+ ...saved,
62456
+ ...savedId ? { id: savedId } : {}
62457
+ };
62458
+ for (const field of DASHBOARD_REPORT_RESULT_FIELDS) {
62459
+ if (merged[field] == null && previousReport?.[field] != null) {
62460
+ merged[field] = previousReport[field];
62461
+ }
62462
+ }
62463
+ return { report: merged, error: void 0 };
62464
+ }
62440
62465
  function findCachedDashboardReportQuery(queryClient, reportId) {
62441
62466
  const id = String(reportId ?? "").trim();
62442
62467
  if (!id) return void 0;
62443
- return queryClient.getQueryCache().findAll({ queryKey: ["quill", "dashboard-report", id] }).find((query) => {
62468
+ return queryClient.getQueryCache().findAll({ queryKey: dashboardReportQueryKey(id) }).find((query) => {
62469
+ if (query.state.isInvalidated) return false;
62444
62470
  const data = query.state.data;
62445
62471
  return Boolean(data?.report) && !data?.error;
62446
62472
  });
62447
62473
  }
62474
+ function syncDashboardReportQueryCacheAfterSave(queryClient, reportId, saved) {
62475
+ const id = String(reportId ?? "").trim();
62476
+ if (!id) return;
62477
+ queryClient.setQueriesData(
62478
+ { queryKey: dashboardReportQueryKey(id) },
62479
+ (previous) => mergeSavedReportIntoDashboardQueryData(previous, saved)
62480
+ );
62481
+ }
62448
62482
  function shouldBootstrapUseFormInitialLoad(input) {
62449
62483
  return !input.hasInitialReportBuilderState && input.previouslyBootstrappedIdentity !== input.currentIdentity;
62450
62484
  }
@@ -63505,7 +63539,7 @@ function pivotFallbackValueKeys(chart) {
63505
63539
  return (chart.pivotColumns ?? []).slice(1).map((column) => String(column.field ?? "").trim()).filter(Boolean);
63506
63540
  }
63507
63541
  function findSavedYAxisField(saved, field) {
63508
- return saved.find((axis) => String(axis.field ?? "").trim() === field) ?? (saved.length === 1 ? saved[0] : void 0);
63542
+ return saved.find((axis) => String(axis.field ?? "").trim() === field);
63509
63543
  }
63510
63544
  function isPlaceholderAxisLabel(label, field) {
63511
63545
  const trimmed = String(label ?? "").trim();
@@ -63889,6 +63923,19 @@ function mergePivotColumnSeriesLabelWithUserEdit(normalizedLabel, userRowLabel,
63889
63923
  }
63890
63924
  return user;
63891
63925
  }
63926
+ function applySingleResolvedYAxisFormatToPivotDisplay(normalizedPivotYAxisFields, resolvedYAxisFields) {
63927
+ if (resolvedYAxisFields.length !== 1) return normalizedPivotYAxisFields;
63928
+ const only = resolvedYAxisFields[0];
63929
+ return normalizedPivotYAxisFields.map((axis) => ({
63930
+ ...axis,
63931
+ label: mergePivotColumnSeriesLabelWithUserEdit(
63932
+ String(axis.label ?? "").trim(),
63933
+ only.label,
63934
+ String(axis.field ?? "").trim() || void 0
63935
+ ),
63936
+ format: toAxisFormat(only.format, axis.format)
63937
+ }));
63938
+ }
63892
63939
  function mergeChartColumnFormatsFromYAxisFields(columns, yAxisFields) {
63893
63940
  if (!columns?.length || !yAxisFields?.length) return columns;
63894
63941
  const formatByField = /* @__PURE__ */ new Map();
@@ -63910,10 +63957,6 @@ function mergeChartColumnFormatsFromYAxisFields(columns, yAxisFields) {
63910
63957
  return { ...col, format: nextFormat };
63911
63958
  });
63912
63959
  }
63913
- function looksLikeCustomPivotTableMeasureLabel(label) {
63914
- const l = String(label ?? "").trim();
63915
- return l.includes(" \xB7 ") || l.includes(" \u2014 ") || /\([^)]+\)/.test(l);
63916
- }
63917
63960
  function mergePivotTableDisplayColumnLabelsFromYAxis({
63918
63961
  columns,
63919
63962
  yAxisFields,
@@ -63923,16 +63966,11 @@ function mergePivotTableDisplayColumnLabelsFromYAxis({
63923
63966
  if (!columns?.length) return columns;
63924
63967
  const row = String(pivotRowField ?? "").trim();
63925
63968
  const xLab = String(xAxisLabel ?? "").trim();
63926
- const yList = (yAxisFields ?? []).map((y) => ({
63927
- field: String(y.field ?? "").trim(),
63928
- label: String(y.label ?? "").trim()
63929
- }));
63930
- const valueLabels = yList.map((y) => y.label).filter((l) => l.length > 0);
63931
- const distinct = new Set(valueLabels);
63932
- const anyCustom = valueLabels.some(looksLikeCustomPivotTableMeasureLabel);
63933
- const shouldMergeValueLabels = distinct.size > 1 || anyCustom;
63934
63969
  const labelByField = new Map(
63935
- yList.filter((y) => y.field).map((y) => [y.field, y.label])
63970
+ (yAxisFields ?? []).map((y) => ({
63971
+ field: String(y.field ?? "").trim(),
63972
+ label: String(y.label ?? "").trim()
63973
+ })).filter((y) => y.field && y.label).map((y) => [y.field, y.label])
63936
63974
  );
63937
63975
  return columns.map((c) => {
63938
63976
  const f = String(c.field ?? "").trim();
@@ -63940,7 +63978,6 @@ function mergePivotTableDisplayColumnLabelsFromYAxis({
63940
63978
  if (row && f === row && xLab && xLab !== row) {
63941
63979
  return { ...c, label: xLab };
63942
63980
  }
63943
- if (!shouldMergeValueLabels) return c;
63944
63981
  const yl = labelByField.get(f);
63945
63982
  if (!yl || String(c.label ?? "").trim() === yl) return c;
63946
63983
  return { ...c, label: yl };
@@ -69405,6 +69442,7 @@ function useReport(reportIdArg, options = {}) {
69405
69442
  ...report,
69406
69443
  // Keep chart axis metadata from the pivot load; detail fetch is flat
69407
69444
  // (`pivot: null`) and must supply wide `columns` for the detail table.
69445
+ xAxisLabel: previousReport.xAxisLabel,
69408
69446
  xAxisFormat: previousReport.xAxisFormat,
69409
69447
  yAxisFields: previousReport.yAxisFields,
69410
69448
  pivot: previousReport.pivot,
@@ -69755,10 +69793,16 @@ function useReport(reportIdArg, options = {}) {
69755
69793
  );
69756
69794
  const yAxisSeries = (0, import_react63.useMemo)(() => {
69757
69795
  if (yAxisResolved.series.length > 0) {
69796
+ if (yAxisResolved.measures.length === 1 && yAxisResolved.series !== yAxisResolved.measures) {
69797
+ return applySingleResolvedYAxisFormatToPivotDisplay(
69798
+ yAxisResolved.series,
69799
+ yAxisResolved.measures
69800
+ );
69801
+ }
69758
69802
  return yAxisResolved.series;
69759
69803
  }
69760
69804
  return yAxisMeasures;
69761
- }, [yAxisMeasures, yAxisResolved.series]);
69805
+ }, [yAxisMeasures, yAxisResolved.measures, yAxisResolved.series]);
69762
69806
  const chart = (0, import_react63.useMemo)(() => {
69763
69807
  if (!baseChart) return void 0;
69764
69808
  let columns2 = mergeChartColumnFormatsFromYAxisFields(
@@ -69780,7 +69824,7 @@ function useReport(reportIdArg, options = {}) {
69780
69824
  if (pivotAggregations2.length > 1 || hasCustomMeasureLabel) {
69781
69825
  columns2 = mergePivotTableDisplayColumnLabelsFromYAxis({
69782
69826
  columns: columns2 ?? baseChart.columns,
69783
- yAxisFields: yAxisSeries,
69827
+ yAxisFields: [...yAxisMeasures, ...yAxisSeries],
69784
69828
  pivotRowField: pivotRowKey(baseChart),
69785
69829
  xAxisLabel: resolvedXAxisLabel
69786
69830
  });
@@ -70162,7 +70206,7 @@ function useReport(reportIdArg, options = {}) {
70162
70206
  ) : mergedFromReport;
70163
70207
  const pivotLabeledColumns = String(chartType ?? "").toLowerCase() === "table" && sourceReport?.pivot ? mergePivotTableDisplayColumnLabelsFromYAxis({
70164
70208
  columns: columns2,
70165
- yAxisFields: yAxisSeries,
70209
+ yAxisFields: [...yAxisMeasures, ...yAxisSeries],
70166
70210
  pivotRowField: pivotRowKey(sourceReport),
70167
70211
  xAxisLabel: resolvedXAxisLabel
70168
70212
  }) ?? columns2 : columns2;
@@ -70245,6 +70289,7 @@ function useReport(reportIdArg, options = {}) {
70245
70289
  resolvedXAxisField,
70246
70290
  resolvedXAxisFormat,
70247
70291
  resolvedXAxisLabel,
70292
+ yAxisMeasures,
70248
70293
  yAxisSeries,
70249
70294
  scopedSchemaColumns,
70250
70295
  sourceReport,
@@ -70398,7 +70443,10 @@ function useReport(reportIdArg, options = {}) {
70398
70443
  }
70399
70444
  }
70400
70445
  const yAxisByField = /* @__PURE__ */ new Map();
70401
- for (const yAxisField of chart?.yAxisFields ?? []) {
70446
+ for (const yAxisField of [
70447
+ ...chart?.yAxisFields ?? [],
70448
+ ...yAxisResolved.measures
70449
+ ]) {
70402
70450
  const f = String(yAxisField.field ?? "").trim();
70403
70451
  if (!f || yAxisByField.has(f)) continue;
70404
70452
  yAxisByField.set(f, {
@@ -70448,7 +70496,7 @@ function useReport(reportIdArg, options = {}) {
70448
70496
  ).trim();
70449
70497
  const resolvedColFormat = isRowPivotCol ? String(resolvedXAxisFormat ?? "").trim() || effectiveFromId || mergeByFieldFormat || fromDisplay || String(chartFallback?.format ?? "").trim() || "string" : fromDisplay || effectiveFromId || mergeByFieldFormat;
70450
70498
  map.set(columnId, {
70451
- label: selectedLabel || pivotLabel || (!isPivotTableChart ? persistedTableLabel : ""),
70499
+ label: isPivotTableChart ? pivotLabel || selectedLabel : selectedLabel || pivotLabel || persistedTableLabel,
70452
70500
  format: resolvedColFormat
70453
70501
  });
70454
70502
  }
@@ -70708,12 +70756,7 @@ function useReport(reportIdArg, options = {}) {
70708
70756
  const same = clickedAgg && yAgg && getAggregationIdentityKey(clickedAgg) === getAggregationIdentityKey(yAgg);
70709
70757
  const singleBroadcast = Boolean(clickedAgg) && yAxisMeasures.length === 1;
70710
70758
  if (same || singleBroadcast) {
70711
- const nextLabel2 = yAxisMeasures.length === 1 && pivotModel.columnField ? mergePivotColumnSeriesLabelWithUserEdit(
70712
- String(y.label ?? "").trim(),
70713
- lab,
70714
- String(y.field ?? "").trim() || void 0
70715
- ) : lab;
70716
- return { ...y, label: nextLabel2 };
70759
+ return { ...y, label: lab };
70717
70760
  }
70718
70761
  return y;
70719
70762
  });
@@ -71414,13 +71457,14 @@ function useReport(reportIdArg, options = {}) {
71414
71457
  }
71415
71458
  );
71416
71459
  const columnsSelectedForSave = table.columns.length > 0 ? table.columns : fallbackDetailColumns;
71460
+ const persistedName = overriddenName || (String(formReportName ?? "").trim() ? formReportName : String(sourceRest.name ?? "").trim() ? sourceRest.name : effectiveReportBuilderState.tables[0]?.name ? snakeAndCamelCaseToTitleCase(
71461
+ String(effectiveReportBuilderState.tables[0].name)
71462
+ ) : "New report");
71417
71463
  const resp = await saveReport({
71418
71464
  report: {
71419
71465
  ...EMPTY_INTERNAL_REPORT,
71420
71466
  ...sourceRest,
71421
- name: overriddenName || (String(formReportName ?? "").trim() ? formReportName : String(sourceRest.name ?? "").trim() ? sourceRest.name : effectiveReportBuilderState.tables[0]?.name ? snakeAndCamelCaseToTitleCase(
71422
- String(effectiveReportBuilderState.tables[0].name)
71423
- ) : "New report"),
71467
+ name: persistedName,
71424
71468
  chartType: resolvedChartType,
71425
71469
  dashboardName: resolvedDashboardName,
71426
71470
  ...isAdmin ? { adminMode: true } : {},
@@ -71458,11 +71502,27 @@ function useReport(reportIdArg, options = {}) {
71458
71502
  if (savedReportId && resp && resp.name !== "error" && !resp.error) {
71459
71503
  await cacheCab.evictReport(savedReportId, tenants);
71460
71504
  evictSharedReportRequests(savedReportId);
71461
- await queryClient.invalidateQueries({
71462
- queryKey: ["quill", "dashboard-report", savedReportId],
71463
- refetchType: "none"
71505
+ const savedReport = {
71506
+ id: savedReportId,
71507
+ name: persistedName,
71508
+ chartType: resolvedChartType,
71509
+ xAxisField: resolvedXAxisField,
71510
+ xAxisFormat: resolvedXAxisFormat,
71511
+ xAxisLabel: resolvedXAxisLabel,
71512
+ yAxisFields: yAxisMeasures,
71513
+ pivot: effectiveReportBuilderState.pivot ?? null,
71514
+ reportBuilderState: effectiveReportBuilderState,
71515
+ columns: columnsSelectedForSave
71516
+ };
71517
+ syncDashboardReportQueryCacheAfterSave(
71518
+ queryClient,
71519
+ savedReportId,
71520
+ savedReport
71521
+ );
71522
+ await loadDashboard(resolvedDashboardName, true, {
71523
+ report: { ...sourceRest, ...savedReport },
71524
+ action: "upsert"
71464
71525
  });
71465
- await loadDashboard(resolvedDashboardName, true);
71466
71526
  }
71467
71527
  return resp;
71468
71528
  },
package/dist/index.js CHANGED
@@ -62645,14 +62645,48 @@ function createUseFormInitialLoadQueryKey(input) {
62645
62645
  ];
62646
62646
  }
62647
62647
  var DASHBOARD_REPORT_STALE_TIME_MS = 5 * 60 * 1e3;
62648
+ var DASHBOARD_REPORT_RESULT_FIELDS = [
62649
+ "rows",
62650
+ "compareRows",
62651
+ "pivotRows",
62652
+ "pivotColumns",
62653
+ "pivotRowCount"
62654
+ ];
62655
+ function dashboardReportQueryKey(reportId) {
62656
+ return ["quill", "dashboard-report", reportId];
62657
+ }
62658
+ function mergeSavedReportIntoDashboardQueryData(previous, saved) {
62659
+ const previousReport = previous?.report && typeof previous.report === "object" ? previous.report : void 0;
62660
+ const savedId = String(saved.id ?? saved._id ?? "").trim();
62661
+ const merged = {
62662
+ ...previousReport,
62663
+ ...saved,
62664
+ ...savedId ? { id: savedId } : {}
62665
+ };
62666
+ for (const field of DASHBOARD_REPORT_RESULT_FIELDS) {
62667
+ if (merged[field] == null && previousReport?.[field] != null) {
62668
+ merged[field] = previousReport[field];
62669
+ }
62670
+ }
62671
+ return { report: merged, error: void 0 };
62672
+ }
62648
62673
  function findCachedDashboardReportQuery(queryClient, reportId) {
62649
62674
  const id = String(reportId ?? "").trim();
62650
62675
  if (!id) return void 0;
62651
- return queryClient.getQueryCache().findAll({ queryKey: ["quill", "dashboard-report", id] }).find((query) => {
62676
+ return queryClient.getQueryCache().findAll({ queryKey: dashboardReportQueryKey(id) }).find((query) => {
62677
+ if (query.state.isInvalidated) return false;
62652
62678
  const data = query.state.data;
62653
62679
  return Boolean(data?.report) && !data?.error;
62654
62680
  });
62655
62681
  }
62682
+ function syncDashboardReportQueryCacheAfterSave(queryClient, reportId, saved) {
62683
+ const id = String(reportId ?? "").trim();
62684
+ if (!id) return;
62685
+ queryClient.setQueriesData(
62686
+ { queryKey: dashboardReportQueryKey(id) },
62687
+ (previous) => mergeSavedReportIntoDashboardQueryData(previous, saved)
62688
+ );
62689
+ }
62656
62690
  function shouldBootstrapUseFormInitialLoad(input) {
62657
62691
  return !input.hasInitialReportBuilderState && input.previouslyBootstrappedIdentity !== input.currentIdentity;
62658
62692
  }
@@ -63713,7 +63747,7 @@ function pivotFallbackValueKeys(chart) {
63713
63747
  return (chart.pivotColumns ?? []).slice(1).map((column) => String(column.field ?? "").trim()).filter(Boolean);
63714
63748
  }
63715
63749
  function findSavedYAxisField(saved, field) {
63716
- return saved.find((axis) => String(axis.field ?? "").trim() === field) ?? (saved.length === 1 ? saved[0] : void 0);
63750
+ return saved.find((axis) => String(axis.field ?? "").trim() === field);
63717
63751
  }
63718
63752
  function isPlaceholderAxisLabel(label, field) {
63719
63753
  const trimmed = String(label ?? "").trim();
@@ -64097,6 +64131,19 @@ function mergePivotColumnSeriesLabelWithUserEdit(normalizedLabel, userRowLabel,
64097
64131
  }
64098
64132
  return user;
64099
64133
  }
64134
+ function applySingleResolvedYAxisFormatToPivotDisplay(normalizedPivotYAxisFields, resolvedYAxisFields) {
64135
+ if (resolvedYAxisFields.length !== 1) return normalizedPivotYAxisFields;
64136
+ const only = resolvedYAxisFields[0];
64137
+ return normalizedPivotYAxisFields.map((axis) => ({
64138
+ ...axis,
64139
+ label: mergePivotColumnSeriesLabelWithUserEdit(
64140
+ String(axis.label ?? "").trim(),
64141
+ only.label,
64142
+ String(axis.field ?? "").trim() || void 0
64143
+ ),
64144
+ format: toAxisFormat(only.format, axis.format)
64145
+ }));
64146
+ }
64100
64147
  function mergeChartColumnFormatsFromYAxisFields(columns, yAxisFields) {
64101
64148
  if (!columns?.length || !yAxisFields?.length) return columns;
64102
64149
  const formatByField = /* @__PURE__ */ new Map();
@@ -64118,10 +64165,6 @@ function mergeChartColumnFormatsFromYAxisFields(columns, yAxisFields) {
64118
64165
  return { ...col, format: nextFormat };
64119
64166
  });
64120
64167
  }
64121
- function looksLikeCustomPivotTableMeasureLabel(label) {
64122
- const l = String(label ?? "").trim();
64123
- return l.includes(" \xB7 ") || l.includes(" \u2014 ") || /\([^)]+\)/.test(l);
64124
- }
64125
64168
  function mergePivotTableDisplayColumnLabelsFromYAxis({
64126
64169
  columns,
64127
64170
  yAxisFields,
@@ -64131,16 +64174,11 @@ function mergePivotTableDisplayColumnLabelsFromYAxis({
64131
64174
  if (!columns?.length) return columns;
64132
64175
  const row = String(pivotRowField ?? "").trim();
64133
64176
  const xLab = String(xAxisLabel ?? "").trim();
64134
- const yList = (yAxisFields ?? []).map((y) => ({
64135
- field: String(y.field ?? "").trim(),
64136
- label: String(y.label ?? "").trim()
64137
- }));
64138
- const valueLabels = yList.map((y) => y.label).filter((l) => l.length > 0);
64139
- const distinct = new Set(valueLabels);
64140
- const anyCustom = valueLabels.some(looksLikeCustomPivotTableMeasureLabel);
64141
- const shouldMergeValueLabels = distinct.size > 1 || anyCustom;
64142
64177
  const labelByField = new Map(
64143
- yList.filter((y) => y.field).map((y) => [y.field, y.label])
64178
+ (yAxisFields ?? []).map((y) => ({
64179
+ field: String(y.field ?? "").trim(),
64180
+ label: String(y.label ?? "").trim()
64181
+ })).filter((y) => y.field && y.label).map((y) => [y.field, y.label])
64144
64182
  );
64145
64183
  return columns.map((c) => {
64146
64184
  const f = String(c.field ?? "").trim();
@@ -64148,7 +64186,6 @@ function mergePivotTableDisplayColumnLabelsFromYAxis({
64148
64186
  if (row && f === row && xLab && xLab !== row) {
64149
64187
  return { ...c, label: xLab };
64150
64188
  }
64151
- if (!shouldMergeValueLabels) return c;
64152
64189
  const yl = labelByField.get(f);
64153
64190
  if (!yl || String(c.label ?? "").trim() === yl) return c;
64154
64191
  return { ...c, label: yl };
@@ -69613,6 +69650,7 @@ function useReport(reportIdArg, options = {}) {
69613
69650
  ...report,
69614
69651
  // Keep chart axis metadata from the pivot load; detail fetch is flat
69615
69652
  // (`pivot: null`) and must supply wide `columns` for the detail table.
69653
+ xAxisLabel: previousReport.xAxisLabel,
69616
69654
  xAxisFormat: previousReport.xAxisFormat,
69617
69655
  yAxisFields: previousReport.yAxisFields,
69618
69656
  pivot: previousReport.pivot,
@@ -69963,10 +70001,16 @@ function useReport(reportIdArg, options = {}) {
69963
70001
  );
69964
70002
  const yAxisSeries = useMemo33(() => {
69965
70003
  if (yAxisResolved.series.length > 0) {
70004
+ if (yAxisResolved.measures.length === 1 && yAxisResolved.series !== yAxisResolved.measures) {
70005
+ return applySingleResolvedYAxisFormatToPivotDisplay(
70006
+ yAxisResolved.series,
70007
+ yAxisResolved.measures
70008
+ );
70009
+ }
69966
70010
  return yAxisResolved.series;
69967
70011
  }
69968
70012
  return yAxisMeasures;
69969
- }, [yAxisMeasures, yAxisResolved.series]);
70013
+ }, [yAxisMeasures, yAxisResolved.measures, yAxisResolved.series]);
69970
70014
  const chart = useMemo33(() => {
69971
70015
  if (!baseChart) return void 0;
69972
70016
  let columns2 = mergeChartColumnFormatsFromYAxisFields(
@@ -69988,7 +70032,7 @@ function useReport(reportIdArg, options = {}) {
69988
70032
  if (pivotAggregations2.length > 1 || hasCustomMeasureLabel) {
69989
70033
  columns2 = mergePivotTableDisplayColumnLabelsFromYAxis({
69990
70034
  columns: columns2 ?? baseChart.columns,
69991
- yAxisFields: yAxisSeries,
70035
+ yAxisFields: [...yAxisMeasures, ...yAxisSeries],
69992
70036
  pivotRowField: pivotRowKey(baseChart),
69993
70037
  xAxisLabel: resolvedXAxisLabel
69994
70038
  });
@@ -70370,7 +70414,7 @@ function useReport(reportIdArg, options = {}) {
70370
70414
  ) : mergedFromReport;
70371
70415
  const pivotLabeledColumns = String(chartType ?? "").toLowerCase() === "table" && sourceReport?.pivot ? mergePivotTableDisplayColumnLabelsFromYAxis({
70372
70416
  columns: columns2,
70373
- yAxisFields: yAxisSeries,
70417
+ yAxisFields: [...yAxisMeasures, ...yAxisSeries],
70374
70418
  pivotRowField: pivotRowKey(sourceReport),
70375
70419
  xAxisLabel: resolvedXAxisLabel
70376
70420
  }) ?? columns2 : columns2;
@@ -70453,6 +70497,7 @@ function useReport(reportIdArg, options = {}) {
70453
70497
  resolvedXAxisField,
70454
70498
  resolvedXAxisFormat,
70455
70499
  resolvedXAxisLabel,
70500
+ yAxisMeasures,
70456
70501
  yAxisSeries,
70457
70502
  scopedSchemaColumns,
70458
70503
  sourceReport,
@@ -70606,7 +70651,10 @@ function useReport(reportIdArg, options = {}) {
70606
70651
  }
70607
70652
  }
70608
70653
  const yAxisByField = /* @__PURE__ */ new Map();
70609
- for (const yAxisField of chart?.yAxisFields ?? []) {
70654
+ for (const yAxisField of [
70655
+ ...chart?.yAxisFields ?? [],
70656
+ ...yAxisResolved.measures
70657
+ ]) {
70610
70658
  const f = String(yAxisField.field ?? "").trim();
70611
70659
  if (!f || yAxisByField.has(f)) continue;
70612
70660
  yAxisByField.set(f, {
@@ -70656,7 +70704,7 @@ function useReport(reportIdArg, options = {}) {
70656
70704
  ).trim();
70657
70705
  const resolvedColFormat = isRowPivotCol ? String(resolvedXAxisFormat ?? "").trim() || effectiveFromId || mergeByFieldFormat || fromDisplay || String(chartFallback?.format ?? "").trim() || "string" : fromDisplay || effectiveFromId || mergeByFieldFormat;
70658
70706
  map.set(columnId, {
70659
- label: selectedLabel || pivotLabel || (!isPivotTableChart ? persistedTableLabel : ""),
70707
+ label: isPivotTableChart ? pivotLabel || selectedLabel : selectedLabel || pivotLabel || persistedTableLabel,
70660
70708
  format: resolvedColFormat
70661
70709
  });
70662
70710
  }
@@ -70916,12 +70964,7 @@ function useReport(reportIdArg, options = {}) {
70916
70964
  const same = clickedAgg && yAgg && getAggregationIdentityKey(clickedAgg) === getAggregationIdentityKey(yAgg);
70917
70965
  const singleBroadcast = Boolean(clickedAgg) && yAxisMeasures.length === 1;
70918
70966
  if (same || singleBroadcast) {
70919
- const nextLabel2 = yAxisMeasures.length === 1 && pivotModel.columnField ? mergePivotColumnSeriesLabelWithUserEdit(
70920
- String(y.label ?? "").trim(),
70921
- lab,
70922
- String(y.field ?? "").trim() || void 0
70923
- ) : lab;
70924
- return { ...y, label: nextLabel2 };
70967
+ return { ...y, label: lab };
70925
70968
  }
70926
70969
  return y;
70927
70970
  });
@@ -71622,13 +71665,14 @@ function useReport(reportIdArg, options = {}) {
71622
71665
  }
71623
71666
  );
71624
71667
  const columnsSelectedForSave = table.columns.length > 0 ? table.columns : fallbackDetailColumns;
71668
+ const persistedName = overriddenName || (String(formReportName ?? "").trim() ? formReportName : String(sourceRest.name ?? "").trim() ? sourceRest.name : effectiveReportBuilderState.tables[0]?.name ? snakeAndCamelCaseToTitleCase(
71669
+ String(effectiveReportBuilderState.tables[0].name)
71670
+ ) : "New report");
71625
71671
  const resp = await saveReport({
71626
71672
  report: {
71627
71673
  ...EMPTY_INTERNAL_REPORT,
71628
71674
  ...sourceRest,
71629
- name: overriddenName || (String(formReportName ?? "").trim() ? formReportName : String(sourceRest.name ?? "").trim() ? sourceRest.name : effectiveReportBuilderState.tables[0]?.name ? snakeAndCamelCaseToTitleCase(
71630
- String(effectiveReportBuilderState.tables[0].name)
71631
- ) : "New report"),
71675
+ name: persistedName,
71632
71676
  chartType: resolvedChartType,
71633
71677
  dashboardName: resolvedDashboardName,
71634
71678
  ...isAdmin ? { adminMode: true } : {},
@@ -71666,11 +71710,27 @@ function useReport(reportIdArg, options = {}) {
71666
71710
  if (savedReportId && resp && resp.name !== "error" && !resp.error) {
71667
71711
  await cacheCab.evictReport(savedReportId, tenants);
71668
71712
  evictSharedReportRequests(savedReportId);
71669
- await queryClient.invalidateQueries({
71670
- queryKey: ["quill", "dashboard-report", savedReportId],
71671
- refetchType: "none"
71713
+ const savedReport = {
71714
+ id: savedReportId,
71715
+ name: persistedName,
71716
+ chartType: resolvedChartType,
71717
+ xAxisField: resolvedXAxisField,
71718
+ xAxisFormat: resolvedXAxisFormat,
71719
+ xAxisLabel: resolvedXAxisLabel,
71720
+ yAxisFields: yAxisMeasures,
71721
+ pivot: effectiveReportBuilderState.pivot ?? null,
71722
+ reportBuilderState: effectiveReportBuilderState,
71723
+ columns: columnsSelectedForSave
71724
+ };
71725
+ syncDashboardReportQueryCacheAfterSave(
71726
+ queryClient,
71727
+ savedReportId,
71728
+ savedReport
71729
+ );
71730
+ await loadDashboard(resolvedDashboardName, true, {
71731
+ report: { ...sourceRest, ...savedReport },
71732
+ action: "upsert"
71672
71733
  });
71673
- await loadDashboard(resolvedDashboardName, true);
71674
71734
  }
71675
71735
  return resp;
71676
71736
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillsql/react",
3
- "version": "2.16.98",
3
+ "version": "2.16.100",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {