@quillsql/react 2.16.63 → 2.16.64

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
@@ -61220,22 +61220,18 @@ function normalizePivotChartForAxisControls(chart, reportId) {
61220
61220
  yAxisFields
61221
61221
  };
61222
61222
  }
61223
- function buildPivotColumnPivotTableFormattingColumns(chart) {
61224
- if (!Array.isArray(chart.columns) || chart.columns.length === 0) {
61225
- return null;
61226
- }
61227
- const columnField = String(chart.pivot?.columnField ?? "").trim();
61228
- const aggregations = getPivotAggregations(chart);
61229
- if (!columnField || aggregations.length === 0) {
61230
- return null;
61231
- }
61223
+ function buildPivotColumnPivotTableFormattingColumns(pivot, chart) {
61224
+ if (!pivot) return null;
61225
+ const reportForControls = chart ? { ...chart, pivot } : { pivot };
61226
+ const aggregations = getPivotAggregations(reportForControls);
61227
+ if (aggregations.length === 0) return null;
61232
61228
  const hasMultipleAggregations = aggregations.length > 1;
61233
- const rowField = String(chart.pivot?.rowField ?? "").trim();
61229
+ const rowField = String(pivot.rowField ?? "").trim();
61234
61230
  const tableColumns = [];
61235
61231
  const selectedColumnIds = [];
61236
61232
  if (rowField) {
61237
- const rowSource = chart.columns.find(
61238
- (c) => String(c.field ?? "").trim() === rowField
61233
+ const rowSource = chart?.columns?.find(
61234
+ (column) => String(column.field ?? "").trim() === rowField
61239
61235
  );
61240
61236
  const rowTable = String(
61241
61237
  rowSource?.table ?? ""
@@ -61243,8 +61239,8 @@ function buildPivotColumnPivotTableFormattingColumns(chart) {
61243
61239
  tableColumns.push({
61244
61240
  field: rowField,
61245
61241
  label: String(
61246
- rowSource?.label ?? chart.xAxisLabel ?? chart.xAxisField ?? rowField
61247
- ).trim() || rowField
61242
+ rowSource?.label ?? chart?.xAxisLabel ?? chart?.xAxisField ?? toTitleCaseLabel(rowField)
61243
+ ).trim() || toTitleCaseLabel(rowField)
61248
61244
  });
61249
61245
  const rowId = encodeColumnOptionValue(rowTable || void 0, rowField);
61250
61246
  if (rowId) {
@@ -61259,14 +61255,14 @@ function buildPivotColumnPivotTableFormattingColumns(chart) {
61259
61255
  if (!fieldKey) continue;
61260
61256
  tableColumns.push({
61261
61257
  field: fieldKey,
61262
- label: buildAggregationLabel(aggregation, chart)
61258
+ label: buildAggregationLabel(aggregation, reportForControls)
61263
61259
  });
61264
61260
  const id = encodeColumnOptionValue(void 0, fieldKey);
61265
61261
  if (id) {
61266
61262
  selectedColumnIds.push(id);
61267
61263
  }
61268
61264
  }
61269
- return { tableColumns, selectedColumnIds };
61265
+ return { tableColumns, selectedColumnIds, aggregations };
61270
61266
  }
61271
61267
  function mergePivotColumnSeriesLabelWithUserEdit(normalizedLabel, userRowLabel, pivotSeriesField) {
61272
61268
  const user = String(userRowLabel ?? "").trim();
@@ -64096,7 +64092,7 @@ function useReport(reportIdArg, options = {}) {
64096
64092
  }
64097
64093
  });
64098
64094
  return { uniqueValuesByColumn: normalizedUniqueValuesByColumn };
64099
- } catch (error) {
64095
+ } catch {
64100
64096
  return { uniqueValuesByColumn: {} };
64101
64097
  }
64102
64098
  }),
@@ -66602,8 +66598,10 @@ function useReport(reportIdArg, options = {}) {
66602
66598
  }
66603
66599
  };
66604
66600
  }, [chart, filterOptions, filtersForQueryBuilder]);
66605
- const isPivotTableChart = String(chartType ?? "").toLowerCase() === "table" && Boolean(
66606
- chart && chart.pivot && Array.isArray(chart.columns) && chart.columns.length > 0
66601
+ const isPivotTableChart = String(chartType ?? "").toLowerCase() === "table" && Boolean(pivotState);
66602
+ const pivotTableColumnControls = (0, import_react61.useMemo)(
66603
+ () => isPivotTableChart ? buildPivotColumnPivotTableFormattingColumns(pivotState, chart) : null,
66604
+ [chart, isPivotTableChart, pivotState]
66607
66605
  );
66608
66606
  const chartAxes = (0, import_react61.useMemo)(() => {
66609
66607
  const yAxisItems = resolvedYAxisFields.map(
@@ -66903,24 +66901,19 @@ function useReport(reportIdArg, options = {}) {
66903
66901
  columnsOptions: tableFormattingColumnOptions,
66904
66902
  hasTableDrivenColumnOrder
66905
66903
  } = (0, import_react61.useMemo)(() => {
66906
- if (isPivotTableChart && chart?.columns?.length) {
66907
- const aggregationSlotColumns = buildPivotColumnPivotTableFormattingColumns(chart);
66908
- const pivotTableColumns = aggregationSlotColumns ? aggregationSlotColumns.tableColumns : chart.columns.map((c) => ({
66909
- field: String(c.field ?? "").trim(),
66910
- label: String(c.label ?? c.field ?? "").trim() || String(c.field ?? "")
66911
- }));
66912
- const selectedPivotIds = aggregationSlotColumns ? aggregationSlotColumns.selectedColumnIds : chart.columns.map(
66913
- (c) => encodeColumnOptionValue(
66914
- String(c.table ?? "").trim() || void 0,
66915
- String(c.field ?? "").trim()
66916
- )
66917
- ).filter(Boolean);
66904
+ if (pivotTableColumnControls) {
66918
66905
  return getAllColumnOptions({
66919
66906
  schemaColumnOptions,
66920
- tableColumns: pivotTableColumns,
66921
- selectedColumnIds: selectedPivotIds
66907
+ tableColumns: pivotTableColumnControls.tableColumns,
66908
+ selectedColumnIds: pivotTableColumnControls.selectedColumnIds
66922
66909
  });
66923
66910
  }
66911
+ if (isPivotTableChart) {
66912
+ return {
66913
+ columnsOptions: [],
66914
+ hasTableDrivenColumnOrder: true
66915
+ };
66916
+ }
66924
66917
  return getAllColumnOptions({
66925
66918
  schemaColumnOptions,
66926
66919
  tableColumns: table.columns,
@@ -66933,6 +66926,7 @@ function useReport(reportIdArg, options = {}) {
66933
66926
  chart?.xAxisLabel,
66934
66927
  columns,
66935
66928
  isPivotTableChart,
66929
+ pivotTableColumnControls,
66936
66930
  schemaColumnOptions,
66937
66931
  table.columns
66938
66932
  ]);
@@ -66954,17 +66948,11 @@ function useReport(reportIdArg, options = {}) {
66954
66948
  [tableDerivedColumnOrder]
66955
66949
  );
66956
66950
  const activeTableColumnIds = (0, import_react61.useMemo)(() => {
66957
- if (isPivotTableChart && chart?.columns?.length) {
66958
- const aggregationSlotColumns = buildPivotColumnPivotTableFormattingColumns(chart);
66959
- if (aggregationSlotColumns) {
66960
- return aggregationSlotColumns.selectedColumnIds;
66961
- }
66962
- return chart.columns.map(
66963
- (c) => encodeColumnOptionValue(
66964
- String(c.table ?? "").trim() || void 0,
66965
- String(c.field ?? "").trim()
66966
- )
66967
- ).filter(Boolean);
66951
+ if (pivotTableColumnControls) {
66952
+ return pivotTableColumnControls.selectedColumnIds;
66953
+ }
66954
+ if (isPivotTableChart) {
66955
+ return [];
66968
66956
  }
66969
66957
  const currentColumns = (columns ?? []).filter(Boolean);
66970
66958
  if (!hasTableDrivenColumnOrder) {
@@ -66989,6 +66977,7 @@ function useReport(reportIdArg, options = {}) {
66989
66977
  columns,
66990
66978
  hasTableDrivenColumnOrder,
66991
66979
  isPivotTableChart,
66980
+ pivotTableColumnControls,
66992
66981
  tableDerivedColumnOrder,
66993
66982
  tableFormattingColumnOptions
66994
66983
  ]);
@@ -67043,12 +67032,12 @@ function useReport(reportIdArg, options = {}) {
67043
67032
  });
67044
67033
  }
67045
67034
  const columnPivotMeasureFormatByAggregationField = /* @__PURE__ */ new Map();
67046
- if (isPivotTableChart && chart?.pivot) {
67047
- const slotFormatting = buildPivotColumnPivotTableFormattingColumns(chart);
67035
+ if (pivotTableColumnControls && chart) {
67036
+ const slotFormatting = pivotTableColumnControls;
67048
67037
  if (slotFormatting) {
67049
- const aggregations = getPivotAggregations(chart);
67038
+ const aggregations = slotFormatting.aggregations;
67050
67039
  const hasMultiple = aggregations.length > 1;
67051
- const rowField = String(chart.pivot.rowField ?? "").trim();
67040
+ const rowField = String(pivotState?.rowField ?? "").trim();
67052
67041
  const firstValueColumnFormat = String(
67053
67042
  (chart.columns ?? []).find(
67054
67043
  (c) => String(c.field ?? "").trim() !== rowField
@@ -67128,6 +67117,8 @@ function useReport(reportIdArg, options = {}) {
67128
67117
  columnOptionById,
67129
67118
  displayColumnById,
67130
67119
  isPivotTableChart,
67120
+ pivotState,
67121
+ pivotTableColumnControls,
67131
67122
  resolvedXAxisFormat,
67132
67123
  resolvedXAxisLabel,
67133
67124
  sourceReport?.columns,
@@ -67199,8 +67190,8 @@ function useReport(reportIdArg, options = {}) {
67199
67190
  ]);
67200
67191
  const initialLoadInProgress = !reportOverride && Boolean(effectiveReportId) && (!client || initialLoadQuery.isPending || initialLoadQuery.isFetching);
67201
67192
  const filterUniqueValuesLoading = filterUniqueValuesEnabled && (filterUniqueValuesQuery.isPending || filterUniqueValuesQuery.isFetching);
67202
- const chartLoading = initialLoadInProgress || (Boolean(nextPivot) ? pivotRefreshQuery.isFetching : tableRefreshQuery.isFetching);
67203
- const tableLoading = initialLoadInProgress || tablePageFetching || (Boolean(nextPivot) ? pivotTableDataRefreshQuery.isFetching : tableRefreshQuery.isFetching);
67193
+ const chartLoading = initialLoadInProgress || pendingPivotRefresh || (Boolean(nextPivot) ? pivotRefreshQuery.isFetching : tableRefreshQuery.isFetching);
67194
+ const tableLoading = initialLoadInProgress || pendingPivotRefresh || tablePageFetching || (Boolean(nextPivot) ? pivotTableDataRefreshQuery.isFetching : tableRefreshQuery.isFetching);
67204
67195
  const loading = chartLoading || tableLoading;
67205
67196
  const buildSetReportColumnsFromIds = (nextColumnIds, settingsById) => {
67206
67197
  const normalizedNextIds = nextColumnIds.map((columnId) => String(columnId ?? "").trim()).filter(Boolean);
@@ -67553,13 +67544,25 @@ function useReport(reportIdArg, options = {}) {
67553
67544
  const normalizedDisplayColumns = normalizedRequestedDisplayColumns ?? [];
67554
67545
  const addedDisplayColumns = addedRequestedDisplayColumns;
67555
67546
  next.columns = normalizedDisplayColumns;
67556
- if (addedDisplayColumns.length > 0) {
67547
+ const hasPivotSelection = Boolean(
67548
+ decodePivotGroupOptionValue(next.groupRowsBy) || decodePivotGroupOptionValue(next.groupColumnsBy)
67549
+ ) || next.aggregationState.some(isAppliedAggregation);
67550
+ const requestedDisplayTableNames = new Set(
67551
+ normalizedDisplayColumns.map((column) => String(column.table ?? "").trim()).filter(Boolean)
67552
+ );
67553
+ const selectedDatasourceTableNames = new Set(
67554
+ (next.schemaDatasourceIds ?? []).map((tableName) => String(tableName ?? "").trim()).filter(Boolean)
67555
+ );
67556
+ const replacesDatasourceTableScope = !hasPivotSelection && requestedDisplayTableNames.size > 0 && selectedDatasourceTableNames.size > 0 && [...requestedDisplayTableNames].every(
67557
+ (tableName) => !selectedDatasourceTableNames.has(tableName)
67558
+ );
67559
+ if (replacesDatasourceTableScope) {
67560
+ next.queryColumns = normalizedDisplayColumns;
67561
+ next.schemaDatasourceIds = [...requestedDisplayTableNames];
67562
+ } else if (addedDisplayColumns.length > 0) {
67557
67563
  const queryTableNames = new Set(
67558
67564
  next.queryColumns.map((column) => String(column.table ?? "").trim()).filter(Boolean)
67559
67565
  );
67560
- const hasPivotSelection = Boolean(
67561
- decodePivotGroupOptionValue(next.groupRowsBy) || decodePivotGroupOptionValue(next.groupColumnsBy)
67562
- ) || next.aggregationState.some(isAppliedAggregation);
67563
67566
  const queryColumnsToInclude = addedDisplayColumns.filter(
67564
67567
  (column) => {
67565
67568
  const tableName = String(column.table ?? "").trim();
package/dist/index.js CHANGED
@@ -61432,22 +61432,18 @@ function normalizePivotChartForAxisControls(chart, reportId) {
61432
61432
  yAxisFields
61433
61433
  };
61434
61434
  }
61435
- function buildPivotColumnPivotTableFormattingColumns(chart) {
61436
- if (!Array.isArray(chart.columns) || chart.columns.length === 0) {
61437
- return null;
61438
- }
61439
- const columnField = String(chart.pivot?.columnField ?? "").trim();
61440
- const aggregations = getPivotAggregations(chart);
61441
- if (!columnField || aggregations.length === 0) {
61442
- return null;
61443
- }
61435
+ function buildPivotColumnPivotTableFormattingColumns(pivot, chart) {
61436
+ if (!pivot) return null;
61437
+ const reportForControls = chart ? { ...chart, pivot } : { pivot };
61438
+ const aggregations = getPivotAggregations(reportForControls);
61439
+ if (aggregations.length === 0) return null;
61444
61440
  const hasMultipleAggregations = aggregations.length > 1;
61445
- const rowField = String(chart.pivot?.rowField ?? "").trim();
61441
+ const rowField = String(pivot.rowField ?? "").trim();
61446
61442
  const tableColumns = [];
61447
61443
  const selectedColumnIds = [];
61448
61444
  if (rowField) {
61449
- const rowSource = chart.columns.find(
61450
- (c) => String(c.field ?? "").trim() === rowField
61445
+ const rowSource = chart?.columns?.find(
61446
+ (column) => String(column.field ?? "").trim() === rowField
61451
61447
  );
61452
61448
  const rowTable = String(
61453
61449
  rowSource?.table ?? ""
@@ -61455,8 +61451,8 @@ function buildPivotColumnPivotTableFormattingColumns(chart) {
61455
61451
  tableColumns.push({
61456
61452
  field: rowField,
61457
61453
  label: String(
61458
- rowSource?.label ?? chart.xAxisLabel ?? chart.xAxisField ?? rowField
61459
- ).trim() || rowField
61454
+ rowSource?.label ?? chart?.xAxisLabel ?? chart?.xAxisField ?? toTitleCaseLabel(rowField)
61455
+ ).trim() || toTitleCaseLabel(rowField)
61460
61456
  });
61461
61457
  const rowId = encodeColumnOptionValue(rowTable || void 0, rowField);
61462
61458
  if (rowId) {
@@ -61471,14 +61467,14 @@ function buildPivotColumnPivotTableFormattingColumns(chart) {
61471
61467
  if (!fieldKey) continue;
61472
61468
  tableColumns.push({
61473
61469
  field: fieldKey,
61474
- label: buildAggregationLabel(aggregation, chart)
61470
+ label: buildAggregationLabel(aggregation, reportForControls)
61475
61471
  });
61476
61472
  const id = encodeColumnOptionValue(void 0, fieldKey);
61477
61473
  if (id) {
61478
61474
  selectedColumnIds.push(id);
61479
61475
  }
61480
61476
  }
61481
- return { tableColumns, selectedColumnIds };
61477
+ return { tableColumns, selectedColumnIds, aggregations };
61482
61478
  }
61483
61479
  function mergePivotColumnSeriesLabelWithUserEdit(normalizedLabel, userRowLabel, pivotSeriesField) {
61484
61480
  const user = String(userRowLabel ?? "").trim();
@@ -64308,7 +64304,7 @@ function useReport(reportIdArg, options = {}) {
64308
64304
  }
64309
64305
  });
64310
64306
  return { uniqueValuesByColumn: normalizedUniqueValuesByColumn };
64311
- } catch (error) {
64307
+ } catch {
64312
64308
  return { uniqueValuesByColumn: {} };
64313
64309
  }
64314
64310
  }),
@@ -66814,8 +66810,10 @@ function useReport(reportIdArg, options = {}) {
66814
66810
  }
66815
66811
  };
66816
66812
  }, [chart, filterOptions, filtersForQueryBuilder]);
66817
- const isPivotTableChart = String(chartType ?? "").toLowerCase() === "table" && Boolean(
66818
- chart && chart.pivot && Array.isArray(chart.columns) && chart.columns.length > 0
66813
+ const isPivotTableChart = String(chartType ?? "").toLowerCase() === "table" && Boolean(pivotState);
66814
+ const pivotTableColumnControls = useMemo32(
66815
+ () => isPivotTableChart ? buildPivotColumnPivotTableFormattingColumns(pivotState, chart) : null,
66816
+ [chart, isPivotTableChart, pivotState]
66819
66817
  );
66820
66818
  const chartAxes = useMemo32(() => {
66821
66819
  const yAxisItems = resolvedYAxisFields.map(
@@ -67115,24 +67113,19 @@ function useReport(reportIdArg, options = {}) {
67115
67113
  columnsOptions: tableFormattingColumnOptions,
67116
67114
  hasTableDrivenColumnOrder
67117
67115
  } = useMemo32(() => {
67118
- if (isPivotTableChart && chart?.columns?.length) {
67119
- const aggregationSlotColumns = buildPivotColumnPivotTableFormattingColumns(chart);
67120
- const pivotTableColumns = aggregationSlotColumns ? aggregationSlotColumns.tableColumns : chart.columns.map((c) => ({
67121
- field: String(c.field ?? "").trim(),
67122
- label: String(c.label ?? c.field ?? "").trim() || String(c.field ?? "")
67123
- }));
67124
- const selectedPivotIds = aggregationSlotColumns ? aggregationSlotColumns.selectedColumnIds : chart.columns.map(
67125
- (c) => encodeColumnOptionValue(
67126
- String(c.table ?? "").trim() || void 0,
67127
- String(c.field ?? "").trim()
67128
- )
67129
- ).filter(Boolean);
67116
+ if (pivotTableColumnControls) {
67130
67117
  return getAllColumnOptions({
67131
67118
  schemaColumnOptions,
67132
- tableColumns: pivotTableColumns,
67133
- selectedColumnIds: selectedPivotIds
67119
+ tableColumns: pivotTableColumnControls.tableColumns,
67120
+ selectedColumnIds: pivotTableColumnControls.selectedColumnIds
67134
67121
  });
67135
67122
  }
67123
+ if (isPivotTableChart) {
67124
+ return {
67125
+ columnsOptions: [],
67126
+ hasTableDrivenColumnOrder: true
67127
+ };
67128
+ }
67136
67129
  return getAllColumnOptions({
67137
67130
  schemaColumnOptions,
67138
67131
  tableColumns: table.columns,
@@ -67145,6 +67138,7 @@ function useReport(reportIdArg, options = {}) {
67145
67138
  chart?.xAxisLabel,
67146
67139
  columns,
67147
67140
  isPivotTableChart,
67141
+ pivotTableColumnControls,
67148
67142
  schemaColumnOptions,
67149
67143
  table.columns
67150
67144
  ]);
@@ -67166,17 +67160,11 @@ function useReport(reportIdArg, options = {}) {
67166
67160
  [tableDerivedColumnOrder]
67167
67161
  );
67168
67162
  const activeTableColumnIds = useMemo32(() => {
67169
- if (isPivotTableChart && chart?.columns?.length) {
67170
- const aggregationSlotColumns = buildPivotColumnPivotTableFormattingColumns(chart);
67171
- if (aggregationSlotColumns) {
67172
- return aggregationSlotColumns.selectedColumnIds;
67173
- }
67174
- return chart.columns.map(
67175
- (c) => encodeColumnOptionValue(
67176
- String(c.table ?? "").trim() || void 0,
67177
- String(c.field ?? "").trim()
67178
- )
67179
- ).filter(Boolean);
67163
+ if (pivotTableColumnControls) {
67164
+ return pivotTableColumnControls.selectedColumnIds;
67165
+ }
67166
+ if (isPivotTableChart) {
67167
+ return [];
67180
67168
  }
67181
67169
  const currentColumns = (columns ?? []).filter(Boolean);
67182
67170
  if (!hasTableDrivenColumnOrder) {
@@ -67201,6 +67189,7 @@ function useReport(reportIdArg, options = {}) {
67201
67189
  columns,
67202
67190
  hasTableDrivenColumnOrder,
67203
67191
  isPivotTableChart,
67192
+ pivotTableColumnControls,
67204
67193
  tableDerivedColumnOrder,
67205
67194
  tableFormattingColumnOptions
67206
67195
  ]);
@@ -67255,12 +67244,12 @@ function useReport(reportIdArg, options = {}) {
67255
67244
  });
67256
67245
  }
67257
67246
  const columnPivotMeasureFormatByAggregationField = /* @__PURE__ */ new Map();
67258
- if (isPivotTableChart && chart?.pivot) {
67259
- const slotFormatting = buildPivotColumnPivotTableFormattingColumns(chart);
67247
+ if (pivotTableColumnControls && chart) {
67248
+ const slotFormatting = pivotTableColumnControls;
67260
67249
  if (slotFormatting) {
67261
- const aggregations = getPivotAggregations(chart);
67250
+ const aggregations = slotFormatting.aggregations;
67262
67251
  const hasMultiple = aggregations.length > 1;
67263
- const rowField = String(chart.pivot.rowField ?? "").trim();
67252
+ const rowField = String(pivotState?.rowField ?? "").trim();
67264
67253
  const firstValueColumnFormat = String(
67265
67254
  (chart.columns ?? []).find(
67266
67255
  (c) => String(c.field ?? "").trim() !== rowField
@@ -67340,6 +67329,8 @@ function useReport(reportIdArg, options = {}) {
67340
67329
  columnOptionById,
67341
67330
  displayColumnById,
67342
67331
  isPivotTableChart,
67332
+ pivotState,
67333
+ pivotTableColumnControls,
67343
67334
  resolvedXAxisFormat,
67344
67335
  resolvedXAxisLabel,
67345
67336
  sourceReport?.columns,
@@ -67411,8 +67402,8 @@ function useReport(reportIdArg, options = {}) {
67411
67402
  ]);
67412
67403
  const initialLoadInProgress = !reportOverride && Boolean(effectiveReportId) && (!client || initialLoadQuery.isPending || initialLoadQuery.isFetching);
67413
67404
  const filterUniqueValuesLoading = filterUniqueValuesEnabled && (filterUniqueValuesQuery.isPending || filterUniqueValuesQuery.isFetching);
67414
- const chartLoading = initialLoadInProgress || (Boolean(nextPivot) ? pivotRefreshQuery.isFetching : tableRefreshQuery.isFetching);
67415
- const tableLoading = initialLoadInProgress || tablePageFetching || (Boolean(nextPivot) ? pivotTableDataRefreshQuery.isFetching : tableRefreshQuery.isFetching);
67405
+ const chartLoading = initialLoadInProgress || pendingPivotRefresh || (Boolean(nextPivot) ? pivotRefreshQuery.isFetching : tableRefreshQuery.isFetching);
67406
+ const tableLoading = initialLoadInProgress || pendingPivotRefresh || tablePageFetching || (Boolean(nextPivot) ? pivotTableDataRefreshQuery.isFetching : tableRefreshQuery.isFetching);
67416
67407
  const loading = chartLoading || tableLoading;
67417
67408
  const buildSetReportColumnsFromIds = (nextColumnIds, settingsById) => {
67418
67409
  const normalizedNextIds = nextColumnIds.map((columnId) => String(columnId ?? "").trim()).filter(Boolean);
@@ -67765,13 +67756,25 @@ function useReport(reportIdArg, options = {}) {
67765
67756
  const normalizedDisplayColumns = normalizedRequestedDisplayColumns ?? [];
67766
67757
  const addedDisplayColumns = addedRequestedDisplayColumns;
67767
67758
  next.columns = normalizedDisplayColumns;
67768
- if (addedDisplayColumns.length > 0) {
67759
+ const hasPivotSelection = Boolean(
67760
+ decodePivotGroupOptionValue(next.groupRowsBy) || decodePivotGroupOptionValue(next.groupColumnsBy)
67761
+ ) || next.aggregationState.some(isAppliedAggregation);
67762
+ const requestedDisplayTableNames = new Set(
67763
+ normalizedDisplayColumns.map((column) => String(column.table ?? "").trim()).filter(Boolean)
67764
+ );
67765
+ const selectedDatasourceTableNames = new Set(
67766
+ (next.schemaDatasourceIds ?? []).map((tableName) => String(tableName ?? "").trim()).filter(Boolean)
67767
+ );
67768
+ const replacesDatasourceTableScope = !hasPivotSelection && requestedDisplayTableNames.size > 0 && selectedDatasourceTableNames.size > 0 && [...requestedDisplayTableNames].every(
67769
+ (tableName) => !selectedDatasourceTableNames.has(tableName)
67770
+ );
67771
+ if (replacesDatasourceTableScope) {
67772
+ next.queryColumns = normalizedDisplayColumns;
67773
+ next.schemaDatasourceIds = [...requestedDisplayTableNames];
67774
+ } else if (addedDisplayColumns.length > 0) {
67769
67775
  const queryTableNames = new Set(
67770
67776
  next.queryColumns.map((column) => String(column.table ?? "").trim()).filter(Boolean)
67771
67777
  );
67772
- const hasPivotSelection = Boolean(
67773
- decodePivotGroupOptionValue(next.groupRowsBy) || decodePivotGroupOptionValue(next.groupColumnsBy)
67774
- ) || next.aggregationState.some(isAppliedAggregation);
67775
67778
  const queryColumnsToInclude = addedDisplayColumns.filter(
67776
67779
  (column) => {
67777
67780
  const tableName = String(column.table ?? "").trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillsql/react",
3
- "version": "2.16.63",
3
+ "version": "2.16.64",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {