@quillsql/react 2.16.50 → 2.16.52

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.
Files changed (3) hide show
  1. package/dist/index.cjs +114 -437
  2. package/dist/index.js +255 -573
  3. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -20015,27 +20015,6 @@ function parseData(rows, queryType) {
20015
20015
  return rows;
20016
20016
  }
20017
20017
  }
20018
- function isQuillFetchDebugEnabled() {
20019
- if (typeof globalThis !== "undefined") {
20020
- for (const debugFlag of QUILL_FETCH_DEBUG_FLAGS) {
20021
- if (globalThis?.[debugFlag] === true) {
20022
- return true;
20023
- }
20024
- }
20025
- }
20026
- if (typeof process !== "undefined" && typeof process.env !== "undefined") {
20027
- const envCandidates = [
20028
- process?.env?.QUILL_DEBUG_USEFORM_HYDRATION,
20029
- process?.env?.QUILL_DEBUG_USEFORM_FILTERS,
20030
- process?.env?.QUILL_DEBUG_DATA_FETCHER
20031
- ];
20032
- return envCandidates.some((candidate) => {
20033
- const normalized = String(candidate ?? "").trim().toLowerCase();
20034
- return normalized === "1" || normalized === "true";
20035
- });
20036
- }
20037
- return false;
20038
- }
20039
20018
  async function testSqlViewState(client, referencedTables, getToken) {
20040
20019
  let errorMessage = null;
20041
20020
  await Promise.all(
@@ -20521,7 +20500,7 @@ async function fetchRelevantInfoFromState(reportBuilderState, tables, columns, a
20521
20500
  return { error: error.message };
20522
20501
  }
20523
20502
  }
20524
- var QUILL_FETCH_DEBUG_FLAGS, quillFetchDebugSeq, logQuillFetchDebug, quillFetch, parseFetchResponse;
20503
+ var quillFetch, parseFetchResponse;
20525
20504
  var init_dataFetcher = __esm({
20526
20505
  "src/utils/dataFetcher.tsx"() {
20527
20506
  "use strict";
@@ -20530,16 +20509,6 @@ var init_dataFetcher = __esm({
20530
20509
  init_tableProcessing();
20531
20510
  init_dates();
20532
20511
  init_changelogNotify();
20533
- QUILL_FETCH_DEBUG_FLAGS = [
20534
- "__QUILL_DEBUG_USEFORM_HYDRATION__",
20535
- "__QUILL_DEBUG_USEFORM_FILTERS__",
20536
- "__QUILL_DEBUG_DATA_FETCHER__"
20537
- ];
20538
- quillFetchDebugSeq = 0;
20539
- logQuillFetchDebug = (label, payload) => {
20540
- if (!isQuillFetchDebugEnabled()) return;
20541
- console.log(`[quillFetch-debug] ${label}`, payload);
20542
- };
20543
20512
  quillFetch = async ({
20544
20513
  client,
20545
20514
  task,
@@ -20550,24 +20519,7 @@ var init_dataFetcher = __esm({
20550
20519
  urlParameters,
20551
20520
  getToken
20552
20521
  }) => {
20553
- const debugSeq = ++quillFetchDebugSeq;
20554
- const debugStart = Date.now();
20555
- logQuillFetchDebug("request", {
20556
- seq: debugSeq,
20557
- task,
20558
- reportId: metadata?.reportId,
20559
- dashboardItemId: metadata?.dashboardItemId,
20560
- hasPivot: Boolean(metadata?.pivot),
20561
- hasReportBuilderState: Boolean(metadata?.reportBuilderState),
20562
- filtersLength: Array.isArray(metadata?.filters) ? metadata.filters.length : void 0
20563
- });
20564
20522
  const token = await getToken();
20565
- logQuillFetchDebug("token-acquired", {
20566
- seq: debugSeq,
20567
- task,
20568
- ms: Date.now() - debugStart,
20569
- hasToken: Boolean(token)
20570
- });
20571
20523
  const queryString = urlParameters ?? `task=${task}`;
20572
20524
  const endpoint = client.queryEndpoint ? `${client.queryEndpoint}?${queryString}` : `${QUILL_SERVER}${QUILL_QUERY_ENDPOINT}?${queryString}`;
20573
20525
  try {
@@ -20599,17 +20551,6 @@ var init_dataFetcher = __esm({
20599
20551
  if (task !== "fetch-changelog-list" && Array.isArray(normalizedData?.changelogs)) {
20600
20552
  notifyChangelogs(normalizedData.changelogs);
20601
20553
  }
20602
- logQuillFetchDebug("response", {
20603
- seq: debugSeq,
20604
- task,
20605
- ms: Date.now() - debugStart,
20606
- status: result.status,
20607
- error: result.error,
20608
- dataError: normalizedData?.error,
20609
- queryResultRowCounts: Array.isArray(result.queries?.queryResults) ? result.queries.queryResults.map(
20610
- (qr) => Array.isArray(qr?.rows) ? qr.rows.length : null
20611
- ) : void 0
20612
- });
20613
20554
  return {
20614
20555
  data: normalizedData,
20615
20556
  queries: result.queries,
@@ -20618,19 +20559,8 @@ var init_dataFetcher = __esm({
20618
20559
  };
20619
20560
  } catch (e) {
20620
20561
  if (e instanceof Error && e.name === "AbortError") {
20621
- logQuillFetchDebug("aborted", {
20622
- seq: debugSeq,
20623
- task,
20624
- ms: Date.now() - debugStart
20625
- });
20626
20562
  throw e;
20627
20563
  }
20628
- logQuillFetchDebug("threw", {
20629
- seq: debugSeq,
20630
- task,
20631
- ms: Date.now() - debugStart,
20632
- message: e instanceof Error ? e.message : String(e)
20633
- });
20634
20564
  if (task !== "set-section-order") {
20635
20565
  console.error("Failed to fetch:", e);
20636
20566
  }
@@ -29251,62 +29181,6 @@ function stableColorIndex(field) {
29251
29181
  }
29252
29182
  return hash;
29253
29183
  }
29254
- function assignStableSeriesColors(fields, colors, knownFields = fields) {
29255
- const normalize2 = (values) => [
29256
- ...new Set(
29257
- values.filter((field) => typeof field === "string").map((field) => field.replace("comparison_", ""))
29258
- )
29259
- ];
29260
- const uniqueFields = normalize2(fields);
29261
- const universe = normalize2([...knownFields, ...fields]);
29262
- const result = /* @__PURE__ */ new Map();
29263
- if (universe.length === 0) {
29264
- return result;
29265
- }
29266
- if (!colors.length) {
29267
- for (const field of uniqueFields) {
29268
- result.set(field, "gray");
29269
- }
29270
- return result;
29271
- }
29272
- const palette = colors.length >= universe.length ? colors : generateArrayFromColor(colors, universe.length);
29273
- const ordered = [...universe].sort((a, b) => {
29274
- const diff = stableColorIndex(a) - stableColorIndex(b);
29275
- return diff !== 0 ? diff : a.localeCompare(b);
29276
- });
29277
- const usedIndices = /* @__PURE__ */ new Set();
29278
- const deferred = [];
29279
- const assigned = /* @__PURE__ */ new Map();
29280
- for (const field of ordered) {
29281
- const preferred = stableColorIndex(field) % palette.length;
29282
- if (!usedIndices.has(preferred)) {
29283
- usedIndices.add(preferred);
29284
- assigned.set(field, palette[preferred]);
29285
- } else {
29286
- deferred.push(field);
29287
- }
29288
- }
29289
- for (const field of deferred) {
29290
- const preferred = stableColorIndex(field) % palette.length;
29291
- let found = false;
29292
- for (let offset = 1; offset < palette.length; offset++) {
29293
- const idx = (preferred + offset) % palette.length;
29294
- if (!usedIndices.has(idx)) {
29295
- usedIndices.add(idx);
29296
- assigned.set(field, palette[idx]);
29297
- found = true;
29298
- break;
29299
- }
29300
- }
29301
- if (!found) {
29302
- assigned.set(field, palette[preferred]);
29303
- }
29304
- }
29305
- for (const field of uniqueFields) {
29306
- result.set(field, assigned.get(field));
29307
- }
29308
- return result;
29309
- }
29310
29184
  function selectColor(element, colors, index) {
29311
29185
  if (!element?.field) return "gray";
29312
29186
  const isComparison = element.field.includes("comparison_");
@@ -34327,21 +34201,6 @@ function BarChart({
34327
34201
  () => stackedMode ? getStackedDomain(data, yAxisFields, comparison) : getDomain(data, yAxisFields, referenceLines),
34328
34202
  [stackedMode, data, yAxisFields, referenceLines, comparison]
34329
34203
  );
34330
- const knownSeriesFieldsRef = (0, import_react18.useRef)([]);
34331
- const knownColorsKeyRef = (0, import_react18.useRef)("");
34332
- const seriesColorByField = (0, import_react18.useMemo)(() => {
34333
- const visibleFields = yAxisFields.filter((field) => comparison || !field.field.startsWith("comparison_")).map((field) => field.field);
34334
- const colorsKey = colors.join("\0");
34335
- if (knownColorsKeyRef.current !== colorsKey) {
34336
- knownSeriesFieldsRef.current = [];
34337
- knownColorsKeyRef.current = colorsKey;
34338
- }
34339
- const knownFields = [
34340
- .../* @__PURE__ */ new Set([...knownSeriesFieldsRef.current, ...visibleFields])
34341
- ];
34342
- knownSeriesFieldsRef.current = knownFields;
34343
- return assignStableSeriesColors(visibleFields, colors, knownFields);
34344
- }, [yAxisFields, colors, comparison]);
34345
34204
  const allowDecimals = (0, import_react18.useMemo)(
34346
34205
  () => getAllowDecimals(data, yAxisFields, referenceLines),
34347
34206
  [data, yAxisFields, referenceLines]
@@ -34604,15 +34463,7 @@ function BarChart({
34604
34463
  dataKey: elem.field,
34605
34464
  stackId: stackedMode ? "same_id" : isStacked ? elem.field.replace("comparison_", "") : void 0,
34606
34465
  type: "linear",
34607
- fill: getCustomColor(elem.field) ?? selectColor(
34608
- elem,
34609
- [
34610
- seriesColorByField.get(
34611
- elem.field.replace("comparison_", "")
34612
- ) ?? colors[0] ?? "gray"
34613
- ],
34614
- 0
34615
- ),
34466
+ fill: getCustomColor(elem.field) ?? selectColor(elem, colors, stableColorIndex(elem.field)),
34616
34467
  isAnimationActive,
34617
34468
  shape: customBarShape,
34618
34469
  activeBar: customActiveBarShape ?? {
@@ -59924,6 +59775,32 @@ function useFormReducer(state, action) {
59924
59775
  }
59925
59776
  }
59926
59777
 
59778
+ // src/utils/pivotDateBuckets.ts
59779
+ var import_date_fns18 = require("date-fns");
59780
+ function buildPivotDateBucketStarts(range, bucket) {
59781
+ const min2 = new Date(range.min);
59782
+ const max2 = new Date(range.max);
59783
+ if (Number.isNaN(min2.getTime()) || Number.isNaN(max2.getTime())) return [];
59784
+ const start = min2 <= max2 ? min2 : max2;
59785
+ const end = min2 <= max2 ? max2 : min2;
59786
+ const asLocalCalendarDate = (date) => new Date(
59787
+ date.getUTCFullYear(),
59788
+ date.getUTCMonth(),
59789
+ date.getUTCDate(),
59790
+ 12
59791
+ );
59792
+ const interval = {
59793
+ start: asLocalCalendarDate(start),
59794
+ end: asLocalCalendarDate(end)
59795
+ };
59796
+ const dates = bucket === "day" ? (0, import_date_fns18.eachDayOfInterval)(interval) : bucket === "week" ? (0, import_date_fns18.eachWeekOfInterval)(interval, { weekStartsOn: 1 }) : bucket === "year" ? (0, import_date_fns18.eachYearOfInterval)(interval) : (0, import_date_fns18.eachMonthOfInterval)(interval);
59797
+ return dates.map(
59798
+ (date) => new Date(
59799
+ Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())
59800
+ ).toISOString()
59801
+ );
59802
+ }
59803
+
59927
59804
  // src/hooks/useForm.queries.ts
59928
59805
  var QUERY_KEY_UNDEFINED = "__undefined__";
59929
59806
  var QUERY_KEY_FUNCTION = "__function__";
@@ -60101,70 +59978,6 @@ var AXIS_FORMAT_OPTIONS = [
60101
59978
  { value: "MMM_dd_hh:mm_ap_pm", label: "date and time" },
60102
59979
  { value: "hh_ap_pm", label: "hour" }
60103
59980
  ];
60104
- var USEFORM_FILTERS_DEBUG_FLAG = "__QUILL_DEBUG_USEFORM_FILTERS__";
60105
- var USEFORM_REFRESH_DEBUG_FLAG = "__QUILL_DEBUG_USEFORM_REFRESH__";
60106
- var USEFORM_PIVOT_SHAPE_DEBUG_FLAG = "__QUILL_DEBUG_USEFORM_PIVOT_SHAPE__";
60107
- var USEFORM_TASK_DEBUG_FLAG = "__QUILL_DEBUG_USEFORM_TASKS__";
60108
- var isUseFormFiltersDebugEnabled = () => {
60109
- const globalValue = typeof globalThis !== "undefined" ? globalThis?.[USEFORM_FILTERS_DEBUG_FLAG] : void 0;
60110
- if (globalValue === true) {
60111
- return true;
60112
- }
60113
- if (typeof process !== "undefined" && typeof process.env !== "undefined") {
60114
- const envValue = String(
60115
- process?.env?.QUILL_DEBUG_USEFORM_FILTERS ?? ""
60116
- ).trim().toLowerCase();
60117
- return envValue === "1" || envValue === "true";
60118
- }
60119
- return false;
60120
- };
60121
- var isUseFormRefreshDebugEnabled = () => {
60122
- const globalValue = typeof globalThis !== "undefined" ? globalThis?.[USEFORM_REFRESH_DEBUG_FLAG] : void 0;
60123
- if (globalValue === true) {
60124
- return true;
60125
- }
60126
- if (typeof process !== "undefined" && typeof process.env !== "undefined") {
60127
- const envValue = String(
60128
- process?.env?.QUILL_DEBUG_USEFORM_REFRESH ?? ""
60129
- ).trim().toLowerCase();
60130
- return envValue === "1" || envValue === "true";
60131
- }
60132
- return false;
60133
- };
60134
- var isUseFormTaskDebugEnabled = () => {
60135
- const globalValue = typeof globalThis !== "undefined" ? globalThis?.[USEFORM_TASK_DEBUG_FLAG] : void 0;
60136
- if (globalValue === true) {
60137
- return true;
60138
- }
60139
- if (typeof process !== "undefined" && typeof process.env !== "undefined") {
60140
- const envValue = String(
60141
- process?.env?.QUILL_DEBUG_USEFORM_TASKS ?? ""
60142
- ).trim().toLowerCase();
60143
- return envValue === "1" || envValue === "true";
60144
- }
60145
- return false;
60146
- };
60147
- var logUseFormTaskDebug = (label, payload) => {
60148
- if (!isUseFormTaskDebugEnabled()) return;
60149
- console.log(`[useReport][task] ${label}`, payload);
60150
- };
60151
- var isUseFormPivotShapeDebugEnabled = () => {
60152
- const globalValue = typeof globalThis !== "undefined" ? globalThis?.[USEFORM_PIVOT_SHAPE_DEBUG_FLAG] : void 0;
60153
- if (globalValue === true) {
60154
- return true;
60155
- }
60156
- if (typeof process !== "undefined" && typeof process.env !== "undefined") {
60157
- const envValue = String(
60158
- process?.env?.QUILL_DEBUG_USEFORM_PIVOT_SHAPE ?? ""
60159
- ).trim().toLowerCase();
60160
- return envValue === "1" || envValue === "true";
60161
- }
60162
- return false;
60163
- };
60164
- var logUseFormPivotShapeDebug = (label, payload) => {
60165
- if (!isUseFormPivotShapeDebugEnabled()) return;
60166
- console.log(`[useReport][pivot-shape] ${label}`, payload);
60167
- };
60168
59981
  var BOOLEAN_FILTER_VALUE_OPTIONS = [
60169
59982
  { name: "true", label: "True", value: "true" },
60170
59983
  { name: "false", label: "False", value: "false" }
@@ -61056,30 +60869,24 @@ function shouldUsePivotRowFieldAsXAxis(chartType, pivotRowField, rowColumnFormat
61056
60869
  function normalizePivotChartForDisplay(chart) {
61057
60870
  const swapPivotRowsForChartRows = Boolean(chart?.pivot) && Array.isArray(chart?.pivotRows) && chart.pivotRows.length > 0;
61058
60871
  const syntheticAggregationOnlyRows = chart && !swapPivotRowsForChartRows ? buildSyntheticAggregationOnlyDisplayRows(chart) : null;
60872
+ const hasExplicitEmptyGroupedPivot = Boolean(
60873
+ String(chart?.pivot?.rowField ?? "").trim() || String(chart?.pivot?.columnField ?? "").trim()
60874
+ ) && Array.isArray(chart?.pivotRows) && chart.pivotRows.length === 0;
61059
60875
  const detailRowsAreNotPivotBuckets = Boolean(chart) && !swapPivotRowsForChartRows && !syntheticAggregationOnlyRows && chartDetailRowsMissingPivotRowBucket(chart);
61060
- logUseFormPivotShapeDebug("normalizePivotChartForDisplay:gate", {
61061
- hasPivot: Boolean(chart?.pivot),
61062
- pivotRowField: chart?.pivot?.rowField,
61063
- pivotRowsIsArray: Array.isArray(chart?.pivotRows),
61064
- pivotRowsLength: Array.isArray(chart?.pivotRows) ? chart.pivotRows.length : null,
61065
- incomingChartRowsLength: Array.isArray(chart?.rows) ? chart.rows.length : null,
61066
- swapPivotRowsForChartRows
61067
- });
61068
60876
  const config = swapPivotRowsForChartRows ? {
61069
60877
  ...chart,
61070
60878
  rows: chart.pivotRows
61071
60879
  } : syntheticAggregationOnlyRows ? {
61072
60880
  ...chart,
61073
60881
  rows: syntheticAggregationOnlyRows
60882
+ } : hasExplicitEmptyGroupedPivot ? {
60883
+ ...chart,
60884
+ rows: []
61074
60885
  } : detailRowsAreNotPivotBuckets ? {
61075
60886
  ...chart,
61076
60887
  rows: []
61077
60888
  } : chart;
61078
60889
  if (!config) return config;
61079
- logUseFormPivotShapeDebug("normalizePivotChartForDisplay:postGateRows", {
61080
- effectiveRowsLength: Array.isArray(config.rows) ? config.rows.length : null,
61081
- stillUsingDetailRows: Boolean(config.pivot) && !swapPivotRowsForChartRows && Array.isArray(config.rows) && config.rows.length > 0
61082
- });
61083
60890
  if (!config.pivot) return config;
61084
60891
  const pivotRowFieldEarly = String(config.pivot?.rowField ?? "").trim();
61085
60892
  const rowColumn = (config.pivotColumns ?? config.columns ?? []).find(
@@ -62119,7 +61926,8 @@ function mergeDisplayAndSourceForTableFormats(args) {
62119
61926
  effectiveReportBuilderTableNames,
62120
61927
  scopedSchemaColumns,
62121
61928
  displayColumns,
62122
- sourceReport
61929
+ sourceReport,
61930
+ includeSelectedSchemaFallback
62123
61931
  } = args;
62124
61932
  const selectedTableNames = new Set(effectiveReportBuilderTableNames);
62125
61933
  const persistedReportColumns = Array.isArray(sourceReport?.columns) && sourceReport.columns.length > 0 ? sourceReport.columns : null;
@@ -62140,6 +61948,21 @@ function mergeDisplayAndSourceForTableFormats(args) {
62140
61948
  ...tableName ? { table: tableName } : {}
62141
61949
  };
62142
61950
  }).filter((column) => Boolean(column));
61951
+ const normalizedSchemaColumns = includeSelectedSchemaFallback ? scopedSchemaColumns.filter(
61952
+ (column) => selectedTableNames.has(String(column.table ?? "").trim())
61953
+ ).map((column) => {
61954
+ const field = String(column.field ?? "").trim();
61955
+ if (!field) return null;
61956
+ const label = String(column.label ?? "").trim() || field;
61957
+ const format9 = String(column.format ?? "").trim() || "string";
61958
+ const tableName = String(column.table ?? "").trim();
61959
+ return {
61960
+ label,
61961
+ field,
61962
+ format: format9,
61963
+ ...tableName ? { table: tableName } : {}
61964
+ };
61965
+ }).filter((column) => Boolean(column)) : [];
62143
61966
  const normalizedDisplayColumns = (displayColumns ?? []).map((column) => {
62144
61967
  const field = String(column?.field ?? "").trim();
62145
61968
  if (!field) return null;
@@ -62164,7 +61987,10 @@ function mergeDisplayAndSourceForTableFormats(args) {
62164
61987
  sourceColumnsByKey.set(key, [column]);
62165
61988
  }
62166
61989
  };
62167
- for (const sourceColumn of normalizedSourceColumns) {
61990
+ for (const sourceColumn of [
61991
+ ...normalizedSourceColumns,
61992
+ ...normalizedSchemaColumns
61993
+ ]) {
62168
61994
  const tableName = String(sourceColumn.table ?? "").trim();
62169
61995
  addSourceColumnKey(sourceColumn.field, sourceColumn);
62170
61996
  addSourceColumnKey(sourceColumn.label, sourceColumn);
@@ -62722,9 +62548,6 @@ async function loadViaInMemoryEngines({
62722
62548
  pivot,
62723
62549
  reportBuilderState,
62724
62550
  allowReportTaskBootstrap = false,
62725
- debugSource,
62726
- debugRunId,
62727
- debugLoadRequestId,
62728
62551
  draftSessionId
62729
62552
  }) {
62730
62553
  const requestedTask = allowReportTaskBootstrap ? "report" : "item";
@@ -62734,17 +62557,6 @@ async function loadViaInMemoryEngines({
62734
62557
  rowsPerRequest: DEFAULT_USE_REPORT_ROWS_PER_REQUEST
62735
62558
  }
62736
62559
  } : {};
62737
- logUseFormTaskDebug("dispatch fetchReport", {
62738
- reportId,
62739
- task: requestedTask,
62740
- source: debugSource ?? "unknown",
62741
- runId: debugRunId ?? null,
62742
- loadRequestId: debugLoadRequestId ?? null,
62743
- allowReportTaskBootstrap,
62744
- filterCount: internalFilters.length,
62745
- hasPivot: Boolean(pivot),
62746
- hasReportBuilderState: Boolean(reportBuilderState)
62747
- });
62748
62560
  const { report, error } = await fetchReport({
62749
62561
  reportId,
62750
62562
  client,
@@ -62824,9 +62636,6 @@ async function loadViaPivotTemplate({
62824
62636
  reportBuilderState,
62825
62637
  baseReport,
62826
62638
  schema,
62827
- debugSource,
62828
- debugRunId,
62829
- debugLoadRequestId,
62830
62639
  draftSessionId
62831
62640
  }) {
62832
62641
  const pivotForTemplate = enrichPivotRowFieldTypeForTemplate(
@@ -62834,16 +62643,6 @@ async function loadViaPivotTemplate({
62834
62643
  schema,
62835
62644
  baseReport
62836
62645
  );
62837
- logUseFormTaskDebug("dispatch fetchReport", {
62838
- reportId,
62839
- task: "pivot-template",
62840
- source: debugSource ?? "unknown",
62841
- runId: debugRunId ?? null,
62842
- loadRequestId: debugLoadRequestId ?? null,
62843
- filterCount: internalFilters.length,
62844
- hasPivot: Boolean(pivotForTemplate),
62845
- hasReportBuilderState: Boolean(reportBuilderState)
62846
- });
62847
62646
  const { report, error } = await fetchPivotTemplateReportForUseForm({
62848
62647
  reportId,
62849
62648
  client,
@@ -63071,19 +62870,8 @@ async function loadPivotTemplateInParallelWithReportTask({
63071
62870
  customFields,
63072
62871
  dashboardName,
63073
62872
  pivotRefreshOnly = false,
63074
- debugSource,
63075
- debugRunId,
63076
- debugLoadRequestId,
63077
62873
  draftSessionId
63078
62874
  }) {
63079
- logUseFormTaskDebug("parallel loader route", {
63080
- reportId,
63081
- source: debugSource ?? "unknown",
63082
- runId: debugRunId ?? null,
63083
- loadRequestId: debugLoadRequestId ?? null,
63084
- pivotRefreshOnly,
63085
- tasks: pivotRefreshOnly ? ["pivot-template"] : ["report", "pivot-template", "report-builder-state"]
63086
- });
63087
62875
  if (pivotRefreshOnly) {
63088
62876
  const pivotOnlyResult = await loadViaPivotTemplate({
63089
62877
  reportId,
@@ -63096,9 +62884,6 @@ async function loadPivotTemplateInParallelWithReportTask({
63096
62884
  reportBuilderState,
63097
62885
  baseReport,
63098
62886
  schema,
63099
- debugSource,
63100
- debugRunId,
63101
- debugLoadRequestId,
63102
62887
  draftSessionId
63103
62888
  });
63104
62889
  return pivotOnlyResult;
@@ -63114,9 +62899,6 @@ async function loadPivotTemplateInParallelWithReportTask({
63114
62899
  pivot,
63115
62900
  reportBuilderState,
63116
62901
  allowReportTaskBootstrap: true,
63117
- debugSource,
63118
- debugRunId,
63119
- debugLoadRequestId,
63120
62902
  draftSessionId
63121
62903
  }),
63122
62904
  loadViaPivotTemplate({
@@ -63130,9 +62912,6 @@ async function loadPivotTemplateInParallelWithReportTask({
63130
62912
  reportBuilderState,
63131
62913
  baseReport,
63132
62914
  schema,
63133
- debugSource,
63134
- debugRunId,
63135
- debugLoadRequestId,
63136
62915
  draftSessionId
63137
62916
  }),
63138
62917
  fetchReportBuilderStateByReportId({
@@ -63315,9 +63094,6 @@ async function loadReportForUseForm({
63315
63094
  customFields,
63316
63095
  dashboardName,
63317
63096
  useInMemoryEngines,
63318
- debugSource,
63319
- debugRunId,
63320
- debugLoadRequestId,
63321
63097
  draftSessionId
63322
63098
  }) {
63323
63099
  const effectivePivot = pivot ?? initialReportBuilderState?.pivot ?? void 0;
@@ -63326,18 +63102,6 @@ async function loadReportForUseForm({
63326
63102
  ...initialReportBuilderState,
63327
63103
  pivot: effectivePivot ?? initialReportBuilderState.pivot ?? null
63328
63104
  } : void 0;
63329
- logUseFormTaskDebug("resolve loader route", {
63330
- reportId,
63331
- source: debugSource ?? "unknown",
63332
- runId: debugRunId ?? null,
63333
- loadRequestId: debugLoadRequestId ?? null,
63334
- hasPivot,
63335
- hasReportBuilderState: Boolean(reportBuilderStateForLoad),
63336
- allowReportTaskBootstrap,
63337
- includeReportBuilderStateInPivotTask,
63338
- filterCount: internalFilters.length,
63339
- useInMemoryEngines
63340
- });
63341
63105
  if (hasPivot) {
63342
63106
  const pivotResult = await loadPivotTemplateInParallelWithReportTask({
63343
63107
  reportId,
@@ -63353,9 +63117,6 @@ async function loadReportForUseForm({
63353
63117
  customFields,
63354
63118
  dashboardName,
63355
63119
  pivotRefreshOnly: includeReportBuilderStateInPivotTask,
63356
- debugSource,
63357
- debugRunId,
63358
- debugLoadRequestId,
63359
63120
  draftSessionId
63360
63121
  });
63361
63122
  const pivotRows = pivotResult.report?.pivotRows;
@@ -63364,7 +63125,7 @@ async function loadReportForUseForm({
63364
63125
  const hasRowBucketKey = !rowFieldTrimmed || Array.isArray(pivotRows) && pivotRows.some(
63365
63126
  (row) => row && typeof row === "object" && Object.prototype.hasOwnProperty.call(row, rowFieldTrimmed)
63366
63127
  );
63367
- const hasMatchingPivotData = pivotResult.report && !pivotResult.error && Array.isArray(pivotRows) && pivotRows.length > 0 && hasRowBucketKey;
63128
+ const hasMatchingPivotData = pivotResult.report && !pivotResult.error && Array.isArray(pivotRows) && (pivotRows.length === 0 || hasRowBucketKey);
63368
63129
  if (hasMatchingPivotData) {
63369
63130
  return pivotResult;
63370
63131
  }
@@ -63404,25 +63165,12 @@ async function loadReportForUseForm({
63404
63165
  schema,
63405
63166
  customFields,
63406
63167
  dashboardName,
63407
- debugSource,
63408
- debugRunId,
63409
- debugLoadRequestId,
63410
63168
  draftSessionId
63411
63169
  });
63412
63170
  const normalizedBootstrapResult = bootstrapResult.report?.pivot == null ? stripPivotFromResult(bootstrapResult) : bootstrapResult;
63413
63171
  return normalizedBootstrapResult;
63414
63172
  }
63415
63173
  const shouldUseReportTaskForReload = internalFilters.length > 0;
63416
- const resolvedTask = shouldUseReportTaskForReload ? "report" : "item";
63417
- logUseFormTaskDebug("non-bootstrap task route", {
63418
- reportId,
63419
- task: resolvedTask,
63420
- source: debugSource ?? "unknown",
63421
- runId: debugRunId ?? null,
63422
- loadRequestId: debugLoadRequestId ?? null,
63423
- reason: shouldUseReportTaskForReload ? "live internal filters are present" : "no live internal filters are present",
63424
- filterCount: internalFilters.length
63425
- });
63426
63174
  return loadViaInMemoryEngines({
63427
63175
  reportId,
63428
63176
  client,
@@ -63431,9 +63179,6 @@ async function loadReportForUseForm({
63431
63179
  tenants,
63432
63180
  flags,
63433
63181
  allowReportTaskBootstrap: shouldUseReportTaskForReload,
63434
- debugSource,
63435
- debugRunId,
63436
- debugLoadRequestId,
63437
63182
  draftSessionId
63438
63183
  });
63439
63184
  }
@@ -63452,18 +63197,12 @@ async function loadReportForUseForm({
63452
63197
  function generateDraftSessionId() {
63453
63198
  return typeof crypto !== "undefined" && typeof crypto.randomUUID === "function" ? crypto.randomUUID() : `draft-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
63454
63199
  }
63455
- var nextUseReportDebugRunId = 0;
63456
63200
  function useReport(reportIdArg, options = {}) {
63457
63201
  const propReportId = String(reportIdArg ?? "").trim();
63458
63202
  const [createdReportId, setCreatedReportId] = (0, import_react61.useState)(null);
63459
63203
  const effectiveReportId = propReportId || createdReportId || "";
63460
63204
  const { eventTracking } = (0, import_react61.useContext)(EventTrackingContext);
63461
63205
  const [draftSessionId, setDraftSessionId] = (0, import_react61.useState)(generateDraftSessionId);
63462
- const [taskDebugRunId] = (0, import_react61.useState)(() => {
63463
- nextUseReportDebugRunId += 1;
63464
- return nextUseReportDebugRunId;
63465
- });
63466
- const taskDebugLoadRequestIdRef = (0, import_react61.useRef)(0);
63467
63206
  const useInMemoryEngines = options.useInMemoryEngines ?? false;
63468
63207
  const restrictFieldOptionsToSelectedDatasources = options.restrictFieldOptionsToSelectedDatasources ?? true;
63469
63208
  const reportOverride = options.reportOverride ?? null;
@@ -63602,6 +63341,9 @@ function useReport(reportIdArg, options = {}) {
63602
63341
  const [preserveSchemaWideOptions, setPreserveSchemaWideOptions] = (0, import_react61.useState)(false);
63603
63342
  const [initialSchemaScopedTableNames, setInitialSchemaScopedTableNames] = (0, import_react61.useState)(null);
63604
63343
  const [tableColumnsEditedSignature, setTableColumnsEditedSignature] = (0, import_react61.useState)(null);
63344
+ (0, import_react61.useEffect)(() => {
63345
+ setTableColumnsEditedSignature(null);
63346
+ }, [effectiveReportId]);
63605
63347
  const [chartAxisEdits, setChartAxisEdits] = (0, import_react61.useState)({});
63606
63348
  const [chartVisibilityOverrides, setChartVisibilityOverrides] = (0, import_react61.useState)({});
63607
63349
  const [client] = (0, import_react61.useContext)(ClientContext);
@@ -63677,8 +63419,6 @@ function useReport(reportIdArg, options = {}) {
63677
63419
  filterStackRef.current = filterStack;
63678
63420
  const resolvedGroupRowsBy = decodePivotGroupOptionValue(groupRowsBy);
63679
63421
  const resolvedGroupColumnsBy = decodePivotGroupOptionValue(groupColumnsBy);
63680
- const useFormRefreshDebugEnabled = isUseFormRefreshDebugEnabled();
63681
- const useFormFiltersDebugEnabled = isUseFormFiltersDebugEnabled();
63682
63422
  (0, import_react61.useEffect)(() => {
63683
63423
  if (propReportId) {
63684
63424
  setCreatedReportId(null);
@@ -64227,26 +63967,6 @@ function useReport(reportIdArg, options = {}) {
64227
63967
  const filterUniqueValuesEnabled = Boolean(
64228
63968
  client && client?.queryEndpoint && filterUniqueValuesRequest && filterUniqueValuesRequest.stringColumns.length > 0
64229
63969
  );
64230
- (0, import_react61.useEffect)(() => {
64231
- if (!useFormFiltersDebugEnabled) return;
64232
- const hasClient = Boolean(client);
64233
- const hasQueryEndpoint = Boolean(client?.queryEndpoint);
64234
- const hasRequest = Boolean(filterUniqueValuesRequest);
64235
- const stringColumnsCount = filterUniqueValuesRequest?.stringColumns.length ?? 0;
64236
- const stringColumnsByTableCount = filterUniqueValuesRequest?.stringColumnsByTable.length ?? 0;
64237
- const missingReasons = [];
64238
- if (!hasClient) missingReasons.push("missing-client");
64239
- if (!hasQueryEndpoint) missingReasons.push("missing-query-endpoint");
64240
- if (!hasRequest) missingReasons.push("missing-filterUniqueValuesRequest");
64241
- if (stringColumnsCount === 0) missingReasons.push("no-string-columns");
64242
- }, [
64243
- client,
64244
- filterUniqueValuesEnabled,
64245
- filterUniqueValuesRequest,
64246
- filterUniqueValuesRequestHash,
64247
- effectiveReportId,
64248
- useFormFiltersDebugEnabled
64249
- ]);
64250
63970
  const filterUniqueValuesQuery = (0, import_react_query2.useQuery)({
64251
63971
  queryKey: [
64252
63972
  "useReport",
@@ -64350,22 +64070,6 @@ function useReport(reportIdArg, options = {}) {
64350
64070
  filterUniqueValuesQuery.data?.uniqueValuesByColumn,
64351
64071
  filterUniqueValuesRequest?.stringColumnsByTable
64352
64072
  ]);
64353
- (0, import_react61.useEffect)(() => {
64354
- if (!useFormFiltersDebugEnabled) return;
64355
- if (filterUniqueValuesQuery.status !== "success" && filterUniqueValuesQuery.status !== "error") {
64356
- return;
64357
- }
64358
- const uniqueValuesByColumn = filterUniqueValuesQuery.data?.uniqueValuesByColumn ?? {};
64359
- const uniqueValuesByColumnRecord = uniqueValuesByColumn && typeof uniqueValuesByColumn === "object" ? uniqueValuesByColumn : {};
64360
- }, [
64361
- backendUniqueValuesByFieldName,
64362
- filterUniqueValuesEnabled,
64363
- filterUniqueValuesQuery.data,
64364
- filterUniqueValuesQuery.status,
64365
- filterUniqueValuesRequest,
64366
- effectiveReportId,
64367
- useFormFiltersDebugEnabled
64368
- ]);
64369
64073
  const filterValueOptionsByFieldName = (0, import_react61.useMemo)(() => {
64370
64074
  const optionsByField = /* @__PURE__ */ new Map();
64371
64075
  const selectedMultiselectByField = collectSelectedStringMultiselectValuesByField(queryFilters);
@@ -64766,8 +64470,6 @@ function useReport(reportIdArg, options = {}) {
64766
64470
  clientHash
64767
64471
  }),
64768
64472
  queryFn: createUseFormQueryFn(async () => {
64769
- taskDebugLoadRequestIdRef.current += 1;
64770
- const debugLoadRequestId = taskDebugLoadRequestIdRef.current;
64771
64473
  const allowReportTaskBootstrap = !initialReportBuilderState && bootstrapReportTaskUsedForReportIdRef.current !== effectiveReportId;
64772
64474
  const loadTargetId = String(effectiveReportId ?? "").trim();
64773
64475
  const sourceReportIdentity = String(
@@ -64791,9 +64493,6 @@ function useReport(reportIdArg, options = {}) {
64791
64493
  customFields: customFieldsRef.current,
64792
64494
  dashboardName: resolvedSourceDashboardName,
64793
64495
  useInMemoryEngines,
64794
- debugSource: "initial-load",
64795
- debugRunId: taskDebugRunId,
64796
- debugLoadRequestId,
64797
64496
  draftSessionId: draftSessionId || void 0
64798
64497
  });
64799
64498
  return loadResult;
@@ -65133,19 +64832,6 @@ function useReport(reportIdArg, options = {}) {
65133
64832
  resolveCache.set(fieldName, resolved);
65134
64833
  return resolved;
65135
64834
  }
65136
- if (isUseFormFiltersDebugEnabled()) {
65137
- console.error(
65138
- "[useForm-debug] normalizeQueryBuilderFieldNameForConfig ambiguous",
65139
- {
65140
- fieldName,
65141
- candidateKeys: candidates.map(([key]) => key),
65142
- preferredTableNames: Array.from(preferredTableNames),
65143
- primaryTableName,
65144
- effectiveReportBuilderTableNames,
65145
- baseReportBuilderTableNames
65146
- }
65147
- );
65148
- }
65149
64835
  return fieldName;
65150
64836
  };
65151
64837
  }, [
@@ -65537,8 +65223,7 @@ function useReport(reportIdArg, options = {}) {
65537
65223
  }, [
65538
65224
  effectiveReportId,
65539
65225
  tableRefreshQuery.data,
65540
- tableRefreshQueryEnabled,
65541
- useFormRefreshDebugEnabled
65226
+ tableRefreshQueryEnabled
65542
65227
  ]);
65543
65228
  const chartTypes = (0, import_react61.useMemo)(() => {
65544
65229
  return getChartTypeOptions2({ pivot: pivotState });
@@ -66101,7 +65786,6 @@ function useReport(reportIdArg, options = {}) {
66101
65786
  ...sourceReport,
66102
65787
  reportBuilderState: effectiveReportBuilderState
66103
65788
  };
66104
- taskDebugLoadRequestIdRef.current += 1;
66105
65789
  const pivotRefreshResult = await loadReportForUseForm({
66106
65790
  reportId: effectiveReportId,
66107
65791
  initialReportBuilderState: effectiveReportBuilderState,
@@ -66117,9 +65801,6 @@ function useReport(reportIdArg, options = {}) {
66117
65801
  customFields: schemaData.customFields,
66118
65802
  dashboardName: resolvedSourceDashboardName,
66119
65803
  useInMemoryEngines,
66120
- debugSource: "pivot-refresh",
66121
- debugRunId: taskDebugRunId,
66122
- debugLoadRequestId: taskDebugLoadRequestIdRef.current,
66123
65804
  draftSessionId: draftSessionId || void 0
66124
65805
  });
66125
65806
  return pivotRefreshResult;
@@ -66283,8 +65964,7 @@ function useReport(reportIdArg, options = {}) {
66283
65964
  pivotTableDataRefreshQuery.data,
66284
65965
  pivotTableDataRefreshQuery.status,
66285
65966
  pivotTableDataRefreshQueryEnabled,
66286
- effectiveReportId,
66287
- useFormRefreshDebugEnabled
65967
+ effectiveReportId
66288
65968
  ]);
66289
65969
  (0, import_react61.useEffect)(() => {
66290
65970
  if (!pivotRefreshQueryEnabled) return;
@@ -66336,8 +66016,7 @@ function useReport(reportIdArg, options = {}) {
66336
66016
  pivotRefreshQuery.data,
66337
66017
  pivotRefreshQuery.status,
66338
66018
  pivotRefreshQueryEnabled,
66339
- effectiveReportId,
66340
- useFormRefreshDebugEnabled
66019
+ effectiveReportId
66341
66020
  ]);
66342
66021
  const chartData = (0, import_react61.useMemo)(() => {
66343
66022
  if (!sourceReport) return void 0;
@@ -66345,8 +66024,8 @@ function useReport(reportIdArg, options = {}) {
66345
66024
  const chartPivotForDisplay = nextPivot ?? (!chartPivotHydratedFromSourceRef.current ? sourceReport.pivot ?? null : null);
66346
66025
  const rowCountForChart = chartPivotForDisplay ? sourceReport.pivotRowCount ?? (Array.isArray(sourceReport.pivotRows) ? sourceReport.pivotRows.length : sourceReport.rowCount) : useInMemoryEngines ? rowsForChart.length : sourceReport.rowCount;
66347
66026
  const referencedTablesForChart = effectiveReportBuilderState?.tables.map((table2) => table2.name).filter((name2) => Boolean(name2));
66348
- const pivotRowsForChart = Array.isArray(sourceReport.pivotRows) && sourceReport.pivotRows.length > 0 ? sourceReport.pivotRows : [];
66349
- const rowCountForChartResolved = chartPivotForDisplay ? pivotRowsForChart.length > 0 ? pivotRowsForChart.length : rowCountForChart : rowCountForChart;
66027
+ const pivotRowsForChart = Array.isArray(sourceReport.pivotRows) ? sourceReport.pivotRows : void 0;
66028
+ const rowCountForChartResolved = chartPivotForDisplay ? Array.isArray(pivotRowsForChart) ? pivotRowsForChart.length : rowCountForChart : rowCountForChart;
66350
66029
  const chartDataPayload = {
66351
66030
  ...sourceReport,
66352
66031
  rows: rowsForChart,
@@ -66357,15 +66036,8 @@ function useReport(reportIdArg, options = {}) {
66357
66036
  referencedTables: referencedTablesForChart && referencedTablesForChart.length > 0 ? referencedTablesForChart : sourceReport.referencedTables,
66358
66037
  pivotRows: pivotRowsForChart,
66359
66038
  pivotColumns: sourceReport.pivotColumns,
66360
- pivotRowCount: pivotRowsForChart.length
66039
+ pivotRowCount: Array.isArray(pivotRowsForChart) ? pivotRowsForChart.length : sourceReport.pivotRowCount
66361
66040
  };
66362
- logUseFormPivotShapeDebug("chartData:memo", {
66363
- reportId: sourceReport.id,
66364
- detailRowsLength: rowsForChart.length,
66365
- pivotRowsIsArray: Array.isArray(sourceReport.pivotRows),
66366
- pivotRowsLength: Array.isArray(sourceReport.pivotRows) ? sourceReport.pivotRows.length : null,
66367
- hasNextPivot: Boolean(nextPivot)
66368
- });
66369
66041
  return chartDataPayload;
66370
66042
  }, [
66371
66043
  sourceReport,
@@ -66677,26 +66349,6 @@ function useReport(reportIdArg, options = {}) {
66677
66349
  xAxisLabel: resolvedXAxisLabel
66678
66350
  });
66679
66351
  }
66680
- logUseFormPivotShapeDebug("chart:formatting(yAxis+pivotColumns)", {
66681
- chartType: baseChart.chartType,
66682
- pivotRowField: baseChart.pivot?.rowField,
66683
- xAxisField: resolvedXAxisField,
66684
- xAxisFormat: resolvedXAxisFormat,
66685
- yAxisFieldsForDisplay: (resolvedYAxisFieldsForDisplay ?? []).map((y) => ({
66686
- field: y.field,
66687
- format: y.format,
66688
- label: y.label
66689
- })),
66690
- pivotColumnsSample: (baseChart.pivotColumns ?? []).slice(0, 12).map((c) => ({
66691
- field: c.field,
66692
- format: c.format,
66693
- label: c.label
66694
- })),
66695
- mergedColumnFormatsSample: (columns2 ?? baseChart.columns ?? []).slice(0, 12).map((c) => ({
66696
- field: c.field,
66697
- format: c.format
66698
- }))
66699
- });
66700
66352
  return {
66701
66353
  ...baseChart,
66702
66354
  xAxisField: resolvedXAxisField,
@@ -66712,6 +66364,7 @@ function useReport(reportIdArg, options = {}) {
66712
66364
  resolvedXAxisLabel,
66713
66365
  resolvedYAxisFieldsForDisplay
66714
66366
  ]);
66367
+ const pivotDateFilterRangeCacheRef = (0, import_react61.useRef)({ key: "", min: null, max: null });
66715
66368
  const filterOptions = (0, import_react61.useMemo)(() => {
66716
66369
  const out = [];
66717
66370
  for (const [field, values] of filterValueOptionsByFieldName) {
@@ -66727,25 +66380,43 @@ function useReport(reportIdArg, options = {}) {
66727
66380
  if (rowField && isDateType(String(pivot?.rowFieldType ?? ""))) {
66728
66381
  const field = pivot?.rowFieldTable ? `${pivot.rowFieldTable}.${rowField}` : rowField;
66729
66382
  const bucket = dateBucket || pivot?.dateBucket || "month";
66730
- const byRaw = /* @__PURE__ */ new Map();
66383
+ const labelsByRaw = /* @__PURE__ */ new Map();
66384
+ const cacheKey = `${String(effectiveReportId ?? "")}\0${field}\0${bucket}`;
66385
+ if (pivotDateFilterRangeCacheRef.current.key !== cacheKey) {
66386
+ pivotDateFilterRangeCacheRef.current = {
66387
+ key: cacheKey,
66388
+ min: null,
66389
+ max: null
66390
+ };
66391
+ }
66731
66392
  for (const row of chart?.rows ?? []) {
66732
66393
  const record = row;
66733
66394
  const raw = record.__quillRawDate;
66734
66395
  if (raw == null || raw === "") continue;
66735
66396
  const key = String(raw);
66736
- if (!byRaw.has(key)) {
66737
- byRaw.set(key, String(record[rowField] ?? key));
66397
+ const timestamp = new Date(key).getTime();
66398
+ if (Number.isNaN(timestamp)) continue;
66399
+ labelsByRaw.set(key, String(record[rowField] ?? key));
66400
+ const cachedMin = pivotDateFilterRangeCacheRef.current.min;
66401
+ const cachedMax = pivotDateFilterRangeCacheRef.current.max;
66402
+ if (cachedMin == null || timestamp < new Date(cachedMin).getTime()) {
66403
+ pivotDateFilterRangeCacheRef.current.min = key;
66404
+ }
66405
+ if (cachedMax == null || timestamp > new Date(cachedMax).getTime()) {
66406
+ pivotDateFilterRangeCacheRef.current.max = key;
66738
66407
  }
66739
66408
  }
66409
+ const { min: min2, max: max2 } = pivotDateFilterRangeCacheRef.current;
66410
+ const options2 = min2 && max2 ? buildPivotDateBucketStarts({ min: min2, max: max2 }, bucket).map((value) => ({
66411
+ value,
66412
+ label: labelsByRaw.get(value) ?? getDateString(value, void 0, bucket)
66413
+ })) : [];
66740
66414
  out.push({
66741
66415
  field,
66742
66416
  fieldType: "date",
66743
66417
  operator: "inBucket",
66744
66418
  dateBucket: bucket,
66745
- options: [...byRaw.keys()].sort().map((value) => ({
66746
- value,
66747
- label: byRaw.get(value) ?? value
66748
- }))
66419
+ options: options2
66749
66420
  });
66750
66421
  }
66751
66422
  return out;
@@ -66753,6 +66424,7 @@ function useReport(reportIdArg, options = {}) {
66753
66424
  chart?.pivot,
66754
66425
  chart?.rows,
66755
66426
  dateBucket,
66427
+ effectiveReportId,
66756
66428
  filterValueOptionsByFieldName
66757
66429
  ]);
66758
66430
  const chartForUi = (0, import_react61.useMemo)(() => {
@@ -66988,13 +66660,15 @@ function useReport(reportIdArg, options = {}) {
66988
66660
  effectiveReportBuilderTableNames,
66989
66661
  scopedSchemaColumns,
66990
66662
  displayColumns,
66991
- sourceReport
66663
+ sourceReport,
66664
+ includeSelectedSchemaFallback: tableColumnsEditedSignature !== null
66992
66665
  }),
66993
66666
  [
66994
66667
  effectiveReportBuilderTableNames,
66995
66668
  scopedSchemaColumns,
66996
66669
  displayColumns,
66997
- sourceReport
66670
+ sourceReport,
66671
+ tableColumnsEditedSignature
66998
66672
  ]
66999
66673
  );
67000
66674
  const table = (0, import_react61.useMemo)(() => {
@@ -67004,7 +66678,8 @@ function useReport(reportIdArg, options = {}) {
67004
66678
  effectiveReportBuilderTableNames,
67005
66679
  scopedSchemaColumns,
67006
66680
  displayColumns,
67007
- sourceReport
66681
+ sourceReport,
66682
+ includeSelectedSchemaFallback: tableColumnsEditedSignature !== null
67008
66683
  });
67009
66684
  const pivotRowFieldForTable = String(
67010
66685
  sourceReport?.pivot?.rowField ?? ""
@@ -67105,6 +66780,7 @@ function useReport(reportIdArg, options = {}) {
67105
66780
  resolvedYAxisFieldsForDisplay,
67106
66781
  scopedSchemaColumns,
67107
66782
  sourceReport,
66783
+ tableColumnsEditedSignature,
67108
66784
  pagination,
67109
66785
  paginationActive,
67110
66786
  paginationPageCount,
@@ -67599,6 +67275,17 @@ function useReport(reportIdArg, options = {}) {
67599
67275
  };
67600
67276
  applyReportChange = (nextState) => {
67601
67277
  const effectiveNextState = nextState;
67278
+ const normalizedRequestedDisplayColumns = effectiveNextState.columns === void 0 ? void 0 : normalizeColumnsInput(
67279
+ effectiveNextState.columns,
67280
+ columnIdentifierLookup
67281
+ );
67282
+ const visibleDisplayColumnKeys = new Set(
67283
+ activeTableColumnIds.map((id) => columnIdentifierLookup.get(id)).filter((column) => Boolean(column)).map((column) => toReportBuilderColumnKey(column)).filter(Boolean)
67284
+ );
67285
+ const addedRequestedDisplayColumns = (normalizedRequestedDisplayColumns ?? []).filter((column) => {
67286
+ const key = toReportBuilderColumnKey(column);
67287
+ return Boolean(key) && !visibleDisplayColumnKeys.has(key);
67288
+ });
67602
67289
  if (effectiveNextState.showLegend !== void 0) {
67603
67290
  setChartVisibilityOverrides((previous) => ({
67604
67291
  ...previous,
@@ -67694,7 +67381,7 @@ function useReport(reportIdArg, options = {}) {
67694
67381
  dispatchFormRuntime({
67695
67382
  type: "APPLY_SET_REPORT",
67696
67383
  touchesPivotState: dispatchTouchesPivot,
67697
- shouldRefreshExpandedTableData: shouldRefreshExpandedTableData || isDatasourceUpdate,
67384
+ shouldRefreshExpandedTableData: shouldRefreshExpandedTableData || isDatasourceUpdate || addedRequestedDisplayColumns.length > 0,
67698
67385
  queuePromoteColumnToRow,
67699
67386
  updater: (prev) => {
67700
67387
  const next = {
@@ -67760,19 +67447,8 @@ function useReport(reportIdArg, options = {}) {
67760
67447
  }
67761
67448
  }
67762
67449
  if (effectiveNextState.columns !== void 0) {
67763
- const normalizedDisplayColumns = normalizeColumnsInput(
67764
- effectiveNextState.columns,
67765
- columnIdentifierLookup
67766
- );
67767
- const previousDisplayColumnKeys = new Set(
67768
- next.columns.map((column) => toReportBuilderColumnKey(column)).filter(Boolean)
67769
- );
67770
- const addedDisplayColumns = normalizedDisplayColumns.filter(
67771
- (column) => {
67772
- const key = toReportBuilderColumnKey(column);
67773
- return Boolean(key) && !previousDisplayColumnKeys.has(key);
67774
- }
67775
- );
67450
+ const normalizedDisplayColumns = normalizedRequestedDisplayColumns ?? [];
67451
+ const addedDisplayColumns = addedRequestedDisplayColumns;
67776
67452
  next.columns = normalizedDisplayColumns;
67777
67453
  if (addedDisplayColumns.length > 0) {
67778
67454
  const queryTableNames = new Set(
@@ -68175,6 +67851,7 @@ function useReport(reportIdArg, options = {}) {
68175
67851
  } catch (error) {
68176
67852
  console.error("[useForm] setFilters swallowed error", {
68177
67853
  error: error instanceof Error ? error.message : String(error),
67854
+ stack: error instanceof Error ? error.stack : void 0,
68178
67855
  requestedRules: (resolved?.rules ?? []).map((rule) => ({
68179
67856
  table: rule?.table,
68180
67857
  field: rule?.field,