@quillsql/react 2.16.16 → 2.16.18

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
@@ -378,7 +378,7 @@ var init_constants = __esm({
378
378
  "src/utils/constants.ts"() {
379
379
  "use strict";
380
380
  MAX_PIVOT_UNIQUE_VALUES = 250;
381
- QUILL_SERVER = typeof process !== "undefined" && process.env ? process.env.QUILL_SERVER_HOST ?? "https://quill-344421.uc.r.appspot.com" : "https://quill-344421.uc.r.appspot.com";
381
+ QUILL_SERVER = typeof process !== "undefined" && process.env ? process.env.QUILL_SERVER_HOST ?? "https://api.quill.co" : "https://api.quill.co";
382
382
  QUILL_QUERY_ENDPOINT = typeof process !== "undefined" && process.env ? process.env.QUILL_QUERY_ENDPOINT ?? "/cloud/engine" : "/cloud/engine";
383
383
  ALL_TENANTS = "QUILL_ALL_TENANTS";
384
384
  SINGLE_TENANT = "QUILL_SINGLE_TENANT";
@@ -24292,15 +24292,33 @@ var useDashboard = (dashboardName, config) => {
24292
24292
  const { eventTracking } = (0, import_react2.useContext)(EventTrackingContext);
24293
24293
  const customFiltersRef = (0, import_react2.useRef)(customReportFilters);
24294
24294
  const reportRequestIds = (0, import_react2.useRef)({});
24295
+ const lastDashboardName = (0, import_react2.useRef)(null);
24296
+ const pendingNameChangeReload = (0, import_react2.useRef)(false);
24295
24297
  (0, import_react2.useEffect)(() => {
24296
24298
  customFiltersRef.current = customReportFilters;
24297
24299
  }, [customReportFilters]);
24298
24300
  (0, import_react2.useEffect)(() => {
24299
- if (!isLoading && !data && initialLoad.current) {
24301
+ const nameChanged = dashboardName !== lastDashboardName.current;
24302
+ if (nameChanged) {
24303
+ lastDashboardName.current = dashboardName ?? null;
24304
+ initialLoad.current = true;
24305
+ fetchedInitialReports.current = false;
24306
+ backfilledDashboards.current = false;
24307
+ reportRequestIds.current = {};
24308
+ pendingNameChangeReload.current = true;
24309
+ }
24310
+ if (!dashboardName) return;
24311
+ if (pendingNameChangeReload.current && data) {
24312
+ pendingNameChangeReload.current = false;
24313
+ initialLoad.current = false;
24314
+ return;
24315
+ }
24316
+ if (pendingNameChangeReload.current && !isLoading && !data && initialLoad.current) {
24300
24317
  initialLoad.current = false;
24318
+ pendingNameChangeReload.current = false;
24301
24319
  reload();
24302
24320
  }
24303
- }, [isLoading, data]);
24321
+ }, [isLoading, data, dashboardName]);
24304
24322
  (0, import_react2.useEffect)(() => {
24305
24323
  if (backfilledDashboards.current) return;
24306
24324
  if (isLoading || !data) return;
@@ -24310,7 +24328,7 @@ var useDashboard = (dashboardName, config) => {
24310
24328
  if (!needsBackfill) return;
24311
24329
  backfilledDashboards.current = true;
24312
24330
  reload(dashboardName, false);
24313
- }, [isLoading, data, dashboardFilters, dashboardName, reload]);
24331
+ }, [isLoading, data, dashboardFilters, dashboardName]);
24314
24332
  const { allReportsById } = useAllReports();
24315
24333
  const sections = (0, import_react2.useMemo)(() => {
24316
24334
  if (!data?.sections) return null;
@@ -43842,6 +43860,20 @@ function ChartBuilder({
43842
43860
  const resolvedReport = reportId && !tempReport ? allReportsById[reportId] : tempReport;
43843
43861
  return resolvedReport;
43844
43862
  }, [reportId, tempReport, allReportsById]);
43863
+ const reportFieldsByName = (0, import_react44.useMemo)(() => {
43864
+ const fields = report?.fields;
43865
+ if (!fields || fields.length === 0) {
43866
+ return {};
43867
+ }
43868
+ const map = {};
43869
+ for (const f of fields) {
43870
+ const key = f?.name ?? f?.field;
43871
+ if (key) {
43872
+ map[key] = f;
43873
+ }
43874
+ }
43875
+ return map;
43876
+ }, [report]);
43845
43877
  const [windowWidth, setWindowWidth] = (0, import_react44.useState)(1200);
43846
43878
  const [rows, setRows] = (0, import_react44.useState)(() => report?.rows ?? []);
43847
43879
  const [itemQuery, setItemQuery] = (0, import_react44.useState)(report?.itemQuery);
@@ -43872,6 +43904,19 @@ function ChartBuilder({
43872
43904
  return col;
43873
43905
  }
43874
43906
  const newCol = { ...col };
43907
+ const reportField = reportFieldsByName[col.field];
43908
+ if (reportField && typeof reportField.dataTypeID === "number") {
43909
+ const converted = convertPostgresColumn({
43910
+ name: col.field,
43911
+ dataTypeID: reportField.dataTypeID
43912
+ });
43913
+ return {
43914
+ ...col,
43915
+ fieldType: col.fieldType ?? converted.fieldType,
43916
+ jsType: col.jsType ?? converted.jsType,
43917
+ dataTypeID: col.dataTypeID ?? converted.dataTypeID
43918
+ };
43919
+ }
43875
43920
  let foundColumn;
43876
43921
  schemaData.schemaWithCustomFields.forEach((table) => {
43877
43922
  if (table.columns) {
@@ -43884,6 +43929,18 @@ function ChartBuilder({
43884
43929
  }
43885
43930
  });
43886
43931
  if (!foundColumn) {
43932
+ if (typeof col.dataTypeID === "number") {
43933
+ const converted = convertPostgresColumn({
43934
+ field: col.field,
43935
+ dataTypeID: col.dataTypeID
43936
+ });
43937
+ return {
43938
+ ...col,
43939
+ fieldType: col.fieldType ?? converted.fieldType,
43940
+ jsType: col.jsType ?? converted.jsType,
43941
+ dataTypeID: col.dataTypeID ?? converted.dataTypeID
43942
+ };
43943
+ }
43887
43944
  return col;
43888
43945
  }
43889
43946
  newCol.fieldType = foundColumn.fieldType;
@@ -45362,6 +45419,9 @@ function ChartBuilder({
45362
45419
  ),
45363
45420
  pivotRows: selectedPivotTable?.rows || void 0,
45364
45421
  pivotColumns: selectedPivotTable?.columns || void 0,
45422
+ // Preserve underlying column metadata in the in-memory cache.
45423
+ // ChartEditor/ChartBuilder use this for Pivot form field options on edit-chart.
45424
+ columnInternal: report?.columnInternal ?? columns ?? [],
45365
45425
  triggerReload: true,
45366
45426
  error: void 0,
45367
45427
  section: formData.section
@@ -45980,9 +46040,9 @@ function ChartBuilder({
45980
46040
  /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
45981
46041
  SelectComponent,
45982
46042
  {
45983
- value: formData.pivot && isDateField(formData.pivot.rowFieldType ?? "") ? "string" : formData.xAxisFormat,
46043
+ value: formData.pivot && formData.xAxisField === formData.pivot.rowField && isDateField(formData.pivot.rowFieldType ?? "") ? "string" : formData.xAxisFormat,
45984
46044
  onChange: (e) => handleChange(e.target.value, "xAxisFormat"),
45985
- options: formData.pivot && isDateField(formData.pivot.rowFieldType ?? "") ? [{ value: "string", label: "date" }] : xAxisFormatOptions,
46045
+ options: formData.pivot && formData.xAxisField === formData.pivot.rowField && isDateField(formData.pivot.rowFieldType ?? "") ? [{ value: "string", label: "date" }] : xAxisFormatOptions,
45986
46046
  width: 200,
45987
46047
  hideEmptyOption: true
45988
46048
  }
package/dist/index.js CHANGED
@@ -392,7 +392,7 @@ var init_constants = __esm({
392
392
  "src/utils/constants.ts"() {
393
393
  "use strict";
394
394
  MAX_PIVOT_UNIQUE_VALUES = 250;
395
- QUILL_SERVER = typeof process !== "undefined" && process.env ? process.env.QUILL_SERVER_HOST ?? "https://quill-344421.uc.r.appspot.com" : "https://quill-344421.uc.r.appspot.com";
395
+ QUILL_SERVER = typeof process !== "undefined" && process.env ? process.env.QUILL_SERVER_HOST ?? "https://api.quill.co" : "https://api.quill.co";
396
396
  QUILL_QUERY_ENDPOINT = typeof process !== "undefined" && process.env ? process.env.QUILL_QUERY_ENDPOINT ?? "/cloud/engine" : "/cloud/engine";
397
397
  ALL_TENANTS = "QUILL_ALL_TENANTS";
398
398
  SINGLE_TENANT = "QUILL_SINGLE_TENANT";
@@ -24312,15 +24312,33 @@ var useDashboard = (dashboardName, config) => {
24312
24312
  const { eventTracking } = useContext(EventTrackingContext);
24313
24313
  const customFiltersRef = useRef2(customReportFilters);
24314
24314
  const reportRequestIds = useRef2({});
24315
+ const lastDashboardName = useRef2(null);
24316
+ const pendingNameChangeReload = useRef2(false);
24315
24317
  useEffect2(() => {
24316
24318
  customFiltersRef.current = customReportFilters;
24317
24319
  }, [customReportFilters]);
24318
24320
  useEffect2(() => {
24319
- if (!isLoading && !data && initialLoad.current) {
24321
+ const nameChanged = dashboardName !== lastDashboardName.current;
24322
+ if (nameChanged) {
24323
+ lastDashboardName.current = dashboardName ?? null;
24324
+ initialLoad.current = true;
24325
+ fetchedInitialReports.current = false;
24326
+ backfilledDashboards.current = false;
24327
+ reportRequestIds.current = {};
24328
+ pendingNameChangeReload.current = true;
24329
+ }
24330
+ if (!dashboardName) return;
24331
+ if (pendingNameChangeReload.current && data) {
24332
+ pendingNameChangeReload.current = false;
24333
+ initialLoad.current = false;
24334
+ return;
24335
+ }
24336
+ if (pendingNameChangeReload.current && !isLoading && !data && initialLoad.current) {
24320
24337
  initialLoad.current = false;
24338
+ pendingNameChangeReload.current = false;
24321
24339
  reload();
24322
24340
  }
24323
- }, [isLoading, data]);
24341
+ }, [isLoading, data, dashboardName]);
24324
24342
  useEffect2(() => {
24325
24343
  if (backfilledDashboards.current) return;
24326
24344
  if (isLoading || !data) return;
@@ -24330,7 +24348,7 @@ var useDashboard = (dashboardName, config) => {
24330
24348
  if (!needsBackfill) return;
24331
24349
  backfilledDashboards.current = true;
24332
24350
  reload(dashboardName, false);
24333
- }, [isLoading, data, dashboardFilters, dashboardName, reload]);
24351
+ }, [isLoading, data, dashboardFilters, dashboardName]);
24334
24352
  const { allReportsById } = useAllReports();
24335
24353
  const sections = useMemo2(() => {
24336
24354
  if (!data?.sections) return null;
@@ -43999,6 +44017,20 @@ function ChartBuilder({
43999
44017
  const resolvedReport = reportId && !tempReport ? allReportsById[reportId] : tempReport;
44000
44018
  return resolvedReport;
44001
44019
  }, [reportId, tempReport, allReportsById]);
44020
+ const reportFieldsByName = useMemo21(() => {
44021
+ const fields = report?.fields;
44022
+ if (!fields || fields.length === 0) {
44023
+ return {};
44024
+ }
44025
+ const map = {};
44026
+ for (const f of fields) {
44027
+ const key = f?.name ?? f?.field;
44028
+ if (key) {
44029
+ map[key] = f;
44030
+ }
44031
+ }
44032
+ return map;
44033
+ }, [report]);
44002
44034
  const [windowWidth, setWindowWidth] = useState29(1200);
44003
44035
  const [rows, setRows] = useState29(() => report?.rows ?? []);
44004
44036
  const [itemQuery, setItemQuery] = useState29(report?.itemQuery);
@@ -44029,6 +44061,19 @@ function ChartBuilder({
44029
44061
  return col;
44030
44062
  }
44031
44063
  const newCol = { ...col };
44064
+ const reportField = reportFieldsByName[col.field];
44065
+ if (reportField && typeof reportField.dataTypeID === "number") {
44066
+ const converted = convertPostgresColumn({
44067
+ name: col.field,
44068
+ dataTypeID: reportField.dataTypeID
44069
+ });
44070
+ return {
44071
+ ...col,
44072
+ fieldType: col.fieldType ?? converted.fieldType,
44073
+ jsType: col.jsType ?? converted.jsType,
44074
+ dataTypeID: col.dataTypeID ?? converted.dataTypeID
44075
+ };
44076
+ }
44032
44077
  let foundColumn;
44033
44078
  schemaData.schemaWithCustomFields.forEach((table) => {
44034
44079
  if (table.columns) {
@@ -44041,6 +44086,18 @@ function ChartBuilder({
44041
44086
  }
44042
44087
  });
44043
44088
  if (!foundColumn) {
44089
+ if (typeof col.dataTypeID === "number") {
44090
+ const converted = convertPostgresColumn({
44091
+ field: col.field,
44092
+ dataTypeID: col.dataTypeID
44093
+ });
44094
+ return {
44095
+ ...col,
44096
+ fieldType: col.fieldType ?? converted.fieldType,
44097
+ jsType: col.jsType ?? converted.jsType,
44098
+ dataTypeID: col.dataTypeID ?? converted.dataTypeID
44099
+ };
44100
+ }
44044
44101
  return col;
44045
44102
  }
44046
44103
  newCol.fieldType = foundColumn.fieldType;
@@ -45519,6 +45576,9 @@ function ChartBuilder({
45519
45576
  ),
45520
45577
  pivotRows: selectedPivotTable?.rows || void 0,
45521
45578
  pivotColumns: selectedPivotTable?.columns || void 0,
45579
+ // Preserve underlying column metadata in the in-memory cache.
45580
+ // ChartEditor/ChartBuilder use this for Pivot form field options on edit-chart.
45581
+ columnInternal: report?.columnInternal ?? columns ?? [],
45522
45582
  triggerReload: true,
45523
45583
  error: void 0,
45524
45584
  section: formData.section
@@ -46137,9 +46197,9 @@ function ChartBuilder({
46137
46197
  /* @__PURE__ */ jsx66(
46138
46198
  SelectComponent,
46139
46199
  {
46140
- value: formData.pivot && isDateField(formData.pivot.rowFieldType ?? "") ? "string" : formData.xAxisFormat,
46200
+ value: formData.pivot && formData.xAxisField === formData.pivot.rowField && isDateField(formData.pivot.rowFieldType ?? "") ? "string" : formData.xAxisFormat,
46141
46201
  onChange: (e) => handleChange(e.target.value, "xAxisFormat"),
46142
- options: formData.pivot && isDateField(formData.pivot.rowFieldType ?? "") ? [{ value: "string", label: "date" }] : xAxisFormatOptions,
46202
+ options: formData.pivot && formData.xAxisField === formData.pivot.rowField && isDateField(formData.pivot.rowFieldType ?? "") ? [{ value: "string", label: "date" }] : xAxisFormatOptions,
46143
46203
  width: 200,
46144
46204
  hideEmptyOption: true
46145
46205
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillsql/react",
3
- "version": "2.16.16",
3
+ "version": "2.16.18",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {