@quillsql/react 2.16.57 → 2.16.58

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
@@ -60837,7 +60837,12 @@ function isPivotTableDateBucketRowAxis(chart, xAxisField) {
60837
60837
  if (!rowField || xf !== rowField) return false;
60838
60838
  return isDateType(String(chart.pivot.rowFieldType ?? ""));
60839
60839
  }
60840
- var RESOLVABLE_X_AXIS_DATE_BUCKETS = /* @__PURE__ */ new Set(["year", "month", "day"]);
60840
+ var RESOLVABLE_X_AXIS_DATE_BUCKETS = /* @__PURE__ */ new Set([
60841
+ "year",
60842
+ "month",
60843
+ "week",
60844
+ "day"
60845
+ ]);
60841
60846
  function resolvePivotDateBucketXAxisFormat(chart, xAxisField) {
60842
60847
  if (String(chart?.chartType ?? "").toLowerCase() === "table") return null;
60843
60848
  const dateBucket = String(chart?.pivot?.dateBucket ?? "").trim().toLowerCase();
@@ -63400,6 +63405,7 @@ function useReport(reportIdArg, options = {}) {
63400
63405
  ].map((entry) => String(entry ?? "").trim()).find((entry) => entry.length > 0) ?? "";
63401
63406
  const initialFormState = (0, import_react61.useMemo)(
63402
63407
  () => ({
63408
+ reportName: void 0,
63403
63409
  columns: [],
63404
63410
  queryColumns: [],
63405
63411
  filterStack: [],
@@ -63430,6 +63436,7 @@ function useReport(reportIdArg, options = {}) {
63430
63436
  pivotRefreshVersion
63431
63437
  } = formRuntimeState;
63432
63438
  const {
63439
+ reportName: formReportName,
63433
63440
  columns: displayColumns,
63434
63441
  queryColumns,
63435
63442
  filterStack,
@@ -64474,6 +64481,7 @@ function useReport(reportIdArg, options = {}) {
64474
64481
  updater: (previous) => {
64475
64482
  return {
64476
64483
  ...previous,
64484
+ reportName: void 0,
64477
64485
  schemaDatasourceIds: void 0,
64478
64486
  filterStack: [],
64479
64487
  queryFilters: { combinator: "and", rules: [] },
@@ -64566,6 +64574,7 @@ function useReport(reportIdArg, options = {}) {
64566
64574
  const sourceReportNameForTitle = String(sourceReport?.name ?? "").trim();
64567
64575
  const reportTitleFromTask = String(reportNameQuery.data?.name ?? "").trim();
64568
64576
  const resolvedReportName = reportNameQueryReportId && sourceReportIdForTitle === reportNameQueryReportId && sourceReportNameForTitle ? sourceReportNameForTitle : reportTitleFromTask || sourceReportNameForTitle || "";
64577
+ const displayReportName = formReportName !== void 0 ? formReportName : resolvedReportName;
64569
64578
  (0, import_react61.useEffect)(() => {
64570
64579
  if (reportOverride) return;
64571
64580
  const report = initialLoadQuery.data?.report ?? null;
@@ -64669,12 +64678,15 @@ function useReport(reportIdArg, options = {}) {
64669
64678
  schemaTables: schemaForReportBuilderState
64670
64679
  });
64671
64680
  const sourceDisplayColumns = sourceDisplayColumnsFromSchema.length > 0 ? sourceDisplayColumnsFromSchema : sourceQueryColumns;
64672
- const nextGroupRowsBy = shouldTakePivotGroupsFromSource ? groupRowsBySetViaSetReportRef.current ? prev.groupRowsBy : sourceRowGroupOption : prev.groupRowsBy !== void 0 ? prev.groupRowsBy : groupRowsBySetViaSetReportRef.current ? prev.groupRowsBy : sourceRowGroupOption;
64673
- const nextGroupColumnsBy = shouldTakePivotGroupsFromSource ? groupColumnsBySetViaSetReportRef.current ? prev.groupColumnsBy : sourceColumnGroupOption : prev.groupColumnsBy !== void 0 ? prev.groupColumnsBy : prev.groupRowsBy !== void 0 ? prev.groupColumnsBy : sourceColumnGroupOption;
64681
+ const shouldKeepLocalRowGroup = groupRowsBySetViaSetReportRef.current || groupColumnsBySetViaSetReportRef.current && prev.groupRowsBy !== void 0;
64682
+ const shouldKeepLocalColumnGroup = groupColumnsBySetViaSetReportRef.current || groupRowsBySetViaSetReportRef.current && prev.groupColumnsBy !== void 0;
64683
+ const nextGroupRowsBy = shouldTakePivotGroupsFromSource ? shouldKeepLocalRowGroup ? prev.groupRowsBy : sourceRowGroupOption : prev.groupRowsBy !== void 0 ? prev.groupRowsBy : groupRowsBySetViaSetReportRef.current ? prev.groupRowsBy : sourceRowGroupOption;
64684
+ const nextGroupColumnsBy = shouldTakePivotGroupsFromSource ? shouldKeepLocalColumnGroup ? prev.groupColumnsBy : sourceColumnGroupOption : prev.groupColumnsBy !== void 0 ? prev.groupColumnsBy : prev.groupRowsBy !== void 0 ? prev.groupColumnsBy : sourceColumnGroupOption;
64674
64685
  const sourceDateBucket = sourceReport.pivot?.dateBucket ?? sourceReport.reportBuilderState?.pivot?.dateBucket;
64675
64686
  const nextDateBucket = dateBucketSetViaSetReportRef.current ? prev.dateBucket : sourceDateBucket;
64676
64687
  const nextFromSource = {
64677
64688
  ...prev,
64689
+ reportName: prev.reportName !== void 0 ? prev.reportName : String(sourceReport.name ?? "").trim() || void 0,
64678
64690
  queryColumns: prev.queryColumns.length ? prev.queryColumns : sourceQueryColumns,
64679
64691
  columns: prev.columns.length ? prev.columns : sourceDisplayColumns,
64680
64692
  filterStack: nextFilterStack.length > 0 ? nextFilterStack : prev.filterStack,
@@ -65261,11 +65273,7 @@ function useReport(reportIdArg, options = {}) {
65261
65273
  const report = tableRefreshQuery.data?.report;
65262
65274
  if (tableRefreshQuery.data?.error || !report) return;
65263
65275
  setSourceReport(report);
65264
- }, [
65265
- effectiveReportId,
65266
- tableRefreshQuery.data,
65267
- tableRefreshQueryEnabled
65268
- ]);
65276
+ }, [effectiveReportId, tableRefreshQuery.data, tableRefreshQueryEnabled]);
65269
65277
  const chartTypes = (0, import_react61.useMemo)(() => {
65270
65278
  return getChartTypeOptions2({ pivot: pivotState });
65271
65279
  }, [pivotState]);
@@ -66304,14 +66312,12 @@ function useReport(reportIdArg, options = {}) {
66304
66312
  chartAxisOptionByField.get(resolvedXAxisField)?.format ?? chartAxesBaseChart.xAxisFormat ?? resolvedYAxisFields[0]?.format,
66305
66313
  "string"
66306
66314
  );
66307
- if (defaultFormat === "string") {
66308
- const bucketFormat = resolvePivotDateBucketXAxisFormat(
66309
- chartAxesBaseChart,
66310
- resolvedXAxisField
66311
- );
66312
- if (bucketFormat) {
66313
- defaultFormat = bucketFormat;
66314
- }
66315
+ const bucketFormat = resolvePivotDateBucketXAxisFormat(
66316
+ chartAxesBaseChart,
66317
+ resolvedXAxisField
66318
+ );
66319
+ if (bucketFormat && (defaultFormat === "string" || chartAxesBaseChart.pivot?.dateBucket === "week")) {
66320
+ defaultFormat = bucketFormat;
66315
66321
  }
66316
66322
  if (isPivotTableDateBucketRowAxis(chartAxesBaseChart, resolvedXAxisField) && chartAxisEdits.xAxisFormat === void 0) {
66317
66323
  defaultFormat = "string";
@@ -67434,6 +67440,9 @@ function useReport(reportIdArg, options = {}) {
67434
67440
  columns: normalizeReportBuilderColumns(prev.columns ?? []),
67435
67441
  queryColumns: normalizeReportBuilderColumns(prev.queryColumns ?? [])
67436
67442
  };
67443
+ if (effectiveNextState.name !== void 0) {
67444
+ next.reportName = String(effectiveNextState.name);
67445
+ }
67437
67446
  if (effectiveNextState.datasources !== void 0) {
67438
67447
  const nextIds = effectiveNextState.datasources.map((tableName) => String(tableName ?? "").trim()).filter(Boolean);
67439
67448
  next.schemaDatasourceIds = nextIds.length > 0 ? nextIds : void 0;
@@ -67923,7 +67932,7 @@ function useReport(reportIdArg, options = {}) {
67923
67932
  report: {
67924
67933
  ...EMPTY_INTERNAL_REPORT,
67925
67934
  ...sourceRest,
67926
- name: String(sourceRest.name ?? "").trim() ? sourceRest.name : effectiveReportBuilderState.tables[0]?.name ? snakeAndCamelCaseToTitleCase(
67935
+ name: String(formReportName ?? "").trim() ? formReportName : String(sourceRest.name ?? "").trim() ? sourceRest.name : effectiveReportBuilderState.tables[0]?.name ? snakeAndCamelCaseToTitleCase(
67927
67936
  String(effectiveReportBuilderState.tables[0].name)
67928
67937
  ) : "New report",
67929
67938
  // Match chart rendering (`chartData`): form `chartType` wins over stale `sourceReport`.
@@ -67959,6 +67968,7 @@ function useReport(reportIdArg, options = {}) {
67959
67968
  effectiveReportBuilderState,
67960
67969
  effectiveReportId,
67961
67970
  eventTracking,
67971
+ formReportName,
67962
67972
  getToken,
67963
67973
  resolvedXAxisField,
67964
67974
  resolvedXAxisFormat,
@@ -67977,8 +67987,8 @@ function useReport(reportIdArg, options = {}) {
67977
67987
  table,
67978
67988
  tableLoading,
67979
67989
  loading,
67980
- /** Report title: matching `sourceReport.name`, else `report-name` task, else empty. */
67981
- name: resolvedReportName,
67990
+ /** Report title: form override, then `sourceReport.name`, else `report-name` task. */
67991
+ name: displayReportName,
67982
67992
  /**
67983
67993
  * Resolved report id: the `reportId` argument when provided, otherwise the id
67984
67994
  * returned from `create-report` after the first datasource selection.
package/dist/index.d.cts CHANGED
@@ -3004,6 +3004,8 @@ type SetReportChartAxesInput = {
3004
3004
  };
3005
3005
  };
3006
3006
  interface SetReportBuilderInput {
3007
+ /** Report display name, persisted by `saveChanges`. */
3008
+ name?: string;
3007
3009
  /** Complete selected column list in display order. */
3008
3010
  columns?: ReportColumnValue[];
3009
3011
  filters?: Filter[];
@@ -3186,7 +3188,7 @@ declare function useReport(reportIdArg?: string, options?: UseReportOptions): {
3186
3188
  table: UseFormTable;
3187
3189
  tableLoading: boolean;
3188
3190
  loading: boolean;
3189
- /** Report title: matching `sourceReport.name`, else `report-name` task, else empty. */
3191
+ /** Report title: form override, then `sourceReport.name`, else `report-name` task. */
3190
3192
  name: string;
3191
3193
  /**
3192
3194
  * Resolved report id: the `reportId` argument when provided, otherwise the id
package/dist/index.d.ts CHANGED
@@ -3004,6 +3004,8 @@ type SetReportChartAxesInput = {
3004
3004
  };
3005
3005
  };
3006
3006
  interface SetReportBuilderInput {
3007
+ /** Report display name, persisted by `saveChanges`. */
3008
+ name?: string;
3007
3009
  /** Complete selected column list in display order. */
3008
3010
  columns?: ReportColumnValue[];
3009
3011
  filters?: Filter[];
@@ -3186,7 +3188,7 @@ declare function useReport(reportIdArg?: string, options?: UseReportOptions): {
3186
3188
  table: UseFormTable;
3187
3189
  tableLoading: boolean;
3188
3190
  loading: boolean;
3189
- /** Report title: matching `sourceReport.name`, else `report-name` task, else empty. */
3191
+ /** Report title: form override, then `sourceReport.name`, else `report-name` task. */
3190
3192
  name: string;
3191
3193
  /**
3192
3194
  * Resolved report id: the `reportId` argument when provided, otherwise the id
package/dist/index.js CHANGED
@@ -61049,7 +61049,12 @@ function isPivotTableDateBucketRowAxis(chart, xAxisField) {
61049
61049
  if (!rowField || xf !== rowField) return false;
61050
61050
  return isDateType(String(chart.pivot.rowFieldType ?? ""));
61051
61051
  }
61052
- var RESOLVABLE_X_AXIS_DATE_BUCKETS = /* @__PURE__ */ new Set(["year", "month", "day"]);
61052
+ var RESOLVABLE_X_AXIS_DATE_BUCKETS = /* @__PURE__ */ new Set([
61053
+ "year",
61054
+ "month",
61055
+ "week",
61056
+ "day"
61057
+ ]);
61053
61058
  function resolvePivotDateBucketXAxisFormat(chart, xAxisField) {
61054
61059
  if (String(chart?.chartType ?? "").toLowerCase() === "table") return null;
61055
61060
  const dateBucket = String(chart?.pivot?.dateBucket ?? "").trim().toLowerCase();
@@ -63612,6 +63617,7 @@ function useReport(reportIdArg, options = {}) {
63612
63617
  ].map((entry) => String(entry ?? "").trim()).find((entry) => entry.length > 0) ?? "";
63613
63618
  const initialFormState = useMemo32(
63614
63619
  () => ({
63620
+ reportName: void 0,
63615
63621
  columns: [],
63616
63622
  queryColumns: [],
63617
63623
  filterStack: [],
@@ -63642,6 +63648,7 @@ function useReport(reportIdArg, options = {}) {
63642
63648
  pivotRefreshVersion
63643
63649
  } = formRuntimeState;
63644
63650
  const {
63651
+ reportName: formReportName,
63645
63652
  columns: displayColumns,
63646
63653
  queryColumns,
63647
63654
  filterStack,
@@ -64686,6 +64693,7 @@ function useReport(reportIdArg, options = {}) {
64686
64693
  updater: (previous) => {
64687
64694
  return {
64688
64695
  ...previous,
64696
+ reportName: void 0,
64689
64697
  schemaDatasourceIds: void 0,
64690
64698
  filterStack: [],
64691
64699
  queryFilters: { combinator: "and", rules: [] },
@@ -64778,6 +64786,7 @@ function useReport(reportIdArg, options = {}) {
64778
64786
  const sourceReportNameForTitle = String(sourceReport?.name ?? "").trim();
64779
64787
  const reportTitleFromTask = String(reportNameQuery.data?.name ?? "").trim();
64780
64788
  const resolvedReportName = reportNameQueryReportId && sourceReportIdForTitle === reportNameQueryReportId && sourceReportNameForTitle ? sourceReportNameForTitle : reportTitleFromTask || sourceReportNameForTitle || "";
64789
+ const displayReportName = formReportName !== void 0 ? formReportName : resolvedReportName;
64781
64790
  useEffect31(() => {
64782
64791
  if (reportOverride) return;
64783
64792
  const report = initialLoadQuery.data?.report ?? null;
@@ -64881,12 +64890,15 @@ function useReport(reportIdArg, options = {}) {
64881
64890
  schemaTables: schemaForReportBuilderState
64882
64891
  });
64883
64892
  const sourceDisplayColumns = sourceDisplayColumnsFromSchema.length > 0 ? sourceDisplayColumnsFromSchema : sourceQueryColumns;
64884
- const nextGroupRowsBy = shouldTakePivotGroupsFromSource ? groupRowsBySetViaSetReportRef.current ? prev.groupRowsBy : sourceRowGroupOption : prev.groupRowsBy !== void 0 ? prev.groupRowsBy : groupRowsBySetViaSetReportRef.current ? prev.groupRowsBy : sourceRowGroupOption;
64885
- const nextGroupColumnsBy = shouldTakePivotGroupsFromSource ? groupColumnsBySetViaSetReportRef.current ? prev.groupColumnsBy : sourceColumnGroupOption : prev.groupColumnsBy !== void 0 ? prev.groupColumnsBy : prev.groupRowsBy !== void 0 ? prev.groupColumnsBy : sourceColumnGroupOption;
64893
+ const shouldKeepLocalRowGroup = groupRowsBySetViaSetReportRef.current || groupColumnsBySetViaSetReportRef.current && prev.groupRowsBy !== void 0;
64894
+ const shouldKeepLocalColumnGroup = groupColumnsBySetViaSetReportRef.current || groupRowsBySetViaSetReportRef.current && prev.groupColumnsBy !== void 0;
64895
+ const nextGroupRowsBy = shouldTakePivotGroupsFromSource ? shouldKeepLocalRowGroup ? prev.groupRowsBy : sourceRowGroupOption : prev.groupRowsBy !== void 0 ? prev.groupRowsBy : groupRowsBySetViaSetReportRef.current ? prev.groupRowsBy : sourceRowGroupOption;
64896
+ const nextGroupColumnsBy = shouldTakePivotGroupsFromSource ? shouldKeepLocalColumnGroup ? prev.groupColumnsBy : sourceColumnGroupOption : prev.groupColumnsBy !== void 0 ? prev.groupColumnsBy : prev.groupRowsBy !== void 0 ? prev.groupColumnsBy : sourceColumnGroupOption;
64886
64897
  const sourceDateBucket = sourceReport.pivot?.dateBucket ?? sourceReport.reportBuilderState?.pivot?.dateBucket;
64887
64898
  const nextDateBucket = dateBucketSetViaSetReportRef.current ? prev.dateBucket : sourceDateBucket;
64888
64899
  const nextFromSource = {
64889
64900
  ...prev,
64901
+ reportName: prev.reportName !== void 0 ? prev.reportName : String(sourceReport.name ?? "").trim() || void 0,
64890
64902
  queryColumns: prev.queryColumns.length ? prev.queryColumns : sourceQueryColumns,
64891
64903
  columns: prev.columns.length ? prev.columns : sourceDisplayColumns,
64892
64904
  filterStack: nextFilterStack.length > 0 ? nextFilterStack : prev.filterStack,
@@ -65473,11 +65485,7 @@ function useReport(reportIdArg, options = {}) {
65473
65485
  const report = tableRefreshQuery.data?.report;
65474
65486
  if (tableRefreshQuery.data?.error || !report) return;
65475
65487
  setSourceReport(report);
65476
- }, [
65477
- effectiveReportId,
65478
- tableRefreshQuery.data,
65479
- tableRefreshQueryEnabled
65480
- ]);
65488
+ }, [effectiveReportId, tableRefreshQuery.data, tableRefreshQueryEnabled]);
65481
65489
  const chartTypes = useMemo32(() => {
65482
65490
  return getChartTypeOptions2({ pivot: pivotState });
65483
65491
  }, [pivotState]);
@@ -66516,14 +66524,12 @@ function useReport(reportIdArg, options = {}) {
66516
66524
  chartAxisOptionByField.get(resolvedXAxisField)?.format ?? chartAxesBaseChart.xAxisFormat ?? resolvedYAxisFields[0]?.format,
66517
66525
  "string"
66518
66526
  );
66519
- if (defaultFormat === "string") {
66520
- const bucketFormat = resolvePivotDateBucketXAxisFormat(
66521
- chartAxesBaseChart,
66522
- resolvedXAxisField
66523
- );
66524
- if (bucketFormat) {
66525
- defaultFormat = bucketFormat;
66526
- }
66527
+ const bucketFormat = resolvePivotDateBucketXAxisFormat(
66528
+ chartAxesBaseChart,
66529
+ resolvedXAxisField
66530
+ );
66531
+ if (bucketFormat && (defaultFormat === "string" || chartAxesBaseChart.pivot?.dateBucket === "week")) {
66532
+ defaultFormat = bucketFormat;
66527
66533
  }
66528
66534
  if (isPivotTableDateBucketRowAxis(chartAxesBaseChart, resolvedXAxisField) && chartAxisEdits.xAxisFormat === void 0) {
66529
66535
  defaultFormat = "string";
@@ -67646,6 +67652,9 @@ function useReport(reportIdArg, options = {}) {
67646
67652
  columns: normalizeReportBuilderColumns(prev.columns ?? []),
67647
67653
  queryColumns: normalizeReportBuilderColumns(prev.queryColumns ?? [])
67648
67654
  };
67655
+ if (effectiveNextState.name !== void 0) {
67656
+ next.reportName = String(effectiveNextState.name);
67657
+ }
67649
67658
  if (effectiveNextState.datasources !== void 0) {
67650
67659
  const nextIds = effectiveNextState.datasources.map((tableName) => String(tableName ?? "").trim()).filter(Boolean);
67651
67660
  next.schemaDatasourceIds = nextIds.length > 0 ? nextIds : void 0;
@@ -68135,7 +68144,7 @@ function useReport(reportIdArg, options = {}) {
68135
68144
  report: {
68136
68145
  ...EMPTY_INTERNAL_REPORT,
68137
68146
  ...sourceRest,
68138
- name: String(sourceRest.name ?? "").trim() ? sourceRest.name : effectiveReportBuilderState.tables[0]?.name ? snakeAndCamelCaseToTitleCase(
68147
+ name: String(formReportName ?? "").trim() ? formReportName : String(sourceRest.name ?? "").trim() ? sourceRest.name : effectiveReportBuilderState.tables[0]?.name ? snakeAndCamelCaseToTitleCase(
68139
68148
  String(effectiveReportBuilderState.tables[0].name)
68140
68149
  ) : "New report",
68141
68150
  // Match chart rendering (`chartData`): form `chartType` wins over stale `sourceReport`.
@@ -68171,6 +68180,7 @@ function useReport(reportIdArg, options = {}) {
68171
68180
  effectiveReportBuilderState,
68172
68181
  effectiveReportId,
68173
68182
  eventTracking,
68183
+ formReportName,
68174
68184
  getToken,
68175
68185
  resolvedXAxisField,
68176
68186
  resolvedXAxisFormat,
@@ -68189,8 +68199,8 @@ function useReport(reportIdArg, options = {}) {
68189
68199
  table,
68190
68200
  tableLoading,
68191
68201
  loading,
68192
- /** Report title: matching `sourceReport.name`, else `report-name` task, else empty. */
68193
- name: resolvedReportName,
68202
+ /** Report title: form override, then `sourceReport.name`, else `report-name` task. */
68203
+ name: displayReportName,
68194
68204
  /**
68195
68205
  * Resolved report id: the `reportId` argument when provided, otherwise the id
68196
68206
  * returned from `create-report` after the first datasource selection.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillsql/react",
3
- "version": "2.16.57",
3
+ "version": "2.16.58",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {