@quillsql/react 2.16.21 → 2.16.23

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.js CHANGED
@@ -277,6 +277,9 @@ var init_valueFormatter = __esm({
277
277
  maximumFractionDigits: 2
278
278
  });
279
279
  formatPercent = (value) => {
280
+ if (typeof value === "string" && /^\s*[+-]?(?:\d+(?:\.\d+)?|\.\d+)\s*%\s*$/.test(value)) {
281
+ return value;
282
+ }
280
283
  return formatterPercent.format(Number(value));
281
284
  };
282
285
  _getUTCDateHelper = (value, fmt) => {
@@ -1566,6 +1569,7 @@ var init_dateRangePickerUtils = __esm({
1566
1569
  };
1567
1570
  convertPresetOptionsToSelectableList = (customIntervals, defaultIntervals) => {
1568
1571
  const customLabelMap = /* @__PURE__ */ new Map();
1572
+ const displayLabelByValue = /* @__PURE__ */ new Map();
1569
1573
  defaultIntervals.forEach((interval2) => {
1570
1574
  if (interval2.customLabel) {
1571
1575
  customLabelMap.set(interval2.label, interval2.customLabel);
@@ -1735,11 +1739,14 @@ var init_dateRangePickerUtils = __esm({
1735
1739
  }
1736
1740
  ];
1737
1741
  }
1738
- if (interval2.customLabel && createdIntervals.length > 0) {
1739
- return createdIntervals.map((i) => ({
1740
- ...i,
1741
- label: interval2.customLabel
1742
- }));
1742
+ if (createdIntervals.length > 0) {
1743
+ const displayLabel = interval2.customLabel ?? interval2.label;
1744
+ createdIntervals.forEach((createdInterval) => {
1745
+ const canonicalValue = getLabelForCustomInterval(createdInterval).toUpperCase().replace(/ /g, "_");
1746
+ if (displayLabel && canonicalValue) {
1747
+ displayLabelByValue.set(canonicalValue, displayLabel);
1748
+ }
1749
+ });
1743
1750
  }
1744
1751
  return createdIntervals;
1745
1752
  });
@@ -1795,9 +1802,10 @@ var init_dateRangePickerUtils = __esm({
1795
1802
  customLabel2 = customLabelMap.get("This year") || customLabelMap.get("Yearly");
1796
1803
  }
1797
1804
  }
1805
+ const value2 = getLabelForSubInterval(currentSubInterval).toUpperCase().replace(/ /g, "_") ?? "";
1798
1806
  presets.push({
1799
- label: customLabel2 || baseLabel,
1800
- value: getLabelForSubInterval(currentSubInterval).toUpperCase().replace(/ /g, "_") ?? "",
1807
+ label: displayLabelByValue.get(value2) || customLabel2 || baseLabel,
1808
+ value: value2,
1801
1809
  startDate: set(/* @__PURE__ */ new Date(), {
1802
1810
  year: currentYear,
1803
1811
  month: currentSubInterval.startDate.month - 1,
@@ -1829,13 +1837,14 @@ var init_dateRangePickerUtils = __esm({
1829
1837
  }
1830
1838
  const dateRange = convertCustomIntervalToDateRange(option);
1831
1839
  const generatedLabel = getLabelForCustomInterval(option);
1840
+ const value = getLabelForCustomInterval(option).toUpperCase().replace(/ /g, "_") ?? "";
1832
1841
  const customLabel = customLabelMap.get(generatedLabel);
1833
- const finalLabel = customLabel || generatedLabel;
1842
+ const finalLabel = displayLabelByValue.get(value) || customLabel || generatedLabel;
1834
1843
  return [
1835
1844
  {
1836
1845
  label: finalLabel,
1837
1846
  // Value is option label in uppercase with spaces replaced by underscores
1838
- value: getLabelForCustomInterval(option).toUpperCase().replace(/ /g, "_") ?? "",
1847
+ value,
1839
1848
  startDate: dateRange.startDate,
1840
1849
  endDate: dateRange.endDate
1841
1850
  }
@@ -2031,7 +2040,10 @@ var init_dateRangePickerUtils = __esm({
2031
2040
  getRangeFromPresetOptions = (preset, presetOptions) => {
2032
2041
  const foundPreset = presetOptions.find((elem) => elem.value === preset);
2033
2042
  if (foundPreset) {
2034
- return { startDate: foundPreset?.startDate, endDate: foundPreset?.endDate };
2043
+ return {
2044
+ startDate: foundPreset.startDate ? startOfDay(foundPreset.startDate) : foundPreset.startDate,
2045
+ endDate: foundPreset.endDate ? endOfDay(foundPreset.endDate) : foundPreset.endDate
2046
+ };
2035
2047
  } else {
2036
2048
  return { startDate: null, endDate: null };
2037
2049
  }
@@ -19893,11 +19905,12 @@ async function cleanDashboardItem({
19893
19905
  page: DEFAULT_PAGINATION
19894
19906
  };
19895
19907
  if (item.pivot && skipPivotFetch && item.rows && item.fields) {
19908
+ const pivotSourceRows = item.rows.map((row) => ({ ...row }));
19896
19909
  const dateFilter = dashboardFilters?.find(
19897
19910
  (filter) => filter.filterType === "date_range"
19898
19911
  );
19899
19912
  pivotTable = processPivotData({
19900
- rows: item.rows,
19913
+ rows: pivotSourceRows,
19901
19914
  fields: item.fields,
19902
19915
  pivot: {
19903
19916
  ...item.pivot,
@@ -22177,7 +22190,20 @@ var applyFiltersInMemory = (rows, filters, options) => {
22177
22190
  // src/utils/inMemoryPivotEngine.ts
22178
22191
  init_columnType();
22179
22192
  var MS_IN_DAY = 24 * 60 * 60 * 1e3;
22180
- var MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
22193
+ var MONTHS = [
22194
+ "Jan",
22195
+ "Feb",
22196
+ "Mar",
22197
+ "Apr",
22198
+ "May",
22199
+ "Jun",
22200
+ "Jul",
22201
+ "Aug",
22202
+ "Sep",
22203
+ "Oct",
22204
+ "Nov",
22205
+ "Dec"
22206
+ ];
22181
22207
  var INVALID_DATE_KEY = "-2026";
22182
22208
  function singleAggToMultiAgg(pivot) {
22183
22209
  if (pivot.aggregations) {
@@ -22185,7 +22211,12 @@ function singleAggToMultiAgg(pivot) {
22185
22211
  }
22186
22212
  const newPivot = { ...pivot };
22187
22213
  const newAgg = { aggregationType: pivot.aggregationType };
22188
- const fieldsToCopy = ["valueField", "valueFieldType", "valueField2", "valueField2Type"];
22214
+ const fieldsToCopy = [
22215
+ "valueField",
22216
+ "valueFieldType",
22217
+ "valueField2",
22218
+ "valueField2Type"
22219
+ ];
22189
22220
  fieldsToCopy.forEach((x) => {
22190
22221
  if (pivot[x]) {
22191
22222
  newAgg[x] = pivot[x];
@@ -22216,6 +22247,12 @@ function isValidDate3(date) {
22216
22247
  return false;
22217
22248
  }
22218
22249
  }
22250
+ function isDateLikeType(fieldType) {
22251
+ if (!fieldType) {
22252
+ return false;
22253
+ }
22254
+ return isDateType(fieldType) || isDateFormat2(fieldType);
22255
+ }
22219
22256
  function inferDateBucketFromFilters(pivot, filters) {
22220
22257
  if (!pivot?.rowFieldType) {
22221
22258
  return void 0;
@@ -22359,8 +22396,12 @@ function getDateRangeFromFilters(filters) {
22359
22396
  }
22360
22397
  function generateBucketKeys(start2, end, bucket) {
22361
22398
  const keys = /* @__PURE__ */ new Set();
22362
- const startDay = new Date(Date.UTC(start2.getUTCFullYear(), start2.getUTCMonth(), start2.getUTCDate()));
22363
- const endDay = new Date(Date.UTC(end.getUTCFullYear(), end.getUTCMonth(), end.getUTCDate()));
22399
+ const startDay = new Date(
22400
+ Date.UTC(start2.getUTCFullYear(), start2.getUTCMonth(), start2.getUTCDate())
22401
+ );
22402
+ const endDay = new Date(
22403
+ Date.UTC(end.getUTCFullYear(), end.getUTCMonth(), end.getUTCDate())
22404
+ );
22364
22405
  const cur = new Date(startDay);
22365
22406
  while (cur <= endDay) {
22366
22407
  keys.add(getDateKey(cur, bucket));
@@ -22384,7 +22425,9 @@ function getBucketRange(dateKey, bucket) {
22384
22425
  let end = new Date(d);
22385
22426
  switch (bucket) {
22386
22427
  case "day":
22387
- start2 = new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate()));
22428
+ start2 = new Date(
22429
+ Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate())
22430
+ );
22388
22431
  end = new Date(start2);
22389
22432
  break;
22390
22433
  case "week":
@@ -22426,10 +22469,18 @@ function getDateKey(date, bucket) {
22426
22469
  }
22427
22470
  switch (bucket) {
22428
22471
  case "day":
22429
- return Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()).toString();
22472
+ return Date.UTC(
22473
+ date.getUTCFullYear(),
22474
+ date.getUTCMonth(),
22475
+ date.getUTCDate()
22476
+ ).toString();
22430
22477
  case "week": {
22431
22478
  const day = date.getUTCDay();
22432
- const mondayUtc = Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate() - (day + 6) % 7);
22479
+ const mondayUtc = Date.UTC(
22480
+ date.getUTCFullYear(),
22481
+ date.getUTCMonth(),
22482
+ date.getUTCDate() - (day + 6) % 7
22483
+ );
22433
22484
  return mondayUtc.toString();
22434
22485
  }
22435
22486
  case "month":
@@ -22493,7 +22544,11 @@ function assembleFinalRows(seen, rowKey, dateBucket, dateRange) {
22493
22544
  if (bucketEnd > dateRange.end) bucketEnd = dateRange.end;
22494
22545
  }
22495
22546
  return {
22496
- [rowKey]: formatBucketNameFromRange(bucketStart, bucketEnd, dateBucket),
22547
+ [rowKey]: formatBucketNameFromRange(
22548
+ bucketStart,
22549
+ bucketEnd,
22550
+ dateBucket
22551
+ ),
22497
22552
  ...filled[k],
22498
22553
  __quillRawDate: bucketStart.toISOString()
22499
22554
  };
@@ -22652,7 +22707,13 @@ function aggregateWithColumn(rows, colKey, aggregations, getGroupKey) {
22652
22707
  const seen = {};
22653
22708
  const multiAgg = aggregations.length > 1;
22654
22709
  aggregations.forEach((agg) => {
22655
- const { aggregationType: type, valueField, valueFieldType, valueField2, valueField2Type } = agg;
22710
+ const {
22711
+ aggregationType: type,
22712
+ valueField,
22713
+ valueFieldType,
22714
+ valueField2,
22715
+ valueField2Type
22716
+ } = agg;
22656
22717
  if (!valueField) {
22657
22718
  if (type !== "count" && type !== "percentage") return;
22658
22719
  }
@@ -22685,7 +22746,10 @@ function aggregateWithColumn(rows, colKey, aggregations, getGroupKey) {
22685
22746
  });
22686
22747
  Object.keys(accs).forEach((groupKey) => {
22687
22748
  if (!seen[groupKey]) seen[groupKey] = {};
22688
- const sumOfDenom = Object.values(accs[groupKey]).reduce((t, a) => t + a.count, 0);
22749
+ const sumOfDenom = Object.values(accs[groupKey]).reduce(
22750
+ (t, a) => t + a.count,
22751
+ 0
22752
+ );
22689
22753
  Object.keys(accs[groupKey]).forEach((colVal) => {
22690
22754
  const acc = accs[groupKey][colVal];
22691
22755
  const finalKey = `${colVal}` + (multiAgg ? `_${type}` : "");
@@ -22707,7 +22771,13 @@ function aggregateWithoutColumn(rows, aggregations, getGroupKey) {
22707
22771
  const seen = {};
22708
22772
  const multiAgg = aggregations.length > 1;
22709
22773
  aggregations.forEach((agg) => {
22710
- const { aggregationType: type, valueField, valueFieldType, valueField2, valueField2Type } = agg;
22774
+ const {
22775
+ aggregationType: type,
22776
+ valueField,
22777
+ valueFieldType,
22778
+ valueField2,
22779
+ valueField2Type
22780
+ } = agg;
22711
22781
  if (!valueField) {
22712
22782
  if (type !== "count" && type !== "percentage") return;
22713
22783
  }
@@ -22738,7 +22808,10 @@ function aggregateWithoutColumn(rows, aggregations, getGroupKey) {
22738
22808
  }
22739
22809
  updateAccumulator(acc, row, agg, false);
22740
22810
  });
22741
- const sumOfDenom = Object.values(accs).reduce((t, a) => t + a.count, 0);
22811
+ const sumOfDenom = Object.values(accs).reduce(
22812
+ (t, a) => t + a.count,
22813
+ 0
22814
+ );
22742
22815
  Object.keys(accs).forEach((k) => {
22743
22816
  const acc = accs[k];
22744
22817
  seen[k][finalKey] = getFinalAggregationValue({
@@ -22766,13 +22839,18 @@ function applyPivotInMemory(rows, pivot, filters) {
22766
22839
  const dateRange = dateBucket ? getDateRangeFromFilters(filters) : void 0;
22767
22840
  const getRowKey = dateBucket ? (row) => {
22768
22841
  const rawValue = row[rowField];
22769
- const rawDateValue = rawValue !== null && typeof rawValue === "object" && rawValue.value ? rawValue.value : rawValue;
22842
+ const rawDateFromQuill = row.__quillRawDate;
22843
+ const rawDateValue = rawDateFromQuill ?? (rawValue !== null && typeof rawValue === "object" && rawValue.value ? rawValue.value : rawValue);
22770
22844
  return getDateKey(new Date(rawDateValue), dateBucket);
22771
22845
  } : (row) => row[rowField];
22772
22846
  const aggregated = columnField ? aggregateWithColumn(rows, columnField, aggregations, getRowKey) : aggregateWithoutColumn(rows, aggregations, getRowKey);
22773
22847
  const aggregatedRows = aggregated || {};
22774
22848
  if (rows.length === 0 && dateBucket && dateRange && !columnField) {
22775
- const bucketKeys = generateBucketKeys(dateRange.start, dateRange.end, dateBucket);
22849
+ const bucketKeys = generateBucketKeys(
22850
+ dateRange.start,
22851
+ dateRange.end,
22852
+ dateBucket
22853
+ );
22776
22854
  const emptyAgg = buildEmptyAggRow(aggregations);
22777
22855
  bucketKeys.forEach((k) => {
22778
22856
  aggregatedRows[k] = { ...emptyAgg };
@@ -22790,6 +22868,61 @@ function applyPivotInMemory(rows, pivot, filters) {
22790
22868
  }
22791
22869
  return sorted;
22792
22870
  }
22871
+ function generatePivotColumnsInMemory({
22872
+ pivot,
22873
+ pivotRows,
22874
+ sourceColumns
22875
+ }) {
22876
+ if (!pivot?.rowField || !Array.isArray(pivotRows) || pivotRows.length === 0) {
22877
+ return void 0;
22878
+ }
22879
+ const columns = Array.isArray(sourceColumns) ? sourceColumns : [];
22880
+ const rowSource = columns.find((col) => col.field === pivot.rowField);
22881
+ const isRowFieldDate = isDateLikeType(pivot.rowFieldType);
22882
+ const rowFieldType = rowSource?.fieldType ?? pivot.rowFieldType ?? "string";
22883
+ const rowColumn = {
22884
+ field: pivot.rowField,
22885
+ label: rowSource?.label ?? pivot.rowField,
22886
+ format: isRowFieldDate ? "string" : rowSource?.format ?? "string",
22887
+ fieldType: rowFieldType,
22888
+ dataTypeID: rowSource?.dataTypeID ?? 1043,
22889
+ jsType: rowSource?.jsType ?? (isRowFieldDate ? "date" : "string")
22890
+ };
22891
+ const valueFieldFormat = (valueField) => columns.find((col) => col.field === valueField)?.format ?? "whole_number";
22892
+ const multiAgg = (pivot.aggregations?.length ?? 0) > 1;
22893
+ const aggregationBySuffix = new Map(
22894
+ (pivot.aggregations ?? []).map((agg) => [
22895
+ multiAgg ? `_${agg.aggregationType}` : "",
22896
+ agg
22897
+ ])
22898
+ );
22899
+ const valueKeys = Array.from(
22900
+ new Set(
22901
+ pivotRows.flatMap(
22902
+ (row) => Object.keys(row).filter(
22903
+ (key) => key !== pivot.rowField && key !== "__quillRawDate"
22904
+ )
22905
+ )
22906
+ )
22907
+ );
22908
+ const valueColumns = valueKeys.map((key) => {
22909
+ const matchingSuffix = Array.from(aggregationBySuffix.keys()).find(
22910
+ (suffix) => suffix && key.endsWith(suffix)
22911
+ );
22912
+ const matchedAgg = matchingSuffix ? aggregationBySuffix.get(matchingSuffix) : pivot.aggregations?.[0];
22913
+ const format9 = matchedAgg?.aggregationType === "percentage" ? "percent" : valueFieldFormat(matchedAgg?.valueField);
22914
+ const valueFieldType = matchedAgg?.valueFieldType ?? "number";
22915
+ return {
22916
+ field: key,
22917
+ label: key,
22918
+ format: format9,
22919
+ fieldType: valueFieldType,
22920
+ jsType: valueFieldType,
22921
+ dataTypeID: columns.find((col) => col.field === matchedAgg?.valueField)?.dataTypeID ?? 20
22922
+ };
22923
+ });
22924
+ return [rowColumn, ...valueColumns];
22925
+ }
22793
22926
 
22794
22927
  // src/utils/cacheCab.ts
22795
22928
  import { openDB } from "idb";
@@ -22907,7 +23040,12 @@ var CacheCab = class {
22907
23040
  }
22908
23041
  const newRows = await this.applyPivotsAndFilters(result, dashboardFilters, customFilters, pivot, tenantPart, false);
22909
23042
  if (pivot) {
22910
- return { ...result, pivotRows: newRows, pivotRowCount: newRows.length };
23043
+ const pivotColumns = generatePivotColumnsInMemory({
23044
+ pivot,
23045
+ pivotRows: newRows,
23046
+ sourceColumns: result.columnInternal ?? result.columns
23047
+ });
23048
+ return { ...result, pivotRows: newRows, pivotColumns: pivotColumns ?? result.pivotColumns, pivotRowCount: newRows.length };
22911
23049
  }
22912
23050
  return { ...result, rows: newRows, rowCount: newRows.length };
22913
23051
  } else {
@@ -22993,7 +23131,12 @@ var CacheCab = class {
22993
23131
  await this.persistMetaToStorage();
22994
23132
  const newRows = await this.applyPivotsAndFilters(merged, dashboardFilters, customFilters, pivot, tenantPart, false);
22995
23133
  if (pivot) {
22996
- return { ...merged, pivotRows: newRows, pivotRowCount: newRows.length };
23134
+ const pivotColumns = generatePivotColumnsInMemory({
23135
+ pivot,
23136
+ pivotRows: newRows,
23137
+ sourceColumns: merged.columnInternal ?? merged.columns
23138
+ });
23139
+ return { ...merged, pivotRows: newRows, pivotColumns: pivotColumns ?? merged.pivotColumns, pivotRowCount: newRows.length };
22997
23140
  }
22998
23141
  return { ...merged, rows: newRows, rowCount: newRows.length };
22999
23142
  }
@@ -23021,7 +23164,12 @@ var CacheCab = class {
23021
23164
  const tenantPart = tenants ? JSON.stringify(tenants) : "";
23022
23165
  const newRows = await this.applyPivotsAndFilters(parsed, dashboardFilters, customFilters, pivot, tenantPart);
23023
23166
  if (pivot) {
23024
- return { ...parsed, pivotRows: newRows, pivotRowCount: newRows.length };
23167
+ const pivotColumns = generatePivotColumnsInMemory({
23168
+ pivot,
23169
+ pivotRows: newRows,
23170
+ sourceColumns: parsed.columnInternal ?? parsed.columns
23171
+ });
23172
+ return { ...parsed, pivotRows: newRows, pivotColumns: pivotColumns ?? parsed.pivotColumns, pivotRowCount: newRows.length };
23025
23173
  }
23026
23174
  return { ...parsed, rows: newRows, rowCount: newRows.length };
23027
23175
  } catch (err) {
@@ -26397,6 +26545,29 @@ var useDashboard = (dashboardName, config) => {
26397
26545
  };
26398
26546
  const usePivotTask = !cacheEnabled && !!reportInfo.pivot;
26399
26547
  const allFilters = dashboardFilters2.concat(customFilters).concat(customReportFiltersArray);
26548
+ const applyInMemoryPivotIfNeeded = (report2) => {
26549
+ const pivotToApply = reportInfo.pivot ?? report2.pivot;
26550
+ if (!pivotToApply || usePivotTask) {
26551
+ return report2;
26552
+ }
26553
+ const pivotRows = applyPivotInMemory(
26554
+ report2.rows ?? [],
26555
+ pivotToApply,
26556
+ allFilters
26557
+ );
26558
+ const pivotColumns = generatePivotColumnsInMemory({
26559
+ pivot: pivotToApply,
26560
+ pivotRows,
26561
+ sourceColumns: report2.columnInternal ?? report2.columns
26562
+ });
26563
+ return {
26564
+ ...report2,
26565
+ pivot: pivotToApply,
26566
+ pivotRows,
26567
+ pivotColumns: pivotColumns ?? report2.pivotColumns,
26568
+ pivotRowCount: pivotRows.length
26569
+ };
26570
+ };
26400
26571
  if (cacheEnabled && cacheCab.isCacheable(reportId)) {
26401
26572
  const report2 = await cacheCab.get(reportId, dashboardFilters2, customFilters.concat(customReportFiltersArray), reportInfo.pivot, client, tenants, flags, pageSize, getToken, eventTracking, forceCacheToRefresh);
26402
26573
  if (reportRequestIds.current[reportId] !== requestId) {
@@ -26454,11 +26625,12 @@ var useDashboard = (dashboardName, config) => {
26454
26625
  if (reportRequestIds.current[reportId] !== requestId) {
26455
26626
  return null;
26456
26627
  }
26628
+ const uncacheableReportWithPivot = applyInMemoryPivotIfNeeded(uncacheableReport);
26457
26629
  reportsDispatch({
26458
26630
  type: "UPDATE_REPORT",
26459
26631
  id: reportId,
26460
26632
  data: {
26461
- ...uncacheableReport,
26633
+ ...uncacheableReportWithPivot,
26462
26634
  pagination,
26463
26635
  triggerReload: false
26464
26636
  }
@@ -26509,7 +26681,7 @@ var useDashboard = (dashboardName, config) => {
26509
26681
  console.error("Failed to fetch background rows", e);
26510
26682
  });
26511
26683
  }
26512
- return uncacheableReport;
26684
+ return uncacheableReportWithPivot;
26513
26685
  } catch (error2) {
26514
26686
  console.error(error2);
26515
26687
  return null;
@@ -32608,6 +32780,7 @@ import {
32608
32780
  import {
32609
32781
  startOfMonth as startOfMonth4,
32610
32782
  endOfMonth as endOfMonth2,
32783
+ endOfDay as endOfDay4,
32611
32784
  format as format7,
32612
32785
  eachDayOfInterval,
32613
32786
  subMonths as subMonths5,
@@ -33438,24 +33611,24 @@ function DayPicker({
33438
33611
  if (localStartDate && !localEndDate) {
33439
33612
  setLocalEndDate(date);
33440
33613
  updateDateFilter({
33441
- startDate: localStartDate,
33442
- endDate: date
33614
+ startDate: startOfDay6(localStartDate),
33615
+ endDate: endOfDay4(date)
33443
33616
  });
33444
33617
  setLocalPreset("");
33445
33618
  }
33446
33619
  if (localStartDate && localEndDate && isAfter2(date, localStartDate)) {
33447
33620
  setLocalEndDate(date);
33448
33621
  updateDateFilter({
33449
- startDate: localStartDate,
33450
- endDate: date
33622
+ startDate: startOfDay6(localStartDate),
33623
+ endDate: endOfDay4(date)
33451
33624
  });
33452
33625
  setLocalPreset("");
33453
33626
  }
33454
33627
  if (localStartDate && localEndDate && isBefore2(date, localStartDate)) {
33455
33628
  setLocalStartDate(date);
33456
33629
  updateDateFilter({
33457
- startDate: date,
33458
- endDate: localEndDate
33630
+ startDate: startOfDay6(date),
33631
+ endDate: endOfDay4(localEndDate)
33459
33632
  });
33460
33633
  setLocalPreset("");
33461
33634
  }
@@ -35973,17 +36146,41 @@ var useReportInternal = (reportId) => {
35973
36146
  import equal3 from "fast-deep-equal";
35974
36147
 
35975
36148
  // src/components/Chart/MapChart.tsx
35976
- import {
35977
- ComposableMap,
35978
- Geographies,
35979
- Geography,
35980
- useMapContext
35981
- } from "react-simple-maps";
35982
- import { useEffect as useEffect13, useMemo as useMemo12, useRef as useRef11, useState as useState16 } from "react";
36149
+ import React10, { useEffect as useEffect13, useMemo as useMemo12, useRef as useRef11, useState as useState16 } from "react";
35983
36150
  init_valueFormatter();
36151
+ import usStates10m from "us-atlas/states-10m.json";
36152
+ import worldCountries50m from "world-atlas/countries-50m.json";
35984
36153
  import { jsx as jsx46, jsxs as jsxs35 } from "react/jsx-runtime";
35985
- var statesUrl = "https://cdn.jsdelivr.net/npm/us-atlas@3/states-10m.json";
35986
- var countriesUrl = "https://cdn.jsdelivr.net/npm/world-atlas@2/countries-50m.json";
36154
+ var statesGeography = usStates10m;
36155
+ var countriesGeography = worldCountries50m;
36156
+ var getSimpleMapsImport = () => {
36157
+ const majorVersion = Number.parseInt(React10.version.split(".")[0] ?? "18", 10);
36158
+ if (majorVersion >= 19) {
36159
+ const react19Maps = "@vnedyalk0v/react19-simple-maps";
36160
+ return import(
36161
+ /* @vite-ignore */
36162
+ react19Maps
36163
+ ).catch(() => {
36164
+ return import("react-simple-maps");
36165
+ });
36166
+ }
36167
+ return import("react-simple-maps");
36168
+ };
36169
+ var useSimpleMapsModule = () => {
36170
+ const [simpleMapsModule, setSimpleMapsModule] = useState16();
36171
+ useEffect13(() => {
36172
+ let mounted = true;
36173
+ getSimpleMapsImport().then((module) => {
36174
+ if (mounted) {
36175
+ setSimpleMapsModule(module);
36176
+ }
36177
+ });
36178
+ return () => {
36179
+ mounted = false;
36180
+ };
36181
+ }, []);
36182
+ return simpleMapsModule;
36183
+ };
35987
36184
  var fipsToNames = {
35988
36185
  "01": { name: "Alabama", abbreviation: "AL" },
35989
36186
  "02": { name: "Alaska", abbreviation: "AK" },
@@ -36306,6 +36503,7 @@ function USMap({
36306
36503
  className,
36307
36504
  containerStyle
36308
36505
  }) {
36506
+ const simpleMaps = useSimpleMapsModule();
36309
36507
  const containerRef = useRef11(null);
36310
36508
  const [hoveredState, setHoveredState] = useState16(
36311
36509
  void 0
@@ -36374,6 +36572,9 @@ function USMap({
36374
36572
  }
36375
36573
  );
36376
36574
  }
36575
+ if (!simpleMaps) {
36576
+ return null;
36577
+ }
36377
36578
  return /* @__PURE__ */ jsxs35(
36378
36579
  "div",
36379
36580
  {
@@ -36388,9 +36589,10 @@ function USMap({
36388
36589
  position: "relative"
36389
36590
  },
36390
36591
  children: [
36391
- /* @__PURE__ */ jsx46(ComposableMap, { projection: "geoAlbersUsa", children: /* @__PURE__ */ jsx46(
36592
+ /* @__PURE__ */ jsx46(simpleMaps.ComposableMap, { projection: "geoAlbersUsa", children: /* @__PURE__ */ jsx46(
36392
36593
  MapLayout,
36393
36594
  {
36595
+ simpleMaps,
36394
36596
  hoveredRegion: hoveredState,
36395
36597
  setHoveredRegion: setHoveredState,
36396
36598
  setHoveredCoords,
@@ -36400,7 +36602,7 @@ function USMap({
36400
36602
  colorScale,
36401
36603
  onClickChartElement,
36402
36604
  regionNames: fipsToNames,
36403
- geographyUrl: statesUrl
36605
+ geographyUrl: statesGeography
36404
36606
  }
36405
36607
  ) }),
36406
36608
  hoveredCoords && hoveredState && /* @__PURE__ */ jsx46(
@@ -36497,6 +36699,7 @@ function WorldMap({
36497
36699
  className,
36498
36700
  containerStyle
36499
36701
  }) {
36702
+ const simpleMaps = useSimpleMapsModule();
36500
36703
  const containerRef = useRef11(null);
36501
36704
  const [hoveredCountry, setHoveredCountry] = useState16(
36502
36705
  void 0
@@ -36565,6 +36768,9 @@ function WorldMap({
36565
36768
  }
36566
36769
  );
36567
36770
  }
36771
+ if (!simpleMaps) {
36772
+ return null;
36773
+ }
36568
36774
  return /* @__PURE__ */ jsxs35(
36569
36775
  "div",
36570
36776
  {
@@ -36580,9 +36786,10 @@ function WorldMap({
36580
36786
  position: "relative"
36581
36787
  },
36582
36788
  children: [
36583
- /* @__PURE__ */ jsx46(ComposableMap, { projection: "geoEqualEarth", children: /* @__PURE__ */ jsx46(
36789
+ /* @__PURE__ */ jsx46(simpleMaps.ComposableMap, { projection: "geoEqualEarth", children: /* @__PURE__ */ jsx46(
36584
36790
  MapLayout,
36585
36791
  {
36792
+ simpleMaps,
36586
36793
  hoveredRegion: hoveredCountry,
36587
36794
  setHoveredRegion: setHoveredCountry,
36588
36795
  setHoveredCoords,
@@ -36591,7 +36798,7 @@ function WorldMap({
36591
36798
  measureField,
36592
36799
  colorScale,
36593
36800
  onClickChartElement,
36594
- geographyUrl: countriesUrl,
36801
+ geographyUrl: countriesGeography,
36595
36802
  regionNames: isoToNames
36596
36803
  }
36597
36804
  ) }),
@@ -36678,6 +36885,7 @@ function WorldMap({
36678
36885
  );
36679
36886
  }
36680
36887
  function MapLayout({
36888
+ simpleMaps,
36681
36889
  geographyUrl,
36682
36890
  hoveredRegion,
36683
36891
  setHoveredRegion,
@@ -36689,19 +36897,19 @@ function MapLayout({
36689
36897
  onClickChartElement,
36690
36898
  regionNames
36691
36899
  }) {
36692
- const { projection } = useMapContext();
36900
+ const { projection } = simpleMaps.useMapContext();
36693
36901
  const [geoCentroid, setGeoCentroid] = useState16(null);
36694
36902
  useEffect13(() => {
36695
36903
  import("d3-geo").then((geo) => {
36696
36904
  setGeoCentroid(() => geo.geoCentroid);
36697
36905
  });
36698
36906
  }, []);
36699
- return /* @__PURE__ */ jsx46(Geographies, { geography: geographyUrl, children: ({ geographies }) => geographies.map((geo, index) => {
36907
+ return /* @__PURE__ */ jsx46(simpleMaps.Geographies, { geography: geographyUrl, children: ({ geographies }) => geographies.map((geo, index) => {
36700
36908
  const regionData = mappedData[geo.id] ?? mappedData[regionNames[geo.id]?.abbreviation ?? ""] ?? mappedData[regionNames[geo.id]?.name ?? ""] ?? mappedData[regionNames[geo.id]?.abbreviation?.toLowerCase() ?? ""] ?? mappedData[regionNames[geo.id]?.name?.toLowerCase() ?? ""];
36701
36909
  const value = regionData ? parseFloat(regionData[measureField]) : null;
36702
36910
  const fill = value != null ? colorScale(value) : "#D6D6DA";
36703
36911
  return /* @__PURE__ */ jsx46(
36704
- Geography,
36912
+ simpleMaps.Geography,
36705
36913
  {
36706
36914
  geography: geo,
36707
36915
  fill,
@@ -38793,13 +39001,28 @@ function Chart({
38793
39001
  return /* @__PURE__ */ jsx49("div", { style: containerStyle, className, children: /* @__PURE__ */ jsx49(ChartError, { errorMessage: report?.error ?? error }) });
38794
39002
  }
38795
39003
  if (isMissingDateField) {
38796
- return /* @__PURE__ */ jsx49("div", { style: containerStyle, className, children: /* @__PURE__ */ jsx49(ChartError, { errorMessage: `The query for this report is missing dashboard date filter field ${report?.dateField?.field}, which is necessary for date filtering on this dashboard when the cache is enabled.` }) });
39004
+ return /* @__PURE__ */ jsx49("div", { style: containerStyle, className, children: /* @__PURE__ */ jsx49(
39005
+ ChartError,
39006
+ {
39007
+ errorMessage: `The query for this report is missing dashboard date filter field ${report?.dateField?.field}, which is necessary for date filtering on this dashboard when the cache is enabled.`
39008
+ }
39009
+ ) });
38797
39010
  }
38798
39011
  if (usesLimitInQuery) {
38799
- return /* @__PURE__ */ jsx49("div", { style: containerStyle, className, children: /* @__PURE__ */ jsx49(ChartError, { errorMessage: `The query for this report uses the LIMIT keyword, which is not supported when the cache is enabled.` }) });
39012
+ return /* @__PURE__ */ jsx49("div", { style: containerStyle, className, children: /* @__PURE__ */ jsx49(
39013
+ ChartError,
39014
+ {
39015
+ errorMessage: `The query for this report uses the LIMIT keyword, which is not supported when the cache is enabled.`
39016
+ }
39017
+ ) });
38800
39018
  }
38801
39019
  if (missingDashboardFilterFields.length) {
38802
- return /* @__PURE__ */ jsx49("div", { style: containerStyle, className, children: /* @__PURE__ */ jsx49(ChartError, { errorMessage: `The query for this report is missing dashboard filter fields: ${missingDashboardFilterFields.join(", ")}` }) });
39020
+ return /* @__PURE__ */ jsx49("div", { style: containerStyle, className, children: /* @__PURE__ */ jsx49(
39021
+ ChartError,
39022
+ {
39023
+ errorMessage: `The query for this report is missing dashboard filter fields: ${missingDashboardFilterFields.join(", ")}`
39024
+ }
39025
+ ) });
38803
39026
  }
38804
39027
  return /* @__PURE__ */ jsxs37(
38805
39028
  "div",
@@ -41354,9 +41577,12 @@ function Dashboard({
41354
41577
  setFilterListAddFilterPopoverIsOpen
41355
41578
  ] = useState25(false);
41356
41579
  const presetOptions = useMemo16(() => {
41357
- return populatedDashboardFilters?.[0]?.filterType === "date_range" ? convertPresetOptionsToSelectableList(
41358
- populatedDashboardFilters[0].presetOptions ?? [],
41359
- populatedDashboardFilters[0].defaultPresetRanges ?? []
41580
+ const dashboardDateFilter = populatedDashboardFilters?.find(
41581
+ (filter) => filter.filterType === "date_range"
41582
+ );
41583
+ return dashboardDateFilter ? convertPresetOptionsToSelectableList(
41584
+ dashboardDateFilter.presetOptions ?? [],
41585
+ dashboardDateFilter.defaultPresetRanges ?? []
41360
41586
  ) : defaultOptionsV2;
41361
41587
  }, [populatedDashboardFilters]);
41362
41588
  const [filterValues, setFilterValues] = useState25({});
@@ -45455,7 +45681,7 @@ init_dataFetcher();
45455
45681
  init_dates();
45456
45682
 
45457
45683
  // src/components/QuillMultiSelectSectionList.tsx
45458
- import React13, {
45684
+ import React14, {
45459
45685
  useContext as useContext25,
45460
45686
  useMemo as useMemo20,
45461
45687
  useRef as useRef18,
@@ -45481,7 +45707,7 @@ function QuillMultiSelectSectionList({
45481
45707
  const modalRef = useRef18(null);
45482
45708
  const buttonRef = useRef18(null);
45483
45709
  const debounceTimeoutId = useRef18(null);
45484
- const [searchQuery, setSearchQuery] = React13.useState("");
45710
+ const [searchQuery, setSearchQuery] = React14.useState("");
45485
45711
  useOnClickOutside_default(
45486
45712
  modalRef,
45487
45713
  (event) => {
@@ -45498,10 +45724,10 @@ function QuillMultiSelectSectionList({
45498
45724
  onChange(updatedChangeEvent);
45499
45725
  }, 200);
45500
45726
  };
45501
- const optionsLength = React13.useMemo(() => {
45727
+ const optionsLength = React14.useMemo(() => {
45502
45728
  return Object.values(options).reduce((a, b) => a + b.length, 0);
45503
45729
  }, [options]);
45504
- const filteredItems = React13.useMemo(() => {
45730
+ const filteredItems = React14.useMemo(() => {
45505
45731
  const uuidRegex = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/;
45506
45732
  const sample = Object.values(options).find((arr) => arr.length > 0)?.[0];
45507
45733
  if (!sample) {
@@ -45528,7 +45754,7 @@ function QuillMultiSelectSectionList({
45528
45754
  Object.entries(filteredOptions).filter(([, value2]) => !!value2?.length).sort(([key]) => key === owner ? -1 : 1)
45529
45755
  );
45530
45756
  }, [options, searchQuery]);
45531
- const filteredLength = React13.useMemo(() => {
45757
+ const filteredLength = React14.useMemo(() => {
45532
45758
  return Object.values(filteredItems).reduce((a, b) => a + b.length, 0);
45533
45759
  }, [filteredItems]);
45534
45760
  const selectedOptionsLabel = useMemo20(() => {
@@ -48854,7 +49080,7 @@ function ChartBuilder({
48854
49080
  )
48855
49081
  }
48856
49082
  ),
48857
- (showTableFormatOptions || isAdmin) && /* @__PURE__ */ jsxs48(
49083
+ (showTableFormatOptions || isAdmin || formData.chartType === "table" && !hideTableView) && /* @__PURE__ */ jsxs48(
48858
49084
  "div",
48859
49085
  {
48860
49086
  style: {
@@ -56731,10 +56957,29 @@ function StaticChart(props) {
56731
56957
  ...report,
56732
56958
  ...report.pivot ? formattedPivotRowsAndColumns(report) : {}
56733
56959
  } : void 0;
56960
+ const patchedConfig = config && config.pivot ? {
56961
+ ...config,
56962
+ yAxisFields: config.columns?.slice(1).map((col) => ({
56963
+ field: col.field,
56964
+ label: col.label ?? col.field,
56965
+ format: col.format ?? "number"
56966
+ })) ?? config.yAxisFields
56967
+ } : config;
56968
+ if (patchedConfig) {
56969
+ const sample = (patchedConfig.pivotRows ?? patchedConfig.rows ?? []).slice(0, 1).map((row) => {
56970
+ const field = patchedConfig.yAxisFields?.[0]?.field;
56971
+ return {
56972
+ ...row,
56973
+ _firstField: field,
56974
+ _firstFieldType: field ? typeof row[field] : void 0
56975
+ };
56976
+ });
56977
+ }
56734
56978
  return /* @__PURE__ */ jsx84(
56735
56979
  ChartDisplay,
56736
56980
  {
56737
- config,
56981
+ reportId,
56982
+ config: patchedConfig,
56738
56983
  onClickChartElement,
56739
56984
  loading,
56740
56985
  className,