@quillsql/react 2.16.55 → 2.16.57

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
@@ -22575,7 +22575,8 @@ var formatRowsFromReport = (report, xAxisField, xAxisFormat) => {
22575
22575
  return formattedRow;
22576
22576
  });
22577
22577
  };
22578
- function formattedPivotRowsAndColumns(report, dashboardFilters = []) {
22578
+ function formattedPivotRowsAndColumns(report, dashboardFilters = [], options = {}) {
22579
+ const shouldFormatRows = options.formatRows ?? true;
22579
22580
  let columns = report.pivotColumns ?? report.columns;
22580
22581
  let rows = report.pivotRows ?? report.rows;
22581
22582
  if (report.chartType === "table") {
@@ -22591,12 +22592,16 @@ function formattedPivotRowsAndColumns(report, dashboardFilters = []) {
22591
22592
  format: col.format ?? "whole_number"
22592
22593
  };
22593
22594
  }) ?? report.columns;
22594
- rows = formatRowsFromReport({ rows, columns });
22595
+ if (shouldFormatRows) {
22596
+ rows = formatRowsFromReport({ rows, columns });
22597
+ }
22595
22598
  } else if (report.chartType === "metric") {
22596
22599
  columns = report.pivotColumns?.map((col) => {
22597
22600
  return { ...col, format: report.xAxisFormat };
22598
22601
  }) ?? report.columns;
22599
- rows = formatRowsFromReport({ rows, columns });
22602
+ if (shouldFormatRows) {
22603
+ rows = formatRowsFromReport({ rows, columns });
22604
+ }
22600
22605
  }
22601
22606
  const legacyPivotFormat = report.yAxisFields?.[0]?.format;
22602
22607
  const formattedYAxisFields = getYAxisFields(
@@ -22652,7 +22657,7 @@ function convertInternalReportToReport(report, dashboardFilters, eventTracking,
22652
22657
  report.xAxisField,
22653
22658
  report.xAxisFormat
22654
22659
  );
22655
- } else if (report.chartType === "table") {
22660
+ } else if (report.chartType === "table" && initiator !== "useDashboardReport") {
22656
22661
  rows = formatRowsFromReport(report);
22657
22662
  }
22658
22663
  return {
@@ -34150,8 +34155,7 @@ var createCustomBar = (yAxisFields, theme, layout, active = false) => {
34150
34155
  yAxisFields,
34151
34156
  theme,
34152
34157
  layout,
34153
- stroke: active ? theme?.primaryTextColor ?? "#111827" : props.stroke,
34154
- strokeWidth: active ? 1.5 : props.strokeWidth
34158
+ fillOpacity: active ? 0.8 : props.fillOpacity
34155
34159
  }
34156
34160
  );
34157
34161
  };
@@ -34402,24 +34406,27 @@ function BarChart({
34402
34406
  if (!payload || payload.length === 0) {
34403
34407
  return null;
34404
34408
  }
34405
- const activeLabel = label ?? payload[0]?.payload?.[xAxisField] ?? "";
34406
- const payloadItems = payload.map((p) => {
34407
- const rawName = yAxisFields?.find(
34408
- (f) => f.field === p.name?.toString()
34409
- )?.label;
34409
+ const row = payload[0]?.payload ?? {};
34410
+ const activeLabel = label ?? row[xAxisField] ?? "";
34411
+ const payloadItems = sortYAxisFields([
34412
+ ...yAxisFields
34413
+ ]).map((field) => {
34414
+ const rawName = field.label;
34410
34415
  const name2 = rawName ? humanizeChartSeriesTooltipLabel(rawName) : "";
34411
34416
  return {
34412
- ...p,
34413
- color: p.color || "black",
34414
34417
  chartType: "line",
34415
- dataKey: p.dataKey?.toLocaleString() || "",
34418
+ color: getCustomColor(field.field) ?? selectColor(
34419
+ field,
34420
+ colors,
34421
+ stableColorIndex(field.field)
34422
+ ),
34423
+ dataKey: field.field,
34416
34424
  name: snakeAndCamelCaseToTitleCase(
34417
- name2 || p.name?.toString() || ""
34425
+ name2 || field.field
34418
34426
  ),
34419
- payload: p.payload || {},
34420
- type: p.type || "none",
34421
- unit: "string",
34422
- value: p.value || ""
34427
+ payload: row,
34428
+ type: "none",
34429
+ value: row[field.field] ?? ""
34423
34430
  };
34424
34431
  });
34425
34432
  return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
@@ -34468,9 +34475,7 @@ function BarChart({
34468
34475
  isAnimationActive,
34469
34476
  shape: customBarShape,
34470
34477
  activeBar: customActiveBarShape ?? {
34471
- fillOpacity: 1,
34472
- stroke: theme?.primaryTextColor ?? "#111827",
34473
- strokeWidth: 1.5
34478
+ fillOpacity: 0.8
34474
34479
  },
34475
34480
  style: {
34476
34481
  cursor: onClickChartElement ? "pointer" : void 0
@@ -43595,7 +43600,7 @@ function StaticChart(props) {
43595
43600
  const config = (0, import_react41.useMemo)(() => {
43596
43601
  return report ? {
43597
43602
  ...report,
43598
- ...report.pivot ? formattedPivotRowsAndColumns(report) : {}
43603
+ ...report.pivot ? formattedPivotRowsAndColumns(report, [], { formatRows: false }) : {}
43599
43604
  } : void 0;
43600
43605
  }, [report]);
43601
43606
  if (error) {
@@ -65982,8 +65987,9 @@ function useReport(reportIdArg, options = {}) {
65982
65987
  return {
65983
65988
  ...previousReport,
65984
65989
  ...report,
65990
+ // Keep chart axis metadata from the pivot load; detail fetch is flat
65991
+ // (`pivot: null`) and must supply wide `columns` for the detail table.
65985
65992
  xAxisFormat: previousReport.xAxisFormat,
65986
- columns: previousReport.columns,
65987
65993
  yAxisFields: previousReport.yAxisFields,
65988
65994
  pivot: previousReport.pivot,
65989
65995
  pivotRows: previousReport.pivotRows,
@@ -67912,6 +67918,7 @@ function useReport(reportIdArg, options = {}) {
67912
67918
  adminMode: _omitAdminMode,
67913
67919
  ...sourceRest
67914
67920
  } = sourceReport;
67921
+ const isFlatTable = String(resolvedChartType).toLowerCase() === "table" && !effectiveReportBuilderState.pivot;
67915
67922
  const resp = await saveReport({
67916
67923
  report: {
67917
67924
  ...EMPTY_INTERNAL_REPORT,
@@ -67922,6 +67929,10 @@ function useReport(reportIdArg, options = {}) {
67922
67929
  // Match chart rendering (`chartData`): form `chartType` wins over stale `sourceReport`.
67923
67930
  chartType: resolvedChartType,
67924
67931
  dashboardName: dashboardNameForNewReport,
67932
+ ...isFlatTable ? {
67933
+ columns: table.columns,
67934
+ sort: effectiveReportBuilderState.sort?.[0] ?? null
67935
+ } : {},
67925
67936
  reportBuilderState: effectiveReportBuilderState,
67926
67937
  pivot: effectiveReportBuilderState.pivot ?? null,
67927
67938
  // Axis control state (measures / aggregation fields). Do not use
@@ -67956,6 +67967,7 @@ function useReport(reportIdArg, options = {}) {
67956
67967
  resolvedYAxisFields,
67957
67968
  sourceReport,
67958
67969
  setDraftSessionId,
67970
+ table.columns,
67959
67971
  tenants
67960
67972
  ]);
67961
67973
  return {
@@ -69070,7 +69082,8 @@ function ReportDetail({
69070
69082
  table,
69071
69083
  tableLoading,
69072
69084
  showLegend,
69073
- hideTableChartOuterBorder = false
69085
+ hideTableChartOuterBorder = false,
69086
+ onClickChartElement
69074
69087
  }) {
69075
69088
  const [theme] = (0, import_react65.useContext)(ThemeContext);
69076
69089
  const surfaceBackground = theme?.backgroundColor ?? "#fff";
@@ -69162,6 +69175,7 @@ function ReportDetail({
69162
69175
  flexShrink: 0
69163
69176
  },
69164
69177
  showLegend,
69178
+ onClickChartElement,
69165
69179
  tableChartWrapperBorders: hideTableChartOuterBorder && isTableChart ? {
69166
69180
  borderRadius: 0,
69167
69181
  borderLeft: "none",
package/dist/index.d.cts CHANGED
@@ -3421,8 +3421,10 @@ type ReportDetailProps = {
3421
3421
  showLegend?: boolean;
3422
3422
  /** Strip QuillTable's outer frame when chart type is `table` (cell borders unchanged). */
3423
3423
  hideTableChartOuterBorder?: boolean;
3424
+ /** Forwarded to `ChartDisplay` for chart element click interactions (e.g. drilldowns). */
3425
+ onClickChartElement?: (data: any) => void;
3424
3426
  };
3425
- declare function ReportDetail({ reportTitle, chart, chartLoading, table, tableLoading, showLegend, hideTableChartOuterBorder, }: ReportDetailProps): react_jsx_runtime.JSX.Element;
3427
+ declare function ReportDetail({ reportTitle, chart, chartLoading, table, tableLoading, showLegend, hideTableChartOuterBorder, onClickChartElement, }: ReportDetailProps): react_jsx_runtime.JSX.Element;
3426
3428
 
3427
3429
  declare const quillFormat: ({ value, format, }: {
3428
3430
  value: any;
package/dist/index.d.ts CHANGED
@@ -3421,8 +3421,10 @@ type ReportDetailProps = {
3421
3421
  showLegend?: boolean;
3422
3422
  /** Strip QuillTable's outer frame when chart type is `table` (cell borders unchanged). */
3423
3423
  hideTableChartOuterBorder?: boolean;
3424
+ /** Forwarded to `ChartDisplay` for chart element click interactions (e.g. drilldowns). */
3425
+ onClickChartElement?: (data: any) => void;
3424
3426
  };
3425
- declare function ReportDetail({ reportTitle, chart, chartLoading, table, tableLoading, showLegend, hideTableChartOuterBorder, }: ReportDetailProps): react_jsx_runtime.JSX.Element;
3427
+ declare function ReportDetail({ reportTitle, chart, chartLoading, table, tableLoading, showLegend, hideTableChartOuterBorder, onClickChartElement, }: ReportDetailProps): react_jsx_runtime.JSX.Element;
3426
3428
 
3427
3429
  declare const quillFormat: ({ value, format, }: {
3428
3430
  value: any;
package/dist/index.js CHANGED
@@ -22572,7 +22572,8 @@ var formatRowsFromReport = (report, xAxisField, xAxisFormat) => {
22572
22572
  return formattedRow;
22573
22573
  });
22574
22574
  };
22575
- function formattedPivotRowsAndColumns(report, dashboardFilters = []) {
22575
+ function formattedPivotRowsAndColumns(report, dashboardFilters = [], options = {}) {
22576
+ const shouldFormatRows = options.formatRows ?? true;
22576
22577
  let columns = report.pivotColumns ?? report.columns;
22577
22578
  let rows = report.pivotRows ?? report.rows;
22578
22579
  if (report.chartType === "table") {
@@ -22588,12 +22589,16 @@ function formattedPivotRowsAndColumns(report, dashboardFilters = []) {
22588
22589
  format: col.format ?? "whole_number"
22589
22590
  };
22590
22591
  }) ?? report.columns;
22591
- rows = formatRowsFromReport({ rows, columns });
22592
+ if (shouldFormatRows) {
22593
+ rows = formatRowsFromReport({ rows, columns });
22594
+ }
22592
22595
  } else if (report.chartType === "metric") {
22593
22596
  columns = report.pivotColumns?.map((col) => {
22594
22597
  return { ...col, format: report.xAxisFormat };
22595
22598
  }) ?? report.columns;
22596
- rows = formatRowsFromReport({ rows, columns });
22599
+ if (shouldFormatRows) {
22600
+ rows = formatRowsFromReport({ rows, columns });
22601
+ }
22597
22602
  }
22598
22603
  const legacyPivotFormat = report.yAxisFields?.[0]?.format;
22599
22604
  const formattedYAxisFields = getYAxisFields(
@@ -22649,7 +22654,7 @@ function convertInternalReportToReport(report, dashboardFilters, eventTracking,
22649
22654
  report.xAxisField,
22650
22655
  report.xAxisFormat
22651
22656
  );
22652
- } else if (report.chartType === "table") {
22657
+ } else if (report.chartType === "table" && initiator !== "useDashboardReport") {
22653
22658
  rows = formatRowsFromReport(report);
22654
22659
  }
22655
22660
  return {
@@ -34210,8 +34215,7 @@ var createCustomBar = (yAxisFields, theme, layout, active = false) => {
34210
34215
  yAxisFields,
34211
34216
  theme,
34212
34217
  layout,
34213
- stroke: active ? theme?.primaryTextColor ?? "#111827" : props.stroke,
34214
- strokeWidth: active ? 1.5 : props.strokeWidth
34218
+ fillOpacity: active ? 0.8 : props.fillOpacity
34215
34219
  }
34216
34220
  );
34217
34221
  };
@@ -34462,24 +34466,27 @@ function BarChart({
34462
34466
  if (!payload || payload.length === 0) {
34463
34467
  return null;
34464
34468
  }
34465
- const activeLabel = label ?? payload[0]?.payload?.[xAxisField] ?? "";
34466
- const payloadItems = payload.map((p) => {
34467
- const rawName = yAxisFields?.find(
34468
- (f) => f.field === p.name?.toString()
34469
- )?.label;
34469
+ const row = payload[0]?.payload ?? {};
34470
+ const activeLabel = label ?? row[xAxisField] ?? "";
34471
+ const payloadItems = sortYAxisFields([
34472
+ ...yAxisFields
34473
+ ]).map((field) => {
34474
+ const rawName = field.label;
34470
34475
  const name2 = rawName ? humanizeChartSeriesTooltipLabel(rawName) : "";
34471
34476
  return {
34472
- ...p,
34473
- color: p.color || "black",
34474
34477
  chartType: "line",
34475
- dataKey: p.dataKey?.toLocaleString() || "",
34478
+ color: getCustomColor(field.field) ?? selectColor(
34479
+ field,
34480
+ colors,
34481
+ stableColorIndex(field.field)
34482
+ ),
34483
+ dataKey: field.field,
34476
34484
  name: snakeAndCamelCaseToTitleCase(
34477
- name2 || p.name?.toString() || ""
34485
+ name2 || field.field
34478
34486
  ),
34479
- payload: p.payload || {},
34480
- type: p.type || "none",
34481
- unit: "string",
34482
- value: p.value || ""
34487
+ payload: row,
34488
+ type: "none",
34489
+ value: row[field.field] ?? ""
34483
34490
  };
34484
34491
  });
34485
34492
  return /* @__PURE__ */ jsx38(
@@ -34528,9 +34535,7 @@ function BarChart({
34528
34535
  isAnimationActive,
34529
34536
  shape: customBarShape,
34530
34537
  activeBar: customActiveBarShape ?? {
34531
- fillOpacity: 1,
34532
- stroke: theme?.primaryTextColor ?? "#111827",
34533
- strokeWidth: 1.5
34538
+ fillOpacity: 0.8
34534
34539
  },
34535
34540
  style: {
34536
34541
  cursor: onClickChartElement ? "pointer" : void 0
@@ -43698,7 +43703,7 @@ function StaticChart(props) {
43698
43703
  const config = useMemo20(() => {
43699
43704
  return report ? {
43700
43705
  ...report,
43701
- ...report.pivot ? formattedPivotRowsAndColumns(report) : {}
43706
+ ...report.pivot ? formattedPivotRowsAndColumns(report, [], { formatRows: false }) : {}
43702
43707
  } : void 0;
43703
43708
  }, [report]);
43704
43709
  if (error) {
@@ -66194,8 +66199,9 @@ function useReport(reportIdArg, options = {}) {
66194
66199
  return {
66195
66200
  ...previousReport,
66196
66201
  ...report,
66202
+ // Keep chart axis metadata from the pivot load; detail fetch is flat
66203
+ // (`pivot: null`) and must supply wide `columns` for the detail table.
66197
66204
  xAxisFormat: previousReport.xAxisFormat,
66198
- columns: previousReport.columns,
66199
66205
  yAxisFields: previousReport.yAxisFields,
66200
66206
  pivot: previousReport.pivot,
66201
66207
  pivotRows: previousReport.pivotRows,
@@ -68124,6 +68130,7 @@ function useReport(reportIdArg, options = {}) {
68124
68130
  adminMode: _omitAdminMode,
68125
68131
  ...sourceRest
68126
68132
  } = sourceReport;
68133
+ const isFlatTable = String(resolvedChartType).toLowerCase() === "table" && !effectiveReportBuilderState.pivot;
68127
68134
  const resp = await saveReport({
68128
68135
  report: {
68129
68136
  ...EMPTY_INTERNAL_REPORT,
@@ -68134,6 +68141,10 @@ function useReport(reportIdArg, options = {}) {
68134
68141
  // Match chart rendering (`chartData`): form `chartType` wins over stale `sourceReport`.
68135
68142
  chartType: resolvedChartType,
68136
68143
  dashboardName: dashboardNameForNewReport,
68144
+ ...isFlatTable ? {
68145
+ columns: table.columns,
68146
+ sort: effectiveReportBuilderState.sort?.[0] ?? null
68147
+ } : {},
68137
68148
  reportBuilderState: effectiveReportBuilderState,
68138
68149
  pivot: effectiveReportBuilderState.pivot ?? null,
68139
68150
  // Axis control state (measures / aggregation fields). Do not use
@@ -68168,6 +68179,7 @@ function useReport(reportIdArg, options = {}) {
68168
68179
  resolvedYAxisFields,
68169
68180
  sourceReport,
68170
68181
  setDraftSessionId,
68182
+ table.columns,
68171
68183
  tenants
68172
68184
  ]);
68173
68185
  return {
@@ -69287,7 +69299,8 @@ function ReportDetail({
69287
69299
  table,
69288
69300
  tableLoading,
69289
69301
  showLegend,
69290
- hideTableChartOuterBorder = false
69302
+ hideTableChartOuterBorder = false,
69303
+ onClickChartElement
69291
69304
  }) {
69292
69305
  const [theme] = useContext38(ThemeContext);
69293
69306
  const surfaceBackground = theme?.backgroundColor ?? "#fff";
@@ -69379,6 +69392,7 @@ function ReportDetail({
69379
69392
  flexShrink: 0
69380
69393
  },
69381
69394
  showLegend,
69395
+ onClickChartElement,
69382
69396
  tableChartWrapperBorders: hideTableChartOuterBorder && isTableChart ? {
69383
69397
  borderRadius: 0,
69384
69398
  borderLeft: "none",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillsql/react",
3
- "version": "2.16.55",
3
+ "version": "2.16.57",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {