@quillsql/react 2.16.93 → 2.16.94

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
@@ -103,7 +103,7 @@ function formatIdentifierLabel(str) {
103
103
  if (hasUnderscore || hasCamelCaseBoundary) {
104
104
  return snakeAndCamelCaseToTitleCase(str);
105
105
  }
106
- return str;
106
+ return str.split(/\s+/).map((word) => word === "id" ? "ID" : capitalize(word)).join(" ");
107
107
  }
108
108
  function removeDoubleQuotes(str) {
109
109
  if (!str) {
@@ -137,13 +137,14 @@ function getValidDate(dateString) {
137
137
  const dates = FORMATS.map((fmt) => (0, import_date_fns.parse)(dateString, fmt, /* @__PURE__ */ new Date()));
138
138
  return dates.find((date) => (0, import_date_fns.isValid)(date));
139
139
  }
140
- var import_date_fns, import_date_fns_tz, DATE_FORMAT_TYPES, NUMBER_FORMAT_TYPES, valueFormatter, quillFormat, quillAutoFormat, formatString, formatterDollar, formatDollarAmount, formatterCentsDollar, formatDollarCents, wholeNumberFormatter, formatWholeNumber, formatOneDecimalPlace, formatterTwoDecimalPlaces, formatTwoDecimalPlaces, formatterPercent, formatPercent, _getUTCDateHelper, format_YYYY, format_MMM_yyyy, format_hh_ap_pm, format_MMM_d, format_MMM_dd_yyyy, format_MMM_d_MMM_d, format_MMM_dd_hh_mm_ap_pm, format_wo_yyyy, localeFormatter, FORMATS, compareValues;
140
+ var import_date_fns, import_date_fns_tz, DATE_OUTSIDE_RANGE, DATE_FORMAT_TYPES, NUMBER_FORMAT_TYPES, valueFormatter, quillFormat, quillAutoFormat, formatString, formatterDollar, formatDollarAmount, formatterCentsDollar, formatDollarCents, wholeNumberFormatter, formatWholeNumber, formatOneDecimalPlace, formatterTwoDecimalPlaces, formatTwoDecimalPlaces, formatterPercent, formatPercent, _getUTCDateHelper, format_YYYY, format_MMM_yyyy, format_hh_ap_pm, format_MMM_d, format_MMM_dd_yyyy, format_MMM_d_MMM_d, format_MMM_dd_hh_mm_ap_pm, format_wo_yyyy, localeFormatter, FORMATS, compareValues;
141
141
  var init_valueFormatter = __esm({
142
142
  "src/utils/valueFormatter.ts"() {
143
143
  "use strict";
144
144
  import_date_fns = require("date-fns");
145
145
  import_date_fns_tz = require("date-fns-tz");
146
146
  init_textProcessing();
147
+ DATE_OUTSIDE_RANGE = "Date outside range";
147
148
  DATE_FORMAT_TYPES = [
148
149
  "yyyy",
149
150
  "MMM_yyyy",
@@ -392,7 +393,7 @@ var init_valueFormatter = __esm({
392
393
  weekEnd = utcEnd;
393
394
  }
394
395
  if ((0, import_date_fns.isAfter)(weekStart, utcEnd) || (0, import_date_fns.isBefore)(weekEnd, utcStart)) {
395
- return "Date outside range";
396
+ return DATE_OUTSIDE_RANGE;
396
397
  }
397
398
  }
398
399
  }
@@ -17136,79 +17137,6 @@ var init_paginationProcessing = __esm({
17136
17137
  }
17137
17138
  });
17138
17139
 
17139
- // src/utils/dashboardProfiler.ts
17140
- function profilingEnabled() {
17141
- if (typeof process !== "undefined" && process.env?.QUILL_DASHBOARD_PROFILE === "true") {
17142
- return true;
17143
- }
17144
- if (typeof window === "undefined") return false;
17145
- return Boolean(window.__QUILL_DASHBOARD_PROFILE__);
17146
- }
17147
- function profileStore() {
17148
- if (typeof window !== "undefined") {
17149
- const profileWindow = window;
17150
- profileWindow.__QUILL_DASHBOARD_TRACE__ ??= [];
17151
- return profileWindow.__QUILL_DASHBOARD_TRACE__;
17152
- }
17153
- const globalStore = globalThis;
17154
- globalStore.__QUILL_DASHBOARD_TRACE__ ??= [];
17155
- return globalStore.__QUILL_DASHBOARD_TRACE__;
17156
- }
17157
- function queryKeyFamily(queryKey) {
17158
- const head = String(queryKey[0] ?? "");
17159
- const next = String(queryKey[1] ?? "");
17160
- if (head === "quill" && next === "dashboard-report") {
17161
- return "quill/dashboard-report";
17162
- }
17163
- if (head === "useReport") {
17164
- return `useReport/${next || "unknown"}`;
17165
- }
17166
- return head || "other";
17167
- }
17168
- function summarizeEngineRequest(input) {
17169
- const metadata = input.metadata ?? {};
17170
- return {
17171
- task: input.task ?? null,
17172
- shareRequest: Boolean(input.shareRequest),
17173
- reuseExisting: input.reuseExisting ?? null,
17174
- settled: input.settled ?? null,
17175
- reportId: metadata.reportId ?? null,
17176
- metadataKeys: Object.keys(metadata).sort(),
17177
- dashboardName: metadata.dashboardName ?? null,
17178
- dashboardItemId: metadata.dashboardItemId ?? null,
17179
- useNewNodeSql: metadata.useNewNodeSql ?? null,
17180
- dateBucket: metadata.dateBucket ?? null,
17181
- hasPivot: Boolean(metadata.pivot),
17182
- hasReportBuilderState: Boolean(metadata.reportBuilderState),
17183
- additionalProcessing: metadata.additionalProcessing ?? null,
17184
- filterCount: Array.isArray(metadata.filters) ? metadata.filters.length : null
17185
- };
17186
- }
17187
- function profileDashboard(event, data) {
17188
- if (!profilingEnabled()) return;
17189
- const entry = {
17190
- at: Math.round(performance.now() * 10) / 10,
17191
- event,
17192
- data
17193
- };
17194
- profileStore().push(entry);
17195
- if (typeof window !== "undefined") {
17196
- const profileWindow = window;
17197
- profileWindow.__QUILL_DASHBOARD_PROFILE__ = true;
17198
- profileWindow.__QUILL_DUMP_DASHBOARD_PROFILE__ = () => profileWindow.__QUILL_DASHBOARD_TRACE__ ?? [];
17199
- }
17200
- if (typeof process !== "undefined" && process.env?.QUILL_DASHBOARD_PROFILE_CONSOLE === "true" && CONSOLE_EVENT_PATTERN.test(event)) {
17201
- console.log(`[quill-profile] ${event}`, data ?? {});
17202
- }
17203
- }
17204
- var CONSOLE_EVENT_PATTERN;
17205
- var init_dashboardProfiler = __esm({
17206
- "src/utils/dashboardProfiler.ts"() {
17207
- "use strict";
17208
- CONSOLE_EVENT_PATTERN = /cache|initial-load|use-report-loading|network|unique-values|table-refresh|pivot|shared-request|engine-fetch|generate-pivot/;
17209
- }
17210
- });
17211
-
17212
17140
  // src/utils/pivotConstructor.ts
17213
17141
  function normalizeLegacyPivotSortFieldValue(sortField) {
17214
17142
  if (sortField === void 0) {
@@ -17321,22 +17249,6 @@ async function generatePivotWithSQL({
17321
17249
  rowLimit: pivot.rowLimit,
17322
17250
  dateBucket: resolvedDateBucket
17323
17251
  };
17324
- profileDashboard(
17325
- "generate-pivot-sql",
17326
- summarizeEngineRequest({
17327
- task: "pivot-template",
17328
- shareRequest: false,
17329
- metadata: {
17330
- reportId: report?.id,
17331
- dashboardName,
17332
- dateBucket: resolvedDateBucket,
17333
- additionalProcessing,
17334
- pivot: pivotConfig,
17335
- reportBuilderState,
17336
- filters: dashboardFilters
17337
- }
17338
- })
17339
- );
17340
17252
  const resp = await quillFetch({
17341
17253
  client,
17342
17254
  task: "pivot-template",
@@ -17376,7 +17288,7 @@ async function generatePivotWithSQL({
17376
17288
  );
17377
17289
  const responseRows = queryResponseRows;
17378
17290
  const responseFields = queryResponseFields;
17379
- const rows = resultRowField ? responseRows.map(
17291
+ let rows = resultRowField ? responseRows.map(
17380
17292
  (row) => !row[resultRowField] ? { ...row, [resultRowField]: "-" } : row
17381
17293
  ) : responseRows;
17382
17294
  if (pivot.columnField && client.databaseType?.toLowerCase() === "bigquery") {
@@ -17415,24 +17327,21 @@ async function generatePivotWithSQL({
17415
17327
  return 0;
17416
17328
  });
17417
17329
  if (resultRowField && !isStringType(pivot.rowFieldType || "")) {
17418
- rows.forEach((row) => {
17419
- row.__quillRawDate = typeof row[resultRowField] === "object" ? row[resultRowField].value : row[resultRowField];
17420
- let value = typeof row[resultRowField] === "object" ? row[resultRowField].value : row[resultRowField];
17421
- if (dateBucket === "week" && dateFilter?.startDate && dateFilter?.endDate) {
17422
- const rowDate = new Date(value);
17423
- if (rowDate < dateFilter.startDate) {
17424
- value = dateFilter.startDate.toISOString();
17425
- } else if (rowDate > dateFilter.endDate) {
17426
- value = dateFilter.endDate.toISOString();
17427
- }
17428
- }
17330
+ const dateRange = dateFilter?.startDate && dateFilter?.endDate ? { start: dateFilter.startDate, end: dateFilter.endDate } : void 0;
17331
+ rows = rows.filter((row) => {
17332
+ const rawValue = typeof row[resultRowField] === "object" ? row[resultRowField].value : row[resultRowField];
17333
+ row.__quillRawDate = rawValue;
17429
17334
  const dateString = getDateString(
17430
- value,
17431
- dateFilter?.startDate && dateFilter?.endDate ? { start: dateFilter.startDate, end: dateFilter.endDate } : void 0,
17335
+ rawValue,
17336
+ dateRange,
17432
17337
  dateBucket,
17433
17338
  databaseType
17434
17339
  );
17340
+ if (dateBucket === "week" && dateRange && dateString === DATE_OUTSIDE_RANGE) {
17341
+ return false;
17342
+ }
17435
17343
  row[resultRowField] = dateString;
17344
+ return true;
17436
17345
  });
17437
17346
  if (resultRowField && pivot.rowFieldType && !isStringType(pivot.rowFieldType) && dateFilter?.startDate && dateFilter?.endDate) {
17438
17347
  const dateSet = new Set(rows.map((row) => row[resultRowField]));
@@ -17597,7 +17506,7 @@ function processPivotData({
17597
17506
  const pivotRowField = processColumnName(
17598
17507
  String(resultRowField ?? pivot.rowField ?? "")
17599
17508
  );
17600
- const rows = pivotRowField ? responseRows.map(
17509
+ let rows = pivotRowField ? responseRows.map(
17601
17510
  (row) => !row[pivotRowField] ? { ...row, [pivotRowField]: "-" } : row
17602
17511
  ) : responseRows;
17603
17512
  if (pivot.columnField && client.databaseType?.toLowerCase() === "bigquery") {
@@ -17636,24 +17545,21 @@ function processPivotData({
17636
17545
  return 0;
17637
17546
  });
17638
17547
  if (pivotRowField && !isStringType(pivot.rowFieldType || "")) {
17639
- rows.forEach((row) => {
17640
- row.__quillRawDate = typeof row[pivotRowField] === "object" ? row[pivotRowField].value : row[pivotRowField];
17641
- let value = typeof row[pivotRowField] === "object" ? row[pivotRowField].value : row[pivotRowField];
17642
- if (dateBucket === "week" && dateFilter?.startDate && dateFilter?.endDate) {
17643
- const rowDate = new Date(value);
17644
- if (rowDate < dateFilter.startDate) {
17645
- value = dateFilter.startDate.toISOString();
17646
- } else if (rowDate > dateFilter.endDate) {
17647
- value = dateFilter.endDate.toISOString();
17648
- }
17649
- }
17548
+ const dateRange = dateFilter?.startDate && dateFilter?.endDate ? { start: dateFilter.startDate, end: dateFilter.endDate } : void 0;
17549
+ rows = rows.filter((row) => {
17550
+ const rawValue = typeof row[pivotRowField] === "object" ? row[pivotRowField].value : row[pivotRowField];
17551
+ row.__quillRawDate = rawValue;
17650
17552
  const dateString = getDateString(
17651
- value,
17652
- dateFilter?.startDate && dateFilter?.endDate ? { start: dateFilter.startDate, end: dateFilter.endDate } : void 0,
17553
+ rawValue,
17554
+ dateRange,
17653
17555
  dateBucket,
17654
17556
  databaseType
17655
17557
  );
17558
+ if (dateBucket === "week" && dateRange && dateString === DATE_OUTSIDE_RANGE) {
17559
+ return false;
17560
+ }
17656
17561
  row[pivotRowField] = dateString;
17562
+ return true;
17657
17563
  });
17658
17564
  if (pivotRowField && pivot.rowFieldType && !isStringType(pivot.rowFieldType) && dateFilter?.startDate && dateFilter?.endDate) {
17659
17565
  const dateSet = new Set(rows.map((row) => row[pivotRowField]));
@@ -17715,9 +17621,9 @@ var init_pivotConstructor = __esm({
17715
17621
  init_columnType();
17716
17622
  init_dataFetcher();
17717
17623
  init_dataProcessing();
17718
- init_dashboardProfiler();
17719
17624
  init_dates();
17720
17625
  init_textProcessing();
17626
+ init_valueFormatter();
17721
17627
  }
17722
17628
  });
17723
17629
 
@@ -20138,20 +20044,6 @@ async function getOrFetchSharedRequest({
20138
20044
  }) {
20139
20045
  if (signal?.aborted) throw createAbortError(signal);
20140
20046
  let entry = entries.get(key);
20141
- const reuseExisting = Boolean(entry);
20142
- profileDashboard("shared-request", {
20143
- ...summarizeEngineRequest({
20144
- task: void 0,
20145
- shareRequest: true,
20146
- reuseExisting,
20147
- settled: entry?.settled,
20148
- metadata: { reportId }
20149
- }),
20150
- reportId: reportId ?? null,
20151
- reuseExisting,
20152
- settled: entry?.settled ?? false,
20153
- keyLength: key.length
20154
- });
20155
20047
  if (!entry) {
20156
20048
  const controller = new AbortController();
20157
20049
  entry = {
@@ -20227,7 +20119,6 @@ var ORPHAN_GRACE_MS, COMPLETED_TTL_MS, entries;
20227
20119
  var init_reportRequestPool = __esm({
20228
20120
  "src/utils/reportRequestPool.ts"() {
20229
20121
  "use strict";
20230
- init_dashboardProfiler();
20231
20122
  ORPHAN_GRACE_MS = 100;
20232
20123
  COMPLETED_TTL_MS = 15e3;
20233
20124
  entries = /* @__PURE__ */ new Map();
@@ -20790,7 +20681,6 @@ var init_dataFetcher = __esm({
20790
20681
  init_dates();
20791
20682
  init_changelogNotify();
20792
20683
  init_reportRequestPool();
20793
- init_dashboardProfiler();
20794
20684
  quillFetch = async ({
20795
20685
  client,
20796
20686
  task,
@@ -20851,14 +20741,6 @@ var init_dataFetcher = __esm({
20851
20741
  return { error: "Failed to fetch data" };
20852
20742
  }
20853
20743
  };
20854
- profileDashboard(
20855
- "engine-fetch",
20856
- summarizeEngineRequest({
20857
- task,
20858
- shareRequest,
20859
- metadata
20860
- })
20861
- );
20862
20744
  if (!shareRequest) {
20863
20745
  return execute(abortSignal);
20864
20746
  }
@@ -21494,7 +21376,22 @@ init_dates();
21494
21376
  init_pivotConstructor();
21495
21377
  init_columnProcessing();
21496
21378
  init_paginationProcessing();
21497
- init_dashboardProfiler();
21379
+
21380
+ // src/utils/dashboardProfiler.ts
21381
+ function profileDashboard(event, data) {
21382
+ if (typeof window === "undefined") return;
21383
+ const profileWindow = window;
21384
+ if (!profileWindow.__QUILL_DASHBOARD_PROFILE__) return;
21385
+ const entry = {
21386
+ at: Math.round(performance.now() * 10) / 10,
21387
+ event,
21388
+ data
21389
+ };
21390
+ profileWindow.__QUILL_DASHBOARD_TRACE__ ??= [];
21391
+ profileWindow.__QUILL_DASHBOARD_TRACE__.push(entry);
21392
+ }
21393
+
21394
+ // src/utils/dashboard.ts
21498
21395
  var defaultDashboardItem = {
21499
21396
  id: "",
21500
21397
  name: "",
@@ -22901,13 +22798,13 @@ init_columnProcessing();
22901
22798
  init_dataFetcher();
22902
22799
  init_dataProcessing();
22903
22800
  init_dates();
22801
+ init_columnType();
22904
22802
  init_paginationProcessing();
22905
22803
  init_pivotProcessing();
22906
22804
  init_tableProcessing();
22907
22805
  init_textProcessing();
22908
22806
  init_valueFormatter();
22909
22807
  init_astFilterProcessing();
22910
- init_dashboardProfiler();
22911
22808
  init_reportBuilder();
22912
22809
  init_astProcessing();
22913
22810
 
@@ -23827,6 +23724,15 @@ function hasPreformattedDateBucketLabels(report) {
23827
23724
  if (report.chartType?.toLowerCase() === "table") return false;
23828
23725
  return report.xAxisField?.trim() === pivot.rowField?.trim();
23829
23726
  }
23727
+ function resolvePivotBucketXAxisFormat(report) {
23728
+ const pivot = report.pivot;
23729
+ if (!pivot?.dateBucket) return null;
23730
+ if (report.chartType?.toLowerCase() === "table") return null;
23731
+ const rowField = pivot.rowField?.trim();
23732
+ if (!rowField || report.xAxisField?.trim() !== rowField) return null;
23733
+ if (!isDateType(String(pivot.rowFieldType ?? ""))) return null;
23734
+ return getDateFormatFromBucket(pivot.dateBucket);
23735
+ }
23830
23736
  function applySavedPivotColumnLabels(report, pivotColumns) {
23831
23737
  return pivotColumns?.map((column) => {
23832
23738
  const savedColumn = report.columns?.find(
@@ -23902,6 +23808,10 @@ function convertInternalReportToReport(report, dashboardFilters, eventTracking,
23902
23808
  ...extractAllReportValuesFromQuillInternalReport(formattedReport),
23903
23809
  ...pivotFormatted
23904
23810
  };
23811
+ const bucketXAxisFormat = resolvePivotBucketXAxisFormat(pivotReport);
23812
+ if (bucketXAxisFormat) {
23813
+ pivotReport.xAxisFormat = bucketXAxisFormat;
23814
+ }
23905
23815
  pivotReport.formattedBaseRows = formattedBaseRows;
23906
23816
  return applyChartSort(pivotReport);
23907
23817
  }
@@ -26667,7 +26577,6 @@ function normalizePSTRanges(start, end) {
26667
26577
 
26668
26578
  // src/Context.tsx
26669
26579
  init_changelogNotify();
26670
- init_dashboardProfiler();
26671
26580
 
26672
26581
  // src/reportStore.ts
26673
26582
  var import_react = require("react");
@@ -32438,7 +32347,7 @@ function QuillTable({
32438
32347
  setSortColumn(sort?.field || "");
32439
32348
  setSortDirection(sort?.direction || "desc");
32440
32349
  }, [sort]);
32441
- const holdFullPageLoader = Boolean(isLoading);
32350
+ const holdFullPageLoader = rows?.length === 0 && isLoading;
32442
32351
  const pageCountUnknown = manualPagination && pageCount === -1;
32443
32352
  const { activeRows, maxPage } = (0, import_react14.useMemo)(() => {
32444
32353
  const start = currentPage * rowsPerPage;
@@ -34175,9 +34084,8 @@ function RadarChart({
34175
34084
  fields: [{ field: xAxisField, format: xAxisFormat }]
34176
34085
  }),
34177
34086
  valueFormatter: (value, name2) => {
34178
- const field = payloadItems.find(
34179
- (p) => p.dataKey === name2
34180
- )?.dataKey;
34087
+ const payloadItem = payloadItems.find((p) => p.dataKey === name2) ?? payloadItems.find((p) => p.name === name2);
34088
+ const field = payloadItem?.dataKey;
34181
34089
  if (!field) return value;
34182
34090
  return valueFormatter({
34183
34091
  value,
@@ -37296,7 +37204,6 @@ function getDashboardReportProcessing(report, serverPagination) {
37296
37204
  }
37297
37205
 
37298
37206
  // src/hooks/useDashboard.ts
37299
- init_dashboardProfiler();
37300
37207
  var DEFAULT_DASHBOARD_REPORT_STALE_TIME_MS = 5 * 60 * 1e3;
37301
37208
  var useDashboardConfigInternal = (dashboardName) => {
37302
37209
  const { dashboardConfig, isLoading: dashboardsLoading } = (0, import_react26.useContext)(
@@ -37675,7 +37582,8 @@ var useDashboards = () => {
37675
37582
  reports: Object.values(dashboard.config.sections ?? {}).flat(),
37676
37583
  tenantKeys: dashboard.config.tenantKeys,
37677
37584
  createdAt: dashboard.config.createdAt,
37678
- sectionOrder: dashboard.config.sectionOrder
37585
+ sectionOrder: dashboard.config.sectionOrder,
37586
+ hidden: dashboard.config.hidden
37679
37587
  };
37680
37588
  }).sort(
37681
37589
  (a, b) => (a.createdAt?.getTime() ?? 0) - (b.createdAt?.getTime() ?? 0)
@@ -38406,14 +38314,6 @@ var useDashboard = (dashboardName, config) => {
38406
38314
  additionalProcessing
38407
38315
  );
38408
38316
  const usePivotTask = !cacheEnabled && !!reportInfo.pivot;
38409
- profileDashboard("dashboard-report-cache-path", {
38410
- reportId,
38411
- cacheEnabled,
38412
- cacheCabCacheable: cacheCab.isCacheable(reportId),
38413
- usePivotTask,
38414
- forceCacheToRefresh,
38415
- hasPivot: Boolean(reportInfo.pivot)
38416
- });
38417
38317
  const allFilters = dashboardFilters2.concat(customFilters).concat(customReportFiltersArray);
38418
38318
  const applyInMemoryPivotIfNeeded = (report2) => {
38419
38319
  const pivotToApply = reportInfo.pivot ?? report2.pivot;
@@ -38647,9 +38547,7 @@ var useDashboard = (dashboardName, config) => {
38647
38547
  pivotColumns: pivotData.columns,
38648
38548
  pivotRowCount: pivotData.rowCount,
38649
38549
  pivotQuery: pivotData.pivotQuery,
38650
- comparisonPivotQuery: pivotData.comparisonPivotQuery,
38651
- pivotResultRowField: pivotData.rowField,
38652
- pivotResultSourceRowField: reportInfo.pivot?.rowField
38550
+ comparisonPivotQuery: pivotData.comparisonPivotQuery
38653
38551
  },
38654
38552
  error: void 0
38655
38553
  };
@@ -38679,26 +38577,6 @@ var useDashboard = (dashboardName, config) => {
38679
38577
  shareRequest: !forceCacheToRefresh
38680
38578
  });
38681
38579
  };
38682
- const existingState = queryClient.getQueryState(queryKey);
38683
- const existingData = queryClient.getQueryData(queryKey);
38684
- const dataUpdatedAt = existingState?.dataUpdatedAt ?? 0;
38685
- const ageMs = dataUpdatedAt ? Date.now() - dataUpdatedAt : null;
38686
- const isStale = dataUpdatedAt === 0 || Date.now() - dataUpdatedAt >= reportStaleTimeMs;
38687
- profileDashboard("dashboard-report-tanstack-cache", {
38688
- reportId,
38689
- keyFamily: "quill/dashboard-report",
38690
- cacheEnabled,
38691
- usePivotTask,
38692
- forceCacheToRefresh,
38693
- staleTimeMs: reportStaleTimeMs,
38694
- status: existingState?.status ?? "missing",
38695
- fetchStatus: existingState?.fetchStatus ?? "idle",
38696
- hasData: existingData !== void 0,
38697
- dataUpdatedAt,
38698
- ageMs,
38699
- isStale,
38700
- willReuseTanstack: !forceCacheToRefresh && existingData !== void 0 && !isStale
38701
- });
38702
38580
  const result = forceCacheToRefresh ? await fetchDashboardReport() : await queryClient.fetchQuery({
38703
38581
  queryKey,
38704
38582
  queryFn: fetchDashboardReport,
@@ -39101,7 +38979,6 @@ var useDashboardReport = (reportId, config) => {
39101
38979
  };
39102
38980
 
39103
38981
  // src/components/Dashboard/DataLoader.tsx
39104
- init_dashboardProfiler();
39105
38982
  var import_jsx_runtime46 = require("react/jsx-runtime");
39106
38983
  var constructReportFromItem = (item) => {
39107
38984
  return {
@@ -41517,7 +41394,6 @@ function QuillTableDashboardComponent({
41517
41394
 
41518
41395
  // src/Chart.tsx
41519
41396
  init_valueFormatter();
41520
- init_dashboardProfiler();
41521
41397
  var import_jsx_runtime50 = require("react/jsx-runtime");
41522
41398
  function Chart({
41523
41399
  colors,
@@ -45502,7 +45378,6 @@ init_Filter();
45502
45378
 
45503
45379
  // src/StaticChart.tsx
45504
45380
  var import_react42 = require("react");
45505
- init_dashboardProfiler();
45506
45381
  var import_jsx_runtime60 = require("react/jsx-runtime");
45507
45382
  var CHART_TYPE_STYLES = {
45508
45383
  metric: { height: "100px", width: "200px" },
@@ -46351,6 +46226,7 @@ var QuillProvider = ({
46351
46226
  isAdmin,
46352
46227
  getAuthorizationToken,
46353
46228
  eventTracking,
46229
+ onChangelogs,
46354
46230
  children
46355
46231
  }
46356
46232
  ) });
@@ -62355,7 +62231,6 @@ function resolveReportFromCacheCab({
62355
62231
  }
62356
62232
 
62357
62233
  // src/hooks/useForm.tsx
62358
- init_dashboardProfiler();
62359
62234
  init_reportRequestPool();
62360
62235
 
62361
62236
  // src/hooks/useForm.queries.ts
@@ -62401,15 +62276,6 @@ function createUseFormInitialLoadQueryKey(input) {
62401
62276
  input.additionalSchemaHash
62402
62277
  ];
62403
62278
  }
62404
- var DASHBOARD_REPORT_STALE_TIME_MS = 5 * 60 * 1e3;
62405
- function findCachedDashboardReportQuery(queryClient, reportId) {
62406
- const id = String(reportId ?? "").trim();
62407
- if (!id) return void 0;
62408
- return queryClient.getQueryCache().findAll({ queryKey: ["quill", "dashboard-report", id] }).find((query) => {
62409
- const data = query.state.data;
62410
- return Boolean(data?.report) && !data?.error;
62411
- });
62412
- }
62413
62279
  function shouldBootstrapUseFormInitialLoad(input) {
62414
62280
  return !input.hasInitialReportBuilderState && input.previouslyBootstrappedIdentity !== input.currentIdentity;
62415
62281
  }
@@ -63392,11 +63258,6 @@ function getPivotTableSlotReportColumn(reportColumns, aggregations, rowField, pi
63392
63258
  }
63393
63259
  return cols[aggIndex + 1];
63394
63260
  }
63395
- function pivotRowKey(chart) {
63396
- return String(
63397
- chart?.pivotResultRowField ?? chart?.pivot?.rowField ?? ""
63398
- ).trim();
63399
- }
63400
63261
  function isPivotTableDateBucketRowAxis(chart, xAxisField) {
63401
63262
  if (!chart?.pivot) return false;
63402
63263
  if (String(chart.chartType ?? "").toLowerCase() !== "table") return false;
@@ -63405,8 +63266,7 @@ function isPivotTableDateBucketRowAxis(chart, xAxisField) {
63405
63266
  }
63406
63267
  const rowField = String(chart.pivot.rowField ?? "").trim();
63407
63268
  const xf = String(xAxisField ?? "").trim();
63408
- const rowKey = pivotRowKey(chart);
63409
- if (!rowField || xf !== rowField && xf !== rowKey) return false;
63269
+ if (!rowField || xf !== rowField) return false;
63410
63270
  return isDateType(String(chart.pivot.rowFieldType ?? ""));
63411
63271
  }
63412
63272
  var RESOLVABLE_X_AXIS_DATE_BUCKETS = /* @__PURE__ */ new Set([
@@ -63420,24 +63280,22 @@ function resolvePivotDateBucketXAxisFormat(chart, xAxisField) {
63420
63280
  const dateBucket = String(chart?.pivot?.dateBucket ?? "").trim().toLowerCase();
63421
63281
  if (!RESOLVABLE_X_AXIS_DATE_BUCKETS.has(dateBucket)) return null;
63422
63282
  const rowField = String(chart?.pivot?.rowField ?? "").trim();
63423
- const xf = String(xAxisField ?? "").trim();
63424
- const rowKey = pivotRowKey(chart);
63425
- if (!rowField || xf !== rowField && xf !== rowKey) return null;
63283
+ if (!rowField || String(xAxisField ?? "").trim() !== rowField) return null;
63426
63284
  if (!isDateType(String(chart?.pivot?.rowFieldType ?? ""))) return null;
63427
63285
  return getDateFormatFromBucket(dateBucket);
63428
63286
  }
63429
63287
  function chartDetailRowsMissingPivotRowBucket(chart) {
63430
63288
  if (!chart?.pivot) return false;
63431
- const rowKey = pivotRowKey(chart);
63432
- if (!rowKey) return false;
63289
+ const rowField = String(chart.pivot.rowField ?? "").trim();
63290
+ if (!rowField) return false;
63433
63291
  const rows = chart.rows;
63434
63292
  if (!Array.isArray(rows) || rows.length === 0) return false;
63435
63293
  const first = rows.find(
63436
63294
  (r) => r && typeof r === "object" && Object.keys(r).length > 0
63437
63295
  );
63438
63296
  if (!first) return false;
63439
- if (!Object.prototype.hasOwnProperty.call(first, rowKey)) return true;
63440
- const v = first[rowKey];
63297
+ if (!Object.prototype.hasOwnProperty.call(first, rowField)) return true;
63298
+ const v = first[rowField];
63441
63299
  return v === void 0 || v === null;
63442
63300
  }
63443
63301
  function shouldUsePivotRowFieldAsXAxis(chartType, pivotRowField, rowColumnFormat) {
@@ -63473,7 +63331,7 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
63473
63331
  } : chart;
63474
63332
  if (!config) return config;
63475
63333
  if (!config.pivot) return config;
63476
- const pivotRowFieldEarly = pivotRowKey(config);
63334
+ const pivotRowFieldEarly = String(config.pivot?.rowField ?? "").trim();
63477
63335
  const rowColumn = (config.pivotColumns ?? config.columns ?? []).find(
63478
63336
  (col) => String(col.field ?? "").trim() === pivotRowFieldEarly
63479
63337
  );
@@ -63492,11 +63350,23 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
63492
63350
  const firstPivotRow = (withResolvedXAxis.rows ?? []).find(
63493
63351
  (row) => Object.keys(row).length > 0
63494
63352
  );
63495
- const pivotRowFields = firstPivotRow ? Object.keys(firstPivotRow).filter(
63496
- (field) => !INTERNAL_PIVOT_ROW_FIELDS.has(field)
63497
- ) : [];
63353
+ const pivotRowFieldName = String(
63354
+ withResolvedXAxis.pivot?.rowField ?? ""
63355
+ ).trim();
63356
+ const pivotRowFields = firstPivotRow ? (() => {
63357
+ const keys = Object.keys(firstPivotRow).filter(
63358
+ (field) => !INTERNAL_PIVOT_ROW_FIELDS.has(field)
63359
+ );
63360
+ if (pivotRowFieldName && keys.includes(pivotRowFieldName)) {
63361
+ return [
63362
+ pivotRowFieldName,
63363
+ ...keys.filter((field) => field !== pivotRowFieldName)
63364
+ ];
63365
+ }
63366
+ return keys;
63367
+ })() : [];
63498
63368
  const pivotValueFields = pivotRowFields.filter(
63499
- (field) => field !== pivotRowKey(withResolvedXAxis) && field !== withResolvedXAxis.pivot?.rowField
63369
+ (field) => field !== withResolvedXAxis.pivot?.rowField
63500
63370
  );
63501
63371
  const isAggregationOnlyPivot = !String(withResolvedXAxis.pivot?.rowField ?? "").trim() && !String(withResolvedXAxis.pivot?.columnField ?? "").trim();
63502
63372
  const yAxisFormatByField = new Map(
@@ -63507,6 +63377,10 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
63507
63377
  );
63508
63378
  const resolveYAxisFormat = (field, aggregation) => {
63509
63379
  if (aggregation?.aggregationType === "count") {
63380
+ const savedFormat = yAxisFormatByField.get(field) ?? yAxisFormatByField.get("count") ?? withResolvedXAxis.yAxisFields?.find(
63381
+ (axis) => String(axis.field ?? "").trim() === field
63382
+ )?.format ?? withResolvedXAxis.yAxisFields?.[0]?.format;
63383
+ if (savedFormat) return savedFormat;
63510
63384
  return "whole_number";
63511
63385
  }
63512
63386
  if (aggregation?.aggregationType === "percentage") {
@@ -63613,7 +63487,7 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
63613
63487
  const normalizedPivotColumns = pivotColumnFields.length > 0 ? pivotColumnFields.map((field) => {
63614
63488
  const knownColumn = knownColumnsByField.get(field);
63615
63489
  const yAxis = yAxisFields.find((axis) => axis.field === field);
63616
- const format9 = yAxis?.format ?? knownColumn?.format ?? (field === pivotRowKey(withResolvedXAxis) || field === withResolvedXAxis.pivot?.rowField ? isMetricOrGauge ? "string" : withResolvedXAxis.xAxisFormat ?? "string" : yAxisFallbackFormat);
63490
+ const format9 = yAxis?.format ?? knownColumn?.format ?? (field === withResolvedXAxis.pivot?.rowField ? isMetricOrGauge ? "string" : withResolvedXAxis.xAxisFormat ?? "string" : yAxisFallbackFormat);
63617
63491
  return {
63618
63492
  field,
63619
63493
  label: yAxis?.label ?? knownColumn?.label ?? field,
@@ -63626,7 +63500,7 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
63626
63500
  const slotCol = getPivotTableSlotReportColumn(
63627
63501
  pivotTableSlotColumns,
63628
63502
  aggregations,
63629
- pivotRowKey(withResolvedXAxis) || withResolvedXAxis.pivot?.rowField,
63503
+ withResolvedXAxis.pivot?.rowField,
63630
63504
  col.field
63631
63505
  );
63632
63506
  if (!slotCol) return col;
@@ -63648,7 +63522,9 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
63648
63522
  const normalizedXAxisFormat = normalizedXAxisField === withResolvedXAxis.xAxisField ? withResolvedXAxis.xAxisFormat : yAxisFields.find((axis) => axis.field === normalizedXAxisField)?.format ?? pivotTableDisplayColumns.find(
63649
63523
  (column) => column.field === normalizedXAxisField
63650
63524
  )?.format ?? withResolvedXAxis.xAxisFormat;
63651
- const pivotDisplayRowField = pivotRowKey(withResolvedXAxis);
63525
+ const pivotDisplayRowField = String(
63526
+ withResolvedXAxis.pivot?.rowField ?? ""
63527
+ ).trim();
63652
63528
  const pivotDisplayRowFieldType = String(
63653
63529
  withResolvedXAxis.pivot?.rowFieldType ?? ""
63654
63530
  ).trim();
@@ -66612,30 +66488,19 @@ function useReport(reportIdArg, options = {}) {
66612
66488
  )
66613
66489
  });
66614
66490
  const diagnostics = globalThis.__QUILL_CACHECAB_DIAGNOSTICS__;
66615
- const durationMs = performance.now() - startedAt;
66616
- const outcome = resolution.resolved ? "hit" : "fallback";
66617
66491
  if (Array.isArray(diagnostics)) {
66618
66492
  diagnostics.push({
66619
66493
  reportId: effectiveReportId,
66620
66494
  operation,
66621
- outcome,
66495
+ outcome: resolution.resolved ? "hit" : "fallback",
66622
66496
  reason: resolution.resolved ? "complete" : resolution.reason,
66623
66497
  details: resolution.resolved ? void 0 : resolution.details,
66624
66498
  snapshotReason: snapshot?.reason ?? "cache_miss",
66625
66499
  forcedIncompleteSnapshot: Boolean(snapshot) && !snapshot?.complete && forceIncompleteCacheCabForParity,
66626
66500
  rowCount: snapshot?.rowCount ?? 0,
66627
- durationMs
66501
+ durationMs: performance.now() - startedAt
66628
66502
  });
66629
66503
  }
66630
- profileDashboard("use-report-cachecab", {
66631
- reportId: effectiveReportId,
66632
- operation,
66633
- outcome,
66634
- reason: resolution.resolved ? "complete" : resolution.reason,
66635
- snapshotReason: snapshot?.reason ?? "cache_miss",
66636
- rowCount: snapshot?.rowCount ?? 0,
66637
- durationMs: Math.round(durationMs * 10) / 10
66638
- });
66639
66504
  return resolution.resolved ? resolution.report : null;
66640
66505
  },
66641
66506
  [
@@ -67209,15 +67074,9 @@ function useReport(reportIdArg, options = {}) {
67209
67074
  if (alias) localValues[alias] = values;
67210
67075
  }
67211
67076
  if (hasEveryColumn) {
67212
- profileDashboard("use-report-unique-values-cachecab-hit", {
67213
- reportId: effectiveReportId
67214
- });
67215
67077
  return { uniqueValuesByColumn: localValues };
67216
67078
  }
67217
67079
  }
67218
- profileDashboard("use-report-unique-values-network", {
67219
- reportId: effectiveReportId
67220
- });
67221
67080
  const tablesForUniqueValues = filterUniqueValuesRequest.reportBuilderState?.tables?.map(
67222
67081
  (table2) => String(table2?.name ?? "").trim()
67223
67082
  ) ?? filterUniqueValuesRequest.stringColumnsByTable.map((column) => String(column.table ?? "").trim()).filter(Boolean);
@@ -67736,29 +67595,6 @@ function useReport(reportIdArg, options = {}) {
67736
67595
  const initialLoadQuery = (0, import_react_query3.useQuery)({
67737
67596
  queryKey: initialLoadQueryKey,
67738
67597
  queryFn: createUseFormQueryFn(async (signal) => {
67739
- const tanstackState = queryClient.getQueryState(initialLoadQueryKey);
67740
- const dashboardReportQueries = queryClient.getQueryCache().getAll().filter(
67741
- (query) => queryKeyFamily(query.queryKey) === "quill/dashboard-report"
67742
- );
67743
- const matchingDashboardReport = dashboardReportQueries.find(
67744
- (query) => String(query.queryKey[2] ?? "") === String(effectiveReportId)
67745
- );
67746
- profileDashboard("use-report-initial-load-queryfn", {
67747
- reportId: effectiveReportId,
67748
- reason: "TanStack ran this queryFn, so useReport/initial-load had no fresh cached data",
67749
- keyFamily: "useReport/initial-load",
67750
- status: tanstackState?.status ?? "missing",
67751
- hasData: tanstackState?.data !== void 0,
67752
- dataUpdatedAt: tanstackState?.dataUpdatedAt ?? 0,
67753
- staleTime: 0,
67754
- dashboardReportQueryCount: dashboardReportQueries.length,
67755
- matchingDashboardReport: matchingDashboardReport ? {
67756
- hasData: matchingDashboardReport.state.data !== void 0,
67757
- status: matchingDashboardReport.state.status,
67758
- staleTime: matchingDashboardReport.options?.staleTime ?? 0,
67759
- unusedByUseReport: true
67760
- } : null
67761
- });
67762
67598
  let cachedReportBuilderState = initialReportBuilderStateForLoad ?? void 0;
67763
67599
  if (!cachedReportBuilderState) {
67764
67600
  const snapshot = await cacheCab.getReportSnapshot(
@@ -67783,9 +67619,6 @@ function useReport(reportIdArg, options = {}) {
67783
67619
  operation: "initial"
67784
67620
  });
67785
67621
  if (cachedReport) {
67786
- profileDashboard("use-report-initial-load-served-from-cachecab", {
67787
- reportId: effectiveReportId
67788
- });
67789
67622
  return { report: cachedReport };
67790
67623
  }
67791
67624
  const allowReportTaskBootstrap = shouldBootstrapUseFormInitialLoad({
@@ -67800,12 +67633,6 @@ function useReport(reportIdArg, options = {}) {
67800
67633
  const formFiltersBelongToLoadTarget = Boolean(loadTargetId) && sourceReportIdentity === loadTargetId;
67801
67634
  const rulesForLoad = useInMemoryEngines || !formFiltersBelongToLoadTarget ? EMPTY_QUERY_FILTERS : queryFilters;
67802
67635
  const shareInitialRequest = sharedInitialRequestUsedForReportIdRef.current !== effectiveReportId;
67803
- profileDashboard("use-report-initial-load-network", {
67804
- reportId: effectiveReportId,
67805
- path: "loadReportForUseForm",
67806
- hasCachedReportBuilderState: Boolean(cachedReportBuilderState)
67807
- });
67808
- const networkStartedAt = performance.now();
67809
67636
  const loadResult = await loadReportForUseForm({
67810
67637
  reportId: effectiveReportId,
67811
67638
  initialReportBuilderState: initialReportBuilderStateForLoad,
@@ -67825,12 +67652,6 @@ function useReport(reportIdArg, options = {}) {
67825
67652
  rowsOnly: isCreatedReportBootstrapLoad,
67826
67653
  abortSignal: signal
67827
67654
  });
67828
- profileDashboard("use-report-initial-load-network-done", {
67829
- reportId: effectiveReportId,
67830
- durationMs: Math.round(performance.now() - networkStartedAt),
67831
- hasReport: Boolean(loadResult.report),
67832
- error: loadResult.error ?? null
67833
- });
67834
67655
  if (loadResult.report && !loadResult.error) {
67835
67656
  if (allowReportTaskBootstrap) {
67836
67657
  bootstrapReportTaskUsedForInitialLoadRef.current = initialLoadIdentityHash;
@@ -67842,17 +67663,7 @@ function useReport(reportIdArg, options = {}) {
67842
67663
  return loadResult;
67843
67664
  }),
67844
67665
  enabled: Boolean(effectiveReportId) && Boolean(client) && !reportOverride,
67845
- retry: false,
67846
- initialData: () => {
67847
- const cached = findCachedDashboardReportQuery(
67848
- queryClient,
67849
- effectiveReportId
67850
- );
67851
- const data = cached?.state.data;
67852
- return data?.report ? { report: data.report, error: data.error } : void 0;
67853
- },
67854
- initialDataUpdatedAt: () => findCachedDashboardReportQuery(queryClient, effectiveReportId)?.state.dataUpdatedAt,
67855
- staleTime: DASHBOARD_REPORT_STALE_TIME_MS
67666
+ retry: false
67856
67667
  });
67857
67668
  const reportNameQueryReportId = String(effectiveReportId ?? "").trim();
67858
67669
  const reportNameQuery = (0, import_react_query3.useQuery)({
@@ -67903,6 +67714,15 @@ function useReport(reportIdArg, options = {}) {
67903
67714
  const shouldPromoteColumnToRowFromPendingFlag = pendingPromoteColumnToRow && !String(prev.groupRowsBy ?? "").trim();
67904
67715
  const sourceReportBuilderTables = (sourceReport.reportBuilderState?.tables ?? []).filter((table2) => Boolean(String(table2?.name ?? "").trim()));
67905
67716
  const sourceReportBuilderTableNames = sourceReportBuilderTables.map((table2) => table2.name).filter((name2) => Boolean(name2));
67717
+ const sourceQueryColumns = normalizeReportBuilderColumns(
67718
+ sourceReport.reportBuilderState?.columns ?? (sourceReport.columns ?? []).map((column) => ({
67719
+ field: column.field,
67720
+ table: column.table ?? resolveColumnTableFromReportMetadata(
67721
+ sourceReport,
67722
+ column.field
67723
+ )
67724
+ }))
67725
+ );
67906
67726
  const nextQueryFilters = prev.queryFilters.rules.length ? prev.queryFilters : rulesFromReport(sourceReport);
67907
67727
  const pivotAggregationsFromSource = Array.isArray(sourceReport.pivot?.aggregations) ? sourceReport.pivot.aggregations : sourceReport.pivot?.aggregationType ? [
67908
67728
  {
@@ -67969,9 +67789,6 @@ function useReport(reportIdArg, options = {}) {
67969
67789
  tables: tableScopeForDisplayColumns,
67970
67790
  schemaTables: schemaForReportBuilderState
67971
67791
  });
67972
- const sourceQueryColumns = normalizeReportBuilderColumns(
67973
- sourceReport.reportBuilderState?.columns?.length ? sourceReport.reportBuilderState.columns : sourceDisplayColumnsFromSchema
67974
- );
67975
67792
  const savedDisplayColumns = normalizeReportBuilderColumns(
67976
67793
  (sourceReport.columns ?? []).map((column) => ({
67977
67794
  ...column,
@@ -68485,12 +68302,13 @@ function useReport(reportIdArg, options = {}) {
68485
68302
  tables: effectiveReportBuilderState.tables,
68486
68303
  schemaTables: schemaForReportBuilderState
68487
68304
  });
68488
- if (allColumnsBySelectedTable.length === 0) {
68305
+ const columnsToFetch = allColumnsBySelectedTable.length > 0 ? allColumnsBySelectedTable : effectiveReportBuilderState.columns;
68306
+ if (columnsToFetch.length === 0) {
68489
68307
  return void 0;
68490
68308
  }
68491
68309
  return {
68492
68310
  ...effectiveReportBuilderState,
68493
- columns: allColumnsBySelectedTable,
68311
+ columns: columnsToFetch,
68494
68312
  pivot: null,
68495
68313
  sort: [],
68496
68314
  limit: null
@@ -68533,29 +68351,6 @@ function useReport(reportIdArg, options = {}) {
68533
68351
  refreshDecision.shouldRefresh,
68534
68352
  queryFilters
68535
68353
  ]);
68536
- const shouldSkipRedundantPivotTableDataQuery = (0, import_react63.useMemo)(() => {
68537
- if (!sourceReport || !pivotState) {
68538
- return false;
68539
- }
68540
- if (tableRefreshVersion !== 0 || pivotRefreshVersion !== 0) {
68541
- return false;
68542
- }
68543
- if (!Array.isArray(sourceReport.rows) || sourceReport.rows.length === 0) {
68544
- return false;
68545
- }
68546
- if (refreshDecision.shouldRefresh) {
68547
- return false;
68548
- }
68549
- const sourceRules = sourceReport.reportBuilderState?.rules ?? EMPTY_QUERY_FILTERS;
68550
- return stableSerializeForQueryKey(queryFilters) === stableSerializeForQueryKey(sourceRules);
68551
- }, [
68552
- sourceReport,
68553
- pivotState,
68554
- tableRefreshVersion,
68555
- pivotRefreshVersion,
68556
- refreshDecision.shouldRefresh,
68557
- queryFilters
68558
- ]);
68559
68354
  const shouldForceTableRefreshFromFilters = !useInMemoryEngines && !pivotState;
68560
68355
  const immediateTableRefreshInput = (0, import_react63.useMemo)(
68561
68356
  () => ({
@@ -68604,14 +68399,8 @@ function useReport(reportIdArg, options = {}) {
68604
68399
  operation: "table"
68605
68400
  });
68606
68401
  if (cachedReport) {
68607
- profileDashboard("use-report-table-refresh-cachecab-hit", {
68608
- reportId: effectiveReportId
68609
- });
68610
68402
  return { report: cachedReport };
68611
68403
  }
68612
- profileDashboard("use-report-table-refresh-network", {
68613
- reportId: effectiveReportId
68614
- });
68615
68404
  return loadViaReportBuilderState({
68616
68405
  reportId: effectiveReportId,
68617
68406
  reportBuilderState: tableRefreshInput.reportBuilderState,
@@ -69225,8 +69014,7 @@ function useReport(reportIdArg, options = {}) {
69225
69014
  sourceReport
69226
69015
  ]);
69227
69016
  const pivotRefreshQueryEnabled = !reportOverride && pendingPivotRefresh && !shouldSkipPivotRefreshForUnchangedPivot && Boolean(sourceReport) && Boolean(client) && Boolean(effectiveReportBuilderState) && Boolean(nextPivot) && sourceReportMatchesEffectiveReportId;
69228
- const initialLoadSettled = Boolean(reportOverride) || !effectiveReportId || Boolean(client) && !initialLoadQuery.isPending && !initialLoadQuery.isFetching;
69229
- const pivotTableDataRefreshQueryEnabled = !reportOverride && Boolean(sourceReport) && Boolean(client) && Boolean(nextPivot) && Boolean(pivotTableDataReportBuilderState) && !pendingPivotRefresh && sourceReportMatchesEffectiveReportId && initialLoadSettled && !shouldSkipRedundantPivotTableDataQuery;
69017
+ const pivotTableDataRefreshQueryEnabled = !reportOverride && Boolean(sourceReport) && Boolean(client) && Boolean(nextPivot) && Boolean(pivotTableDataReportBuilderState) && !pendingPivotRefresh && sourceReportMatchesEffectiveReportId;
69230
69018
  const pivotRefreshQuery = (0, import_react_query3.useQuery)({
69231
69019
  queryKey: createUseFormPivotRefreshQueryKey({
69232
69020
  reportId: effectiveReportId,
@@ -69340,7 +69128,7 @@ function useReport(reportIdArg, options = {}) {
69340
69128
  const paginationRangeStart = pagination.pageIndex * pagination.pageSize;
69341
69129
  const paginationRangeEnd = paginationRangeStart + pagination.pageSize;
69342
69130
  const pageWithinBaseWindow = paginationRangeEnd <= baseWindowRowsLength || trustedSourceRowCount !== void 0 && trustedSourceRowCount <= baseWindowRowsLength;
69343
- const tablePageQueryEnabled = !pageWithinBaseWindow && !reportOverride && !useInMemoryEngines && Boolean(client) && Boolean(sourceReport) && Boolean(tablePageReportBuilderState) && sourceReportMatchesEffectiveReportId && !pendingPivotRefresh && initialLoadSettled;
69131
+ const tablePageQueryEnabled = !pageWithinBaseWindow && !reportOverride && !useInMemoryEngines && Boolean(client) && Boolean(sourceReport) && Boolean(tablePageReportBuilderState) && sourceReportMatchesEffectiveReportId && !pendingPivotRefresh;
69344
69132
  const tablePageQuery = (0, import_react_query3.useQuery)({
69345
69133
  queryKey: createUseFormTablePageQueryKey({
69346
69134
  reportId: effectiveReportId,
@@ -69512,17 +69300,21 @@ function useReport(reportIdArg, options = {}) {
69512
69300
  if (!sourceReport) return void 0;
69513
69301
  const rowsForChart = Array.isArray(sourceReport.rows) ? sourceReport.rows : [];
69514
69302
  const chartPivot = pendingPivotChangesDimensions ? sourceReport.pivot ?? null : nextPivot ?? (!chartPivotHydratedFromSourceRef.current ? sourceReport.pivot ?? null : null);
69515
- const rowCountForChart = chartPivot ? sourceReport.pivotRowCount ?? (Array.isArray(sourceReport.pivotRows) ? sourceReport.pivotRows.length : sourceReport.rowCount) : useInMemoryEngines ? rowsForChart.length : sourceReport.rowCount;
69303
+ const chartPivotForDisplay = chartPivot && sourceReport.pivotResultRowField && sourceReport.pivotResultSourceRowField === chartPivot.rowField ? {
69304
+ ...chartPivot,
69305
+ rowField: sourceReport.pivotResultRowField
69306
+ } : chartPivot;
69307
+ const rowCountForChart = chartPivotForDisplay ? sourceReport.pivotRowCount ?? (Array.isArray(sourceReport.pivotRows) ? sourceReport.pivotRows.length : sourceReport.rowCount) : useInMemoryEngines ? rowsForChart.length : sourceReport.rowCount;
69516
69308
  const referencedTablesForChart = effectiveReportBuilderState?.tables.map((table2) => table2.name).filter((name2) => Boolean(name2));
69517
69309
  const pivotRowsForChart = Array.isArray(sourceReport.pivotRows) ? sourceReport.pivotRows : void 0;
69518
- const rowCountForChartResolved = chartPivot ? Array.isArray(pivotRowsForChart) ? pivotRowsForChart.length : rowCountForChart : rowCountForChart;
69310
+ const rowCountForChartResolved = chartPivotForDisplay ? Array.isArray(pivotRowsForChart) ? pivotRowsForChart.length : rowCountForChart : rowCountForChart;
69519
69311
  const chartDataPayload = {
69520
69312
  ...sourceReport,
69521
69313
  rows: rowsForChart,
69522
69314
  rowCount: rowCountForChartResolved,
69523
69315
  chartType: chartType ?? sourceReport.chartType,
69524
69316
  reportBuilderState: effectiveReportBuilderState,
69525
- pivot: chartPivot,
69317
+ pivot: chartPivotForDisplay,
69526
69318
  referencedTables: referencedTablesForChart && referencedTablesForChart.length > 0 ? referencedTablesForChart : sourceReport.referencedTables,
69527
69319
  pivotRows: pivotRowsForChart,
69528
69320
  pivotColumns: sourceReport.pivotColumns,
@@ -69573,6 +69365,15 @@ function useReport(reportIdArg, options = {}) {
69573
69365
  }
69574
69366
  for (const yAxis2 of chartAxesBaseChart.yAxisFields ?? []) {
69575
69367
  registerOption(yAxis2.field, yAxis2.label, yAxis2.format);
69368
+ if (yAxis2.format) {
69369
+ const existing = optionsByField.get(yAxis2.field);
69370
+ if (existing) {
69371
+ optionsByField.set(yAxis2.field, {
69372
+ ...existing,
69373
+ format: toAxisFormat(yAxis2.format, existing.format)
69374
+ });
69375
+ }
69376
+ }
69576
69377
  }
69577
69378
  if (chartAxesBaseChart.pivot?.columnField) {
69578
69379
  for (const aggregationAxis of buildPivotAggregationAxisFields(
@@ -69586,11 +69387,22 @@ function useReport(reportIdArg, options = {}) {
69586
69387
  );
69587
69388
  }
69588
69389
  }
69390
+ const xField = String(chartAxesBaseChart.xAxisField ?? "").trim();
69391
+ const savedXFormat = String(chartAxesBaseChart.xAxisFormat ?? "").trim();
69589
69392
  registerOption(
69590
- chartAxesBaseChart.xAxisField,
69393
+ xField,
69591
69394
  chartAxesBaseChart.xAxisLabel || chartAxesBaseChart.xAxisField,
69592
69395
  chartAxesBaseChart.xAxisFormat
69593
69396
  );
69397
+ if (xField && savedXFormat) {
69398
+ const existing = optionsByField.get(xField);
69399
+ if (existing) {
69400
+ optionsByField.set(xField, {
69401
+ ...existing,
69402
+ format: toAxisFormat(savedXFormat, existing.format)
69403
+ });
69404
+ }
69405
+ }
69594
69406
  return Array.from(optionsByField.values());
69595
69407
  }, [chartAxesBaseChart, resolveTableDisplayLabel]);
69596
69408
  const chartAxisOptionByField = (0, import_react63.useMemo)(() => {
@@ -69603,7 +69415,7 @@ function useReport(reportIdArg, options = {}) {
69603
69415
  const xAxisOptions = (0, import_react63.useMemo)(() => {
69604
69416
  if (!chartAxesBaseChart) return chartAxisOptions;
69605
69417
  const pivot = chartAxesBaseChart.pivot;
69606
- const pivotRowField = pivotRowKey(chartAxesBaseChart);
69418
+ const pivotRowField = String(pivot?.rowField ?? "").trim();
69607
69419
  const chartType2 = String(chartAxesBaseChart.chartType ?? "").toLowerCase();
69608
69420
  if (pivot && pivotRowField) {
69609
69421
  if (["metric", "gauge"].includes(chartType2)) {
@@ -69724,7 +69536,9 @@ function useReport(reportIdArg, options = {}) {
69724
69536
  const resolvedXAxisField = (0, import_react63.useMemo)(() => {
69725
69537
  if (!chartAxesBaseChart) return "";
69726
69538
  const chartType2 = String(chartAxesBaseChart.chartType ?? "").toLowerCase();
69727
- const pivotRowField = pivotRowKey(chartAxesBaseChart);
69539
+ const pivotRowField = String(
69540
+ chartAxesBaseChart.pivot?.rowField ?? ""
69541
+ ).trim();
69728
69542
  if (pivotRowField) {
69729
69543
  const rowColumn = (chartAxesBaseChart.pivotColumns ?? chartAxesBaseChart.columns ?? []).find((col) => String(col.field ?? "").trim() === pivotRowField);
69730
69544
  if (shouldUsePivotRowFieldAsXAxis(
@@ -69860,11 +69674,11 @@ function useReport(reportIdArg, options = {}) {
69860
69674
  columns2 = mergePivotTableDisplayColumnLabelsFromYAxis({
69861
69675
  columns: columns2 ?? baseChart.columns,
69862
69676
  yAxisFields: resolvedYAxisFieldsForDisplay,
69863
- pivotRowField: pivotRowKey(baseChart),
69677
+ pivotRowField: String(baseChart.pivot.rowField ?? ""),
69864
69678
  xAxisLabel: resolvedXAxisLabel
69865
69679
  });
69866
69680
  } else {
69867
- const pivotRowField = pivotRowKey(baseChart);
69681
+ const pivotRowField = String(baseChart.pivot.rowField ?? "").trim();
69868
69682
  const pivotLabelByField = new Map(
69869
69683
  (baseChart.pivotColumns ?? []).map((column) => [
69870
69684
  String(column.field ?? "").trim(),
@@ -69929,10 +69743,7 @@ function useReport(reportIdArg, options = {}) {
69929
69743
  const key = String(raw);
69930
69744
  const timestamp = new Date(key).getTime();
69931
69745
  if (Number.isNaN(timestamp)) continue;
69932
- labelsByRaw.set(
69933
- key,
69934
- String(record[pivotRowKey(chart)] ?? record[rowField] ?? key)
69935
- );
69746
+ labelsByRaw.set(key, String(record[rowField] ?? key));
69936
69747
  const cachedMin = pivotDateFilterRangeCacheRef.current.min;
69937
69748
  const cachedMax = pivotDateFilterRangeCacheRef.current.max;
69938
69749
  if (cachedMin == null || timestamp < new Date(cachedMin).getTime()) {
@@ -70233,7 +70044,9 @@ function useReport(reportIdArg, options = {}) {
70233
70044
  sourceReport,
70234
70045
  includeSelectedSchemaFallback: tableColumnsEditedSignature !== null
70235
70046
  });
70236
- const pivotRowFieldForTable = pivotRowKey(sourceReport);
70047
+ const pivotRowFieldForTable = String(
70048
+ sourceReport?.pivot?.rowField ?? ""
70049
+ ).trim();
70237
70050
  const pivotRowTableUsesAxisFormat = chartAxisEdits.xAxisFormat !== void 0;
70238
70051
  const columns2 = String(chartType ?? "").toLowerCase() === "table" && sourceReport?.pivot && pivotRowFieldForTable && String(resolvedXAxisField ?? "").trim() === pivotRowFieldForTable ? mergedFromReport.map(
70239
70052
  (column) => column.field === pivotRowFieldForTable ? {
@@ -70245,7 +70058,7 @@ function useReport(reportIdArg, options = {}) {
70245
70058
  const pivotLabeledColumns = String(chartType ?? "").toLowerCase() === "table" && sourceReport?.pivot ? mergePivotTableDisplayColumnLabelsFromYAxis({
70246
70059
  columns: columns2,
70247
70060
  yAxisFields: resolvedYAxisFieldsForDisplay,
70248
- pivotRowField: pivotRowKey(sourceReport),
70061
+ pivotRowField: String(sourceReport.pivot.rowField ?? ""),
70249
70062
  xAxisLabel: resolvedXAxisLabel
70250
70063
  }) ?? columns2 : columns2;
70251
70064
  const tableColumnsWithPivotDisplayLabels = pivotLabeledColumns.map(
@@ -70494,7 +70307,7 @@ function useReport(reportIdArg, options = {}) {
70494
70307
  if (slotFormatting) {
70495
70308
  const aggregations = slotFormatting.aggregations;
70496
70309
  const hasMultiple = aggregations.length > 1;
70497
- const rowField = pivotRowKey(chart);
70310
+ const rowField = String(pivotState?.rowField ?? "").trim();
70498
70311
  const firstValueColumnFormat = String(
70499
70312
  (chart.columns ?? []).find(
70500
70313
  (c) => String(c.field ?? "").trim() !== rowField
@@ -70530,7 +70343,9 @@ function useReport(reportIdArg, options = {}) {
70530
70343
  }
70531
70344
  }
70532
70345
  }
70533
- const pivotRowFieldForSettings = pivotRowKey(chart);
70346
+ const pivotRowFieldForSettings = String(
70347
+ chart?.pivot?.rowField ?? ""
70348
+ ).trim();
70534
70349
  const rowAxisLabel = String(resolvedXAxisLabel ?? "").trim();
70535
70350
  for (const columnId of activeTableColumnIds) {
70536
70351
  const option = columnOptionById.get(columnId);
@@ -70590,7 +70405,7 @@ function useReport(reportIdArg, options = {}) {
70590
70405
  tableColumnSettingsCoalesceRef.current = new Map(tableColumnSettingsById);
70591
70406
  }, [tableColumnSettingsById]);
70592
70407
  const tableColumnItems = (0, import_react63.useMemo)(() => {
70593
- const pivotRowFieldForFormat = pivotRowKey(chart);
70408
+ const pivotRowFieldForFormat = String(chart?.pivot?.rowField ?? "").trim();
70594
70409
  const pivotRowFieldType = String(chart?.pivot?.rowFieldType ?? "").trim();
70595
70410
  const items = activeTableColumnIds.map((columnId) => {
70596
70411
  const option = columnOptionById.get(columnId);
@@ -70629,7 +70444,7 @@ function useReport(reportIdArg, options = {}) {
70629
70444
  return new Map(tableColumnItems.map((item) => [item.id, item]));
70630
70445
  }, [tableColumnItems]);
70631
70446
  const tableColumnValues = (0, import_react63.useMemo)(() => {
70632
- const pivotRowFieldForFormat = pivotRowKey(chart);
70447
+ const pivotRowFieldForFormat = String(chart?.pivot?.rowField ?? "").trim();
70633
70448
  const pivotRowFieldType = String(chart?.pivot?.rowFieldType ?? "").trim();
70634
70449
  return tableColumnItems.map((item) => {
70635
70450
  const coerced = coerceTableColumnFormatToAxisValue(item.format);
@@ -70650,89 +70465,8 @@ function useReport(reportIdArg, options = {}) {
70650
70465
  const initialLoadInProgress = !reportOverride && Boolean(effectiveReportId) && (!client || initialLoadQuery.isPending || initialLoadQuery.isFetching);
70651
70466
  const filterUniqueValuesLoading = filterUniqueValuesEnabled && (filterUniqueValuesQuery.isPending || filterUniqueValuesQuery.isFetching);
70652
70467
  const chartLoading = initialLoadInProgress || pendingPivotRefresh || (Boolean(nextPivot) ? pivotRefreshQuery.isFetching : tableRefreshQuery.isFetching);
70653
- const awaitingPivotDetailRows = Boolean(nextPivot || sourceReport?.pivot) && !reportOverride && Boolean(sourceReport) && sourceReportMatchesEffectiveReportId && (!Array.isArray(sourceReport?.rows) || sourceReport.rows.length === 0) && pivotTableDataRefreshQuery.status !== "error";
70654
- const tableLoading = initialLoadInProgress || pendingPivotRefresh || awaitingPivotDetailRows || tablePageFetching && pagination.pageIndex > 0 || (Boolean(nextPivot) ? pivotTableDataRefreshQuery.isFetching : tableRefreshQuery.isFetching);
70468
+ const tableLoading = initialLoadInProgress || pendingPivotRefresh || tablePageFetching || (Boolean(nextPivot) ? pivotTableDataRefreshQuery.isFetching : tableRefreshQuery.isFetching);
70655
70469
  const loading = chartLoading || tableLoading;
70656
- const lastUseReportLoadingLogRef = (0, import_react63.useRef)("");
70657
- (0, import_react63.useEffect)(() => {
70658
- const snapshot = {
70659
- reportId: effectiveReportId,
70660
- chartLoading,
70661
- tableLoading,
70662
- loading,
70663
- initialLoadInProgress,
70664
- initialLoad: {
70665
- status: initialLoadQuery.status,
70666
- fetchStatus: initialLoadQuery.fetchStatus,
70667
- isPending: initialLoadQuery.isPending,
70668
- isFetching: initialLoadQuery.isFetching,
70669
- hasData: initialLoadQuery.data !== void 0,
70670
- dataUpdatedAt: initialLoadQuery.dataUpdatedAt,
70671
- staleTime: 0
70672
- },
70673
- pendingPivotRefresh,
70674
- pivotRefresh: {
70675
- enabled: pivotRefreshQueryEnabled,
70676
- isFetching: pivotRefreshQuery.isFetching
70677
- },
70678
- tableRefresh: {
70679
- enabled: tableRefreshQueryEnabled,
70680
- isFetching: tableRefreshQuery.isFetching
70681
- },
70682
- pivotTableData: {
70683
- enabled: pivotTableDataRefreshQueryEnabled,
70684
- isFetching: pivotTableDataRefreshQuery.isFetching
70685
- },
70686
- tablePage: {
70687
- enabled: tablePageQueryEnabled,
70688
- isFetching: tablePageQuery.isFetching
70689
- },
70690
- uniqueValues: {
70691
- enabled: filterUniqueValuesEnabled,
70692
- isFetching: filterUniqueValuesQuery.isFetching,
70693
- isPending: filterUniqueValuesQuery.isPending
70694
- },
70695
- whyChartLoading: {
70696
- noClient: !client,
70697
- initialPending: initialLoadQuery.isPending,
70698
- initialFetching: initialLoadQuery.isFetching,
70699
- pendingPivotRefresh,
70700
- pivotRefreshFetching: Boolean(nextPivot) && pivotRefreshQuery.isFetching,
70701
- tableRefreshFetching: !nextPivot && tableRefreshQuery.isFetching
70702
- }
70703
- };
70704
- const serialized = JSON.stringify(snapshot);
70705
- if (serialized === lastUseReportLoadingLogRef.current) return;
70706
- lastUseReportLoadingLogRef.current = serialized;
70707
- profileDashboard("use-report-loading", snapshot);
70708
- }, [
70709
- client,
70710
- chartLoading,
70711
- effectiveReportId,
70712
- filterUniqueValuesEnabled,
70713
- filterUniqueValuesQuery.fetchStatus,
70714
- filterUniqueValuesQuery.isFetching,
70715
- filterUniqueValuesQuery.isPending,
70716
- initialLoadInProgress,
70717
- initialLoadQuery.data,
70718
- initialLoadQuery.dataUpdatedAt,
70719
- initialLoadQuery.fetchStatus,
70720
- initialLoadQuery.isFetching,
70721
- initialLoadQuery.isPending,
70722
- initialLoadQuery.status,
70723
- loading,
70724
- nextPivot,
70725
- pendingPivotRefresh,
70726
- pivotRefreshQuery.isFetching,
70727
- pivotRefreshQueryEnabled,
70728
- pivotTableDataRefreshQuery.isFetching,
70729
- pivotTableDataRefreshQueryEnabled,
70730
- tableLoading,
70731
- tablePageQuery.isFetching,
70732
- tablePageQueryEnabled,
70733
- tableRefreshQuery.isFetching,
70734
- tableRefreshQueryEnabled
70735
- ]);
70736
70470
  const buildSetReportColumnsFromIds = (nextColumnIds, settingsById) => {
70737
70471
  const normalizedNextIds = nextColumnIds.map((columnId) => String(columnId ?? "").trim()).filter(Boolean);
70738
70472
  return normalizedNextIds.map((columnId) => {
@@ -70772,7 +70506,7 @@ function useReport(reportIdArg, options = {}) {
70772
70506
  const option = columnOptionById.get(normalizedId);
70773
70507
  const pivotField = String(option?.field ?? normalizedId).trim();
70774
70508
  const pivotModel = chartAxesBaseChart.pivot;
70775
- const rowField = pivotRowKey(chartAxesBaseChart);
70509
+ const rowField = String(pivotModel?.rowField ?? "").trim();
70776
70510
  if (!pivotModel) return null;
70777
70511
  const isPivotRowColumn = Boolean(
70778
70512
  pivotField && rowField && pivotField === rowField