@quillsql/react 2.16.95 → 2.16.97

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
@@ -23802,11 +23802,17 @@ function formattedPivotRowsAndColumns(report, dashboardFilters = [], options = {
23802
23802
  dashboardFilters
23803
23803
  );
23804
23804
  const pivotValueColumns = columns?.slice(1) ?? [];
23805
- const yAxisFields = report.pivot && !report.pivot.columnField && pivotValueColumns.length > 0 ? pivotValueColumns.map((col, index) => ({
23806
- field: col.field,
23807
- label: col.label ?? report.yAxisFields?.[index]?.label ?? col.field,
23808
- format: report.yAxisFields?.[index]?.format ?? legacyPivotFormat ?? col.format ?? "whole_number"
23809
- })) : formattedYAxisFields?.length > 0 ? formattedYAxisFields : pivotValueColumns.map((col) => ({
23805
+ const yAxisFields = report.pivot && !report.pivot.columnField && pivotValueColumns.length > 0 ? pivotValueColumns.map((col) => {
23806
+ const saved = report.yAxisFields?.find(
23807
+ (axis) => axis.field === col.field
23808
+ );
23809
+ const savedLabel = String(saved?.label ?? "").trim();
23810
+ return {
23811
+ field: col.field,
23812
+ label: savedLabel || col.label || col.field,
23813
+ format: saved?.format ?? legacyPivotFormat ?? col.format ?? "whole_number"
23814
+ };
23815
+ }) : formattedYAxisFields?.length > 0 ? formattedYAxisFields : pivotValueColumns.map((col) => ({
23810
23816
  field: col.field,
23811
23817
  label: col.label ?? col.field,
23812
23818
  format: legacyPivotFormat ?? col.format ?? "whole_number"
@@ -41087,7 +41093,7 @@ function D3Gauge({
41087
41093
  if (!containerRef.current || !select) return;
41088
41094
  const container = containerRef.current;
41089
41095
  select(container).select("svg").remove();
41090
- svgRef.current = select(container).append("svg").attr("width", "100%").attr("height", "100%").attr("preserveAspectRatio", "xMidYMid meet");
41096
+ svgRef.current = select(container).append("svg").attr("width", "100%").attr("height", "100%").attr("preserveAspectRatio", "xMidYMid meet").style("display", "block");
41091
41097
  gaugeGroupRef.current = svgRef.current.append("g");
41092
41098
  for (let i = 0; i < 3; i++) {
41093
41099
  gaugeGroupRef.current.append("path").attr("class", `arc-seg seg${i}`);
@@ -41222,7 +41228,7 @@ function D3Gauge({
41222
41228
  "div",
41223
41229
  {
41224
41230
  ref: containerRef,
41225
- style: { width: "100%", ...containerStyle },
41231
+ style: { width: "100%", height: "100%", ...containerStyle },
41226
41232
  className
41227
41233
  }
41228
41234
  );
@@ -49324,10 +49330,10 @@ function InternalChart({
49324
49330
  config: report,
49325
49331
  containerStyle: {
49326
49332
  minHeight: 300,
49327
- width: ["US map", "World map"].includes(report.chartType) ? "70%" : ["gauge"].includes(report.chartType) ? void 0 : "100%",
49328
- height: ["US map", "World map"].includes(report.chartType) ? "fit-content" : ["gauge"].includes(report.chartType) ? 500 : void 0,
49329
- marginLeft: ["gauge"].includes(report.chartType) ? "undefined" : "auto",
49330
- marginRight: ["gauge"].includes(report.chartType) ? "undefined" : "auto"
49333
+ width: ["US map", "World map"].includes(report.chartType) ? "70%" : "100%",
49334
+ height: ["US map", "World map"].includes(report.chartType) ? "fit-content" : report.chartType === "gauge" ? 300 : void 0,
49335
+ marginLeft: "auto",
49336
+ marginRight: "auto"
49331
49337
  },
49332
49338
  reportId: report.id,
49333
49339
  colors,
@@ -62592,9 +62598,6 @@ function getPageOptionsFromPageCount(pageCount) {
62592
62598
 
62593
62599
  // src/hooks/useForm.tsx
62594
62600
  var INTERNAL_PIVOT_ROW_FIELDS = /* @__PURE__ */ new Set(["__quillRawDate"]);
62595
- var LEGACY_SINGLE_Y_AXIS_COLUMN_PIVOT_REPORT_IDS = /* @__PURE__ */ new Set([
62596
- "69b63941ac8df4cda178a38a"
62597
- ]);
62598
62601
  var AGGREGATION_OPTION_TYPES = [
62599
62602
  "sum",
62600
62603
  "average",
@@ -63399,10 +63402,7 @@ function normalizePivotColumnDisplayValue(value) {
63399
63402
  if (!normalized) return "-";
63400
63403
  return ["undefined", "null"].includes(normalized.toLowerCase()) ? "-" : normalized;
63401
63404
  }
63402
- function getYAxisFormatFromAggregation(aggregation) {
63403
- return aggregation?.aggregationType === "percentage" ? "percentage" : "whole_number";
63404
- }
63405
- function getPivotTableSlotReportColumn(reportColumns, aggregations, rowField, pivotTableColumnKey) {
63405
+ function getPivotTableReportColumn(reportColumns, aggregations, rowField, pivotTableColumnKey) {
63406
63406
  const cols = reportColumns ?? [];
63407
63407
  if (cols.length === 0) return void 0;
63408
63408
  const row = String(rowField ?? "").trim();
@@ -63480,7 +63480,214 @@ function shouldUsePivotRowFieldAsXAxis(chartType, pivotRowField, rowColumnFormat
63480
63480
  }
63481
63481
  return true;
63482
63482
  }
63483
- function normalizePivotChartForDisplay(chart, resolveTableLabel) {
63483
+ function pivotDisplayFieldKeys(chart) {
63484
+ const rowField = String(chart.pivot?.rowField ?? "").trim();
63485
+ const firstPivotRow = (chart.rows ?? []).find(
63486
+ (row) => Object.keys(row).length > 0
63487
+ );
63488
+ if (!firstPivotRow) return [];
63489
+ const keys = Object.keys(firstPivotRow).filter(
63490
+ (field) => !INTERNAL_PIVOT_ROW_FIELDS.has(field)
63491
+ );
63492
+ if (rowField && keys.includes(rowField)) {
63493
+ return [rowField, ...keys.filter((field) => field !== rowField)];
63494
+ }
63495
+ return keys;
63496
+ }
63497
+ function pivotValueFieldKeys(chart) {
63498
+ const rowKey = pivotRowKey(chart);
63499
+ const rowField = String(chart.pivot?.rowField ?? "").trim();
63500
+ return pivotDisplayFieldKeys(chart).filter(
63501
+ (field) => field !== rowKey && field !== rowField
63502
+ );
63503
+ }
63504
+ function pivotFallbackValueKeys(chart) {
63505
+ return (chart.pivotColumns ?? []).slice(1).map((column) => String(column.field ?? "").trim()).filter(Boolean);
63506
+ }
63507
+ function findSavedYAxisField(saved, field) {
63508
+ return saved.find((axis) => String(axis.field ?? "").trim() === field) ?? (saved.length === 1 ? saved[0] : void 0);
63509
+ }
63510
+ function isPlaceholderAxisLabel(label, field) {
63511
+ const trimmed = String(label ?? "").trim();
63512
+ const fieldTrim = String(field ?? "").trim();
63513
+ if (!trimmed) return true;
63514
+ if (trimmed.toLowerCase() === fieldTrim.toLowerCase()) return true;
63515
+ return trimmed === toTitleCaseLabel(fieldTrim);
63516
+ }
63517
+ function resolvedAxisLabel(savedLabel, field, generatedLabel) {
63518
+ return isPlaceholderAxisLabel(savedLabel, field) ? generatedLabel : savedLabel;
63519
+ }
63520
+ function resolveYAxisFormatForField(field, aggregation, saved, fallback) {
63521
+ const formatByField = new Map(
63522
+ saved.map((axis) => [String(axis.field ?? "").trim(), axis.format])
63523
+ );
63524
+ if (aggregation?.aggregationType === "count") {
63525
+ return formatByField.get(field) ?? formatByField.get("count") ?? saved[0]?.format ?? "whole_number";
63526
+ }
63527
+ if (aggregation?.aggregationType === "percentage") {
63528
+ const savedFormat = formatByField.get(field);
63529
+ if (savedFormat === "percent" || savedFormat === "percentage") {
63530
+ return savedFormat;
63531
+ }
63532
+ return "percentage";
63533
+ }
63534
+ const aggType = aggregation?.aggregationType ? String(aggregation.aggregationType) : void 0;
63535
+ return formatByField.get(field) ?? formatByField.get(trimAggregationSuffix(field, aggType)) ?? (aggregation?.valueField ? formatByField.get(aggregation.valueField) : void 0) ?? fallback;
63536
+ }
63537
+ function aggregationIdentityForField(field, aggregations) {
63538
+ return getAggregationIdentityKey(
63539
+ findAggregationForFieldStrict(field, aggregations)
63540
+ );
63541
+ }
63542
+ function indexByAggregationIdentity(axes, aggregations) {
63543
+ const byIdentity = /* @__PURE__ */ new Map();
63544
+ for (const axis of axes) {
63545
+ const identity = aggregationIdentityForField(axis.field, aggregations);
63546
+ if (identity && !byIdentity.has(identity)) {
63547
+ byIdentity.set(identity, axis);
63548
+ }
63549
+ }
63550
+ return byIdentity;
63551
+ }
63552
+ function matchedValueKeyForAggregation(aggregation, valueKeys, canonicalField) {
63553
+ if (valueKeys.includes(canonicalField)) return canonicalField;
63554
+ return valueKeys.find(
63555
+ (key) => findAggregationForFieldStrict(key, [aggregation])
63556
+ );
63557
+ }
63558
+ function composePivotColumnSeriesLabel(field, aggregation, measureLabel, hasMultipleAggregations) {
63559
+ if (!aggregation) return toTitleCaseLabel(String(field ?? ""));
63560
+ const category = normalizePivotColumnDisplayValue(
63561
+ getPivotColumnValueForSeries(field, aggregation, hasMultipleAggregations)
63562
+ );
63563
+ const isMeasureNamedSeries = Boolean(aggregation.valueField) && category === String(aggregation.valueField ?? "").trim();
63564
+ if (isMeasureNamedSeries) return measureLabel;
63565
+ if (!measureLabel || measureLabel === category) return category;
63566
+ return `${category} \xB7 ${measureLabel}`;
63567
+ }
63568
+ function measureFromAggregation(aggregation, chart, saved, fallback, hasMultipleAggregations, resolveTableLabel) {
63569
+ const canonicalField = getAggregationFieldKey(
63570
+ aggregation,
63571
+ hasMultipleAggregations
63572
+ );
63573
+ if (!canonicalField) return null;
63574
+ const previous = findSavedYAxisField(saved, canonicalField);
63575
+ const savedLabel = String(previous?.label ?? "").trim();
63576
+ const generatedLabel = buildAggregationLabel(
63577
+ aggregation,
63578
+ chart,
63579
+ resolveTableLabel
63580
+ );
63581
+ return {
63582
+ field: canonicalField,
63583
+ label: resolvedAxisLabel(savedLabel, canonicalField, generatedLabel),
63584
+ format: resolveYAxisFormatForField(
63585
+ canonicalField,
63586
+ aggregation,
63587
+ saved,
63588
+ fallback
63589
+ )
63590
+ };
63591
+ }
63592
+ function applyYAxisEdits(measures, edits, aggregations) {
63593
+ if (!edits) return measures;
63594
+ const byField = new Map(
63595
+ measures.map((measure) => [String(measure.field ?? "").trim(), measure])
63596
+ );
63597
+ const byIdentity = indexByAggregationIdentity(measures, aggregations);
63598
+ const next = [];
63599
+ for (const edit of edits) {
63600
+ const field = String(edit.field ?? "").trim();
63601
+ if (!field) continue;
63602
+ const identity = aggregationIdentityForField(field, aggregations);
63603
+ const base = (identity ? byIdentity.get(identity) : void 0) ?? byField.get(field);
63604
+ const label = String(edit.label ?? "").trim();
63605
+ if (!base) {
63606
+ next.push({
63607
+ field,
63608
+ label: label || toTitleCaseLabel(field),
63609
+ format: toAxisFormat(edit.format, "string")
63610
+ });
63611
+ continue;
63612
+ }
63613
+ next.push({
63614
+ field: base.field,
63615
+ label: label || base.label,
63616
+ format: toAxisFormat(edit.format, base.format)
63617
+ });
63618
+ }
63619
+ return next.length > 0 ? next : measures;
63620
+ }
63621
+ function resolveReportYAxis(chart, edits, resolveTableLabel) {
63622
+ const saved = chart.yAxisFields ?? [];
63623
+ if (!chart.pivot) {
63624
+ const measures2 = applyYAxisEdits(saved, edits, []);
63625
+ return { measures: measures2, series: measures2 };
63626
+ }
63627
+ const aggregations = getPivotAggregations(chart);
63628
+ const hasMultipleAggregations = aggregations.length > 1;
63629
+ const columnField = String(chart.pivot?.columnField ?? "").trim();
63630
+ const isAggregationOnlyPivot = !String(chart.pivot?.rowField ?? "").trim() && !columnField;
63631
+ const fallback = saved[0]?.format ?? chart.xAxisFormat ?? "whole_number";
63632
+ const valueKeys = pivotValueFieldKeys(chart);
63633
+ const fallbackKeys = pivotFallbackValueKeys(chart);
63634
+ let measures = aggregations.flatMap((aggregation) => {
63635
+ const measure = measureFromAggregation(
63636
+ aggregation,
63637
+ chart,
63638
+ saved,
63639
+ fallback,
63640
+ hasMultipleAggregations,
63641
+ resolveTableLabel
63642
+ );
63643
+ if (!measure) return [];
63644
+ if (columnField) return [measure];
63645
+ if (valueKeys.length === 0) return [measure];
63646
+ const matchedKey = matchedValueKeyForAggregation(
63647
+ aggregation,
63648
+ valueKeys,
63649
+ measure.field
63650
+ );
63651
+ if (matchedKey) return [{ ...measure, field: matchedKey }];
63652
+ return isAggregationOnlyPivot ? [measure] : [];
63653
+ });
63654
+ if (!columnField && measures.length === 0 && saved.length > 0) {
63655
+ measures = saved;
63656
+ }
63657
+ measures = applyYAxisEdits(measures, edits, aggregations);
63658
+ if (!columnField) {
63659
+ return { measures, series: measures };
63660
+ }
63661
+ const keys = valueKeys.length > 0 ? valueKeys : fallbackKeys;
63662
+ const measureByIdentity = indexByAggregationIdentity(measures, aggregations);
63663
+ const selectedIdentities = new Set(measureByIdentity.keys());
63664
+ const series = keys.flatMap((field) => {
63665
+ const aggregation = findAggregationForFieldStrict(field, aggregations);
63666
+ const identity = getAggregationIdentityKey(aggregation);
63667
+ if (selectedIdentities.size > 0 && identity && !selectedIdentities.has(identity)) {
63668
+ return [];
63669
+ }
63670
+ const measure = (identity ? measureByIdentity.get(identity) : void 0) ?? (measures.length === 1 ? measures[0] : void 0);
63671
+ const measureLabel = String(measure?.label ?? "").trim() || (aggregation ? buildAggregationLabel(aggregation, chart, resolveTableLabel) : toTitleCaseLabel(field));
63672
+ return [
63673
+ {
63674
+ field,
63675
+ label: composePivotColumnSeriesLabel(
63676
+ field,
63677
+ aggregation,
63678
+ measureLabel,
63679
+ hasMultipleAggregations
63680
+ ),
63681
+ format: measure?.format ?? resolveYAxisFormatForField(field, aggregation, saved, fallback)
63682
+ }
63683
+ ];
63684
+ });
63685
+ if (series.length > 0) {
63686
+ return { measures, series };
63687
+ }
63688
+ return { measures, series: measures };
63689
+ }
63690
+ function normalizePivotChartForDisplay(chart) {
63484
63691
  const swapPivotRowsForChartRows = Boolean(chart?.pivot) && Array.isArray(chart?.pivotRows) && chart.pivotRows.length > 0;
63485
63692
  const syntheticAggregationOnlyRows = chart && !swapPivotRowsForChartRows ? buildSyntheticAggregationOnlyDisplayRows(chart) : null;
63486
63693
  const hasExplicitEmptyGroupedPivot = Boolean(
@@ -63516,136 +63723,13 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
63516
63723
  String(withResolvedXAxis.chartType ?? "").toLowerCase()
63517
63724
  );
63518
63725
  const aggregations = getPivotAggregations(withResolvedXAxis);
63519
- const hasMultipleAggregations = aggregations.length > 1;
63520
63726
  const yAxisFallbackFormat = withResolvedXAxis.yAxisFields?.[0]?.format ?? withResolvedXAxis.xAxisFormat ?? "whole_number";
63521
63727
  const firstPivotRow = (withResolvedXAxis.rows ?? []).find(
63522
63728
  (row) => Object.keys(row).length > 0
63523
63729
  );
63524
- const pivotRowFieldName = String(
63525
- withResolvedXAxis.pivot?.rowField ?? ""
63526
- ).trim();
63527
- const pivotRowFields = firstPivotRow ? (() => {
63528
- const keys = Object.keys(firstPivotRow).filter(
63529
- (field) => !INTERNAL_PIVOT_ROW_FIELDS.has(field)
63530
- );
63531
- if (pivotRowFieldName && keys.includes(pivotRowFieldName)) {
63532
- return [
63533
- pivotRowFieldName,
63534
- ...keys.filter((field) => field !== pivotRowFieldName)
63535
- ];
63536
- }
63537
- return keys;
63538
- })() : [];
63539
- const pivotValueFields = pivotRowFields.filter(
63540
- (field) => field !== pivotRowKey(withResolvedXAxis) && field !== withResolvedXAxis.pivot?.rowField
63541
- );
63542
- const isAggregationOnlyPivot = !String(withResolvedXAxis.pivot?.rowField ?? "").trim() && !String(withResolvedXAxis.pivot?.columnField ?? "").trim();
63543
- const yAxisFormatByField = new Map(
63544
- (withResolvedXAxis.yAxisFields ?? []).map((axis) => [
63545
- axis.field,
63546
- axis.format
63547
- ])
63548
- );
63549
- const resolveYAxisFormat = (field, aggregation) => {
63550
- if (aggregation?.aggregationType === "count") {
63551
- const savedFormat = yAxisFormatByField.get(field) ?? yAxisFormatByField.get("count") ?? withResolvedXAxis.yAxisFields?.find(
63552
- (axis) => String(axis.field ?? "").trim() === field
63553
- )?.format ?? withResolvedXAxis.yAxisFields?.[0]?.format;
63554
- if (savedFormat) return savedFormat;
63555
- return "whole_number";
63556
- }
63557
- if (aggregation?.aggregationType === "percentage") {
63558
- const savedFormat = yAxisFormatByField.get(field);
63559
- if (savedFormat === "percent" || savedFormat === "percentage") {
63560
- return savedFormat;
63561
- }
63562
- return "percentage";
63563
- }
63564
- const directAxisFormat = yAxisFormatByField.get(field);
63565
- if (directAxisFormat) return directAxisFormat;
63566
- const aggType = aggregation?.aggregationType ? String(aggregation.aggregationType) : void 0;
63567
- const baseField = trimAggregationSuffix(field, aggType);
63568
- const baseAxisFormat = yAxisFormatByField.get(baseField);
63569
- if (baseAxisFormat) return baseAxisFormat;
63570
- if (aggregation?.valueField) {
63571
- const aggregationValueFieldFormat = yAxisFormatByField.get(
63572
- aggregation.valueField
63573
- );
63574
- if (aggregationValueFieldFormat) return aggregationValueFieldFormat;
63575
- }
63576
- return yAxisFallbackFormat;
63577
- };
63578
- const resolveAggregationAxisFieldForDisplay = (aggregation, canonicalField) => {
63579
- if (!canonicalField) return null;
63580
- if (pivotValueFields.includes(canonicalField)) {
63581
- return canonicalField;
63582
- }
63583
- if (!isAggregationOnlyPivot) {
63584
- return null;
63585
- }
63586
- const matchedPivotKey = pivotValueFields.find(
63587
- (pf) => findAggregationForFieldStrict(pf, [aggregation])
63588
- );
63589
- return matchedPivotKey ?? canonicalField;
63590
- };
63591
- const yAxisFromAggregations = !withResolvedXAxis.pivot?.columnField && aggregations.length > 0 ? aggregations.map((aggregation) => {
63592
- const canonicalField = getAggregationFieldKey(
63593
- aggregation,
63594
- hasMultipleAggregations
63595
- );
63596
- const field = resolveAggregationAxisFieldForDisplay(
63597
- aggregation,
63598
- canonicalField
63599
- );
63600
- if (!field) return null;
63601
- return {
63602
- field,
63603
- label: buildAggregationLabel(
63604
- aggregation,
63605
- withResolvedXAxis,
63606
- resolveTableLabel
63607
- ),
63608
- format: resolveYAxisFormat(field, aggregation)
63609
- };
63610
- }).filter((axis) => Boolean(axis)) : [];
63611
- const mappedValueFields = new Set(
63612
- yAxisFromAggregations.map((axis) => axis.field)
63613
- );
63614
- const yAxisFromPivotRowFields = pivotValueFields.filter((field) => !mappedValueFields.has(field)).map((field) => {
63615
- const aggregation = findAggregationForFieldStrict(field, aggregations);
63616
- const cleanedBaseField = aggregation?.aggregationType && hasMultipleAggregations ? trimAggregationSuffix(field, String(aggregation.aggregationType)) : field;
63617
- const displayBase = aggregation?.valueField && withResolvedXAxis.pivot?.columnField ? trimAggregationSuffix(cleanedBaseField, aggregation.valueField) : cleanedBaseField;
63618
- const displayBaseField = normalizePivotColumnDisplayValue(displayBase);
63619
- const aggregationLabel = aggregation ? buildAggregationLabel(
63620
- aggregation,
63621
- withResolvedXAxis,
63622
- resolveTableLabel
63623
- ) : void 0;
63624
- const isMeasureNamedSeries = Boolean(aggregation?.valueField) && displayBaseField === String(aggregation?.valueField ?? "").trim();
63625
- let pivotColumnSeriesLabel = displayBaseField;
63626
- if (withResolvedXAxis.pivot?.columnField && aggregation && aggregationLabel) {
63627
- if (isMeasureNamedSeries) {
63628
- pivotColumnSeriesLabel = aggregationLabel;
63629
- } else if (aggregationLabel !== displayBaseField) {
63630
- const alreadyCombined = String(displayBaseField).endsWith(` \xB7 ${aggregationLabel}`) || String(displayBaseField).endsWith(` \u2014 ${aggregationLabel}`) || String(displayBaseField).endsWith(` (${aggregationLabel})`);
63631
- pivotColumnSeriesLabel = alreadyCombined ? displayBaseField : `${displayBaseField} \xB7 ${aggregationLabel}`;
63632
- }
63633
- }
63634
- const label = aggregation ? withResolvedXAxis.pivot?.columnField ? pivotColumnSeriesLabel : aggregationLabel ?? displayBaseField : toTitleCaseLabel(String(field ?? ""));
63635
- return {
63636
- field,
63637
- label,
63638
- format: resolveYAxisFormat(field, aggregation)
63639
- };
63640
- });
63641
- const supplementalYAxisFromPivotRowFields = yAxisFromAggregations.length > 0 ? yAxisFromPivotRowFields.filter(
63642
- (axis) => Boolean(findAggregationForFieldStrict(axis.field, aggregations))
63643
- ) : yAxisFromPivotRowFields;
63644
- const yAxisFields = yAxisFromAggregations.length > 0 ? [...yAxisFromAggregations, ...supplementalYAxisFromPivotRowFields] : supplementalYAxisFromPivotRowFields.length > 0 ? supplementalYAxisFromPivotRowFields : (withResolvedXAxis.pivotColumns ?? []).slice(1).map((column) => ({
63645
- field: column.field,
63646
- label: column.label ?? column.field,
63647
- format: column.format ?? yAxisFallbackFormat
63648
- }));
63730
+ const pivotRowFields = pivotDisplayFieldKeys(withResolvedXAxis);
63731
+ const pivotValueFields = pivotValueFieldKeys(withResolvedXAxis);
63732
+ const yAxisFields = withResolvedXAxis.yAxisFields ?? [];
63649
63733
  const knownColumnsByField = new Map(
63650
63734
  [
63651
63735
  ...withResolvedXAxis.pivotColumns ?? [],
@@ -63666,21 +63750,21 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
63666
63750
  };
63667
63751
  }) : withResolvedXAxis.columns ?? [];
63668
63752
  const isPivotTableChart = String(withResolvedXAxis.chartType ?? "").toLowerCase() === "table" && Boolean(withResolvedXAxis.pivot);
63669
- const pivotTableSlotColumns = isPivotTableChart && Array.isArray(withResolvedXAxis.pivotColumns) && withResolvedXAxis.pivotColumns.length > 0 ? withResolvedXAxis.pivotColumns : withResolvedXAxis.columns;
63753
+ const savedPivotTableColumns = isPivotTableChart && Array.isArray(withResolvedXAxis.pivotColumns) && withResolvedXAxis.pivotColumns.length > 0 ? withResolvedXAxis.pivotColumns : withResolvedXAxis.columns;
63670
63754
  const pivotTableDisplayColumns = isPivotTableChart && pivotColumnFields.length > 0 ? normalizedPivotColumns.map((col) => {
63671
- const slotCol = getPivotTableSlotReportColumn(
63672
- pivotTableSlotColumns,
63755
+ const savedColumn = getPivotTableReportColumn(
63756
+ savedPivotTableColumns,
63673
63757
  aggregations,
63674
63758
  pivotRowKey(withResolvedXAxis) || withResolvedXAxis.pivot?.rowField,
63675
63759
  col.field
63676
63760
  );
63677
- if (!slotCol) return col;
63761
+ if (!savedColumn) return col;
63678
63762
  const next = {
63679
63763
  ...col,
63680
- format: slotCol.format ?? col.format
63764
+ format: savedColumn.format ?? col.format
63681
63765
  };
63682
- if (slotCol.inferFormat !== void 0) {
63683
- next.inferFormat = slotCol.inferFormat;
63766
+ if (savedColumn.inferFormat !== void 0) {
63767
+ next.inferFormat = savedColumn.inferFormat;
63684
63768
  }
63685
63769
  return next;
63686
63770
  }) : normalizedPivotColumns;
@@ -63741,100 +63825,10 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
63741
63825
  yAxisFields
63742
63826
  };
63743
63827
  }
63744
- function buildPivotAggregationAxisFields(report, resolveTableLabel) {
63745
- const aggregations = getPivotAggregations(report);
63746
- const hasMultipleAggregations = aggregations.length > 1;
63747
- return aggregations.map((aggregation) => {
63748
- const field = getAggregationFieldKey(
63749
- aggregation,
63750
- hasMultipleAggregations
63751
- );
63752
- if (!field) return null;
63753
- return {
63754
- field,
63755
- label: buildAggregationLabel(aggregation, report, resolveTableLabel),
63756
- format: getYAxisFormatFromAggregation(aggregation)
63757
- };
63758
- }).filter((axis) => Boolean(axis));
63759
- }
63760
- function mergePivotColumnAxisFieldsWithMapped(aggregationAxisFields, mapped) {
63761
- const byField = /* @__PURE__ */ new Map();
63762
- for (const y of mapped) {
63763
- const f = String(y.field ?? "").trim();
63764
- if (f) byField.set(f, y);
63765
- }
63766
- return aggregationAxisFields.map((axis) => {
63767
- const f = String(axis.field ?? "").trim();
63768
- const mappedAxis = f ? byField.get(f) : void 0;
63769
- return mappedAxis ?? axis;
63770
- });
63771
- }
63772
- function normalizePivotChartForAxisControls(chart, reportId, resolveTableLabel) {
63773
- if (!chart?.pivot?.columnField) return chart;
63774
- const aggregations = getPivotAggregations(chart);
63775
- if (aggregations.length === 0) return chart;
63776
- const aggregationAxisFields = buildPivotAggregationAxisFields(
63777
- chart,
63778
- resolveTableLabel
63779
- );
63780
- if (aggregationAxisFields.length === 0) return chart;
63781
- const aggregationAxisByIdentity = /* @__PURE__ */ new Map();
63782
- for (const aggregationAxisField of aggregationAxisFields) {
63783
- const aggregation = findAggregationForFieldStrict(
63784
- aggregationAxisField.field,
63785
- aggregations
63786
- );
63787
- const aggregationIdentity = getAggregationIdentityKey(aggregation);
63788
- if (!aggregationIdentity || aggregationAxisByIdentity.has(aggregationIdentity)) {
63789
- continue;
63790
- }
63791
- aggregationAxisByIdentity.set(aggregationIdentity, aggregationAxisField);
63792
- }
63793
- const mappedExistingYAxisFields = [];
63794
- const seenMappedFields = /* @__PURE__ */ new Set();
63795
- for (const existingYAxisField of chart.yAxisFields ?? []) {
63796
- const aggregation = findAggregationForFieldStrict(
63797
- existingYAxisField.field,
63798
- aggregations
63799
- );
63800
- const aggregationIdentity = getAggregationIdentityKey(aggregation);
63801
- if (!aggregationIdentity) continue;
63802
- const mappedAggregationAxis = aggregationAxisByIdentity.get(aggregationIdentity);
63803
- if (!mappedAggregationAxis) continue;
63804
- if (seenMappedFields.has(mappedAggregationAxis.field)) continue;
63805
- seenMappedFields.add(mappedAggregationAxis.field);
63806
- mappedExistingYAxisFields.push({
63807
- field: mappedAggregationAxis.field,
63808
- label: String(existingYAxisField.label ?? "").trim() || mappedAggregationAxis.label,
63809
- format: toAxisFormat(
63810
- existingYAxisField.format,
63811
- mappedAggregationAxis.format
63812
- )
63813
- });
63814
- }
63815
- let yAxisFields;
63816
- if (aggregations.length > 1) {
63817
- const resolvedReportId = String(reportId ?? chart.id ?? "").trim();
63818
- if (LEGACY_SINGLE_Y_AXIS_COLUMN_PIVOT_REPORT_IDS.has(resolvedReportId)) {
63819
- yAxisFields = mappedExistingYAxisFields.length > 0 ? mappedExistingYAxisFields : [aggregationAxisFields[0]];
63820
- } else {
63821
- yAxisFields = mappedExistingYAxisFields.length === 0 || mappedExistingYAxisFields.length < aggregationAxisFields.length ? mergePivotColumnAxisFieldsWithMapped(
63822
- aggregationAxisFields,
63823
- mappedExistingYAxisFields
63824
- ) : mappedExistingYAxisFields;
63825
- }
63826
- } else {
63827
- yAxisFields = mappedExistingYAxisFields.length > 0 ? mappedExistingYAxisFields : [aggregationAxisFields[0]];
63828
- }
63829
- return {
63830
- ...chart,
63831
- yAxisFields
63832
- };
63833
- }
63834
- function buildPivotColumnPivotTableFormattingColumns(pivot, chart, resolveTableLabel) {
63828
+ function buildPivotTableColumns(pivot, chart, resolveTableLabel) {
63835
63829
  if (!pivot) return null;
63836
- const reportForControls = chart ? { ...chart, pivot } : { pivot };
63837
- const aggregations = getPivotAggregations(reportForControls);
63830
+ const chartWithPivot = chart ? { ...chart, pivot } : { pivot };
63831
+ const aggregations = getPivotAggregations(chartWithPivot);
63838
63832
  if (aggregations.length === 0) return null;
63839
63833
  const hasMultipleAggregations = aggregations.length > 1;
63840
63834
  const rowField = String(pivot.rowField ?? "").trim();
@@ -63868,7 +63862,7 @@ function buildPivotColumnPivotTableFormattingColumns(pivot, chart, resolveTableL
63868
63862
  field: fieldKey,
63869
63863
  label: buildAggregationLabel(
63870
63864
  aggregation,
63871
- reportForControls,
63865
+ chartWithPivot,
63872
63866
  resolveTableLabel
63873
63867
  )
63874
63868
  });
@@ -63895,19 +63889,6 @@ function mergePivotColumnSeriesLabelWithUserEdit(normalizedLabel, userRowLabel,
63895
63889
  }
63896
63890
  return user;
63897
63891
  }
63898
- function applySingleResolvedYAxisFormatToPivotDisplay(normalizedPivotYAxisFields, resolvedYAxisFields) {
63899
- if (resolvedYAxisFields.length !== 1) return normalizedPivotYAxisFields;
63900
- const only = resolvedYAxisFields[0];
63901
- return normalizedPivotYAxisFields.map((axis) => ({
63902
- ...axis,
63903
- label: mergePivotColumnSeriesLabelWithUserEdit(
63904
- String(axis.label ?? "").trim(),
63905
- only.label,
63906
- String(axis.field ?? "").trim() || void 0
63907
- ),
63908
- format: toAxisFormat(only.format, axis.format)
63909
- }));
63910
- }
63911
63892
  function mergeChartColumnFormatsFromYAxisFields(columns, yAxisFields) {
63912
63893
  if (!columns?.length || !yAxisFields?.length) return columns;
63913
63894
  const formatByField = /* @__PURE__ */ new Map();
@@ -63965,71 +63946,6 @@ function mergePivotTableDisplayColumnLabelsFromYAxis({
63965
63946
  return { ...c, label: yl };
63966
63947
  });
63967
63948
  }
63968
- function mapResolvedPivotYAxisFieldsForDisplay({
63969
- chart,
63970
- resolvedYAxisFields
63971
- }) {
63972
- if (!chart.pivot?.columnField) return resolvedYAxisFields;
63973
- const normalizedPivotYAxisFields = chart.yAxisFields ?? [];
63974
- if (normalizedPivotYAxisFields.length === 0) return resolvedYAxisFields;
63975
- const aggregations = getPivotAggregations(chart);
63976
- if (aggregations.length === 0) {
63977
- return applySingleResolvedYAxisFormatToPivotDisplay(
63978
- normalizedPivotYAxisFields,
63979
- resolvedYAxisFields
63980
- );
63981
- }
63982
- const selectedAggregationByIdentity = /* @__PURE__ */ new Map();
63983
- for (const yAxisField of resolvedYAxisFields ?? []) {
63984
- const aggregation = findAggregationForFieldStrict(
63985
- yAxisField.field,
63986
- aggregations
63987
- );
63988
- const aggregationIdentity = getAggregationIdentityKey(aggregation);
63989
- if (!aggregationIdentity) continue;
63990
- selectedAggregationByIdentity.set(aggregationIdentity, yAxisField);
63991
- }
63992
- if (selectedAggregationByIdentity.size === 0) {
63993
- return applySingleResolvedYAxisFormatToPivotDisplay(
63994
- normalizedPivotYAxisFields,
63995
- resolvedYAxisFields
63996
- );
63997
- }
63998
- const mappedYAxisFields = [];
63999
- const seenMappedFields = /* @__PURE__ */ new Set();
64000
- for (const normalizedYAxisField of normalizedPivotYAxisFields) {
64001
- const aggregation = findAggregationForFieldStrict(
64002
- normalizedYAxisField.field,
64003
- aggregations
64004
- );
64005
- const aggregationIdentity = getAggregationIdentityKey(aggregation);
64006
- if (!aggregationIdentity) continue;
64007
- const selectedAggregationAxis = selectedAggregationByIdentity.get(aggregationIdentity);
64008
- if (!selectedAggregationAxis) continue;
64009
- const field = String(normalizedYAxisField.field ?? "").trim();
64010
- if (!field || seenMappedFields.has(field)) continue;
64011
- seenMappedFields.add(field);
64012
- mappedYAxisFields.push({
64013
- ...normalizedYAxisField,
64014
- label: mergePivotColumnSeriesLabelWithUserEdit(
64015
- String(normalizedYAxisField.label ?? "").trim(),
64016
- selectedAggregationAxis.label,
64017
- field || void 0
64018
- ),
64019
- format: toAxisFormat(
64020
- selectedAggregationAxis.format,
64021
- normalizedYAxisField.format
64022
- )
64023
- });
64024
- }
64025
- if (mappedYAxisFields.length > 0) {
64026
- return mappedYAxisFields;
64027
- }
64028
- return applySingleResolvedYAxisFormatToPivotDisplay(
64029
- normalizedPivotYAxisFields,
64030
- resolvedYAxisFields
64031
- );
64032
- }
64033
63949
  function encodeColumnOptionValue(table, field) {
64034
63950
  if (!table || !table.trim()) return field;
64035
63951
  return `${table}_${field}`;
@@ -65618,8 +65534,7 @@ async function fetchReportBuilderStateByReportId({
65618
65534
  if (!state || typeof state !== "object") {
65619
65535
  return null;
65620
65536
  }
65621
- const parsedState = state;
65622
- return parsedState;
65537
+ return state;
65623
65538
  } catch (error) {
65624
65539
  if (error instanceof Error && error.name === "AbortError") {
65625
65540
  throw error;
@@ -65658,10 +65573,11 @@ function applyFetchedReportBuilderState(result, fetchedReportBuilderState) {
65658
65573
  }).filter(
65659
65574
  (table) => Boolean(table)
65660
65575
  );
65576
+ const keptExistingRules = existingRules.rules.length > 0;
65661
65577
  const mergedState = {
65662
65578
  tables: mergedTables,
65663
65579
  columns: existingColumns.length > 0 ? existingColumns : fetchedColumns,
65664
- rules: existingRules.rules.length > 0 ? existingRules : fetchedRules,
65580
+ rules: keptExistingRules ? existingRules : fetchedRules,
65665
65581
  pivot: existingState?.pivot ?? fetchedReportBuilderState.pivot ?? null,
65666
65582
  sort: existingSort.length > 0 ? existingSort : fetchedSort,
65667
65583
  limit: existingState?.limit ?? fetchedReportBuilderState.limit ?? null
@@ -66479,7 +66395,7 @@ function useReport(reportIdArg, options = {}) {
66479
66395
  (0, import_react63.useEffect)(() => {
66480
66396
  setTableColumnsEditedSignature(null);
66481
66397
  }, [effectiveReportId]);
66482
- const [chartAxisEdits, setChartAxisEdits] = (0, import_react63.useState)({});
66398
+ const [axisEdits, setAxisEdits] = (0, import_react63.useState)({});
66483
66399
  const [chartVisibilityOverrides, setChartVisibilityOverrides] = (0, import_react63.useState)({});
66484
66400
  const [chartSortOverride, setChartSortOverride] = (0, import_react63.useState)(void 0);
66485
66401
  const [client] = (0, import_react63.useContext)(ClientContext);
@@ -66611,7 +66527,7 @@ function useReport(reportIdArg, options = {}) {
66611
66527
  }
66612
66528
  }, [createdReportBootstrap?.reportId, propReportId]);
66613
66529
  (0, import_react63.useEffect)(() => {
66614
- setChartAxisEdits({});
66530
+ setAxisEdits({});
66615
66531
  setChartVisibilityOverrides({});
66616
66532
  setChartSortOverride(void 0);
66617
66533
  }, [effectiveReportId]);
@@ -67899,6 +67815,24 @@ function useReport(reportIdArg, options = {}) {
67899
67815
  initialDataUpdatedAt: () => findCachedDashboardReportQuery(queryClient, effectiveReportId)?.state.dataUpdatedAt,
67900
67816
  staleTime: DASHBOARD_REPORT_STALE_TIME_MS
67901
67817
  });
67818
+ const reportBuilderStateQuery = (0, import_react_query3.useQuery)({
67819
+ queryKey: ["useReport", "report-builder-state", effectiveReportId],
67820
+ queryFn: createUseFormQueryFn((signal) => {
67821
+ if (!client) {
67822
+ return Promise.resolve(null);
67823
+ }
67824
+ return fetchReportBuilderStateByReportId({
67825
+ reportId: effectiveReportId,
67826
+ client,
67827
+ getToken,
67828
+ draftSessionId: draftSessionId || void 0,
67829
+ tenants,
67830
+ abortSignal: signal
67831
+ });
67832
+ }),
67833
+ enabled: Boolean(effectiveReportId) && Boolean(client) && !reportOverride,
67834
+ staleTime: 0
67835
+ });
67902
67836
  const reportNameQueryReportId = String(effectiveReportId ?? "").trim();
67903
67837
  const reportNameQuery = (0, import_react_query3.useQuery)({
67904
67838
  queryKey: createUseFormReportNameQueryKey({
@@ -67929,10 +67863,21 @@ function useReport(reportIdArg, options = {}) {
67929
67863
  const displayReportName = formReportName !== void 0 ? formReportName : resolvedReportName;
67930
67864
  (0, import_react63.useEffect)(() => {
67931
67865
  if (reportOverride) return;
67932
- const report = initialLoadQuery.data?.report ?? null;
67866
+ const report = applyFetchedReportBuilderState(
67867
+ initialLoadQuery.data ?? { report: null },
67868
+ reportBuilderStateQuery.data ?? null
67869
+ ).report ?? null;
67933
67870
  initializeSchemaScopeForReport(report);
67934
67871
  setSourceReport(report);
67935
- }, [initialLoadQuery.data, reportOverride, effectiveReportId]);
67872
+ }, [
67873
+ initialLoadQuery.data,
67874
+ initialLoadQuery.fetchStatus,
67875
+ initialLoadQuery.isFetching,
67876
+ initialLoadQuery.isPending,
67877
+ reportBuilderStateQuery.data,
67878
+ reportOverride,
67879
+ effectiveReportId
67880
+ ]);
67936
67881
  (0, import_react63.useEffect)(() => {
67937
67882
  if (!sourceReport) {
67938
67883
  return;
@@ -69584,20 +69529,18 @@ function useReport(reportIdArg, options = {}) {
69584
69529
  chartPivotHydrationEpoch
69585
69530
  ]);
69586
69531
  const baseChart = (0, import_react63.useMemo)(
69587
- () => normalizePivotChartForDisplay(chartData, resolveTableDisplayLabel),
69588
- [chartData, resolveTableDisplayLabel]
69532
+ () => normalizePivotChartForDisplay(chartData),
69533
+ [chartData]
69589
69534
  );
69590
- const chartAxesBaseChart = (0, import_react63.useMemo)(() => {
69591
- if (!chartData) return void 0;
69592
- if (chartData.pivot?.columnField) {
69593
- return normalizePivotChartForAxisControls(
69594
- chartData,
69595
- effectiveReportId,
69596
- resolveTableDisplayLabel
69597
- );
69598
- }
69599
- return baseChart;
69600
- }, [baseChart, chartData, effectiveReportId, resolveTableDisplayLabel]);
69535
+ const yAxisResolved = (0, import_react63.useMemo)(() => {
69536
+ if (!baseChart) return { measures: [], series: [] };
69537
+ return resolveReportYAxis(
69538
+ baseChart,
69539
+ axisEdits.yAxisFields,
69540
+ resolveTableDisplayLabel
69541
+ );
69542
+ }, [baseChart, axisEdits.yAxisFields, resolveTableDisplayLabel]);
69543
+ const chartAxesBaseChart = baseChart;
69601
69544
  const chartAxisOptions = (0, import_react63.useMemo)(() => {
69602
69545
  if (!chartAxesBaseChart) return [];
69603
69546
  const optionsByField = /* @__PURE__ */ new Map();
@@ -69616,7 +69559,7 @@ function useReport(reportIdArg, options = {}) {
69616
69559
  for (const column of chartAxesBaseChart.columns ?? []) {
69617
69560
  registerOption(column.field, column.label, column.format);
69618
69561
  }
69619
- for (const yAxis2 of chartAxesBaseChart.yAxisFields ?? []) {
69562
+ for (const yAxis2 of yAxisResolved.measures) {
69620
69563
  registerOption(yAxis2.field, yAxis2.label, yAxis2.format);
69621
69564
  if (yAxis2.format) {
69622
69565
  const existing = optionsByField.get(yAxis2.field);
@@ -69628,18 +69571,6 @@ function useReport(reportIdArg, options = {}) {
69628
69571
  }
69629
69572
  }
69630
69573
  }
69631
- if (chartAxesBaseChart.pivot?.columnField) {
69632
- for (const aggregationAxis of buildPivotAggregationAxisFields(
69633
- chartAxesBaseChart,
69634
- resolveTableDisplayLabel
69635
- )) {
69636
- registerOption(
69637
- aggregationAxis.field,
69638
- aggregationAxis.label,
69639
- aggregationAxis.format
69640
- );
69641
- }
69642
- }
69643
69574
  const xField = String(chartAxesBaseChart.xAxisField ?? "").trim();
69644
69575
  const savedXFormat = String(chartAxesBaseChart.xAxisFormat ?? "").trim();
69645
69576
  registerOption(
@@ -69657,7 +69588,7 @@ function useReport(reportIdArg, options = {}) {
69657
69588
  }
69658
69589
  }
69659
69590
  return Array.from(optionsByField.values());
69660
- }, [chartAxesBaseChart, resolveTableDisplayLabel]);
69591
+ }, [chartAxesBaseChart, yAxisResolved.measures]);
69661
69592
  const chartAxisOptionByField = (0, import_react63.useMemo)(() => {
69662
69593
  const optionsByField = /* @__PURE__ */ new Map();
69663
69594
  for (const option of chartAxisOptions) {
@@ -69702,19 +69633,15 @@ function useReport(reportIdArg, options = {}) {
69702
69633
  const pivot = chartAxesBaseChart.pivot;
69703
69634
  const pivotRowField = String(pivot?.rowField ?? "").trim();
69704
69635
  if (pivot && !pivotRowField) {
69705
- const aggAxis = buildPivotAggregationAxisFields(
69706
- chartAxesBaseChart,
69707
- resolveTableDisplayLabel
69708
- );
69709
- if (aggAxis.length > 0) {
69710
- const allowed = new Set(aggAxis.map((a) => a.field));
69636
+ const allowed = new Set(yAxisResolved.measures.map((axis) => axis.field));
69637
+ if (allowed.size > 0) {
69711
69638
  eligible = eligible.filter((o) => allowed.has(o.value));
69712
69639
  }
69713
69640
  }
69714
69641
  const merged = new Map(
69715
69642
  eligible.map((o) => [o.value, o])
69716
69643
  );
69717
- for (const yAxisField of chartAxesBaseChart.yAxisFields ?? []) {
69644
+ for (const yAxisField of yAxisResolved.measures) {
69718
69645
  const field = String(yAxisField?.field ?? "").trim();
69719
69646
  if (!field || merged.has(field)) continue;
69720
69647
  const opt = chartAxisOptionByField.get(field);
@@ -69725,8 +69652,8 @@ function useReport(reportIdArg, options = {}) {
69725
69652
  chartAxesBaseChart,
69726
69653
  chartAxisOptionByField,
69727
69654
  chartAxisOptions,
69728
- resolveTableDisplayLabel,
69729
- schemaColumnOptions
69655
+ schemaColumnOptions,
69656
+ yAxisResolved.measures
69730
69657
  ]);
69731
69658
  const normalizedChartXAxisOptions = (0, import_react63.useMemo)(() => {
69732
69659
  return xAxisOptions.map((option) => ({
@@ -69742,34 +69669,9 @@ function useReport(reportIdArg, options = {}) {
69742
69669
  format: String(option.format ?? "").trim()
69743
69670
  }));
69744
69671
  }, [yAxisOptions]);
69745
- const resolvedYAxisFields = (0, import_react63.useMemo)(() => {
69746
- if (!chartAxesBaseChart) return [];
69747
- const normalizeYAxisField = (yAxisFieldRaw) => {
69748
- const field = String(yAxisFieldRaw?.field ?? "").trim();
69749
- if (!field) return null;
69750
- const option = chartAxisOptionByField.get(field);
69751
- if (!option) return null;
69752
- const rawLabel = String(yAxisFieldRaw?.label ?? "").trim() || option.label;
69753
- const label = rawLabel === field ? toTitleCaseLabel(field) : rawLabel;
69754
- const format9 = toAxisFormat(yAxisFieldRaw?.format, option.format);
69755
- return {
69756
- field,
69757
- label,
69758
- format: format9
69759
- };
69760
- };
69761
- const fallbackYAxisFields = (chartAxesBaseChart.yAxisFields ?? []).map((yAxisField) => normalizeYAxisField(yAxisField)).filter(
69762
- (yAxisField) => Boolean(yAxisField)
69763
- );
69764
- const requestedYAxisFields = Array.isArray(chartAxisEdits.yAxisFields) ? chartAxisEdits.yAxisFields : fallbackYAxisFields;
69765
- const normalizedRequestedYAxisFields = requestedYAxisFields.map((yAxisField) => normalizeYAxisField(yAxisField)).filter(
69766
- (yAxisField) => Boolean(yAxisField)
69767
- );
69768
- if (normalizedRequestedYAxisFields.length > 0) {
69769
- return normalizedRequestedYAxisFields;
69770
- }
69771
- if (fallbackYAxisFields.length > 0) {
69772
- return fallbackYAxisFields;
69672
+ const yAxisMeasures = (0, import_react63.useMemo)(() => {
69673
+ if (yAxisResolved.measures.length > 0) {
69674
+ return yAxisResolved.measures;
69773
69675
  }
69774
69676
  const fallbackOption = chartAxisOptions[0];
69775
69677
  if (!fallbackOption) return [];
@@ -69780,12 +69682,7 @@ function useReport(reportIdArg, options = {}) {
69780
69682
  format: fallbackOption.format
69781
69683
  }
69782
69684
  ];
69783
- }, [
69784
- chartAxesBaseChart,
69785
- chartAxisEdits.yAxisFields,
69786
- chartAxisOptionByField,
69787
- chartAxisOptions
69788
- ]);
69685
+ }, [chartAxisOptions, yAxisResolved.measures]);
69789
69686
  const resolvedXAxisField = (0, import_react63.useMemo)(() => {
69790
69687
  if (!chartAxesBaseChart) return "";
69791
69688
  const chartType2 = String(chartAxesBaseChart.chartType ?? "").toLowerCase();
@@ -69800,7 +69697,7 @@ function useReport(reportIdArg, options = {}) {
69800
69697
  return pivotRowField;
69801
69698
  }
69802
69699
  }
69803
- const requestedXAxisField = String(chartAxisEdits.xAxisField ?? "").trim();
69700
+ const requestedXAxisField = String(axisEdits.xAxisField ?? "").trim();
69804
69701
  if (requestedXAxisField && chartAxisOptionByField.has(requestedXAxisField)) {
69805
69702
  return requestedXAxisField;
69806
69703
  }
@@ -69808,16 +69705,16 @@ function useReport(reportIdArg, options = {}) {
69808
69705
  if (baseXAxisField && chartAxisOptionByField.has(baseXAxisField)) {
69809
69706
  return baseXAxisField;
69810
69707
  }
69811
- return resolvedYAxisFields[0]?.field ?? chartAxisOptions[0]?.value ?? "";
69708
+ return yAxisMeasures[0]?.field ?? chartAxisOptions[0]?.value ?? "";
69812
69709
  }, [
69813
69710
  chartAxesBaseChart,
69814
- chartAxisEdits.xAxisField,
69711
+ axisEdits.xAxisField,
69815
69712
  chartAxisOptionByField,
69816
69713
  chartAxisOptions,
69817
- resolvedYAxisFields
69714
+ yAxisMeasures
69818
69715
  ]);
69819
69716
  const xAxisMetadataField = String(
69820
- chartAxisEdits.xAxisField ?? chartData?.xAxisField ?? ""
69717
+ axisEdits.xAxisField ?? chartData?.xAxisField ?? ""
69821
69718
  ).trim();
69822
69719
  const xAxisMetadataMatchesResolvedField = !xAxisMetadataField || xAxisMetadataField === resolvedXAxisField;
69823
69720
  const resolvedXAxisFormat = (0, import_react63.useMemo)(() => {
@@ -69825,7 +69722,7 @@ function useReport(reportIdArg, options = {}) {
69825
69722
  return "string";
69826
69723
  }
69827
69724
  let defaultFormat = toAxisFormat(
69828
- chartAxisOptionByField.get(resolvedXAxisField)?.format ?? chartAxesBaseChart.xAxisFormat ?? resolvedYAxisFields[0]?.format,
69725
+ chartAxisOptionByField.get(resolvedXAxisField)?.format ?? chartAxesBaseChart.xAxisFormat ?? yAxisMeasures[0]?.format,
69829
69726
  "string"
69830
69727
  );
69831
69728
  const bucketFormat = resolvePivotDateBucketXAxisFormat(
@@ -69833,16 +69730,16 @@ function useReport(reportIdArg, options = {}) {
69833
69730
  resolvedXAxisField
69834
69731
  );
69835
69732
  if (bucketFormat) return bucketFormat;
69836
- if (isPivotTableDateBucketRowAxis(chartAxesBaseChart, resolvedXAxisField) && (!xAxisMetadataMatchesResolvedField || chartAxisEdits.xAxisFormat === void 0)) {
69733
+ if (isPivotTableDateBucketRowAxis(chartAxesBaseChart, resolvedXAxisField) && (!xAxisMetadataMatchesResolvedField || axisEdits.xAxisFormat === void 0)) {
69837
69734
  defaultFormat = "string";
69838
69735
  }
69839
- return xAxisMetadataMatchesResolvedField && chartAxisEdits.xAxisFormat !== void 0 ? toAxisFormat(chartAxisEdits.xAxisFormat, defaultFormat) : defaultFormat;
69736
+ return xAxisMetadataMatchesResolvedField && axisEdits.xAxisFormat !== void 0 ? toAxisFormat(axisEdits.xAxisFormat, defaultFormat) : defaultFormat;
69840
69737
  }, [
69841
69738
  chartAxesBaseChart,
69842
- chartAxisEdits.xAxisFormat,
69739
+ axisEdits.xAxisFormat,
69843
69740
  chartAxisOptionByField,
69844
69741
  resolvedXAxisField,
69845
- resolvedYAxisFields,
69742
+ yAxisMeasures,
69846
69743
  xAxisMetadataMatchesResolvedField
69847
69744
  ]);
69848
69745
  const resolvedXAxisLabel = (0, import_react63.useMemo)(() => {
@@ -69850,13 +69747,13 @@ function useReport(reportIdArg, options = {}) {
69850
69747
  const defaultXLabel = String(
69851
69748
  xAxisMetadataMatchesResolvedField ? chartAxesBaseChart?.xAxisLabel ?? fieldLabel : fieldLabel
69852
69749
  ).trim();
69853
- if (xAxisMetadataMatchesResolvedField && chartAxisEdits.xAxisLabel !== void 0) {
69854
- return String(chartAxisEdits.xAxisLabel).trim();
69750
+ if (xAxisMetadataMatchesResolvedField && axisEdits.xAxisLabel !== void 0) {
69751
+ return String(axisEdits.xAxisLabel).trim();
69855
69752
  }
69856
69753
  return !defaultXLabel || defaultXLabel === resolvedXAxisField ? toTitleCaseLabel(resolvedXAxisField) : defaultXLabel;
69857
69754
  }, [
69858
69755
  chartAxesBaseChart?.xAxisLabel,
69859
- chartAxisEdits.xAxisLabel,
69756
+ axisEdits.xAxisLabel,
69860
69757
  chartAxisOptionByField,
69861
69758
  resolvedXAxisField,
69862
69759
  xAxisMetadataMatchesResolvedField
@@ -69886,7 +69783,7 @@ function useReport(reportIdArg, options = {}) {
69886
69783
  ]);
69887
69784
  const yAxis = (0, import_react63.useMemo)(
69888
69785
  () => ({
69889
- fields: resolvedYAxisFields.map((yAxisField) => ({
69786
+ fields: yAxisMeasures.map((yAxisField) => ({
69890
69787
  field: yAxisField.field,
69891
69788
  label: String(yAxisField.label ?? "").trim(),
69892
69789
  format: axisFormatToSelectLabel(
@@ -69894,24 +69791,23 @@ function useReport(reportIdArg, options = {}) {
69894
69791
  )
69895
69792
  }))
69896
69793
  }),
69897
- [resolvedYAxisFields]
69794
+ [yAxisMeasures]
69898
69795
  );
69899
- const resolvedYAxisFieldsForDisplay = (0, import_react63.useMemo)(() => {
69900
- if (!baseChart) return resolvedYAxisFields;
69901
- return mapResolvedPivotYAxisFieldsForDisplay({
69902
- chart: baseChart,
69903
- resolvedYAxisFields
69904
- });
69905
- }, [baseChart, resolvedYAxisFields]);
69796
+ const yAxisSeries = (0, import_react63.useMemo)(() => {
69797
+ if (yAxisResolved.series.length > 0) {
69798
+ return yAxisResolved.series;
69799
+ }
69800
+ return yAxisMeasures;
69801
+ }, [yAxisMeasures, yAxisResolved.series]);
69906
69802
  const chart = (0, import_react63.useMemo)(() => {
69907
69803
  if (!baseChart) return void 0;
69908
69804
  let columns2 = mergeChartColumnFormatsFromYAxisFields(
69909
69805
  baseChart.columns,
69910
- resolvedYAxisFieldsForDisplay
69806
+ yAxisSeries
69911
69807
  );
69912
69808
  if (String(baseChart.chartType ?? "").toLowerCase() === "table" && baseChart.pivot) {
69913
69809
  const pivotAggregations2 = getPivotAggregations(baseChart);
69914
- const hasCustomMeasureLabel = resolvedYAxisFields.some((axis) => {
69810
+ const hasCustomMeasureLabel = yAxisMeasures.some((axis) => {
69915
69811
  const aggregation = findAggregationForFieldStrict(
69916
69812
  axis.field,
69917
69813
  pivotAggregations2
@@ -69924,7 +69820,7 @@ function useReport(reportIdArg, options = {}) {
69924
69820
  if (pivotAggregations2.length > 1 || hasCustomMeasureLabel) {
69925
69821
  columns2 = mergePivotTableDisplayColumnLabelsFromYAxis({
69926
69822
  columns: columns2 ?? baseChart.columns,
69927
- yAxisFields: resolvedYAxisFieldsForDisplay,
69823
+ yAxisFields: yAxisSeries,
69928
69824
  pivotRowField: pivotRowKey(baseChart),
69929
69825
  xAxisLabel: resolvedXAxisLabel
69930
69826
  });
@@ -69951,7 +69847,7 @@ function useReport(reportIdArg, options = {}) {
69951
69847
  xAxisField: resolvedXAxisField,
69952
69848
  xAxisFormat: resolvedXAxisFormat,
69953
69849
  xAxisLabel: resolvedXAxisLabel,
69954
- yAxisFields: resolvedYAxisFieldsForDisplay,
69850
+ yAxisFields: yAxisSeries,
69955
69851
  columns: columns2 ?? baseChart.columns
69956
69852
  };
69957
69853
  }, [
@@ -69959,8 +69855,8 @@ function useReport(reportIdArg, options = {}) {
69959
69855
  resolvedXAxisField,
69960
69856
  resolvedXAxisFormat,
69961
69857
  resolvedXAxisLabel,
69962
- resolvedYAxisFields,
69963
- resolvedYAxisFieldsForDisplay
69858
+ yAxisMeasures,
69859
+ yAxisSeries
69964
69860
  ]);
69965
69861
  const pivotDateFilterRangeCacheRef = (0, import_react63.useRef)({ key: "", min: null, max: null });
69966
69862
  const filterOptions = (0, import_react63.useMemo)(() => {
@@ -69978,10 +69874,7 @@ function useReport(reportIdArg, options = {}) {
69978
69874
  if (rowField && isDateType(String(pivot?.rowFieldType ?? ""))) {
69979
69875
  const field = pivot?.rowFieldTable ? `${pivot.rowFieldTable}.${rowField}` : rowField;
69980
69876
  const chartBucket = dateBucket || pivot?.dateBucket || "month";
69981
- const bucket = inBucketDateBucketForField(
69982
- filtersForQueryBuilder.rules ?? [],
69983
- field
69984
- ) ?? chartBucket;
69877
+ const bucket = inBucketDateBucketForField(filtersForQueryBuilder.rules ?? [], field) ?? chartBucket;
69985
69878
  const cacheKey = `${String(effectiveReportId ?? "")}\0${field}\0${bucket}`;
69986
69879
  if (pivotDateFilterRangeCacheRef.current.key !== cacheKey) {
69987
69880
  pivotDateFilterRangeCacheRef.current = {
@@ -70114,8 +70007,8 @@ function useReport(reportIdArg, options = {}) {
70114
70007
  [chartForUi, resolvedChartSort]
70115
70008
  );
70116
70009
  const isPivotTableChart = String(chartType ?? "").toLowerCase() === "table" && Boolean(pivotState);
70117
- const pivotTableColumnControls = (0, import_react63.useMemo)(
70118
- () => isPivotTableChart ? buildPivotColumnPivotTableFormattingColumns(
70010
+ const pivotTableColumns = (0, import_react63.useMemo)(
70011
+ () => isPivotTableChart ? buildPivotTableColumns(
70119
70012
  pivotState,
70120
70013
  chart,
70121
70014
  resolveTableDisplayLabel
@@ -70123,7 +70016,7 @@ function useReport(reportIdArg, options = {}) {
70123
70016
  [chart, isPivotTableChart, pivotState, resolveTableDisplayLabel]
70124
70017
  );
70125
70018
  const chartAxes = (0, import_react63.useMemo)(() => {
70126
- const yAxisItems = resolvedYAxisFields.map(
70019
+ const yAxisItems = yAxisMeasures.map(
70127
70020
  (yAxisField, index) => ({
70128
70021
  id: String(index),
70129
70022
  field: yAxisField.field,
@@ -70131,7 +70024,7 @@ function useReport(reportIdArg, options = {}) {
70131
70024
  format: toAxisFormat(yAxisField.format, "string")
70132
70025
  })
70133
70026
  );
70134
- const getCurrentYAxisFields = () => resolvedYAxisFields.map((yAxisField) => ({
70027
+ const getCurrentYAxisFields = () => yAxisMeasures.map((yAxisField) => ({
70135
70028
  field: yAxisField.field,
70136
70029
  label: yAxisField.label,
70137
70030
  format: toAxisFormat(yAxisField.format, "string")
@@ -70143,7 +70036,7 @@ function useReport(reportIdArg, options = {}) {
70143
70036
  options: xAxisOptions,
70144
70037
  formatOptions: AXIS_FORMAT_OPTIONS,
70145
70038
  update: (updates) => {
70146
- setChartAxisEdits((previousEdits) => {
70039
+ setAxisEdits((previousEdits) => {
70147
70040
  const nextEdits = { ...previousEdits };
70148
70041
  if (updates.field !== void 0) {
70149
70042
  const requestedField = String(updates.field ?? "").trim();
@@ -70200,7 +70093,7 @@ function useReport(reportIdArg, options = {}) {
70200
70093
  resolvedXAxisFormat || "string"
70201
70094
  )
70202
70095
  };
70203
- setChartAxisEdits((previousEdits) => ({
70096
+ setAxisEdits((previousEdits) => ({
70204
70097
  ...previousEdits,
70205
70098
  yAxisFields: [...currentYAxisFields, nextYAxisField]
70206
70099
  }));
@@ -70213,7 +70106,7 @@ function useReport(reportIdArg, options = {}) {
70213
70106
  if (index < 0 || index >= currentYAxisFields.length) return;
70214
70107
  const nextYAxisFields = [...currentYAxisFields];
70215
70108
  nextYAxisFields.splice(index, 1);
70216
- setChartAxisEdits((previousEdits) => ({
70109
+ setAxisEdits((previousEdits) => ({
70217
70110
  ...previousEdits,
70218
70111
  yAxisFields: nextYAxisFields
70219
70112
  }));
@@ -70226,7 +70119,7 @@ function useReport(reportIdArg, options = {}) {
70226
70119
  newIndex
70227
70120
  );
70228
70121
  if (nextYAxisFields === currentYAxisFields) return;
70229
- setChartAxisEdits((previousEdits) => ({
70122
+ setAxisEdits((previousEdits) => ({
70230
70123
  ...previousEdits,
70231
70124
  yAxisFields: nextYAxisFields
70232
70125
  }));
@@ -70255,7 +70148,7 @@ function useReport(reportIdArg, options = {}) {
70255
70148
  label: nextLabel,
70256
70149
  format: nextFormat
70257
70150
  };
70258
- setChartAxisEdits((previousEdits) => ({
70151
+ setAxisEdits((previousEdits) => ({
70259
70152
  ...previousEdits,
70260
70153
  yAxisFields: nextYAxisFields
70261
70154
  }));
@@ -70267,7 +70160,7 @@ function useReport(reportIdArg, options = {}) {
70267
70160
  chartAxisOptionByField,
70268
70161
  resolvedXAxisField,
70269
70162
  resolvedXAxisFormat,
70270
- resolvedYAxisFields,
70163
+ yAxisMeasures,
70271
70164
  xAxisOptions,
70272
70165
  yAxisOptions
70273
70166
  ]);
@@ -70299,7 +70192,7 @@ function useReport(reportIdArg, options = {}) {
70299
70192
  includeSelectedSchemaFallback: tableColumnsEditedSignature !== null
70300
70193
  });
70301
70194
  const pivotRowFieldForTable = pivotRowKey(sourceReport);
70302
- const pivotRowTableUsesAxisFormat = chartAxisEdits.xAxisFormat !== void 0;
70195
+ const pivotRowTableUsesAxisFormat = axisEdits.xAxisFormat !== void 0;
70303
70196
  const columns2 = String(chartType ?? "").toLowerCase() === "table" && sourceReport?.pivot && pivotRowFieldForTable && String(resolvedXAxisField ?? "").trim() === pivotRowFieldForTable ? mergedFromReport.map(
70304
70197
  (column) => column.field === pivotRowFieldForTable ? {
70305
70198
  ...column,
@@ -70309,7 +70202,7 @@ function useReport(reportIdArg, options = {}) {
70309
70202
  ) : mergedFromReport;
70310
70203
  const pivotLabeledColumns = String(chartType ?? "").toLowerCase() === "table" && sourceReport?.pivot ? mergePivotTableDisplayColumnLabelsFromYAxis({
70311
70204
  columns: columns2,
70312
- yAxisFields: resolvedYAxisFieldsForDisplay,
70205
+ yAxisFields: yAxisSeries,
70313
70206
  pivotRowField: pivotRowKey(sourceReport),
70314
70207
  xAxisLabel: resolvedXAxisLabel
70315
70208
  }) ?? columns2 : columns2;
@@ -70385,14 +70278,14 @@ function useReport(reportIdArg, options = {}) {
70385
70278
  getPageOptions: () => getPageOptionsFromPageCount(paginationPageCount)
70386
70279
  };
70387
70280
  }, [
70388
- chartAxisEdits.xAxisFormat,
70281
+ axisEdits.xAxisFormat,
70389
70282
  chartType,
70390
70283
  displayColumns,
70391
70284
  effectiveReportBuilderTableNames,
70392
70285
  resolvedXAxisField,
70393
70286
  resolvedXAxisFormat,
70394
70287
  resolvedXAxisLabel,
70395
- resolvedYAxisFieldsForDisplay,
70288
+ yAxisSeries,
70396
70289
  scopedSchemaColumns,
70397
70290
  sourceReport,
70398
70291
  tableColumnsEditedSignature,
@@ -70417,11 +70310,11 @@ function useReport(reportIdArg, options = {}) {
70417
70310
  columnsOptions: tableFormattingColumnOptions,
70418
70311
  hasTableDrivenColumnOrder
70419
70312
  } = (0, import_react63.useMemo)(() => {
70420
- if (pivotTableColumnControls) {
70313
+ if (pivotTableColumns) {
70421
70314
  return getAllColumnOptions({
70422
70315
  schemaColumnOptions,
70423
- tableColumns: pivotTableColumnControls.tableColumns,
70424
- selectedColumnIds: pivotTableColumnControls.selectedColumnIds
70316
+ tableColumns: pivotTableColumns.tableColumns,
70317
+ selectedColumnIds: pivotTableColumns.selectedColumnIds
70425
70318
  });
70426
70319
  }
70427
70320
  if (isPivotTableChart) {
@@ -70442,7 +70335,7 @@ function useReport(reportIdArg, options = {}) {
70442
70335
  chart?.xAxisLabel,
70443
70336
  columns,
70444
70337
  isPivotTableChart,
70445
- pivotTableColumnControls,
70338
+ pivotTableColumns,
70446
70339
  schemaColumnOptions,
70447
70340
  table.columns
70448
70341
  ]);
@@ -70464,8 +70357,8 @@ function useReport(reportIdArg, options = {}) {
70464
70357
  [tableDerivedColumnOrder]
70465
70358
  );
70466
70359
  const activeTableColumnIds = (0, import_react63.useMemo)(() => {
70467
- if (pivotTableColumnControls) {
70468
- return pivotTableColumnControls.selectedColumnIds;
70360
+ if (pivotTableColumns) {
70361
+ return pivotTableColumns.selectedColumnIds;
70469
70362
  }
70470
70363
  if (isPivotTableChart) {
70471
70364
  return [];
@@ -70493,7 +70386,7 @@ function useReport(reportIdArg, options = {}) {
70493
70386
  columns,
70494
70387
  hasTableDrivenColumnOrder,
70495
70388
  isPivotTableChart,
70496
- pivotTableColumnControls,
70389
+ pivotTableColumns,
70497
70390
  tableDerivedColumnOrder,
70498
70391
  tableFormattingColumnOptions
70499
70392
  ]);
@@ -70554,44 +70447,12 @@ function useReport(reportIdArg, options = {}) {
70554
70447
  });
70555
70448
  }
70556
70449
  const columnPivotMeasureFormatByAggregationField = /* @__PURE__ */ new Map();
70557
- if (pivotTableColumnControls && chart) {
70558
- const slotFormatting = pivotTableColumnControls;
70559
- if (slotFormatting) {
70560
- const aggregations = slotFormatting.aggregations;
70561
- const hasMultiple = aggregations.length > 1;
70562
- const rowField = pivotRowKey(chart);
70563
- const firstValueColumnFormat = String(
70564
- (chart.columns ?? []).find(
70565
- (c) => String(c.field ?? "").trim() !== rowField
70566
- )?.format ?? ""
70567
- ).trim();
70568
- for (let aggIdx = 0; aggIdx < aggregations.length; aggIdx++) {
70569
- const agg = aggregations[aggIdx];
70570
- const fieldKey = getAggregationFieldKey(agg, hasMultiple);
70571
- if (!fieldKey) continue;
70572
- let fmt = "";
70573
- if (!hasMultiple) {
70574
- fmt = String(chart.yAxisFields?.[0]?.format ?? "").trim() || firstValueColumnFormat;
70575
- } else {
70576
- for (const yAxisField of chart.yAxisFields ?? []) {
70577
- const wf = String(yAxisField.field ?? "").trim();
70578
- if (!wf) continue;
70579
- const matched = findAggregationForFieldStrict(wf, aggregations);
70580
- if (!matched || getAggregationIdentityKey(matched) !== getAggregationIdentityKey(agg)) {
70581
- continue;
70582
- }
70583
- fmt = String(yAxisField.format ?? "").trim();
70584
- break;
70585
- }
70586
- if (!fmt && sourceReport?.columns?.[aggIdx + 1]) {
70587
- fmt = String(
70588
- sourceReport.columns[aggIdx + 1]?.format ?? ""
70589
- ).trim();
70590
- }
70591
- }
70592
- if (fmt) {
70593
- columnPivotMeasureFormatByAggregationField.set(fieldKey, fmt);
70594
- }
70450
+ if (pivotTableColumns) {
70451
+ for (const measure of yAxisResolved.measures) {
70452
+ const field = String(measure.field ?? "").trim();
70453
+ const fmt = String(measure.format ?? "").trim();
70454
+ if (field && fmt) {
70455
+ columnPivotMeasureFormatByAggregationField.set(field, fmt);
70595
70456
  }
70596
70457
  }
70597
70458
  }
@@ -70642,11 +70503,11 @@ function useReport(reportIdArg, options = {}) {
70642
70503
  displayColumnById,
70643
70504
  isPivotTableChart,
70644
70505
  pivotState,
70645
- pivotTableColumnControls,
70506
+ pivotTableColumns,
70646
70507
  resolvedXAxisFormat,
70647
70508
  resolvedXAxisLabel,
70648
- sourceReport?.columns,
70649
- tableFormatMerge
70509
+ tableFormatMerge,
70510
+ yAxisResolved.measures
70650
70511
  ]);
70651
70512
  const tableColumnSettingsCoalesceRef = (0, import_react63.useRef)(
70652
70513
  /* @__PURE__ */ new Map()
@@ -70668,8 +70529,8 @@ function useReport(reportIdArg, options = {}) {
70668
70529
  const field = String(option?.field ?? "").trim() || columnId;
70669
70530
  const tableName = String(option?.tableName ?? "").trim();
70670
70531
  const coercedFormat = coerceTableColumnFormatToAxisValue(format9);
70671
- const isPivotDateRowSlot = isPivotTableChart && field === pivotRowFieldForFormat && isDateType(pivotRowFieldType);
70672
- const formatLabel = isPivotDateRowSlot && coercedFormat === "string" ? "date" : axisFormatToSelectLabel(coercedFormat);
70532
+ const isPivotDateRow = isPivotTableChart && field === pivotRowFieldForFormat && isDateType(pivotRowFieldType);
70533
+ const formatLabel = isPivotDateRow && coercedFormat === "string" ? "date" : axisFormatToSelectLabel(coercedFormat);
70673
70534
  return {
70674
70535
  id: columnId,
70675
70536
  label: customLabel || defaultLabel,
@@ -70712,7 +70573,7 @@ function useReport(reportIdArg, options = {}) {
70712
70573
  isPivotTableChart,
70713
70574
  tableColumnItems
70714
70575
  ]);
70715
- const initialLoadInProgress = !reportOverride && Boolean(effectiveReportId) && (!client || initialLoadQuery.isPending || initialLoadQuery.isFetching);
70576
+ const initialLoadInProgress = !reportOverride && Boolean(effectiveReportId) && (!client || initialLoadQuery.isPending || initialLoadQuery.isFetching || reportBuilderStateQuery.isPending || reportBuilderStateQuery.isFetching);
70716
70577
  const filterUniqueValuesLoading = filterUniqueValuesEnabled && (filterUniqueValuesQuery.isPending || filterUniqueValuesQuery.isFetching);
70717
70578
  const chartLoading = initialLoadInProgress || pendingPivotRefresh || (Boolean(nextPivot) ? pivotRefreshQuery.isFetching : tableRefreshQuery.isFetching);
70718
70579
  const awaitingPivotDetailRows = Boolean(nextPivot || sourceReport?.pivot) && !reportOverride && Boolean(sourceReport) && sourceReportMatchesEffectiveReportId && (!Array.isArray(sourceReport?.rows) || sourceReport.rows.length === 0) && pivotTableDataRefreshQuery.status !== "error";
@@ -70862,15 +70723,15 @@ function useReport(reportIdArg, options = {}) {
70862
70723
  chartAxesBaseChart
70863
70724
  );
70864
70725
  const clickedAgg = findAggregationForFieldStrict(pivotField, aggs);
70865
- let nextY = resolvedYAxisFields;
70726
+ let nextY = yAxisMeasures;
70866
70727
  if (updates.format !== void 0) {
70867
70728
  const axisFormatStr = tableColumnFormatFromUiSelection(
70868
70729
  String(updates.format ?? "").trim()
70869
70730
  );
70870
- nextY = resolvedYAxisFields.map((y) => {
70731
+ nextY = yAxisMeasures.map((y) => {
70871
70732
  const yAgg = findAggregationForFieldStrict(y.field, aggs);
70872
70733
  const same = clickedAgg && yAgg && getAggregationIdentityKey(clickedAgg) === getAggregationIdentityKey(yAgg);
70873
- const singleBroadcast = Boolean(clickedAgg) && resolvedYAxisFields.length === 1;
70734
+ const singleBroadcast = Boolean(clickedAgg) && yAxisMeasures.length === 1;
70874
70735
  if (same || singleBroadcast) {
70875
70736
  return {
70876
70737
  ...y,
@@ -70885,9 +70746,9 @@ function useReport(reportIdArg, options = {}) {
70885
70746
  nextY = nextY.map((y) => {
70886
70747
  const yAgg = findAggregationForFieldStrict(y.field, aggs);
70887
70748
  const same = clickedAgg && yAgg && getAggregationIdentityKey(clickedAgg) === getAggregationIdentityKey(yAgg);
70888
- const singleBroadcast = Boolean(clickedAgg) && resolvedYAxisFields.length === 1;
70749
+ const singleBroadcast = Boolean(clickedAgg) && yAxisMeasures.length === 1;
70889
70750
  if (same || singleBroadcast) {
70890
- const nextLabel2 = resolvedYAxisFields.length === 1 && pivotModel.columnField ? mergePivotColumnSeriesLabelWithUserEdit(
70751
+ const nextLabel2 = yAxisMeasures.length === 1 && pivotModel.columnField ? mergePivotColumnSeriesLabelWithUserEdit(
70891
70752
  String(y.label ?? "").trim(),
70892
70753
  lab,
70893
70754
  String(y.field ?? "").trim() || void 0
@@ -71000,7 +70861,7 @@ function useReport(reportIdArg, options = {}) {
71000
70861
  ...effectiveNextState.xAxis !== void 0 ? { xAxis: effectiveNextState.xAxis } : {},
71001
70862
  ...effectiveNextState.yAxis !== void 0 ? { yAxis: effectiveNextState.yAxis } : {}
71002
70863
  };
71003
- setChartAxisEdits((previousEdits) => {
70864
+ setAxisEdits((previousEdits) => {
71004
70865
  const nextEdits = { ...previousEdits };
71005
70866
  if (cx.xAxis) {
71006
70867
  let suppressXAxisLabelFromPayload = false;
@@ -71540,7 +71401,9 @@ function useReport(reportIdArg, options = {}) {
71540
71401
  };
71541
71402
  const saveChanges = (0, import_react63.useCallback)(
71542
71403
  async (overrides) => {
71543
- if (!client || !sourceReport || !effectiveReportBuilderState) return;
71404
+ if (!client || !sourceReport || !effectiveReportBuilderState) {
71405
+ return;
71406
+ }
71544
71407
  const sourceRest = {
71545
71408
  ...sourceReport
71546
71409
  };
@@ -71611,7 +71474,7 @@ function useReport(reportIdArg, options = {}) {
71611
71474
  xAxisField: resolvedXAxisField,
71612
71475
  xAxisFormat: resolvedXAxisFormat,
71613
71476
  xAxisLabel: resolvedXAxisLabel,
71614
- yAxisFields: resolvedYAxisFields,
71477
+ yAxisFields: yAxisMeasures,
71615
71478
  showLegend: chartVisibility.showLegend,
71616
71479
  chartSort: resolvedChartSort ?? null,
71617
71480
  ...overrides?.filterMap !== void 0 ? { filterMap: overrides.filterMap } : {},
@@ -71664,7 +71527,7 @@ function useReport(reportIdArg, options = {}) {
71664
71527
  resolvedXAxisField,
71665
71528
  resolvedXAxisFormat,
71666
71529
  resolvedXAxisLabel,
71667
- resolvedYAxisFields,
71530
+ yAxisMeasures,
71668
71531
  sourceReport,
71669
71532
  table.columns,
71670
71533
  tenants
@@ -71699,9 +71562,9 @@ function useReport(reportIdArg, options = {}) {
71699
71562
  groupColumnsByOptions,
71700
71563
  dateBucket: dateBucketMode === "standard" ? pivotState?.dateBucket : dateBucket,
71701
71564
  dateBucketOptions: hasDatePivotRow ? dateBucketMode === "standard" ? STANDARD_PIVOT_DATE_BUCKET_OPTIONS : PIVOT_DATE_BUCKET_OPTIONS : [],
71702
- /** Encoded selection per aggregation slot (`'sum:transactions::amount'`, `'count:transactions'`, `''` = placeholder). Update via `setReport({ aggregations: nextStringArray })`. */
71565
+ /** Encoded selection per aggregation (`'sum:transactions::amount'`, `'count:transactions'`, `''` = placeholder). Update via `setReport({ aggregations: nextStringArray })`. */
71703
71566
  aggregations: aggregationValues,
71704
- /** Flat aggregation pick list shared by all slots; always contains every non-empty `aggregations` entry. */
71567
+ /** Flat aggregation pick list shared by all aggregations; always contains every non-empty `aggregations` entry. */
71705
71568
  aggregationOptions,
71706
71569
  aggregationDescriptionOptions: cleanedAggregations,
71707
71570
  sort: cleanedSort,
@@ -72646,10 +72509,9 @@ function useReportFilterDraft(args) {
72646
72509
  );
72647
72510
  return stringField?.name ?? fields[0]?.name ?? "";
72648
72511
  }, []);
72649
- const getDefaultValue = (0, import_react66.useCallback)(
72650
- (rule) => defaultFilterRuleValueForOperator(rule?.operator),
72651
- []
72652
- );
72512
+ const getDefaultValue = (0, import_react66.useCallback)((rule) => {
72513
+ return defaultFilterRuleValueForOperator(rule?.operator);
72514
+ }, []);
72653
72515
  const filterDraftQueryBuilderProps = (0, import_react66.useMemo)(
72654
72516
  () => ({
72655
72517
  ...queryBuilderProps,