@quillsql/react 2.16.98 → 2.16.99

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
@@ -63505,7 +63505,7 @@ function pivotFallbackValueKeys(chart) {
63505
63505
  return (chart.pivotColumns ?? []).slice(1).map((column) => String(column.field ?? "").trim()).filter(Boolean);
63506
63506
  }
63507
63507
  function findSavedYAxisField(saved, field) {
63508
- return saved.find((axis) => String(axis.field ?? "").trim() === field) ?? (saved.length === 1 ? saved[0] : void 0);
63508
+ return saved.find((axis) => String(axis.field ?? "").trim() === field);
63509
63509
  }
63510
63510
  function isPlaceholderAxisLabel(label, field) {
63511
63511
  const trimmed = String(label ?? "").trim();
@@ -63889,6 +63889,19 @@ function mergePivotColumnSeriesLabelWithUserEdit(normalizedLabel, userRowLabel,
63889
63889
  }
63890
63890
  return user;
63891
63891
  }
63892
+ function applySingleResolvedYAxisFormatToPivotDisplay(normalizedPivotYAxisFields, resolvedYAxisFields) {
63893
+ if (resolvedYAxisFields.length !== 1) return normalizedPivotYAxisFields;
63894
+ const only = resolvedYAxisFields[0];
63895
+ return normalizedPivotYAxisFields.map((axis) => ({
63896
+ ...axis,
63897
+ label: mergePivotColumnSeriesLabelWithUserEdit(
63898
+ String(axis.label ?? "").trim(),
63899
+ only.label,
63900
+ String(axis.field ?? "").trim() || void 0
63901
+ ),
63902
+ format: toAxisFormat(only.format, axis.format)
63903
+ }));
63904
+ }
63892
63905
  function mergeChartColumnFormatsFromYAxisFields(columns, yAxisFields) {
63893
63906
  if (!columns?.length || !yAxisFields?.length) return columns;
63894
63907
  const formatByField = /* @__PURE__ */ new Map();
@@ -63910,10 +63923,6 @@ function mergeChartColumnFormatsFromYAxisFields(columns, yAxisFields) {
63910
63923
  return { ...col, format: nextFormat };
63911
63924
  });
63912
63925
  }
63913
- function looksLikeCustomPivotTableMeasureLabel(label) {
63914
- const l = String(label ?? "").trim();
63915
- return l.includes(" \xB7 ") || l.includes(" \u2014 ") || /\([^)]+\)/.test(l);
63916
- }
63917
63926
  function mergePivotTableDisplayColumnLabelsFromYAxis({
63918
63927
  columns,
63919
63928
  yAxisFields,
@@ -63923,16 +63932,11 @@ function mergePivotTableDisplayColumnLabelsFromYAxis({
63923
63932
  if (!columns?.length) return columns;
63924
63933
  const row = String(pivotRowField ?? "").trim();
63925
63934
  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
63935
  const labelByField = new Map(
63935
- yList.filter((y) => y.field).map((y) => [y.field, y.label])
63936
+ (yAxisFields ?? []).map((y) => ({
63937
+ field: String(y.field ?? "").trim(),
63938
+ label: String(y.label ?? "").trim()
63939
+ })).filter((y) => y.field && y.label).map((y) => [y.field, y.label])
63936
63940
  );
63937
63941
  return columns.map((c) => {
63938
63942
  const f = String(c.field ?? "").trim();
@@ -63940,7 +63944,6 @@ function mergePivotTableDisplayColumnLabelsFromYAxis({
63940
63944
  if (row && f === row && xLab && xLab !== row) {
63941
63945
  return { ...c, label: xLab };
63942
63946
  }
63943
- if (!shouldMergeValueLabels) return c;
63944
63947
  const yl = labelByField.get(f);
63945
63948
  if (!yl || String(c.label ?? "").trim() === yl) return c;
63946
63949
  return { ...c, label: yl };
@@ -69755,10 +69758,16 @@ function useReport(reportIdArg, options = {}) {
69755
69758
  );
69756
69759
  const yAxisSeries = (0, import_react63.useMemo)(() => {
69757
69760
  if (yAxisResolved.series.length > 0) {
69761
+ if (yAxisResolved.measures.length === 1 && yAxisResolved.series !== yAxisResolved.measures) {
69762
+ return applySingleResolvedYAxisFormatToPivotDisplay(
69763
+ yAxisResolved.series,
69764
+ yAxisResolved.measures
69765
+ );
69766
+ }
69758
69767
  return yAxisResolved.series;
69759
69768
  }
69760
69769
  return yAxisMeasures;
69761
- }, [yAxisMeasures, yAxisResolved.series]);
69770
+ }, [yAxisMeasures, yAxisResolved.measures, yAxisResolved.series]);
69762
69771
  const chart = (0, import_react63.useMemo)(() => {
69763
69772
  if (!baseChart) return void 0;
69764
69773
  let columns2 = mergeChartColumnFormatsFromYAxisFields(
@@ -69780,7 +69789,7 @@ function useReport(reportIdArg, options = {}) {
69780
69789
  if (pivotAggregations2.length > 1 || hasCustomMeasureLabel) {
69781
69790
  columns2 = mergePivotTableDisplayColumnLabelsFromYAxis({
69782
69791
  columns: columns2 ?? baseChart.columns,
69783
- yAxisFields: yAxisSeries,
69792
+ yAxisFields: [...yAxisMeasures, ...yAxisSeries],
69784
69793
  pivotRowField: pivotRowKey(baseChart),
69785
69794
  xAxisLabel: resolvedXAxisLabel
69786
69795
  });
@@ -70162,7 +70171,7 @@ function useReport(reportIdArg, options = {}) {
70162
70171
  ) : mergedFromReport;
70163
70172
  const pivotLabeledColumns = String(chartType ?? "").toLowerCase() === "table" && sourceReport?.pivot ? mergePivotTableDisplayColumnLabelsFromYAxis({
70164
70173
  columns: columns2,
70165
- yAxisFields: yAxisSeries,
70174
+ yAxisFields: [...yAxisMeasures, ...yAxisSeries],
70166
70175
  pivotRowField: pivotRowKey(sourceReport),
70167
70176
  xAxisLabel: resolvedXAxisLabel
70168
70177
  }) ?? columns2 : columns2;
@@ -70245,6 +70254,7 @@ function useReport(reportIdArg, options = {}) {
70245
70254
  resolvedXAxisField,
70246
70255
  resolvedXAxisFormat,
70247
70256
  resolvedXAxisLabel,
70257
+ yAxisMeasures,
70248
70258
  yAxisSeries,
70249
70259
  scopedSchemaColumns,
70250
70260
  sourceReport,
@@ -70398,7 +70408,10 @@ function useReport(reportIdArg, options = {}) {
70398
70408
  }
70399
70409
  }
70400
70410
  const yAxisByField = /* @__PURE__ */ new Map();
70401
- for (const yAxisField of chart?.yAxisFields ?? []) {
70411
+ for (const yAxisField of [
70412
+ ...chart?.yAxisFields ?? [],
70413
+ ...yAxisResolved.measures
70414
+ ]) {
70402
70415
  const f = String(yAxisField.field ?? "").trim();
70403
70416
  if (!f || yAxisByField.has(f)) continue;
70404
70417
  yAxisByField.set(f, {
@@ -70448,7 +70461,7 @@ function useReport(reportIdArg, options = {}) {
70448
70461
  ).trim();
70449
70462
  const resolvedColFormat = isRowPivotCol ? String(resolvedXAxisFormat ?? "").trim() || effectiveFromId || mergeByFieldFormat || fromDisplay || String(chartFallback?.format ?? "").trim() || "string" : fromDisplay || effectiveFromId || mergeByFieldFormat;
70450
70463
  map.set(columnId, {
70451
- label: selectedLabel || pivotLabel || (!isPivotTableChart ? persistedTableLabel : ""),
70464
+ label: isPivotTableChart ? pivotLabel || selectedLabel : selectedLabel || pivotLabel || persistedTableLabel,
70452
70465
  format: resolvedColFormat
70453
70466
  });
70454
70467
  }
@@ -70708,12 +70721,7 @@ function useReport(reportIdArg, options = {}) {
70708
70721
  const same = clickedAgg && yAgg && getAggregationIdentityKey(clickedAgg) === getAggregationIdentityKey(yAgg);
70709
70722
  const singleBroadcast = Boolean(clickedAgg) && yAxisMeasures.length === 1;
70710
70723
  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 };
70724
+ return { ...y, label: lab };
70717
70725
  }
70718
70726
  return y;
70719
70727
  });
package/dist/index.js CHANGED
@@ -63713,7 +63713,7 @@ function pivotFallbackValueKeys(chart) {
63713
63713
  return (chart.pivotColumns ?? []).slice(1).map((column) => String(column.field ?? "").trim()).filter(Boolean);
63714
63714
  }
63715
63715
  function findSavedYAxisField(saved, field) {
63716
- return saved.find((axis) => String(axis.field ?? "").trim() === field) ?? (saved.length === 1 ? saved[0] : void 0);
63716
+ return saved.find((axis) => String(axis.field ?? "").trim() === field);
63717
63717
  }
63718
63718
  function isPlaceholderAxisLabel(label, field) {
63719
63719
  const trimmed = String(label ?? "").trim();
@@ -64097,6 +64097,19 @@ function mergePivotColumnSeriesLabelWithUserEdit(normalizedLabel, userRowLabel,
64097
64097
  }
64098
64098
  return user;
64099
64099
  }
64100
+ function applySingleResolvedYAxisFormatToPivotDisplay(normalizedPivotYAxisFields, resolvedYAxisFields) {
64101
+ if (resolvedYAxisFields.length !== 1) return normalizedPivotYAxisFields;
64102
+ const only = resolvedYAxisFields[0];
64103
+ return normalizedPivotYAxisFields.map((axis) => ({
64104
+ ...axis,
64105
+ label: mergePivotColumnSeriesLabelWithUserEdit(
64106
+ String(axis.label ?? "").trim(),
64107
+ only.label,
64108
+ String(axis.field ?? "").trim() || void 0
64109
+ ),
64110
+ format: toAxisFormat(only.format, axis.format)
64111
+ }));
64112
+ }
64100
64113
  function mergeChartColumnFormatsFromYAxisFields(columns, yAxisFields) {
64101
64114
  if (!columns?.length || !yAxisFields?.length) return columns;
64102
64115
  const formatByField = /* @__PURE__ */ new Map();
@@ -64118,10 +64131,6 @@ function mergeChartColumnFormatsFromYAxisFields(columns, yAxisFields) {
64118
64131
  return { ...col, format: nextFormat };
64119
64132
  });
64120
64133
  }
64121
- function looksLikeCustomPivotTableMeasureLabel(label) {
64122
- const l = String(label ?? "").trim();
64123
- return l.includes(" \xB7 ") || l.includes(" \u2014 ") || /\([^)]+\)/.test(l);
64124
- }
64125
64134
  function mergePivotTableDisplayColumnLabelsFromYAxis({
64126
64135
  columns,
64127
64136
  yAxisFields,
@@ -64131,16 +64140,11 @@ function mergePivotTableDisplayColumnLabelsFromYAxis({
64131
64140
  if (!columns?.length) return columns;
64132
64141
  const row = String(pivotRowField ?? "").trim();
64133
64142
  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
64143
  const labelByField = new Map(
64143
- yList.filter((y) => y.field).map((y) => [y.field, y.label])
64144
+ (yAxisFields ?? []).map((y) => ({
64145
+ field: String(y.field ?? "").trim(),
64146
+ label: String(y.label ?? "").trim()
64147
+ })).filter((y) => y.field && y.label).map((y) => [y.field, y.label])
64144
64148
  );
64145
64149
  return columns.map((c) => {
64146
64150
  const f = String(c.field ?? "").trim();
@@ -64148,7 +64152,6 @@ function mergePivotTableDisplayColumnLabelsFromYAxis({
64148
64152
  if (row && f === row && xLab && xLab !== row) {
64149
64153
  return { ...c, label: xLab };
64150
64154
  }
64151
- if (!shouldMergeValueLabels) return c;
64152
64155
  const yl = labelByField.get(f);
64153
64156
  if (!yl || String(c.label ?? "").trim() === yl) return c;
64154
64157
  return { ...c, label: yl };
@@ -69963,10 +69966,16 @@ function useReport(reportIdArg, options = {}) {
69963
69966
  );
69964
69967
  const yAxisSeries = useMemo33(() => {
69965
69968
  if (yAxisResolved.series.length > 0) {
69969
+ if (yAxisResolved.measures.length === 1 && yAxisResolved.series !== yAxisResolved.measures) {
69970
+ return applySingleResolvedYAxisFormatToPivotDisplay(
69971
+ yAxisResolved.series,
69972
+ yAxisResolved.measures
69973
+ );
69974
+ }
69966
69975
  return yAxisResolved.series;
69967
69976
  }
69968
69977
  return yAxisMeasures;
69969
- }, [yAxisMeasures, yAxisResolved.series]);
69978
+ }, [yAxisMeasures, yAxisResolved.measures, yAxisResolved.series]);
69970
69979
  const chart = useMemo33(() => {
69971
69980
  if (!baseChart) return void 0;
69972
69981
  let columns2 = mergeChartColumnFormatsFromYAxisFields(
@@ -69988,7 +69997,7 @@ function useReport(reportIdArg, options = {}) {
69988
69997
  if (pivotAggregations2.length > 1 || hasCustomMeasureLabel) {
69989
69998
  columns2 = mergePivotTableDisplayColumnLabelsFromYAxis({
69990
69999
  columns: columns2 ?? baseChart.columns,
69991
- yAxisFields: yAxisSeries,
70000
+ yAxisFields: [...yAxisMeasures, ...yAxisSeries],
69992
70001
  pivotRowField: pivotRowKey(baseChart),
69993
70002
  xAxisLabel: resolvedXAxisLabel
69994
70003
  });
@@ -70370,7 +70379,7 @@ function useReport(reportIdArg, options = {}) {
70370
70379
  ) : mergedFromReport;
70371
70380
  const pivotLabeledColumns = String(chartType ?? "").toLowerCase() === "table" && sourceReport?.pivot ? mergePivotTableDisplayColumnLabelsFromYAxis({
70372
70381
  columns: columns2,
70373
- yAxisFields: yAxisSeries,
70382
+ yAxisFields: [...yAxisMeasures, ...yAxisSeries],
70374
70383
  pivotRowField: pivotRowKey(sourceReport),
70375
70384
  xAxisLabel: resolvedXAxisLabel
70376
70385
  }) ?? columns2 : columns2;
@@ -70453,6 +70462,7 @@ function useReport(reportIdArg, options = {}) {
70453
70462
  resolvedXAxisField,
70454
70463
  resolvedXAxisFormat,
70455
70464
  resolvedXAxisLabel,
70465
+ yAxisMeasures,
70456
70466
  yAxisSeries,
70457
70467
  scopedSchemaColumns,
70458
70468
  sourceReport,
@@ -70606,7 +70616,10 @@ function useReport(reportIdArg, options = {}) {
70606
70616
  }
70607
70617
  }
70608
70618
  const yAxisByField = /* @__PURE__ */ new Map();
70609
- for (const yAxisField of chart?.yAxisFields ?? []) {
70619
+ for (const yAxisField of [
70620
+ ...chart?.yAxisFields ?? [],
70621
+ ...yAxisResolved.measures
70622
+ ]) {
70610
70623
  const f = String(yAxisField.field ?? "").trim();
70611
70624
  if (!f || yAxisByField.has(f)) continue;
70612
70625
  yAxisByField.set(f, {
@@ -70656,7 +70669,7 @@ function useReport(reportIdArg, options = {}) {
70656
70669
  ).trim();
70657
70670
  const resolvedColFormat = isRowPivotCol ? String(resolvedXAxisFormat ?? "").trim() || effectiveFromId || mergeByFieldFormat || fromDisplay || String(chartFallback?.format ?? "").trim() || "string" : fromDisplay || effectiveFromId || mergeByFieldFormat;
70658
70671
  map.set(columnId, {
70659
- label: selectedLabel || pivotLabel || (!isPivotTableChart ? persistedTableLabel : ""),
70672
+ label: isPivotTableChart ? pivotLabel || selectedLabel : selectedLabel || pivotLabel || persistedTableLabel,
70660
70673
  format: resolvedColFormat
70661
70674
  });
70662
70675
  }
@@ -70916,12 +70929,7 @@ function useReport(reportIdArg, options = {}) {
70916
70929
  const same = clickedAgg && yAgg && getAggregationIdentityKey(clickedAgg) === getAggregationIdentityKey(yAgg);
70917
70930
  const singleBroadcast = Boolean(clickedAgg) && yAxisMeasures.length === 1;
70918
70931
  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 };
70932
+ return { ...y, label: lab };
70925
70933
  }
70926
70934
  return y;
70927
70935
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillsql/react",
3
- "version": "2.16.98",
3
+ "version": "2.16.99",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {