@quillsql/react 2.16.93 → 2.16.95

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
  }
@@ -15132,7 +15133,7 @@ var init_dates = __esm({
15132
15133
  init_inMemoryPivotEngine();
15133
15134
  init_valueFormatter();
15134
15135
  DATE_BUCKET_AXIS_FORMATS = {
15135
- day: "MMM_dd_yyyy",
15136
+ day: "MMM_dd",
15136
15137
  week: "MMM_dd-MMM_dd",
15137
15138
  month: "MMM_yyyy",
15138
15139
  year: "yyyy"
@@ -17376,7 +17377,7 @@ async function generatePivotWithSQL({
17376
17377
  );
17377
17378
  const responseRows = queryResponseRows;
17378
17379
  const responseFields = queryResponseFields;
17379
- const rows = resultRowField ? responseRows.map(
17380
+ let rows = resultRowField ? responseRows.map(
17380
17381
  (row) => !row[resultRowField] ? { ...row, [resultRowField]: "-" } : row
17381
17382
  ) : responseRows;
17382
17383
  if (pivot.columnField && client.databaseType?.toLowerCase() === "bigquery") {
@@ -17415,24 +17416,21 @@ async function generatePivotWithSQL({
17415
17416
  return 0;
17416
17417
  });
17417
17418
  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
- }
17419
+ const dateRange = dateFilter?.startDate && dateFilter?.endDate ? { start: dateFilter.startDate, end: dateFilter.endDate } : void 0;
17420
+ rows = rows.filter((row) => {
17421
+ const rawValue = typeof row[resultRowField] === "object" ? row[resultRowField].value : row[resultRowField];
17422
+ row.__quillRawDate = rawValue;
17429
17423
  const dateString = getDateString(
17430
- value,
17431
- dateFilter?.startDate && dateFilter?.endDate ? { start: dateFilter.startDate, end: dateFilter.endDate } : void 0,
17424
+ rawValue,
17425
+ dateRange,
17432
17426
  dateBucket,
17433
17427
  databaseType
17434
17428
  );
17429
+ if (dateBucket === "week" && dateRange && dateString === DATE_OUTSIDE_RANGE) {
17430
+ return false;
17431
+ }
17435
17432
  row[resultRowField] = dateString;
17433
+ return true;
17436
17434
  });
17437
17435
  if (resultRowField && pivot.rowFieldType && !isStringType(pivot.rowFieldType) && dateFilter?.startDate && dateFilter?.endDate) {
17438
17436
  const dateSet = new Set(rows.map((row) => row[resultRowField]));
@@ -17597,7 +17595,7 @@ function processPivotData({
17597
17595
  const pivotRowField = processColumnName(
17598
17596
  String(resultRowField ?? pivot.rowField ?? "")
17599
17597
  );
17600
- const rows = pivotRowField ? responseRows.map(
17598
+ let rows = pivotRowField ? responseRows.map(
17601
17599
  (row) => !row[pivotRowField] ? { ...row, [pivotRowField]: "-" } : row
17602
17600
  ) : responseRows;
17603
17601
  if (pivot.columnField && client.databaseType?.toLowerCase() === "bigquery") {
@@ -17636,24 +17634,21 @@ function processPivotData({
17636
17634
  return 0;
17637
17635
  });
17638
17636
  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
- }
17637
+ const dateRange = dateFilter?.startDate && dateFilter?.endDate ? { start: dateFilter.startDate, end: dateFilter.endDate } : void 0;
17638
+ rows = rows.filter((row) => {
17639
+ const rawValue = typeof row[pivotRowField] === "object" ? row[pivotRowField].value : row[pivotRowField];
17640
+ row.__quillRawDate = rawValue;
17650
17641
  const dateString = getDateString(
17651
- value,
17652
- dateFilter?.startDate && dateFilter?.endDate ? { start: dateFilter.startDate, end: dateFilter.endDate } : void 0,
17642
+ rawValue,
17643
+ dateRange,
17653
17644
  dateBucket,
17654
17645
  databaseType
17655
17646
  );
17647
+ if (dateBucket === "week" && dateRange && dateString === DATE_OUTSIDE_RANGE) {
17648
+ return false;
17649
+ }
17656
17650
  row[pivotRowField] = dateString;
17651
+ return true;
17657
17652
  });
17658
17653
  if (pivotRowField && pivot.rowFieldType && !isStringType(pivot.rowFieldType) && dateFilter?.startDate && dateFilter?.endDate) {
17659
17654
  const dateSet = new Set(rows.map((row) => row[pivotRowField]));
@@ -17718,6 +17713,7 @@ var init_pivotConstructor = __esm({
17718
17713
  init_dashboardProfiler();
17719
17714
  init_dates();
17720
17715
  init_textProcessing();
17716
+ init_valueFormatter();
17721
17717
  }
17722
17718
  });
17723
17719
 
@@ -22901,6 +22897,7 @@ init_columnProcessing();
22901
22897
  init_dataFetcher();
22902
22898
  init_dataProcessing();
22903
22899
  init_dates();
22900
+ init_columnType();
22904
22901
  init_paginationProcessing();
22905
22902
  init_pivotProcessing();
22906
22903
  init_tableProcessing();
@@ -23827,6 +23824,15 @@ function hasPreformattedDateBucketLabels(report) {
23827
23824
  if (report.chartType?.toLowerCase() === "table") return false;
23828
23825
  return report.xAxisField?.trim() === pivot.rowField?.trim();
23829
23826
  }
23827
+ function resolvePivotBucketXAxisFormat(report) {
23828
+ const pivot = report.pivot;
23829
+ if (!pivot?.dateBucket) return null;
23830
+ if (report.chartType?.toLowerCase() === "table") return null;
23831
+ const rowField = pivot.rowField?.trim();
23832
+ if (!rowField || report.xAxisField?.trim() !== rowField) return null;
23833
+ if (!isDateType(String(pivot.rowFieldType ?? ""))) return null;
23834
+ return getDateFormatFromBucket(pivot.dateBucket);
23835
+ }
23830
23836
  function applySavedPivotColumnLabels(report, pivotColumns) {
23831
23837
  return pivotColumns?.map((column) => {
23832
23838
  const savedColumn = report.columns?.find(
@@ -23902,6 +23908,10 @@ function convertInternalReportToReport(report, dashboardFilters, eventTracking,
23902
23908
  ...extractAllReportValuesFromQuillInternalReport(formattedReport),
23903
23909
  ...pivotFormatted
23904
23910
  };
23911
+ const bucketXAxisFormat = resolvePivotBucketXAxisFormat(pivotReport);
23912
+ if (bucketXAxisFormat) {
23913
+ pivotReport.xAxisFormat = bucketXAxisFormat;
23914
+ }
23905
23915
  pivotReport.formattedBaseRows = formattedBaseRows;
23906
23916
  return applyChartSort(pivotReport);
23907
23917
  }
@@ -34175,9 +34185,8 @@ function RadarChart({
34175
34185
  fields: [{ field: xAxisField, format: xAxisFormat }]
34176
34186
  }),
34177
34187
  valueFormatter: (value, name2) => {
34178
- const field = payloadItems.find(
34179
- (p) => p.dataKey === name2
34180
- )?.dataKey;
34188
+ const payloadItem = payloadItems.find((p) => p.dataKey === name2) ?? payloadItems.find((p) => p.name === name2);
34189
+ const field = payloadItem?.dataKey;
34181
34190
  if (!field) return value;
34182
34191
  return valueFormatter({
34183
34192
  value,
@@ -37675,7 +37684,8 @@ var useDashboards = () => {
37675
37684
  reports: Object.values(dashboard.config.sections ?? {}).flat(),
37676
37685
  tenantKeys: dashboard.config.tenantKeys,
37677
37686
  createdAt: dashboard.config.createdAt,
37678
- sectionOrder: dashboard.config.sectionOrder
37687
+ sectionOrder: dashboard.config.sectionOrder,
37688
+ hidden: dashboard.config.hidden
37679
37689
  };
37680
37690
  }).sort(
37681
37691
  (a, b) => (a.createdAt?.getTime() ?? 0) - (b.createdAt?.getTime() ?? 0)
@@ -46351,6 +46361,7 @@ var QuillProvider = ({
46351
46361
  isAdmin,
46352
46362
  getAuthorizationToken,
46353
46363
  eventTracking,
46364
+ onChangelogs,
46354
46365
  children
46355
46366
  }
46356
46367
  ) });
@@ -62036,6 +62047,24 @@ function useDebouncedRefreshInput(value, delayMs = REPORT_REFRESH_DEBOUNCE_MS) {
62036
62047
 
62037
62048
  // src/utils/pivotDateBuckets.ts
62038
62049
  var import_date_fns18 = require("date-fns");
62050
+ var PIVOT_DATE_BUCKETS = /* @__PURE__ */ new Set([
62051
+ "day",
62052
+ "week",
62053
+ "month",
62054
+ "year"
62055
+ ]);
62056
+ function inBucketDateBucketForField(rules, field) {
62057
+ for (const entry of rules) {
62058
+ if (!entry || typeof entry !== "object") continue;
62059
+ const rule = entry;
62060
+ if (rule.operator !== "inBucket" || rule.field !== field) continue;
62061
+ const bucket = rule.value && typeof rule.value === "object" && !Array.isArray(rule.value) ? rule.value.bucket : void 0;
62062
+ if (typeof bucket === "string" && PIVOT_DATE_BUCKETS.has(bucket)) {
62063
+ return bucket;
62064
+ }
62065
+ }
62066
+ return void 0;
62067
+ }
62039
62068
  function buildPivotDateBucketStarts(range, bucket) {
62040
62069
  const min2 = new Date(range.min);
62041
62070
  const max2 = new Date(range.max);
@@ -63492,9 +63521,21 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
63492
63521
  const firstPivotRow = (withResolvedXAxis.rows ?? []).find(
63493
63522
  (row) => Object.keys(row).length > 0
63494
63523
  );
63495
- const pivotRowFields = firstPivotRow ? Object.keys(firstPivotRow).filter(
63496
- (field) => !INTERNAL_PIVOT_ROW_FIELDS.has(field)
63497
- ) : [];
63524
+ const pivotRowFieldName = String(
63525
+ withResolvedXAxis.pivot?.rowField ?? ""
63526
+ ).trim();
63527
+ const pivotRowFields = firstPivotRow ? (() => {
63528
+ const keys = Object.keys(firstPivotRow).filter(
63529
+ (field) => !INTERNAL_PIVOT_ROW_FIELDS.has(field)
63530
+ );
63531
+ if (pivotRowFieldName && keys.includes(pivotRowFieldName)) {
63532
+ return [
63533
+ pivotRowFieldName,
63534
+ ...keys.filter((field) => field !== pivotRowFieldName)
63535
+ ];
63536
+ }
63537
+ return keys;
63538
+ })() : [];
63498
63539
  const pivotValueFields = pivotRowFields.filter(
63499
63540
  (field) => field !== pivotRowKey(withResolvedXAxis) && field !== withResolvedXAxis.pivot?.rowField
63500
63541
  );
@@ -63507,6 +63548,10 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
63507
63548
  );
63508
63549
  const resolveYAxisFormat = (field, aggregation) => {
63509
63550
  if (aggregation?.aggregationType === "count") {
63551
+ const savedFormat = yAxisFormatByField.get(field) ?? yAxisFormatByField.get("count") ?? withResolvedXAxis.yAxisFields?.find(
63552
+ (axis) => String(axis.field ?? "").trim() === field
63553
+ )?.format ?? withResolvedXAxis.yAxisFields?.[0]?.format;
63554
+ if (savedFormat) return savedFormat;
63510
63555
  return "whole_number";
63511
63556
  }
63512
63557
  if (aggregation?.aggregationType === "percentage") {
@@ -69573,6 +69618,15 @@ function useReport(reportIdArg, options = {}) {
69573
69618
  }
69574
69619
  for (const yAxis2 of chartAxesBaseChart.yAxisFields ?? []) {
69575
69620
  registerOption(yAxis2.field, yAxis2.label, yAxis2.format);
69621
+ if (yAxis2.format) {
69622
+ const existing = optionsByField.get(yAxis2.field);
69623
+ if (existing) {
69624
+ optionsByField.set(yAxis2.field, {
69625
+ ...existing,
69626
+ format: toAxisFormat(yAxis2.format, existing.format)
69627
+ });
69628
+ }
69629
+ }
69576
69630
  }
69577
69631
  if (chartAxesBaseChart.pivot?.columnField) {
69578
69632
  for (const aggregationAxis of buildPivotAggregationAxisFields(
@@ -69586,11 +69640,22 @@ function useReport(reportIdArg, options = {}) {
69586
69640
  );
69587
69641
  }
69588
69642
  }
69643
+ const xField = String(chartAxesBaseChart.xAxisField ?? "").trim();
69644
+ const savedXFormat = String(chartAxesBaseChart.xAxisFormat ?? "").trim();
69589
69645
  registerOption(
69590
- chartAxesBaseChart.xAxisField,
69646
+ xField,
69591
69647
  chartAxesBaseChart.xAxisLabel || chartAxesBaseChart.xAxisField,
69592
69648
  chartAxesBaseChart.xAxisFormat
69593
69649
  );
69650
+ if (xField && savedXFormat) {
69651
+ const existing = optionsByField.get(xField);
69652
+ if (existing) {
69653
+ optionsByField.set(xField, {
69654
+ ...existing,
69655
+ format: toAxisFormat(savedXFormat, existing.format)
69656
+ });
69657
+ }
69658
+ }
69594
69659
  return Array.from(optionsByField.values());
69595
69660
  }, [chartAxesBaseChart, resolveTableDisplayLabel]);
69596
69661
  const chartAxisOptionByField = (0, import_react63.useMemo)(() => {
@@ -69912,8 +69977,11 @@ function useReport(reportIdArg, options = {}) {
69912
69977
  const rowField = String(pivot?.rowField ?? "").trim();
69913
69978
  if (rowField && isDateType(String(pivot?.rowFieldType ?? ""))) {
69914
69979
  const field = pivot?.rowFieldTable ? `${pivot.rowFieldTable}.${rowField}` : rowField;
69915
- const bucket = dateBucket || pivot?.dateBucket || "month";
69916
- const labelsByRaw = /* @__PURE__ */ new Map();
69980
+ const chartBucket = dateBucket || pivot?.dateBucket || "month";
69981
+ const bucket = inBucketDateBucketForField(
69982
+ filtersForQueryBuilder.rules ?? [],
69983
+ field
69984
+ ) ?? chartBucket;
69917
69985
  const cacheKey = `${String(effectiveReportId ?? "")}\0${field}\0${bucket}`;
69918
69986
  if (pivotDateFilterRangeCacheRef.current.key !== cacheKey) {
69919
69987
  pivotDateFilterRangeCacheRef.current = {
@@ -69929,10 +69997,6 @@ function useReport(reportIdArg, options = {}) {
69929
69997
  const key = String(raw);
69930
69998
  const timestamp = new Date(key).getTime();
69931
69999
  if (Number.isNaN(timestamp)) continue;
69932
- labelsByRaw.set(
69933
- key,
69934
- String(record[pivotRowKey(chart)] ?? record[rowField] ?? key)
69935
- );
69936
70000
  const cachedMin = pivotDateFilterRangeCacheRef.current.min;
69937
70001
  const cachedMax = pivotDateFilterRangeCacheRef.current.max;
69938
70002
  if (cachedMin == null || timestamp < new Date(cachedMin).getTime()) {
@@ -69945,7 +70009,7 @@ function useReport(reportIdArg, options = {}) {
69945
70009
  const { min: min2, max: max2 } = pivotDateFilterRangeCacheRef.current;
69946
70010
  const options2 = min2 && max2 ? buildPivotDateBucketStarts({ min: min2, max: max2 }, bucket).map((value) => ({
69947
70011
  value,
69948
- label: labelsByRaw.get(value) ?? getDateString(value, void 0, bucket)
70012
+ label: getDateString(value, void 0, bucket)
69949
70013
  })) : [];
69950
70014
  out.push({
69951
70015
  field,
@@ -69961,7 +70025,8 @@ function useReport(reportIdArg, options = {}) {
69961
70025
  chart?.rows,
69962
70026
  dateBucket,
69963
70027
  effectiveReportId,
69964
- filterValueOptionsByFieldName
70028
+ filterValueOptionsByFieldName,
70029
+ filtersForQueryBuilder.rules
69965
70030
  ]);
69966
70031
  const chartForUi = (0, import_react63.useMemo)(() => {
69967
70032
  if (!chart?.pivot) return chart;
@@ -69974,10 +70039,10 @@ function useReport(reportIdArg, options = {}) {
69974
70039
  };
69975
70040
  const selectedValue = (field, operator, options2) => {
69976
70041
  const rule = filtersForQueryBuilder.rules.find(
69977
- (entry) => typeof entry === "object" && entry !== null && "field" in entry && entry.field === field && entry.operator === operator
70042
+ (entry) => typeof entry === "object" && entry !== null && "field" in entry && entry.field === field && (entry.operator === operator || operator === "inBucket" && entry.operator === "between")
69978
70043
  );
69979
70044
  if (!rule) return null;
69980
- const raw = operator === "inBucket" ? rule.value?.start : Array.isArray(rule.value) ? rule.value[0] : void 0;
70045
+ const raw = operator === "inBucket" ? rule.operator === "between" && Array.isArray(rule.value) ? rule.value[0] : rule.value?.start : Array.isArray(rule.value) ? rule.value[0] : void 0;
69981
70046
  if (raw == null) return null;
69982
70047
  const value = String(raw);
69983
70048
  return options2.some((option) => option.value === value) ? value : null;
package/dist/index.d.cts CHANGED
@@ -1201,6 +1201,7 @@ declare function Dashboard({ name, onClickReport, containerStyle, EmptyDashboard
1201
1201
  type DashboardConfig = {
1202
1202
  dashboardId: string;
1203
1203
  name: string;
1204
+ hidden?: boolean;
1204
1205
  filters: InternalDashboardStringFilter[];
1205
1206
  allTenantFilters?: InternalDashboardTenantFilter[];
1206
1207
  tenantFilters?: InternalDashboardTenantFilter[];
@@ -3747,6 +3748,7 @@ declare const useDashboards: () => {
3747
3748
  section: string;
3748
3749
  reportOrder: string[];
3749
3750
  }[] | undefined;
3751
+ hidden: boolean | undefined;
3750
3752
  }[] | null;
3751
3753
  isLoading: boolean;
3752
3754
  createDashboard: ({ name, tenantFilters, filters, dateFilter, dashboardOwners, clientId, }: {
package/dist/index.d.ts CHANGED
@@ -1201,6 +1201,7 @@ declare function Dashboard({ name, onClickReport, containerStyle, EmptyDashboard
1201
1201
  type DashboardConfig = {
1202
1202
  dashboardId: string;
1203
1203
  name: string;
1204
+ hidden?: boolean;
1204
1205
  filters: InternalDashboardStringFilter[];
1205
1206
  allTenantFilters?: InternalDashboardTenantFilter[];
1206
1207
  tenantFilters?: InternalDashboardTenantFilter[];
@@ -3747,6 +3748,7 @@ declare const useDashboards: () => {
3747
3748
  section: string;
3748
3749
  reportOrder: string[];
3749
3750
  }[] | undefined;
3751
+ hidden: boolean | undefined;
3750
3752
  }[] | null;
3751
3753
  isLoading: boolean;
3752
3754
  createDashboard: ({ name, tenantFilters, filters, dateFilter, dashboardOwners, clientId, }: {
package/dist/index.js CHANGED
@@ -107,7 +107,7 @@ function formatIdentifierLabel(str) {
107
107
  if (hasUnderscore || hasCamelCaseBoundary) {
108
108
  return snakeAndCamelCaseToTitleCase(str);
109
109
  }
110
- return str;
110
+ return str.split(/\s+/).map((word) => word === "id" ? "ID" : capitalize(word)).join(" ");
111
111
  }
112
112
  function removeDoubleQuotes(str) {
113
113
  if (!str) {
@@ -153,11 +153,12 @@ function getValidDate(dateString) {
153
153
  const dates = FORMATS.map((fmt) => parse(dateString, fmt, /* @__PURE__ */ new Date()));
154
154
  return dates.find((date) => isValid(date));
155
155
  }
156
- var 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;
156
+ var 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;
157
157
  var init_valueFormatter = __esm({
158
158
  "src/utils/valueFormatter.ts"() {
159
159
  "use strict";
160
160
  init_textProcessing();
161
+ DATE_OUTSIDE_RANGE = "Date outside range";
161
162
  DATE_FORMAT_TYPES = [
162
163
  "yyyy",
163
164
  "MMM_yyyy",
@@ -406,7 +407,7 @@ var init_valueFormatter = __esm({
406
407
  weekEnd = utcEnd;
407
408
  }
408
409
  if (isAfter(weekStart, utcEnd) || isBefore(weekEnd, utcStart)) {
409
- return "Date outside range";
410
+ return DATE_OUTSIDE_RANGE;
410
411
  }
411
412
  }
412
413
  }
@@ -15179,7 +15180,7 @@ var init_dates = __esm({
15179
15180
  init_inMemoryPivotEngine();
15180
15181
  init_valueFormatter();
15181
15182
  DATE_BUCKET_AXIS_FORMATS = {
15182
- day: "MMM_dd_yyyy",
15183
+ day: "MMM_dd",
15183
15184
  week: "MMM_dd-MMM_dd",
15184
15185
  month: "MMM_yyyy",
15185
15186
  year: "yyyy"
@@ -17423,7 +17424,7 @@ async function generatePivotWithSQL({
17423
17424
  );
17424
17425
  const responseRows = queryResponseRows;
17425
17426
  const responseFields = queryResponseFields;
17426
- const rows = resultRowField ? responseRows.map(
17427
+ let rows = resultRowField ? responseRows.map(
17427
17428
  (row) => !row[resultRowField] ? { ...row, [resultRowField]: "-" } : row
17428
17429
  ) : responseRows;
17429
17430
  if (pivot.columnField && client.databaseType?.toLowerCase() === "bigquery") {
@@ -17462,24 +17463,21 @@ async function generatePivotWithSQL({
17462
17463
  return 0;
17463
17464
  });
17464
17465
  if (resultRowField && !isStringType(pivot.rowFieldType || "")) {
17465
- rows.forEach((row) => {
17466
- row.__quillRawDate = typeof row[resultRowField] === "object" ? row[resultRowField].value : row[resultRowField];
17467
- let value = typeof row[resultRowField] === "object" ? row[resultRowField].value : row[resultRowField];
17468
- if (dateBucket === "week" && dateFilter?.startDate && dateFilter?.endDate) {
17469
- const rowDate = new Date(value);
17470
- if (rowDate < dateFilter.startDate) {
17471
- value = dateFilter.startDate.toISOString();
17472
- } else if (rowDate > dateFilter.endDate) {
17473
- value = dateFilter.endDate.toISOString();
17474
- }
17475
- }
17466
+ const dateRange = dateFilter?.startDate && dateFilter?.endDate ? { start: dateFilter.startDate, end: dateFilter.endDate } : void 0;
17467
+ rows = rows.filter((row) => {
17468
+ const rawValue = typeof row[resultRowField] === "object" ? row[resultRowField].value : row[resultRowField];
17469
+ row.__quillRawDate = rawValue;
17476
17470
  const dateString = getDateString(
17477
- value,
17478
- dateFilter?.startDate && dateFilter?.endDate ? { start: dateFilter.startDate, end: dateFilter.endDate } : void 0,
17471
+ rawValue,
17472
+ dateRange,
17479
17473
  dateBucket,
17480
17474
  databaseType
17481
17475
  );
17476
+ if (dateBucket === "week" && dateRange && dateString === DATE_OUTSIDE_RANGE) {
17477
+ return false;
17478
+ }
17482
17479
  row[resultRowField] = dateString;
17480
+ return true;
17483
17481
  });
17484
17482
  if (resultRowField && pivot.rowFieldType && !isStringType(pivot.rowFieldType) && dateFilter?.startDate && dateFilter?.endDate) {
17485
17483
  const dateSet = new Set(rows.map((row) => row[resultRowField]));
@@ -17644,7 +17642,7 @@ function processPivotData({
17644
17642
  const pivotRowField = processColumnName(
17645
17643
  String(resultRowField ?? pivot.rowField ?? "")
17646
17644
  );
17647
- const rows = pivotRowField ? responseRows.map(
17645
+ let rows = pivotRowField ? responseRows.map(
17648
17646
  (row) => !row[pivotRowField] ? { ...row, [pivotRowField]: "-" } : row
17649
17647
  ) : responseRows;
17650
17648
  if (pivot.columnField && client.databaseType?.toLowerCase() === "bigquery") {
@@ -17683,24 +17681,21 @@ function processPivotData({
17683
17681
  return 0;
17684
17682
  });
17685
17683
  if (pivotRowField && !isStringType(pivot.rowFieldType || "")) {
17686
- rows.forEach((row) => {
17687
- row.__quillRawDate = typeof row[pivotRowField] === "object" ? row[pivotRowField].value : row[pivotRowField];
17688
- let value = typeof row[pivotRowField] === "object" ? row[pivotRowField].value : row[pivotRowField];
17689
- if (dateBucket === "week" && dateFilter?.startDate && dateFilter?.endDate) {
17690
- const rowDate = new Date(value);
17691
- if (rowDate < dateFilter.startDate) {
17692
- value = dateFilter.startDate.toISOString();
17693
- } else if (rowDate > dateFilter.endDate) {
17694
- value = dateFilter.endDate.toISOString();
17695
- }
17696
- }
17684
+ const dateRange = dateFilter?.startDate && dateFilter?.endDate ? { start: dateFilter.startDate, end: dateFilter.endDate } : void 0;
17685
+ rows = rows.filter((row) => {
17686
+ const rawValue = typeof row[pivotRowField] === "object" ? row[pivotRowField].value : row[pivotRowField];
17687
+ row.__quillRawDate = rawValue;
17697
17688
  const dateString = getDateString(
17698
- value,
17699
- dateFilter?.startDate && dateFilter?.endDate ? { start: dateFilter.startDate, end: dateFilter.endDate } : void 0,
17689
+ rawValue,
17690
+ dateRange,
17700
17691
  dateBucket,
17701
17692
  databaseType
17702
17693
  );
17694
+ if (dateBucket === "week" && dateRange && dateString === DATE_OUTSIDE_RANGE) {
17695
+ return false;
17696
+ }
17703
17697
  row[pivotRowField] = dateString;
17698
+ return true;
17704
17699
  });
17705
17700
  if (pivotRowField && pivot.rowFieldType && !isStringType(pivot.rowFieldType) && dateFilter?.startDate && dateFilter?.endDate) {
17706
17701
  const dateSet = new Set(rows.map((row) => row[pivotRowField]));
@@ -17765,6 +17760,7 @@ var init_pivotConstructor = __esm({
17765
17760
  init_dashboardProfiler();
17766
17761
  init_dates();
17767
17762
  init_textProcessing();
17763
+ init_valueFormatter();
17768
17764
  }
17769
17765
  });
17770
17766
 
@@ -22883,6 +22879,7 @@ init_columnProcessing();
22883
22879
  init_dataFetcher();
22884
22880
  init_dataProcessing();
22885
22881
  init_dates();
22882
+ init_columnType();
22886
22883
  init_paginationProcessing();
22887
22884
  init_pivotProcessing();
22888
22885
  init_tableProcessing();
@@ -23809,6 +23806,15 @@ function hasPreformattedDateBucketLabels(report) {
23809
23806
  if (report.chartType?.toLowerCase() === "table") return false;
23810
23807
  return report.xAxisField?.trim() === pivot.rowField?.trim();
23811
23808
  }
23809
+ function resolvePivotBucketXAxisFormat(report) {
23810
+ const pivot = report.pivot;
23811
+ if (!pivot?.dateBucket) return null;
23812
+ if (report.chartType?.toLowerCase() === "table") return null;
23813
+ const rowField = pivot.rowField?.trim();
23814
+ if (!rowField || report.xAxisField?.trim() !== rowField) return null;
23815
+ if (!isDateType(String(pivot.rowFieldType ?? ""))) return null;
23816
+ return getDateFormatFromBucket(pivot.dateBucket);
23817
+ }
23812
23818
  function applySavedPivotColumnLabels(report, pivotColumns) {
23813
23819
  return pivotColumns?.map((column) => {
23814
23820
  const savedColumn = report.columns?.find(
@@ -23884,6 +23890,10 @@ function convertInternalReportToReport(report, dashboardFilters, eventTracking,
23884
23890
  ...extractAllReportValuesFromQuillInternalReport(formattedReport),
23885
23891
  ...pivotFormatted
23886
23892
  };
23893
+ const bucketXAxisFormat = resolvePivotBucketXAxisFormat(pivotReport);
23894
+ if (bucketXAxisFormat) {
23895
+ pivotReport.xAxisFormat = bucketXAxisFormat;
23896
+ }
23887
23897
  pivotReport.formattedBaseRows = formattedBaseRows;
23888
23898
  return applyChartSort(pivotReport);
23889
23899
  }
@@ -34210,9 +34220,8 @@ function RadarChart({
34210
34220
  fields: [{ field: xAxisField, format: xAxisFormat }]
34211
34221
  }),
34212
34222
  valueFormatter: (value, name2) => {
34213
- const field = payloadItems.find(
34214
- (p) => p.dataKey === name2
34215
- )?.dataKey;
34223
+ const payloadItem = payloadItems.find((p) => p.dataKey === name2) ?? payloadItems.find((p) => p.name === name2);
34224
+ const field = payloadItem?.dataKey;
34216
34225
  if (!field) return value;
34217
34226
  return valueFormatter({
34218
34227
  value,
@@ -37762,7 +37771,8 @@ var useDashboards = () => {
37762
37771
  reports: Object.values(dashboard.config.sections ?? {}).flat(),
37763
37772
  tenantKeys: dashboard.config.tenantKeys,
37764
37773
  createdAt: dashboard.config.createdAt,
37765
- sectionOrder: dashboard.config.sectionOrder
37774
+ sectionOrder: dashboard.config.sectionOrder,
37775
+ hidden: dashboard.config.hidden
37766
37776
  };
37767
37777
  }).sort(
37768
37778
  (a, b) => (a.createdAt?.getTime() ?? 0) - (b.createdAt?.getTime() ?? 0)
@@ -46445,6 +46455,7 @@ var QuillProvider = ({
46445
46455
  isAdmin,
46446
46456
  getAuthorizationToken,
46447
46457
  eventTracking,
46458
+ onChangelogs,
46448
46459
  children
46449
46460
  }
46450
46461
  ) });
@@ -62244,6 +62255,24 @@ import {
62244
62255
  eachWeekOfInterval as eachWeekOfInterval2,
62245
62256
  eachYearOfInterval as eachYearOfInterval2
62246
62257
  } from "date-fns";
62258
+ var PIVOT_DATE_BUCKETS = /* @__PURE__ */ new Set([
62259
+ "day",
62260
+ "week",
62261
+ "month",
62262
+ "year"
62263
+ ]);
62264
+ function inBucketDateBucketForField(rules, field) {
62265
+ for (const entry of rules) {
62266
+ if (!entry || typeof entry !== "object") continue;
62267
+ const rule = entry;
62268
+ if (rule.operator !== "inBucket" || rule.field !== field) continue;
62269
+ const bucket = rule.value && typeof rule.value === "object" && !Array.isArray(rule.value) ? rule.value.bucket : void 0;
62270
+ if (typeof bucket === "string" && PIVOT_DATE_BUCKETS.has(bucket)) {
62271
+ return bucket;
62272
+ }
62273
+ }
62274
+ return void 0;
62275
+ }
62247
62276
  function buildPivotDateBucketStarts(range, bucket) {
62248
62277
  const min2 = new Date(range.min);
62249
62278
  const max2 = new Date(range.max);
@@ -63700,9 +63729,21 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
63700
63729
  const firstPivotRow = (withResolvedXAxis.rows ?? []).find(
63701
63730
  (row) => Object.keys(row).length > 0
63702
63731
  );
63703
- const pivotRowFields = firstPivotRow ? Object.keys(firstPivotRow).filter(
63704
- (field) => !INTERNAL_PIVOT_ROW_FIELDS.has(field)
63705
- ) : [];
63732
+ const pivotRowFieldName = String(
63733
+ withResolvedXAxis.pivot?.rowField ?? ""
63734
+ ).trim();
63735
+ const pivotRowFields = firstPivotRow ? (() => {
63736
+ const keys = Object.keys(firstPivotRow).filter(
63737
+ (field) => !INTERNAL_PIVOT_ROW_FIELDS.has(field)
63738
+ );
63739
+ if (pivotRowFieldName && keys.includes(pivotRowFieldName)) {
63740
+ return [
63741
+ pivotRowFieldName,
63742
+ ...keys.filter((field) => field !== pivotRowFieldName)
63743
+ ];
63744
+ }
63745
+ return keys;
63746
+ })() : [];
63706
63747
  const pivotValueFields = pivotRowFields.filter(
63707
63748
  (field) => field !== pivotRowKey(withResolvedXAxis) && field !== withResolvedXAxis.pivot?.rowField
63708
63749
  );
@@ -63715,6 +63756,10 @@ function normalizePivotChartForDisplay(chart, resolveTableLabel) {
63715
63756
  );
63716
63757
  const resolveYAxisFormat = (field, aggregation) => {
63717
63758
  if (aggregation?.aggregationType === "count") {
63759
+ const savedFormat = yAxisFormatByField.get(field) ?? yAxisFormatByField.get("count") ?? withResolvedXAxis.yAxisFields?.find(
63760
+ (axis) => String(axis.field ?? "").trim() === field
63761
+ )?.format ?? withResolvedXAxis.yAxisFields?.[0]?.format;
63762
+ if (savedFormat) return savedFormat;
63718
63763
  return "whole_number";
63719
63764
  }
63720
63765
  if (aggregation?.aggregationType === "percentage") {
@@ -69781,6 +69826,15 @@ function useReport(reportIdArg, options = {}) {
69781
69826
  }
69782
69827
  for (const yAxis2 of chartAxesBaseChart.yAxisFields ?? []) {
69783
69828
  registerOption(yAxis2.field, yAxis2.label, yAxis2.format);
69829
+ if (yAxis2.format) {
69830
+ const existing = optionsByField.get(yAxis2.field);
69831
+ if (existing) {
69832
+ optionsByField.set(yAxis2.field, {
69833
+ ...existing,
69834
+ format: toAxisFormat(yAxis2.format, existing.format)
69835
+ });
69836
+ }
69837
+ }
69784
69838
  }
69785
69839
  if (chartAxesBaseChart.pivot?.columnField) {
69786
69840
  for (const aggregationAxis of buildPivotAggregationAxisFields(
@@ -69794,11 +69848,22 @@ function useReport(reportIdArg, options = {}) {
69794
69848
  );
69795
69849
  }
69796
69850
  }
69851
+ const xField = String(chartAxesBaseChart.xAxisField ?? "").trim();
69852
+ const savedXFormat = String(chartAxesBaseChart.xAxisFormat ?? "").trim();
69797
69853
  registerOption(
69798
- chartAxesBaseChart.xAxisField,
69854
+ xField,
69799
69855
  chartAxesBaseChart.xAxisLabel || chartAxesBaseChart.xAxisField,
69800
69856
  chartAxesBaseChart.xAxisFormat
69801
69857
  );
69858
+ if (xField && savedXFormat) {
69859
+ const existing = optionsByField.get(xField);
69860
+ if (existing) {
69861
+ optionsByField.set(xField, {
69862
+ ...existing,
69863
+ format: toAxisFormat(savedXFormat, existing.format)
69864
+ });
69865
+ }
69866
+ }
69802
69867
  return Array.from(optionsByField.values());
69803
69868
  }, [chartAxesBaseChart, resolveTableDisplayLabel]);
69804
69869
  const chartAxisOptionByField = useMemo33(() => {
@@ -70120,8 +70185,11 @@ function useReport(reportIdArg, options = {}) {
70120
70185
  const rowField = String(pivot?.rowField ?? "").trim();
70121
70186
  if (rowField && isDateType(String(pivot?.rowFieldType ?? ""))) {
70122
70187
  const field = pivot?.rowFieldTable ? `${pivot.rowFieldTable}.${rowField}` : rowField;
70123
- const bucket = dateBucket || pivot?.dateBucket || "month";
70124
- const labelsByRaw = /* @__PURE__ */ new Map();
70188
+ const chartBucket = dateBucket || pivot?.dateBucket || "month";
70189
+ const bucket = inBucketDateBucketForField(
70190
+ filtersForQueryBuilder.rules ?? [],
70191
+ field
70192
+ ) ?? chartBucket;
70125
70193
  const cacheKey = `${String(effectiveReportId ?? "")}\0${field}\0${bucket}`;
70126
70194
  if (pivotDateFilterRangeCacheRef.current.key !== cacheKey) {
70127
70195
  pivotDateFilterRangeCacheRef.current = {
@@ -70137,10 +70205,6 @@ function useReport(reportIdArg, options = {}) {
70137
70205
  const key = String(raw);
70138
70206
  const timestamp = new Date(key).getTime();
70139
70207
  if (Number.isNaN(timestamp)) continue;
70140
- labelsByRaw.set(
70141
- key,
70142
- String(record[pivotRowKey(chart)] ?? record[rowField] ?? key)
70143
- );
70144
70208
  const cachedMin = pivotDateFilterRangeCacheRef.current.min;
70145
70209
  const cachedMax = pivotDateFilterRangeCacheRef.current.max;
70146
70210
  if (cachedMin == null || timestamp < new Date(cachedMin).getTime()) {
@@ -70153,7 +70217,7 @@ function useReport(reportIdArg, options = {}) {
70153
70217
  const { min: min2, max: max2 } = pivotDateFilterRangeCacheRef.current;
70154
70218
  const options2 = min2 && max2 ? buildPivotDateBucketStarts({ min: min2, max: max2 }, bucket).map((value) => ({
70155
70219
  value,
70156
- label: labelsByRaw.get(value) ?? getDateString(value, void 0, bucket)
70220
+ label: getDateString(value, void 0, bucket)
70157
70221
  })) : [];
70158
70222
  out.push({
70159
70223
  field,
@@ -70169,7 +70233,8 @@ function useReport(reportIdArg, options = {}) {
70169
70233
  chart?.rows,
70170
70234
  dateBucket,
70171
70235
  effectiveReportId,
70172
- filterValueOptionsByFieldName
70236
+ filterValueOptionsByFieldName,
70237
+ filtersForQueryBuilder.rules
70173
70238
  ]);
70174
70239
  const chartForUi = useMemo33(() => {
70175
70240
  if (!chart?.pivot) return chart;
@@ -70182,10 +70247,10 @@ function useReport(reportIdArg, options = {}) {
70182
70247
  };
70183
70248
  const selectedValue = (field, operator, options2) => {
70184
70249
  const rule = filtersForQueryBuilder.rules.find(
70185
- (entry) => typeof entry === "object" && entry !== null && "field" in entry && entry.field === field && entry.operator === operator
70250
+ (entry) => typeof entry === "object" && entry !== null && "field" in entry && entry.field === field && (entry.operator === operator || operator === "inBucket" && entry.operator === "between")
70186
70251
  );
70187
70252
  if (!rule) return null;
70188
- const raw = operator === "inBucket" ? rule.value?.start : Array.isArray(rule.value) ? rule.value[0] : void 0;
70253
+ const raw = operator === "inBucket" ? rule.operator === "between" && Array.isArray(rule.value) ? rule.value[0] : rule.value?.start : Array.isArray(rule.value) ? rule.value[0] : void 0;
70189
70254
  if (raw == null) return null;
70190
70255
  const value = String(raw);
70191
70256
  return options2.some((option) => option.value === value) ? value : null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillsql/react",
3
- "version": "2.16.93",
3
+ "version": "2.16.95",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {