@quillsql/react 2.15.17 → 2.16.1

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
@@ -646,12 +646,9 @@ var formatPercent = (value) => {
646
646
  return formatterPercent.format(Number(value));
647
647
  };
648
648
  var _getUTCDateHelper = (value, fmt) => {
649
- if (value === null || value === void 0) {
650
- return "-";
651
- }
652
649
  const parsedDate = (0, import_date_fns.parse)(value, fmt, /* @__PURE__ */ new Date());
653
650
  const utcDate = (0, import_date_fns.isValid)(parsedDate) ? (0, import_date_fns_tz.utcToZonedTime)(parsedDate, "UTC") : (0, import_date_fns_tz.utcToZonedTime)(new Date(value), "UTC");
654
- if (!(0, import_date_fns.isValid)(utcDate)) return "-";
651
+ if (!(0, import_date_fns.isValid)(utcDate)) return value;
655
652
  return (0, import_date_fns.format)(utcDate, fmt);
656
653
  };
657
654
  var format_YYYY = (value) => _getUTCDateHelper(value, "yyyy");
@@ -662,11 +659,8 @@ var format_MMM_dd_yyyy = (value) => {
662
659
  return _getUTCDateHelper(value, "dd MMM yyyy");
663
660
  };
664
661
  var format_MMM_d_MMM_d = (value, dateRange, databaseType) => {
665
- if (value === null || value === void 0) {
666
- return "-";
667
- }
668
662
  const utcDate = (0, import_date_fns.parseISO)(value.split("T")[0]);
669
- if (!(0, import_date_fns.isValid)(utcDate)) return "-";
663
+ if (!(0, import_date_fns.isValid)(utcDate)) return "Invalid date";
670
664
  let weekStartsOn = 1;
671
665
  if (databaseType && ["mssql"].includes(databaseType)) {
672
666
  weekStartsOn = 0;
@@ -697,21 +691,15 @@ var format_MMM_d_MMM_d = (value, dateRange, databaseType) => {
697
691
  }
698
692
  };
699
693
  var format_MMM_dd_hh_mm_ap_pm = (value) => {
700
- if (value === null || value === void 0) {
701
- return "-";
702
- }
703
694
  const utcDate = (0, import_date_fns_tz.utcToZonedTime)(new Date(value), "UTC");
704
- if (!(0, import_date_fns.isValid)(utcDate)) return "-";
695
+ if (!(0, import_date_fns.isValid)(utcDate)) return "Invalid date";
705
696
  const formatStr = utcDate.getMinutes() === 0 ? "MMM do h a" : "MMM do h:mm a";
706
697
  const res = (0, import_date_fns.format)(utcDate, formatStr);
707
698
  return res.slice(0, -2) + res.slice(-2).toLowerCase();
708
699
  };
709
700
  var format_wo_yyyy = (value) => {
710
- if (value === null || value === void 0) {
711
- return "-";
712
- }
713
701
  const utcDate = (0, import_date_fns_tz.utcToZonedTime)(new Date(value), "UTC");
714
- if (!(0, import_date_fns.isValid)(utcDate)) return "-";
702
+ if (!(0, import_date_fns.isValid)(utcDate)) return "Invalid date";
715
703
  return `${(0, import_date_fns.getWeek)(utcDate)},${utcDate.getFullYear()}`;
716
704
  };
717
705
  function parseNumber(value) {
@@ -28368,7 +28356,7 @@ var ChartTooltipPrimary = (props) => /* @__PURE__ */ (0, import_jsx_runtime31.js
28368
28356
  paddingTop: 2,
28369
28357
  paddingBottom: 2
28370
28358
  },
28371
- children: props.label && !isNaN(new Date(props.label)) && props.dateFormatter ? props.dateFormatter(props.label) : props.label && !isNaN(new Date(props.label)) ? (0, import_date_fns10.format)(new Date(props.label), "MMM yyyy") : props.label || "-"
28359
+ children: !isNaN(new Date(props.label)) && props.dateFormatter ? props.dateFormatter(props.label) : !isNaN(new Date(props.label)) ? (0, import_date_fns10.format)(new Date(props.label), "MMM yyyy") : props.label
28372
28360
  }
28373
28361
  )
28374
28362
  }
@@ -28417,9 +28405,9 @@ function reformatComparisonPayload(props, primaryLabel, comparisonLabel) {
28417
28405
  const nameKey = isComparison ? `comparison_${props.xAxisField}` : props.xAxisField;
28418
28406
  const days = LABEL_TO_DAYS[primaryLabel] ?? 0;
28419
28407
  const primaryDate = item.payload[props.xAxisField] ?? 0;
28420
- const compDate = primaryDate ? (0, import_date_fns10.subDays)(new Date(primaryDate), days + 1) : /* @__PURE__ */ new Date();
28408
+ const compDate = (0, import_date_fns10.subDays)(new Date(primaryDate), days + 1);
28421
28409
  const date = item.payload[nameKey] ?? (0, import_date_fns10.format)(compDate, props.xAxisFormat);
28422
- const name2 = props.dateFormatter ? props.dateFormatter(date) : date;
28410
+ const name2 = props.dateFormatter(date);
28423
28411
  const color2 = item.color;
28424
28412
  const value = props.valueFormatter(item.value, item.name);
28425
28413
  if (!columnsByKey[""]) {
@@ -28451,7 +28439,7 @@ function reformatComparisonPayload(props, primaryLabel, comparisonLabel) {
28451
28439
  return columnsByKey;
28452
28440
  }
28453
28441
  function getTooltipLabel(props, altTooltipLabel, isDateXAxis) {
28454
- return props.payload.length <= 2 && altTooltipLabel && isDateXAxis ? altTooltipLabel && !isNaN(new Date(altTooltipLabel)) && props.dateFormatter ? props.dateFormatter(altTooltipLabel) : altTooltipLabel && !isNaN(new Date(altTooltipLabel)) ? (0, import_date_fns10.format)(new Date(altTooltipLabel), "MMM yyyy") : altTooltipLabel || "-" : props.label && !isNaN(new Date(props.label)) && props.dateFormatter ? props.dateFormatter(props.label) : props.label && !isNaN(new Date(props.label)) ? (0, import_date_fns10.format)(new Date(props.label), "MMM yyyy") : props.label || "-";
28442
+ return props.payload.length <= 2 && altTooltipLabel && isDateXAxis ? !isNaN(new Date(altTooltipLabel)) && props.dateFormatter ? props.dateFormatter(altTooltipLabel) : !isNaN(new Date(altTooltipLabel)) ? (0, import_date_fns10.format)(new Date(altTooltipLabel), "MMM yyyy") : altTooltipLabel : !isNaN(new Date(props.label)) && props.dateFormatter ? props.dateFormatter(props.label) : !isNaN(new Date(props.label)) ? (0, import_date_fns10.format)(new Date(props.label), "MMM yyyy") : props.label;
28455
28443
  }
28456
28444
  function ChartTooltipComparison(props) {
28457
28445
  const isDateXAxis = isDateFormat(props.xAxisFormat);
@@ -31661,23 +31649,53 @@ function QuillMetricComponent({
31661
31649
  width: "100%"
31662
31650
  }
31663
31651
  }
31664
- ) : !report?.rows?.[0] || report.rows[0][report.xAxisField] === null ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
31652
+ ) : !report?.rows || report?.rows?.length === 0 || report.rows[0]?.[report.xAxisField] === null || report.rows[0]?.[report.xAxisField] === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
31665
31653
  "div",
31666
31654
  {
31667
31655
  style: {
31668
- display: "flex",
31669
- flex: "1 0 auto",
31670
- // height: '100%',
31671
- margin: "auto",
31672
- justifyContent: "center",
31673
- alignItems: "center",
31674
- fontSize: 13,
31675
- fontFamily: theme?.fontFamily,
31676
- color: theme?.secondaryTextColor,
31677
- maxWidth: "100%",
31678
- width: "100%"
31656
+ padding: 0,
31657
+ height: "100%",
31658
+ width: "100%",
31659
+ boxSizing: "content-box",
31660
+ flex: 1
31679
31661
  },
31680
- children: "No results"
31662
+ children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
31663
+ "div",
31664
+ {
31665
+ style: {
31666
+ fontFamily: theme?.fontFamily,
31667
+ fontSize: 32,
31668
+ color: theme?.primaryTextColor,
31669
+ fontWeight: "600",
31670
+ textOverflow: "ellipsis",
31671
+ margin: 0,
31672
+ whiteSpace: "nowrap",
31673
+ boxSizing: "content-box",
31674
+ maxWidth: "100%",
31675
+ textAlign: "left",
31676
+ overflow: "hidden",
31677
+ height: "100%",
31678
+ minHeight: "80px",
31679
+ display: "flex",
31680
+ width: "100%",
31681
+ flexDirection: "row",
31682
+ justifyContent: "center",
31683
+ alignItems: "center"
31684
+ },
31685
+ children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
31686
+ "span",
31687
+ {
31688
+ style: {
31689
+ fontFamily: theme?.fontFamily,
31690
+ fontSize: 13,
31691
+ color: theme?.secondaryTextColor,
31692
+ fontWeight: "normal"
31693
+ },
31694
+ children: "No results"
31695
+ }
31696
+ )
31697
+ }
31698
+ )
31681
31699
  }
31682
31700
  ) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
31683
31701
  MetricDisplay,
@@ -32863,7 +32881,7 @@ function USMap({
32863
32881
  acc[curr[xAxisField]?.toString()] = curr;
32864
32882
  return acc;
32865
32883
  }, {});
32866
- const measureField = yAxisFields[0].field;
32884
+ const measureField = yAxisFields[0]?.field;
32867
32885
  const [scaleLog, setScaleLog] = (0, import_react26.useState)(null);
32868
32886
  (0, import_react26.useEffect)(() => {
32869
32887
  import("d3-scale").then((scale) => {
@@ -32899,6 +32917,29 @@ function USMap({
32899
32917
  const hoveredValue = (0, import_react26.useMemo)(() => {
32900
32918
  return !hoveredState ? void 0 : mappedData[fipsToNames[hoveredState]?.abbreviation ?? ""]?.[measureField] ?? mappedData[fipsToNames[hoveredState]?.name ?? ""]?.[measureField] ?? mappedData[fipsToNames[hoveredState]?.abbreviation?.toLowerCase() ?? ""]?.[measureField] ?? mappedData[fipsToNames[hoveredState]?.name?.toLowerCase() ?? ""]?.[measureField];
32901
32919
  }, [hoveredState, mappedData, measureField]);
32920
+ if (!measureField) {
32921
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
32922
+ "div",
32923
+ {
32924
+ style: {
32925
+ display: "flex",
32926
+ flex: "1 0 auto",
32927
+ marginLeft: "auto",
32928
+ marginRight: "auto",
32929
+ marginTop: "auto",
32930
+ marginBottom: "auto",
32931
+ justifyContent: "center",
32932
+ alignItems: "center",
32933
+ fontSize: 13,
32934
+ color: theme?.secondaryTextColor,
32935
+ fontFamily: theme?.fontFamily,
32936
+ ...containerStyle
32937
+ },
32938
+ className,
32939
+ children: "No results"
32940
+ }
32941
+ );
32942
+ }
32902
32943
  return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
32903
32944
  "div",
32904
32945
  {
@@ -33031,7 +33072,7 @@ function WorldMap({
33031
33072
  acc[curr[xAxisField]?.toString()] = curr;
33032
33073
  return acc;
33033
33074
  }, {});
33034
- const measureField = yAxisFields[0].field;
33075
+ const measureField = yAxisFields[0]?.field;
33035
33076
  const [scaleLog, setScaleLog] = (0, import_react26.useState)(null);
33036
33077
  (0, import_react26.useEffect)(() => {
33037
33078
  import("d3-scale").then((scale) => {
@@ -33067,6 +33108,29 @@ function WorldMap({
33067
33108
  const hoveredValue = (0, import_react26.useMemo)(() => {
33068
33109
  return !hoveredCountry ? void 0 : mappedData[isoToNames[hoveredCountry]?.abbreviation ?? ""]?.[measureField] ?? mappedData[isoToNames[hoveredCountry]?.name ?? ""]?.[measureField] ?? mappedData[isoToNames[hoveredCountry]?.abbreviation?.toLowerCase() ?? ""]?.[measureField] ?? mappedData[isoToNames[hoveredCountry]?.name?.toLowerCase() ?? ""]?.[measureField];
33069
33110
  }, [hoveredCountry, mappedData, measureField]);
33111
+ if (!measureField) {
33112
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
33113
+ "div",
33114
+ {
33115
+ style: {
33116
+ display: "flex",
33117
+ flex: "1 0 auto",
33118
+ marginLeft: "auto",
33119
+ marginRight: "auto",
33120
+ marginTop: "auto",
33121
+ marginBottom: "auto",
33122
+ justifyContent: "center",
33123
+ alignItems: "center",
33124
+ fontSize: 13,
33125
+ color: theme?.secondaryTextColor,
33126
+ fontFamily: theme?.fontFamily,
33127
+ ...containerStyle
33128
+ },
33129
+ className,
33130
+ children: "No results"
33131
+ }
33132
+ );
33133
+ }
33070
33134
  return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
33071
33135
  "div",
33072
33136
  {
@@ -35574,27 +35638,41 @@ var ChartDisplay = ({
35574
35638
  );
35575
35639
  }
35576
35640
  if (config?.chartType?.toLowerCase() === "metric") {
35577
- if (!config?.rows || config?.rows?.length === 0 || // @ts-ignore
35578
- config?.rows[0][config?.xAxisField] === null) {
35641
+ if (!config?.rows || config?.rows?.length === 0 || config?.rows[0]?.[config?.xAxisField] === null || config?.rows[0]?.[config?.xAxisField] === void 0) {
35579
35642
  return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
35580
35643
  "div",
35581
35644
  {
35582
35645
  style: {
35583
- display: "flex",
35584
- flex: "1 0 auto",
35585
- // height: containerStyle?.height || '100%',
35586
- margin: "auto",
35587
- justifyContent: "center",
35588
- alignItems: "center",
35589
- fontSize: 13,
35590
35646
  fontFamily: theme?.fontFamily,
35591
- color: theme?.secondaryTextColor,
35647
+ fontSize: 32,
35648
+ color: theme?.primaryTextColor,
35649
+ fontWeight: "600",
35650
+ textOverflow: "ellipsis",
35651
+ margin: 0,
35652
+ whiteSpace: "nowrap",
35653
+ boxSizing: "content-box",
35592
35654
  maxWidth: "100%",
35655
+ textAlign: "left",
35656
+ overflow: "hidden",
35657
+ height: containerStyle?.height || "100%",
35658
+ display: "flex",
35593
35659
  width: "100%",
35660
+ flexDirection: "row",
35661
+ alignItems: "center",
35594
35662
  ...containerStyle
35595
35663
  },
35596
35664
  className,
35597
- children: "No results"
35665
+ children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
35666
+ "span",
35667
+ {
35668
+ style: {
35669
+ fontFamily: theme?.fontFamily,
35670
+ fontSize: 13,
35671
+ color: theme?.secondaryTextColor
35672
+ },
35673
+ children: "No results"
35674
+ }
35675
+ )
35598
35676
  }
35599
35677
  );
35600
35678
  }
@@ -42482,15 +42560,19 @@ function ChartBuilderWithModal(props) {
42482
42560
  title: title || "Add to dashboard",
42483
42561
  width: isHorizontalView ? modalWidth : void 0,
42484
42562
  height: isHorizontalView ? modalHeight : void 0,
42485
- children: (props.reportId ? dashboard[props.reportId] ?? props.tempReport : props.tempReport) ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
42486
- ChartBuilder,
42487
- {
42488
- ...props,
42489
- filtersEnabled: filtersEnabledState,
42490
- onFiltersEnabledChanged: setFiltersEnabledState,
42491
- runQueryOnMount: filtersEnabledState
42492
- }
42493
- ) : /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { style: { padding: 20 }, children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(QuillLoadingComponent, {}) })
42563
+ children: (() => {
42564
+ const resolvedReport = props.reportId ? dashboard[props.reportId] ?? props.tempReport : props.tempReport;
42565
+ return resolvedReport ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
42566
+ ChartBuilder,
42567
+ {
42568
+ ...props,
42569
+ tempReport: resolvedReport,
42570
+ filtersEnabled: filtersEnabledState,
42571
+ onFiltersEnabledChanged: setFiltersEnabledState,
42572
+ runQueryOnMount: filtersEnabledState
42573
+ }
42574
+ ) : /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { style: { padding: 20 }, children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(QuillLoadingComponent, {}) });
42575
+ })()
42494
42576
  }
42495
42577
  ) });
42496
42578
  }
@@ -42540,6 +42622,7 @@ function ChartBuilder({
42540
42622
  hideSubmitButton = false,
42541
42623
  hideDateRangeFilter = false,
42542
42624
  showTableFormatOptions,
42625
+ showDashboardFilterFields,
42543
42626
  initialUniqueValues,
42544
42627
  initialUniqueValuesIsLoading,
42545
42628
  pivotRecommendationsEnabled = true,
@@ -42569,7 +42652,7 @@ function ChartBuilder({
42569
42652
  const { tenants, flags } = (0, import_react43.useContext)(TenantContext);
42570
42653
  const report = (0, import_react43.useMemo)(() => {
42571
42654
  return reportId && !tempReport ? allReportsById[reportId] : tempReport;
42572
- }, [reportId]);
42655
+ }, [reportId, tempReport, allReportsById]);
42573
42656
  const [windowWidth, setWindowWidth] = (0, import_react43.useState)(1200);
42574
42657
  const [rows, setRows] = (0, import_react43.useState)(report?.rows ?? []);
42575
42658
  const [itemQuery, setItemQuery] = (0, import_react43.useState)(report?.itemQuery);
@@ -45062,7 +45145,7 @@ function ChartBuilder({
45062
45145
  ]
45063
45146
  }
45064
45147
  ),
45065
- specificDashboardFilters.length > 0 && isAdmin && /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
45148
+ specificDashboardFilters.length > 0 && (showDashboardFilterFields || isAdmin) && /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
45066
45149
  "div",
45067
45150
  {
45068
45151
  style: {
@@ -45073,7 +45156,7 @@ function ChartBuilder({
45073
45156
  },
45074
45157
  children: [
45075
45158
  /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(HeaderComponent, { label: "Dashboard filter fields" }),
45076
- isAdmin && formData.dateField && dashboardConfig[formData.dashboardName ?? destinationDashboardName ?? ""]?.config.dateFilter?.label && /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(ChartBuilderInputRowContainer, { children: [
45159
+ (showDashboardFilterFields || isAdmin) && formData.dateField && dashboardConfig[formData.dashboardName ?? destinationDashboardName ?? ""]?.config.dateFilter?.label && /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(ChartBuilderInputRowContainer, { children: [
45077
45160
  /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
45078
45161
  TextInputComponent,
45079
45162
  {
@@ -46012,6 +46095,7 @@ function SQLEditor({
46012
46095
  CheckboxComponent = QuillChartBuilderCheckboxComponent,
46013
46096
  defaultQuery,
46014
46097
  destinationDashboard,
46098
+ destinationSection,
46015
46099
  onChangeQuery,
46016
46100
  onChangeData,
46017
46101
  onChangeColumns,
@@ -46021,12 +46105,16 @@ function SQLEditor({
46021
46105
  onCloseChartBuilder,
46022
46106
  isChartBuilderEnabled = false,
46023
46107
  isAdminEnabled = false,
46108
+ chartBuilderOptions,
46024
46109
  chartBuilderTitle,
46025
46110
  runQueryOnMount = false,
46026
46111
  onAddToDashboardComplete,
46112
+ onSubmitCreateReport,
46113
+ onSubmitEditReport,
46027
46114
  onSaveQueryComplete,
46028
46115
  addToDashboardButtonLabel = "Add to dashboard",
46029
46116
  report = void 0,
46117
+ reportId = void 0,
46030
46118
  organizationName = void 0,
46031
46119
  isChartBuilderHorizontalView = true,
46032
46120
  containerStyle = { height: "100vh" },
@@ -46037,7 +46125,7 @@ function SQLEditor({
46037
46125
  const [sqlPrompt, setSqlPrompt] = (0, import_react45.useState)("");
46038
46126
  const [client] = (0, import_react45.useContext)(ClientContext);
46039
46127
  const [theme] = (0, import_react45.useContext)(ThemeContext);
46040
- const { tenants } = (0, import_react45.useContext)(TenantContext);
46128
+ const { tenants, flags } = (0, import_react45.useContext)(TenantContext);
46041
46129
  const { dashboards } = useDashboards();
46042
46130
  const {
46043
46131
  data,
@@ -46046,6 +46134,7 @@ function SQLEditor({
46046
46134
  } = useDashboardInternal(destinationDashboard);
46047
46135
  const { getToken, quillFetchWithToken } = (0, import_react45.useContext)(FetchContext);
46048
46136
  const { eventTracking } = (0, import_react45.useContext)(EventTrackingContext);
46137
+ const { allReportsById } = useAllReports();
46049
46138
  const destinationDashboardConfig = (0, import_react45.useMemo)(() => {
46050
46139
  return dashboards?.find((d) => d.name === destinationDashboard);
46051
46140
  }, [dashboards, destinationDashboard]);
@@ -46113,6 +46202,46 @@ function SQLEditor({
46113
46202
  reload();
46114
46203
  }
46115
46204
  }, [data, dashboardIsLoading]);
46205
+ (0, import_react45.useEffect)(() => {
46206
+ const loadReport = async () => {
46207
+ let reportToLoad;
46208
+ if (!client) {
46209
+ return;
46210
+ }
46211
+ try {
46212
+ if (!reportId) {
46213
+ throw new Error("Report ID is required");
46214
+ }
46215
+ reportToLoad = allReportsById[reportId];
46216
+ if (!reportToLoad) {
46217
+ throw new Error("Report not found");
46218
+ }
46219
+ setQuery(reportToLoad.queryString || "");
46220
+ setTempReport(reportToLoad);
46221
+ if (reportToLoad.rows && reportToLoad.rows.length > 0) {
46222
+ setRows(reportToLoad.rows);
46223
+ setDisplayTable(true);
46224
+ }
46225
+ } catch (err) {
46226
+ console.error(err);
46227
+ eventTracking?.logError?.({
46228
+ type: "bug",
46229
+ severity: "high",
46230
+ message: "Error loading report",
46231
+ errorMessage: err.message,
46232
+ errorStack: err.stack,
46233
+ errorData: {
46234
+ caller: "SQLEditor",
46235
+ function: "loadReport"
46236
+ }
46237
+ });
46238
+ setErrorMessage("Error when loading report");
46239
+ }
46240
+ };
46241
+ if (reportId && client) {
46242
+ loadReport();
46243
+ }
46244
+ }, [allReportsById[reportId || ""], client]);
46116
46245
  const dynamicHeight = tableRef.current ? tableRef.current.clientHeight : cachedHeight;
46117
46246
  const rowsPerPage = Math.max(
46118
46247
  DEFAULT_ROWS_PER_PAGE,
@@ -46931,13 +47060,38 @@ function SQLEditor({
46931
47060
  isHorizontalView: isChartBuilderHorizontalView,
46932
47061
  isOpen: isChartBuilderOpen,
46933
47062
  setIsOpen: setIsChartBuilderOpen,
46934
- onAddToDashboardComplete,
47063
+ onAddToDashboardComplete: reportId || report?.id ? (data2) => {
47064
+ if (onSubmitEditReport) {
47065
+ onSubmitEditReport(data2);
47066
+ } else if (onAddToDashboardComplete) {
47067
+ onAddToDashboardComplete(data2);
47068
+ }
47069
+ if (!isAdminEnabled && destinationDashboard) {
47070
+ reload(destinationDashboard, false, {
47071
+ report: data2,
47072
+ action: "upsert"
47073
+ });
47074
+ }
47075
+ } : (data2) => {
47076
+ if (onSubmitCreateReport) {
47077
+ onSubmitCreateReport(data2);
47078
+ } else if (onAddToDashboardComplete) {
47079
+ onAddToDashboardComplete(data2);
47080
+ }
47081
+ if (!isAdminEnabled && destinationDashboard) {
47082
+ reload(destinationDashboard, false, {
47083
+ report: data2,
47084
+ action: "upsert"
47085
+ });
47086
+ }
47087
+ },
46935
47088
  destinationDashboard,
47089
+ destinationSection,
46936
47090
  isAdmin: isAdminEnabled,
46937
47091
  title: chartBuilderTitle,
46938
47092
  buttonLabel: addToDashboardButtonLabel,
46939
47093
  tempReport,
46940
- reportId: report?.id,
47094
+ reportId: reportId || report?.id,
46941
47095
  organizationName,
46942
47096
  CardComponent,
46943
47097
  TableComponent,
@@ -46962,6 +47116,8 @@ function SQLEditor({
46962
47116
  CheckboxComponent,
46963
47117
  hideDateRangeFilter: true,
46964
47118
  hideDeleteButton: true,
47119
+ showTableFormatOptions: chartBuilderOptions?.showTableFormatOptions,
47120
+ showDashboardFilterFields: chartBuilderOptions?.showDashboardFilterFields,
46965
47121
  onClickChartElement,
46966
47122
  isEditingMode: true
46967
47123
  }
@@ -46981,7 +47137,7 @@ function SQLEditor({
46981
47137
  isAdmin: false,
46982
47138
  title: "Save query",
46983
47139
  buttonLabel: "Save query",
46984
- tempReport,
47140
+ tempReport: { ...tempReport, dashboardName: SAVED_QUERIES_DASHBOARD },
46985
47141
  reportId: report?.id,
46986
47142
  organizationName,
46987
47143
  CardComponent,
@@ -48744,7 +48900,6 @@ var useReportBuilderInternal = ({
48744
48900
  }
48745
48901
  report = allReportsById[reportId];
48746
48902
  if (!report) {
48747
- console.log("no report");
48748
48903
  throw new Error("Report not found");
48749
48904
  }
48750
48905
  const { ast: newAst, pivot: newPivot } = await fetchASTFromQuillReport(
@@ -51269,6 +51424,8 @@ var SaveReport = ({
51269
51424
  onSubmitEditReport = () => void 0,
51270
51425
  onSubmitCreateReport = () => void 0,
51271
51426
  destinationSection,
51427
+ showTableFormatOptions,
51428
+ showDashboardFilterFields,
51272
51429
  SelectComponent = QuillSelectComponent,
51273
51430
  TextInputComponent = QuillTextInput,
51274
51431
  ButtonComponent = MemoizedButton,
@@ -51301,6 +51458,7 @@ var SaveReport = ({
51301
51458
  ),
51302
51459
  submitButtonLabel
51303
51460
  }) => {
51461
+ const { reload } = useDashboardInternal(reportBuilder.destinationDashboard ?? null);
51304
51462
  return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { children: [
51305
51463
  SaveTrigger,
51306
51464
  /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
@@ -51313,7 +51471,17 @@ var SaveReport = ({
51313
51471
  isHorizontalView: true,
51314
51472
  isOpen,
51315
51473
  setIsOpen,
51316
- onAddToDashboardComplete: reportBuilder.reportId ? onSubmitEditReport : onSubmitCreateReport,
51474
+ onAddToDashboardComplete: reportBuilder.reportId ? (data) => {
51475
+ onSubmitEditReport(data);
51476
+ if (!isAdminEnabled && reportBuilder.destinationDashboard) {
51477
+ reload(reportBuilder.destinationDashboard, false, { report: data, action: "upsert" });
51478
+ }
51479
+ } : (data) => {
51480
+ onSubmitCreateReport(data);
51481
+ if (!isAdminEnabled && reportBuilder.destinationDashboard) {
51482
+ reload(reportBuilder.destinationDashboard, false, { report: data, action: "upsert" });
51483
+ }
51484
+ },
51317
51485
  destinationDashboard: reportBuilder.destinationDashboard,
51318
51486
  destinationSection,
51319
51487
  initialUniqueValues: reportBuilder.columnUniqueValues,
@@ -51342,6 +51510,8 @@ var SaveReport = ({
51342
51510
  FormContainer: ChartBuilderFormContainer,
51343
51511
  hideDateRangeFilter: true,
51344
51512
  hideDeleteButton: true,
51513
+ showTableFormatOptions,
51514
+ showDashboardFilterFields,
51345
51515
  buttonLabel: submitButtonLabel ?? (!!reportBuilder.reportId ? "Save changes" : "Add to dashboard"),
51346
51516
  onClickChartElement,
51347
51517
  isEditingMode: true
@@ -51437,6 +51607,7 @@ function ReportBuilder({
51437
51607
  containerStyle,
51438
51608
  className,
51439
51609
  pivotRecommendationsEnabled = true,
51610
+ chartBuilderOptions,
51440
51611
  reportId,
51441
51612
  hideCopySQL = true,
51442
51613
  isChartBuilderHorizontalView = true,
@@ -51876,6 +52047,8 @@ function ReportBuilder({
51876
52047
  ErrorMessageComponent,
51877
52048
  PivotRowContainer,
51878
52049
  PivotColumnContainer,
52050
+ showTableFormatOptions: chartBuilderOptions?.showTableFormatOptions,
52051
+ showDashboardFilterFields: chartBuilderOptions?.showDashboardFilterFields,
51879
52052
  onClickChartElement,
51880
52053
  submitButtonLabel
51881
52054
  }
@@ -51896,7 +52069,7 @@ function ReportBuilder({
51896
52069
  isAdmin: false,
51897
52070
  title: "Save query",
51898
52071
  buttonLabel: "Save query",
51899
- tempReport,
52072
+ tempReport: { ...tempReport, dashboardName: SAVED_QUERIES_DASHBOARD },
51900
52073
  reportId,
51901
52074
  organizationName,
51902
52075
  CardComponent,
package/dist/index.d.cts CHANGED
@@ -1751,8 +1751,13 @@ interface SQLEditorProps {
1751
1751
  onCloseChartBuilder?: () => void;
1752
1752
  /**
1753
1753
  * A callback that is fired when a report has been added to a dashboard.
1754
+ * @deprecated Use onSubmitCreateReport and onSubmitEditReport instead
1754
1755
  */
1755
1756
  onAddToDashboardComplete?: (report: QuillReport) => void;
1757
+ /** A callback function that will trigger when a new chart is saved */
1758
+ onSubmitCreateReport?: (report: QuillReport) => void;
1759
+ /** A callback function that will trigger when a chart is edited */
1760
+ onSubmitEditReport?: (report: QuillReport) => void;
1756
1761
  onSaveQueryComplete?: (report: QuillReport) => void;
1757
1762
  /** A callback function triggered when a chart element is clicked */
1758
1763
  onClickChartElement?: (event: any) => void;
@@ -1779,9 +1784,14 @@ interface SQLEditorProps {
1779
1784
  */
1780
1785
  isAdminEnabled?: boolean;
1781
1786
  /**
1782
- * Whether to show table format options.
1787
+ * Options for the chart builder modal.
1783
1788
  */
1784
- showTableFormatOptions?: boolean;
1789
+ chartBuilderOptions?: {
1790
+ /** Whether to show table format options. */
1791
+ showTableFormatOptions?: boolean;
1792
+ /** Whether to show dashboard filter fields. */
1793
+ showDashboardFilterFields?: boolean;
1794
+ };
1785
1795
  /**
1786
1796
  * Whether to show date field options.
1787
1797
  */
@@ -1794,6 +1804,10 @@ interface SQLEditorProps {
1794
1804
  * A dashboard item.
1795
1805
  */
1796
1806
  report?: QuillReport;
1807
+ /**
1808
+ * A report id that the SQL Editor will query from and modify.
1809
+ */
1810
+ reportId?: string;
1797
1811
  /**
1798
1812
  * The default query to use as a placeholder.
1799
1813
  */
@@ -1802,6 +1816,10 @@ interface SQLEditorProps {
1802
1816
  * The default dashboard to add the query to.
1803
1817
  */
1804
1818
  destinationDashboard: string;
1819
+ /**
1820
+ * The section of the dashboard to add items to.
1821
+ */
1822
+ destinationSection?: string;
1805
1823
  /**
1806
1824
  * The title of the ChartBuilder dialog.
1807
1825
  */
@@ -1856,7 +1874,7 @@ interface SQLEditorProps {
1856
1874
  * ### SQLEditor API
1857
1875
  * @see https://docs.quillsql.com/components/sql-editor
1858
1876
  */
1859
- declare function SQLEditor({ ButtonComponent, SecondaryButtonComponent, DeleteButtonComponent, TextInputComponent, SelectComponent, TableComponent, isNewQueryEnabled, LoadingComponent, ModalComponent, PopoverComponent, CardComponent, LabelComponent, HeaderComponent, SubHeaderComponent, TextComponent, ErrorMessageComponent, ChartBuilderInputRowContainer, ChartBuilderInputColumnContainer, PivotRowContainer, PivotColumnContainer, ChartBuilderFormContainer, CheckboxComponent, defaultQuery, destinationDashboard, onChangeQuery, onChangeData, onChangeColumns, onChangeFields, onDiscardChanges, onSaveChanges, onCloseChartBuilder, isChartBuilderEnabled, isAdminEnabled, chartBuilderTitle, runQueryOnMount, onAddToDashboardComplete, onSaveQueryComplete, addToDashboardButtonLabel, report, organizationName, isChartBuilderHorizontalView, containerStyle, className, onClickChartElement, onRequestAddVirtualTable, }: SQLEditorProps): react_jsx_runtime.JSX.Element;
1877
+ declare function SQLEditor({ ButtonComponent, SecondaryButtonComponent, DeleteButtonComponent, TextInputComponent, SelectComponent, TableComponent, isNewQueryEnabled, LoadingComponent, ModalComponent, PopoverComponent, CardComponent, LabelComponent, HeaderComponent, SubHeaderComponent, TextComponent, ErrorMessageComponent, ChartBuilderInputRowContainer, ChartBuilderInputColumnContainer, PivotRowContainer, PivotColumnContainer, ChartBuilderFormContainer, CheckboxComponent, defaultQuery, destinationDashboard, destinationSection, onChangeQuery, onChangeData, onChangeColumns, onChangeFields, onDiscardChanges, onSaveChanges, onCloseChartBuilder, isChartBuilderEnabled, isAdminEnabled, chartBuilderOptions, chartBuilderTitle, runQueryOnMount, onAddToDashboardComplete, onSubmitCreateReport, onSubmitEditReport, onSaveQueryComplete, addToDashboardButtonLabel, report, reportId, organizationName, isChartBuilderHorizontalView, containerStyle, className, onClickChartElement, onRequestAddVirtualTable, }: SQLEditorProps): react_jsx_runtime.JSX.Element;
1860
1878
  declare const SchemaListComponent: ({ schema, theme, loading, LoadingComponent, width, onClick, style, onRequestAddVirtualTable, ButtonComponent, }: {
1861
1879
  schema: any;
1862
1880
  theme: any;
@@ -2126,6 +2144,15 @@ interface ReportBuilderProps {
2126
2144
  isAIEnabled?: boolean;
2127
2145
  /** Whether the PivotModal's AI features are enabled. */
2128
2146
  pivotRecommendationsEnabled?: boolean;
2147
+ /**
2148
+ * Options for the chart builder modal.
2149
+ */
2150
+ chartBuilderOptions?: {
2151
+ /** Whether to show table format options. */
2152
+ showTableFormatOptions?: boolean;
2153
+ /** Whether to show dashboard filter fields. */
2154
+ showDashboardFilterFields?: boolean;
2155
+ };
2129
2156
  /**
2130
2157
  * Applies the following classes to the ReportBuilder.
2131
2158
  *
@@ -2195,7 +2222,7 @@ interface ReportBuilderProps {
2195
2222
  * ### Report Builder API
2196
2223
  * @see https://docs.quillsql.com/components/report-builder
2197
2224
  */
2198
- declare function ReportBuilder$1({ initialTableName, onSubmitEditReport, onSubmitCreateReport, onSubmitSaveQuery, onDiscardChanges, onSaveChanges, onCloseChartBuilder, destinationDashboard, destinationSection, chartBuilderTitle, organizationName, ButtonComponent, SecondaryButtonComponent, DeleteButtonComponent, ModalComponent, TextInputComponent, SelectComponent, MultiSelectComponent, TableComponent, PopoverComponent, TabsComponent, CheckboxComponent, SidebarComponent, ContainerComponent, SelectColumnComponent, DraggableColumnComponent, SidebarHeadingComponent, FilterPopoverComponent, SortPopoverComponent, LimitPopoverComponent, CardComponent, LabelComponent, HeaderComponent, SubHeaderComponent, TextComponent, ErrorMessageComponent, ChartBuilderInputRowContainer, ChartBuilderInputColumnContainer, PivotRowContainer, PivotColumnContainer, LoadingComponent, ColumnSearchEmptyState, ChartBuilderFormContainer, ChartBuilderModalComponent, isAdminEnabled, isAIEnabled, containerStyle, className, pivotRecommendationsEnabled, reportId, hideCopySQL, isChartBuilderHorizontalView, onClickChartElement, onRequestAddVirtualTable, submitButtonLabel, }: ReportBuilderProps): react_jsx_runtime.JSX.Element;
2225
+ declare function ReportBuilder$1({ initialTableName, onSubmitEditReport, onSubmitCreateReport, onSubmitSaveQuery, onDiscardChanges, onSaveChanges, onCloseChartBuilder, destinationDashboard, destinationSection, chartBuilderTitle, organizationName, ButtonComponent, SecondaryButtonComponent, DeleteButtonComponent, ModalComponent, TextInputComponent, SelectComponent, MultiSelectComponent, TableComponent, PopoverComponent, TabsComponent, CheckboxComponent, SidebarComponent, ContainerComponent, SelectColumnComponent, DraggableColumnComponent, SidebarHeadingComponent, FilterPopoverComponent, SortPopoverComponent, LimitPopoverComponent, CardComponent, LabelComponent, HeaderComponent, SubHeaderComponent, TextComponent, ErrorMessageComponent, ChartBuilderInputRowContainer, ChartBuilderInputColumnContainer, PivotRowContainer, PivotColumnContainer, LoadingComponent, ColumnSearchEmptyState, ChartBuilderFormContainer, ChartBuilderModalComponent, isAdminEnabled, isAIEnabled, containerStyle, className, pivotRecommendationsEnabled, chartBuilderOptions, reportId, hideCopySQL, isChartBuilderHorizontalView, onClickChartElement, onRequestAddVirtualTable, submitButtonLabel, }: ReportBuilderProps): react_jsx_runtime.JSX.Element;
2199
2226
 
2200
2227
  /**
2201
2228
  * Props for the Quill ChartEditor component.
@@ -3260,6 +3287,10 @@ interface SaveReportProps {
3260
3287
  onSubmitCreateReport?: (report: QuillReport) => void;
3261
3288
  /** The destination section for the report. */
3262
3289
  destinationSection?: string;
3290
+ /** Whether to show table format options. */
3291
+ showTableFormatOptions?: boolean;
3292
+ /** Whether to show dashboard filter fields. */
3293
+ showDashboardFilterFields?: boolean;
3263
3294
  /** A select component. */
3264
3295
  SelectComponent?: (props: {
3265
3296
  value: string | number | undefined | null;
@@ -3399,7 +3430,7 @@ interface SaveReportProps {
3399
3430
  /** The label for the submit button. */
3400
3431
  submitButtonLabel?: string;
3401
3432
  }
3402
- declare const SaveReport: ({ reportBuilder, isOpen, setIsOpen, isAdminEnabled, chartBuilderTitle, onSubmitEditReport, onSubmitCreateReport, destinationSection, SelectComponent, TextInputComponent, ButtonComponent, SecondaryButtonComponent, HeaderComponent, SubHeaderComponent, LabelComponent, TextComponent, CardComponent, ModalComponent, PopoverComponent, TableComponent, DeleteButtonComponent, LoadingComponent, ChartBuilderInputRowContainer, ChartBuilderInputColumnContainer, PivotRowContainer, PivotColumnContainer, ErrorMessageComponent, CheckboxComponent, ChartBuilderFormContainer, onClickChartElement, SaveTrigger, submitButtonLabel, }: SaveReportProps) => react_jsx_runtime.JSX.Element;
3433
+ declare const SaveReport: ({ reportBuilder, isOpen, setIsOpen, isAdminEnabled, chartBuilderTitle, onSubmitEditReport, onSubmitCreateReport, destinationSection, showTableFormatOptions, showDashboardFilterFields, SelectComponent, TextInputComponent, ButtonComponent, SecondaryButtonComponent, HeaderComponent, SubHeaderComponent, LabelComponent, TextComponent, CardComponent, ModalComponent, PopoverComponent, TableComponent, DeleteButtonComponent, LoadingComponent, ChartBuilderInputRowContainer, ChartBuilderInputColumnContainer, PivotRowContainer, PivotColumnContainer, ErrorMessageComponent, CheckboxComponent, ChartBuilderFormContainer, onClickChartElement, SaveTrigger, submitButtonLabel, }: SaveReportProps) => react_jsx_runtime.JSX.Element;
3403
3434
 
3404
3435
  interface ReportTableProps {
3405
3436
  reportBuilder: ReportBuilder;