@quillsql/react 2.16.6 → 2.16.8
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 +283 -35
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +288 -39
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -14416,9 +14416,15 @@ function convertCaseWhenToPivotData(column) {
|
|
|
14416
14416
|
return pivot;
|
|
14417
14417
|
}
|
|
14418
14418
|
function convertASTToPivotData(ast, columnInfo) {
|
|
14419
|
+
if (!ast) {
|
|
14420
|
+
return null;
|
|
14421
|
+
}
|
|
14419
14422
|
const newPivot = {};
|
|
14420
14423
|
const aliasMap = {};
|
|
14421
|
-
if (ast.columns === "*") {
|
|
14424
|
+
if (!ast.columns || ast.columns === "*") {
|
|
14425
|
+
return null;
|
|
14426
|
+
}
|
|
14427
|
+
if (!Array.isArray(ast.columns)) {
|
|
14422
14428
|
return null;
|
|
14423
14429
|
}
|
|
14424
14430
|
ast.columns.forEach((column) => {
|
|
@@ -14619,7 +14625,7 @@ var init_reportBuilder = __esm({
|
|
|
14619
14625
|
const schemaTable = schema.find((s) => s.name === table.name);
|
|
14620
14626
|
return schemaTable ? schemaTable.columns : [];
|
|
14621
14627
|
});
|
|
14622
|
-
const pivot = astGroupByToPivot(ast
|
|
14628
|
+
const pivot = astGroupByToPivot(ast, relevantColumns);
|
|
14623
14629
|
const sort = astOrderByToSort(ast.orderby);
|
|
14624
14630
|
const limit = astLimitToLimit(ast.limit);
|
|
14625
14631
|
const filterStack = generateFilterStack(
|
|
@@ -14646,11 +14652,11 @@ var init_reportBuilder = __esm({
|
|
|
14646
14652
|
};
|
|
14647
14653
|
});
|
|
14648
14654
|
};
|
|
14649
|
-
astGroupByToPivot = (
|
|
14650
|
-
if (!
|
|
14655
|
+
astGroupByToPivot = (ast, columnInfo) => {
|
|
14656
|
+
if (!ast || !ast.groupby) {
|
|
14651
14657
|
return null;
|
|
14652
14658
|
}
|
|
14653
|
-
return convertASTToPivotData(
|
|
14659
|
+
return convertASTToPivotData(ast, columnInfo);
|
|
14654
14660
|
};
|
|
14655
14661
|
astFromToTables = (node) => {
|
|
14656
14662
|
if (!node) {
|
|
@@ -24740,25 +24746,58 @@ var import_react5 = __toESM(require("react"), 1);
|
|
|
24740
24746
|
var import_recharts = require("recharts");
|
|
24741
24747
|
|
|
24742
24748
|
// src/utils/color.ts
|
|
24749
|
+
var DEFAULT_GRADIENT_COLORS = [
|
|
24750
|
+
"#4E80EE",
|
|
24751
|
+
// vivid indigo
|
|
24752
|
+
"#586FF4",
|
|
24753
|
+
"#6464FA",
|
|
24754
|
+
"#715AFE",
|
|
24755
|
+
"#8450FF",
|
|
24756
|
+
"#9B48FF",
|
|
24757
|
+
"#B33FFF",
|
|
24758
|
+
"#CA37F3",
|
|
24759
|
+
"#DE2FE1",
|
|
24760
|
+
"#F028CB",
|
|
24761
|
+
"#FF20B5"
|
|
24762
|
+
];
|
|
24743
24763
|
function generateArrayFromColor(colors, length) {
|
|
24764
|
+
if (length <= 0) {
|
|
24765
|
+
return [];
|
|
24766
|
+
}
|
|
24744
24767
|
if (typeof colors === "string") {
|
|
24745
|
-
|
|
24768
|
+
const trimmedColor = colors.trim();
|
|
24769
|
+
return monochromaticInterpolation(
|
|
24770
|
+
trimmedColor.length > 0 ? trimmedColor : DEFAULT_GRADIENT_COLORS[0],
|
|
24771
|
+
length
|
|
24772
|
+
);
|
|
24773
|
+
}
|
|
24774
|
+
const normalizedColors = colors.filter((color2) => typeof color2 === "string").map((color2) => color2.trim()).filter((color2) => color2.length > 0);
|
|
24775
|
+
const baseColors = normalizedColors.length > 0 ? normalizedColors : DEFAULT_GRADIENT_COLORS;
|
|
24776
|
+
if (baseColors.length === 1) {
|
|
24777
|
+
return monochromaticInterpolation(baseColors[0], length);
|
|
24746
24778
|
}
|
|
24747
|
-
if (
|
|
24748
|
-
return
|
|
24779
|
+
if (length <= baseColors.length) {
|
|
24780
|
+
return baseColors.slice(0, length);
|
|
24749
24781
|
}
|
|
24750
|
-
const pairs =
|
|
24751
|
-
|
|
24782
|
+
const pairs = baseColors.length - 1;
|
|
24783
|
+
if (pairs <= 0) {
|
|
24784
|
+
return [baseColors[0]];
|
|
24785
|
+
}
|
|
24786
|
+
const needed = length - baseColors.length;
|
|
24752
24787
|
const baseAmount = Math.floor(needed / pairs);
|
|
24753
24788
|
const extras = needed % pairs;
|
|
24754
24789
|
let result = [];
|
|
24755
24790
|
let i = 0;
|
|
24756
24791
|
let j = 1;
|
|
24757
|
-
while (j <
|
|
24792
|
+
while (j < baseColors.length) {
|
|
24758
24793
|
const additional = i < extras ? 1 : 0;
|
|
24759
24794
|
const interpLength = 2 + baseAmount + additional;
|
|
24760
|
-
const interp = interpolateBetween(
|
|
24761
|
-
|
|
24795
|
+
const interp = interpolateBetween(
|
|
24796
|
+
baseColors[i],
|
|
24797
|
+
baseColors[j],
|
|
24798
|
+
interpLength
|
|
24799
|
+
);
|
|
24800
|
+
const lastIndex = j === baseColors.length - 1 ? void 0 : -1;
|
|
24762
24801
|
result = result.concat(interp.slice(0, lastIndex));
|
|
24763
24802
|
i++;
|
|
24764
24803
|
j++;
|
|
@@ -25082,8 +25121,9 @@ var parseData2 = (data, colors, categoryKey, valueKey) => {
|
|
|
25082
25121
|
dataPoint[valueKey] = totalValue ? rawValue * 100 / totalValue : data.length > maxItems ? 100 / (maxItems + 1) : 100 / slicedData.length;
|
|
25083
25122
|
dataPoint[`raw_${valueKey}`] = parseFloat(rawValue.toFixed(2));
|
|
25084
25123
|
});
|
|
25124
|
+
const palette = colors.length >= maxItems ? colors.slice(0, maxItems) : generateArrayFromColor(colors, maxItems);
|
|
25085
25125
|
const parsedData = slicedData.map((dataPoint, idx) => {
|
|
25086
|
-
const baseColor =
|
|
25126
|
+
const baseColor = palette[idx % palette.length];
|
|
25087
25127
|
return {
|
|
25088
25128
|
...dataPoint,
|
|
25089
25129
|
color: baseColor,
|
|
@@ -25101,7 +25141,7 @@ var parseData2 = (data, colors, categoryKey, valueKey) => {
|
|
|
25101
25141
|
),
|
|
25102
25142
|
0
|
|
25103
25143
|
);
|
|
25104
|
-
const otherColor =
|
|
25144
|
+
const otherColor = palette[parsedData.length % palette.length] ?? palette[palette.length - 1];
|
|
25105
25145
|
const normalizedOtherSum = totalValue ? otherSum * 100 / totalValue : 100 / (maxItems + 1);
|
|
25106
25146
|
parsedData.push({
|
|
25107
25147
|
[categoryKey]: "Other",
|
|
@@ -25474,7 +25514,7 @@ var PieChartWrapper = import_react5.default.forwardRef(
|
|
|
25474
25514
|
(colorMap[category] && colorMap[category]["primary"] && generateArrayFromColor(
|
|
25475
25515
|
colorMap[category]["primary"],
|
|
25476
25516
|
data.length
|
|
25477
|
-
)) ?? (colors.length >= data.length ? colors : generateArrayFromColor(colors
|
|
25517
|
+
)) ?? (colors.length >= data.length ? colors : generateArrayFromColor(colors, data.length)),
|
|
25478
25518
|
index,
|
|
25479
25519
|
category
|
|
25480
25520
|
),
|
|
@@ -31807,7 +31847,16 @@ var MetricDisplay = ({
|
|
|
31807
31847
|
marginRight: "auto"
|
|
31808
31848
|
},
|
|
31809
31849
|
children: [
|
|
31810
|
-
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
31850
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
31851
|
+
"div",
|
|
31852
|
+
{
|
|
31853
|
+
style: {
|
|
31854
|
+
display: "inline-block",
|
|
31855
|
+
lineHeight: 1.1
|
|
31856
|
+
},
|
|
31857
|
+
children
|
|
31858
|
+
}
|
|
31859
|
+
),
|
|
31811
31860
|
dateFilter?.comparison && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
31812
31861
|
"span",
|
|
31813
31862
|
{
|
|
@@ -31836,13 +31885,15 @@ var MetricDisplay = ({
|
|
|
31836
31885
|
},
|
|
31837
31886
|
children: [
|
|
31838
31887
|
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
31839
|
-
"
|
|
31888
|
+
"div",
|
|
31840
31889
|
{
|
|
31841
31890
|
style: {
|
|
31842
31891
|
fontSize: 28,
|
|
31843
31892
|
fontWeight: "500",
|
|
31844
31893
|
fontFamily: theme?.fontFamily,
|
|
31845
|
-
color: theme?.secondaryTextColor
|
|
31894
|
+
color: theme?.secondaryTextColor,
|
|
31895
|
+
display: "inline-block",
|
|
31896
|
+
lineHeight: 1.1
|
|
31846
31897
|
},
|
|
31847
31898
|
children
|
|
31848
31899
|
}
|
|
@@ -39240,6 +39291,7 @@ var PivotCard = ({
|
|
|
39240
39291
|
}) => {
|
|
39241
39292
|
const defaultValueField = pivotTable.pivot && pivotTable.pivot.aggregationType === "count" ? "whole_number" : "two_decimal_places";
|
|
39242
39293
|
const maxRowsInPivotPeak = 5;
|
|
39294
|
+
const headerColumnCount = (pivotTable.pivot?.rowField ? 1 : 0) + (pivotTable.pivot?.columnField ? 1 : 0) + (!pivotTable.pivot?.columnField && pivotTable.pivot?.aggregations?.[0]?.valueField ? 1 : 0);
|
|
39243
39295
|
return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
39244
39296
|
CardComponent,
|
|
39245
39297
|
{
|
|
@@ -39343,16 +39395,16 @@ var PivotCard = ({
|
|
|
39343
39395
|
pivotTable.pivot.aggregations?.[0]?.valueField
|
|
39344
39396
|
)
|
|
39345
39397
|
] }) }),
|
|
39346
|
-
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
39398
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)("tbody", { children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
39347
39399
|
"tr",
|
|
39348
39400
|
{
|
|
39349
39401
|
style: {
|
|
39350
39402
|
paddingLeft: "2px",
|
|
39351
39403
|
width: "100%"
|
|
39352
39404
|
},
|
|
39353
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(TextComponent, { label: "No results" })
|
|
39405
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("td", { colSpan: headerColumnCount || 1, children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(TextComponent, { label: "No results" }) })
|
|
39354
39406
|
}
|
|
39355
|
-
)
|
|
39407
|
+
) })
|
|
39356
39408
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)("table", { children: [
|
|
39357
39409
|
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("tr", { children: pivotTable.columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
39358
39410
|
"th",
|
|
@@ -40714,7 +40766,7 @@ var PivotModal = ({
|
|
|
40714
40766
|
{
|
|
40715
40767
|
id: "pivot-row-field",
|
|
40716
40768
|
label: "Group rows by",
|
|
40717
|
-
value: pivotRowField,
|
|
40769
|
+
value: pivotRowField ?? "",
|
|
40718
40770
|
onChange: (e) => {
|
|
40719
40771
|
pivotFieldChange(
|
|
40720
40772
|
"rowField",
|
|
@@ -40741,7 +40793,7 @@ var PivotModal = ({
|
|
|
40741
40793
|
{
|
|
40742
40794
|
id: "pivot-column-field",
|
|
40743
40795
|
label: "Group columns by",
|
|
40744
|
-
value: pivotColumnField,
|
|
40796
|
+
value: pivotColumnField ?? "",
|
|
40745
40797
|
onChange: (e) => {
|
|
40746
40798
|
pivotFieldChange(
|
|
40747
40799
|
"columnField",
|
|
@@ -40786,7 +40838,7 @@ var PivotModal = ({
|
|
|
40786
40838
|
SelectComponent,
|
|
40787
40839
|
{
|
|
40788
40840
|
id: "pivot-aggregation-type",
|
|
40789
|
-
value: agg.aggregationType,
|
|
40841
|
+
value: agg.aggregationType ?? "",
|
|
40790
40842
|
onChange: (e) => {
|
|
40791
40843
|
const newAgg = [
|
|
40792
40844
|
...pivotAggregations.slice(0, index),
|
|
@@ -40818,7 +40870,7 @@ var PivotModal = ({
|
|
|
40818
40870
|
SelectComponent,
|
|
40819
40871
|
{
|
|
40820
40872
|
id: "pivot-value-field",
|
|
40821
|
-
value: agg.valueField,
|
|
40873
|
+
value: agg.valueField ?? "",
|
|
40822
40874
|
onChange: (e) => {
|
|
40823
40875
|
const newAgg = [
|
|
40824
40876
|
...pivotAggregations.slice(0, index),
|
|
@@ -42433,7 +42485,7 @@ var CHART_TO_LABELS = {
|
|
|
42433
42485
|
column: { xAxisLabel: "X-Axis", yAxisLabel: "Y-Axis" },
|
|
42434
42486
|
line: { xAxisLabel: "X-Axis", yAxisLabel: "Y-Axis" },
|
|
42435
42487
|
table: {},
|
|
42436
|
-
metric: {},
|
|
42488
|
+
metric: { xAxisLabel: "Value" },
|
|
42437
42489
|
bar: { xAxisLabel: "X-Axis", yAxisLabel: "Y-Axis" },
|
|
42438
42490
|
stacked: { xAxisLabel: "X-Axis", yAxisLabel: "Y-Axis" },
|
|
42439
42491
|
pie: { xAxisLabel: "Category", yAxisLabel: "Count" },
|
|
@@ -42863,7 +42915,7 @@ function ChartBuilder({
|
|
|
42863
42915
|
}
|
|
42864
42916
|
return columns2;
|
|
42865
42917
|
};
|
|
42866
|
-
const [
|
|
42918
|
+
const [columns, setColumns] = (0, import_react44.useState)(
|
|
42867
42919
|
processColumns(report?.columnInternal ?? [])
|
|
42868
42920
|
);
|
|
42869
42921
|
const [currentPage, setCurrentPage] = (0, import_react44.useState)(0);
|
|
@@ -42977,7 +43029,6 @@ function ChartBuilder({
|
|
|
42977
43029
|
pivotQuery: report.pivotQuery ?? "",
|
|
42978
43030
|
comparisonPivotQuery: report.comparisonPivotQuery
|
|
42979
43031
|
} : void 0;
|
|
42980
|
-
const columns = report?.columnInternal ?? [];
|
|
42981
43032
|
const destinationDashboardName = report?.dashboardName || destinationDashboard;
|
|
42982
43033
|
const query = report?.queryString;
|
|
42983
43034
|
const [loadingFormData, setLoadingFormData] = (0, import_react44.useState)(false);
|
|
@@ -43529,6 +43580,26 @@ function ChartBuilder({
|
|
|
43529
43580
|
) ?? {};
|
|
43530
43581
|
}, [client?.allTenantTypes]);
|
|
43531
43582
|
const [selectedPivotTable, setSelectedPivotTable] = (0, import_react44.useState)(pivotData);
|
|
43583
|
+
const getDefaultXAxisFormat = (0, import_react44.useCallback)(
|
|
43584
|
+
(form) => {
|
|
43585
|
+
if (form.pivot?.rowField) {
|
|
43586
|
+
if (isDateField(form.pivot.rowFieldType ?? "")) {
|
|
43587
|
+
return "string";
|
|
43588
|
+
}
|
|
43589
|
+
const pivotRowColumn = selectedPivotTable?.columns?.find(
|
|
43590
|
+
(col) => col.field === form.pivot?.rowField
|
|
43591
|
+
) ?? columns.find((col) => col.field === form.pivot?.rowField);
|
|
43592
|
+
if (pivotRowColumn?.format) {
|
|
43593
|
+
return pivotRowColumn.format;
|
|
43594
|
+
}
|
|
43595
|
+
}
|
|
43596
|
+
const currentXAxisColumn = (selectedPivotTable?.columns ?? columns).find(
|
|
43597
|
+
(c) => c.field === form.xAxisField
|
|
43598
|
+
);
|
|
43599
|
+
return currentXAxisColumn?.format ?? "string";
|
|
43600
|
+
},
|
|
43601
|
+
[columns, selectedPivotTable]
|
|
43602
|
+
);
|
|
43532
43603
|
const pivotCardTable = (0, import_react44.useMemo)(() => {
|
|
43533
43604
|
return {
|
|
43534
43605
|
pivot: formData.pivot,
|
|
@@ -43745,7 +43816,8 @@ function ChartBuilder({
|
|
|
43745
43816
|
});
|
|
43746
43817
|
setCurrentProcessing(processing);
|
|
43747
43818
|
setRows(tableInfo.rows);
|
|
43748
|
-
|
|
43819
|
+
const updatedColumns = processColumns(tableInfo.columns);
|
|
43820
|
+
setColumns(updatedColumns);
|
|
43749
43821
|
if (tableInfo.itemQuery) {
|
|
43750
43822
|
setItemQuery(tableInfo.itemQuery);
|
|
43751
43823
|
}
|
|
@@ -43962,6 +44034,7 @@ function ChartBuilder({
|
|
|
43962
44034
|
updatedForm = { ...updatedForm, [fieldName]: value };
|
|
43963
44035
|
}
|
|
43964
44036
|
if (fieldName === "chartType") {
|
|
44037
|
+
const previousChartType = formData.chartType;
|
|
43965
44038
|
if (value === "metric") {
|
|
43966
44039
|
updatedForm.xAxisFormat = "whole_number";
|
|
43967
44040
|
const currentXAxisColumn = (selectedPivotTable?.columns ?? columns).find((c) => c.field === updatedForm.xAxisField);
|
|
@@ -43978,6 +44051,16 @@ function ChartBuilder({
|
|
|
43978
44051
|
(c) => NUMBER_FORMAT_TYPES.includes(c.format)
|
|
43979
44052
|
)?.field ?? updatedForm.xAxisField;
|
|
43980
44053
|
}
|
|
44054
|
+
} else {
|
|
44055
|
+
if (previousChartType === "gauge" && updatedForm.xAxisFormat === "percent") {
|
|
44056
|
+
updatedForm.xAxisFormat = getDefaultXAxisFormat(updatedForm);
|
|
44057
|
+
}
|
|
44058
|
+
if (previousChartType === "metric" && updatedForm.xAxisFormat === "whole_number") {
|
|
44059
|
+
updatedForm.xAxisFormat = getDefaultXAxisFormat(updatedForm);
|
|
44060
|
+
}
|
|
44061
|
+
if (previousChartType === "gauge" && updatedForm.pivot?.rowField && updatedForm.xAxisField !== updatedForm.pivot.rowField) {
|
|
44062
|
+
updatedForm.xAxisField = updatedForm.pivot.rowField;
|
|
44063
|
+
}
|
|
43981
44064
|
}
|
|
43982
44065
|
}
|
|
43983
44066
|
let dashboardName = updatedForm.dashboardName;
|
|
@@ -44680,7 +44763,7 @@ function ChartBuilder({
|
|
|
44680
44763
|
setShowUpdatePivot: setIsEdittingPivot,
|
|
44681
44764
|
parentRef,
|
|
44682
44765
|
data: rows,
|
|
44683
|
-
columns
|
|
44766
|
+
columns,
|
|
44684
44767
|
triggerButtonText: "Add pivot +",
|
|
44685
44768
|
selectedPivotIndex,
|
|
44686
44769
|
setSelectedPivotIndex,
|
|
@@ -44754,7 +44837,7 @@ function ChartBuilder({
|
|
|
44754
44837
|
]
|
|
44755
44838
|
}
|
|
44756
44839
|
),
|
|
44757
|
-
!hideChartView && (formData.pivot || formData.chartType !== "table"
|
|
44840
|
+
!hideChartView && (formData.pivot || formData.chartType !== "table") && /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)("div", { children: [
|
|
44758
44841
|
CHART_TO_LABELS[formData.chartType]?.xAxisLabel && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
44759
44842
|
"div",
|
|
44760
44843
|
{
|
|
@@ -46321,6 +46404,166 @@ function setEditorTheme(_editor, monaco, schema, databaseType, clientName, event
|
|
|
46321
46404
|
return null;
|
|
46322
46405
|
}
|
|
46323
46406
|
}
|
|
46407
|
+
function reconcileReportWithColumns(report, columns, previousReport) {
|
|
46408
|
+
const safeColumns = columns ?? [];
|
|
46409
|
+
const fallbackForm = createInitialFormData(safeColumns);
|
|
46410
|
+
const columnFieldSet = new Set(
|
|
46411
|
+
safeColumns.map((column) => column.field).filter(Boolean)
|
|
46412
|
+
);
|
|
46413
|
+
const previousColumnsByField = new Map(
|
|
46414
|
+
(previousReport?.columns ?? []).map((column) => [column.field, column])
|
|
46415
|
+
);
|
|
46416
|
+
const previousColumnInternalByField = new Map(
|
|
46417
|
+
(previousReport?.columnInternal ?? []).map((column) => [
|
|
46418
|
+
column.field,
|
|
46419
|
+
column
|
|
46420
|
+
])
|
|
46421
|
+
);
|
|
46422
|
+
const existingColumnsByField = new Map(
|
|
46423
|
+
(report.columns ?? []).map((column) => [column.field, column])
|
|
46424
|
+
);
|
|
46425
|
+
const existingColumnInternalByField = new Map(
|
|
46426
|
+
(report.columnInternal ?? []).map((column) => [column.field, column])
|
|
46427
|
+
);
|
|
46428
|
+
const reconciledColumnInternal = safeColumns.map((column) => {
|
|
46429
|
+
const fallback = existingColumnInternalByField.get(column.field) ?? previousColumnInternalByField.get(column.field) ?? existingColumnsByField.get(column.field) ?? previousColumnsByField.get(column.field);
|
|
46430
|
+
return {
|
|
46431
|
+
...column,
|
|
46432
|
+
format: fallback?.format ?? column.format,
|
|
46433
|
+
label: fallback?.label ?? column.label
|
|
46434
|
+
};
|
|
46435
|
+
});
|
|
46436
|
+
const reconciledColumns = reconciledColumnInternal.map((column) => ({
|
|
46437
|
+
field: column.field,
|
|
46438
|
+
label: column.label,
|
|
46439
|
+
format: column.format
|
|
46440
|
+
}));
|
|
46441
|
+
const resolveXAxisField = () => {
|
|
46442
|
+
if (report.xAxisField && columnFieldSet.has(report.xAxisField)) {
|
|
46443
|
+
return report.xAxisField;
|
|
46444
|
+
}
|
|
46445
|
+
if (previousReport?.xAxisField && columnFieldSet.has(previousReport.xAxisField)) {
|
|
46446
|
+
return previousReport.xAxisField;
|
|
46447
|
+
}
|
|
46448
|
+
return fallbackForm.xAxisField;
|
|
46449
|
+
};
|
|
46450
|
+
const xAxisField = resolveXAxisField();
|
|
46451
|
+
const xAxisColumn = reconciledColumnInternal.find(
|
|
46452
|
+
(column) => column.field === xAxisField
|
|
46453
|
+
);
|
|
46454
|
+
const xAxisFormat = (report.xAxisField === xAxisField ? report.xAxisFormat : void 0) ?? (previousReport?.xAxisField === xAxisField ? previousReport.xAxisFormat : void 0) ?? xAxisColumn?.format ?? fallbackForm.xAxisFormat ?? "string";
|
|
46455
|
+
const xAxisLabel = report.xAxisField === xAxisField ? report.xAxisLabel : previousReport?.xAxisField === xAxisField ? previousReport.xAxisLabel : fallbackForm.xAxisLabel ?? "";
|
|
46456
|
+
const existingYAxisFields = report.yAxisFields ?? previousReport?.yAxisFields ?? [];
|
|
46457
|
+
let yAxisFields = existingYAxisFields.filter((axis) => axis?.field && columnFieldSet.has(axis.field)).map((axis) => {
|
|
46458
|
+
const column = reconciledColumnInternal.find(
|
|
46459
|
+
(col) => col.field === axis.field
|
|
46460
|
+
);
|
|
46461
|
+
return {
|
|
46462
|
+
field: axis.field,
|
|
46463
|
+
label: axis.label,
|
|
46464
|
+
format: axis.format ?? column?.format ?? "string"
|
|
46465
|
+
};
|
|
46466
|
+
});
|
|
46467
|
+
if (yAxisFields.length === 0) {
|
|
46468
|
+
yAxisFields = fallbackForm.yAxisFields;
|
|
46469
|
+
}
|
|
46470
|
+
const existingReferenceLines = report.referenceLines ?? previousReport?.referenceLines ?? [];
|
|
46471
|
+
const referenceLines = existingReferenceLines.filter((line) => {
|
|
46472
|
+
if (line.label === REFERENCE_LINE) {
|
|
46473
|
+
return true;
|
|
46474
|
+
}
|
|
46475
|
+
return typeof line.label === "string" && columnFieldSet.has(line.label);
|
|
46476
|
+
});
|
|
46477
|
+
const existingReferenceLineYValues = report.referenceLineYValues ?? previousReport?.referenceLineYValues ?? [];
|
|
46478
|
+
const referenceLineYValues = existingReferenceLineYValues.filter((line) => {
|
|
46479
|
+
if (line.label === REFERENCE_LINE) {
|
|
46480
|
+
return true;
|
|
46481
|
+
}
|
|
46482
|
+
return typeof line.label === "string" && columnFieldSet.has(line.label);
|
|
46483
|
+
});
|
|
46484
|
+
const existingColumnsWithCustomFields = report.columnsWithCustomFields ?? previousReport?.columnsWithCustomFields ?? [];
|
|
46485
|
+
const columnsWithCustomFields = existingColumnsWithCustomFields.filter(
|
|
46486
|
+
(column) => columnFieldSet.has(column.field)
|
|
46487
|
+
);
|
|
46488
|
+
const existingFilterMap = report.filterMap ?? previousReport?.filterMap;
|
|
46489
|
+
const filterMap = existingFilterMap ? Object.fromEntries(
|
|
46490
|
+
Object.entries(existingFilterMap).filter(([, value]) => {
|
|
46491
|
+
return value.field && columnFieldSet.has(value.field);
|
|
46492
|
+
})
|
|
46493
|
+
) : existingFilterMap;
|
|
46494
|
+
const existingFiltersApplied = report.filtersApplied ?? previousReport?.filtersApplied;
|
|
46495
|
+
const filtersApplied = existingFiltersApplied ? existingFiltersApplied.filter((filter) => {
|
|
46496
|
+
if (!filter.field) {
|
|
46497
|
+
return true;
|
|
46498
|
+
}
|
|
46499
|
+
return columnFieldSet.has(filter.field);
|
|
46500
|
+
}) : existingFiltersApplied;
|
|
46501
|
+
const existingSort = report.sort ?? previousReport?.sort;
|
|
46502
|
+
const sort = existingSort && columnFieldSet.has(existingSort.field) ? existingSort : void 0;
|
|
46503
|
+
let pivot = report.pivot ?? previousReport?.pivot ?? null;
|
|
46504
|
+
if (pivot) {
|
|
46505
|
+
const pivotFields = [];
|
|
46506
|
+
if (pivot.rowField) {
|
|
46507
|
+
pivotFields.push(pivot.rowField);
|
|
46508
|
+
}
|
|
46509
|
+
if (pivot.columnField) {
|
|
46510
|
+
pivotFields.push(pivot.columnField);
|
|
46511
|
+
}
|
|
46512
|
+
if ("aggregations" in pivot && Array.isArray(pivot.aggregations)) {
|
|
46513
|
+
pivot.aggregations.forEach((aggregation) => {
|
|
46514
|
+
if (aggregation.valueField) {
|
|
46515
|
+
pivotFields.push(aggregation.valueField);
|
|
46516
|
+
}
|
|
46517
|
+
if (aggregation.valueField2) {
|
|
46518
|
+
pivotFields.push(aggregation.valueField2);
|
|
46519
|
+
}
|
|
46520
|
+
});
|
|
46521
|
+
} else {
|
|
46522
|
+
const singleAggregation = pivot;
|
|
46523
|
+
if (singleAggregation.valueField) {
|
|
46524
|
+
pivotFields.push(singleAggregation.valueField);
|
|
46525
|
+
}
|
|
46526
|
+
if (singleAggregation.valueField2) {
|
|
46527
|
+
pivotFields.push(singleAggregation.valueField2);
|
|
46528
|
+
}
|
|
46529
|
+
}
|
|
46530
|
+
if (pivot.sortField) {
|
|
46531
|
+
pivotFields.push(pivot.sortField);
|
|
46532
|
+
}
|
|
46533
|
+
const missingPivotField = pivotFields.some(
|
|
46534
|
+
(field) => field && !columnFieldSet.has(field)
|
|
46535
|
+
);
|
|
46536
|
+
if (missingPivotField) {
|
|
46537
|
+
pivot = null;
|
|
46538
|
+
}
|
|
46539
|
+
}
|
|
46540
|
+
const pivotColumns = pivot ? (report.pivotColumns ?? previousReport?.pivotColumns)?.filter(
|
|
46541
|
+
(column) => columnFieldSet.has(column.field)
|
|
46542
|
+
) : void 0;
|
|
46543
|
+
const pivotRows = pivot ? report.pivotRows ?? previousReport?.pivotRows : void 0;
|
|
46544
|
+
const pivotRowCount = pivot ? report.pivotRowCount ?? previousReport?.pivotRowCount : void 0;
|
|
46545
|
+
return {
|
|
46546
|
+
...report,
|
|
46547
|
+
columns: reconciledColumns,
|
|
46548
|
+
columnInternal: reconciledColumnInternal,
|
|
46549
|
+
columnsWithCustomFields,
|
|
46550
|
+
xAxisField,
|
|
46551
|
+
xAxisFormat,
|
|
46552
|
+
xAxisLabel,
|
|
46553
|
+
yAxisFields,
|
|
46554
|
+
referenceLines,
|
|
46555
|
+
referenceLineYValues: referenceLineYValues.length ? referenceLineYValues : void 0,
|
|
46556
|
+
filterMap: filterMap && Object.keys(filterMap).length ? filterMap : void 0,
|
|
46557
|
+
filtersApplied: filtersApplied && filtersApplied.length ? filtersApplied : void 0,
|
|
46558
|
+
sort,
|
|
46559
|
+
pivot,
|
|
46560
|
+
pivotColumns,
|
|
46561
|
+
pivotRows,
|
|
46562
|
+
pivotRowCount,
|
|
46563
|
+
pivotQuery: pivot ? report.pivotQuery ?? previousReport?.pivotQuery : void 0,
|
|
46564
|
+
comparisonPivotQuery: pivot ? report.comparisonPivotQuery ?? previousReport?.comparisonPivotQuery : void 0
|
|
46565
|
+
};
|
|
46566
|
+
}
|
|
46324
46567
|
function SQLEditor({
|
|
46325
46568
|
ButtonComponent = MemoizedButton,
|
|
46326
46569
|
SecondaryButtonComponent = MemoizedSecondaryButton,
|
|
@@ -46699,12 +46942,17 @@ function SQLEditor({
|
|
|
46699
46942
|
referencedTables: tableInfo.referencedTables,
|
|
46700
46943
|
queryString: query ?? tempReport.queryString ?? ""
|
|
46701
46944
|
};
|
|
46945
|
+
const reconciledReport = reconcileReportWithColumns(
|
|
46946
|
+
newReport,
|
|
46947
|
+
tableInfo.columns ?? [],
|
|
46948
|
+
tempReport
|
|
46949
|
+
);
|
|
46702
46950
|
if (reportId) {
|
|
46703
|
-
setTempReport(
|
|
46951
|
+
setTempReport(reconciledReport);
|
|
46704
46952
|
} else {
|
|
46705
46953
|
const cleaned = await cleanDashboardItem({
|
|
46706
|
-
item:
|
|
46707
|
-
dashboardFilters:
|
|
46954
|
+
item: reconciledReport,
|
|
46955
|
+
dashboardFilters: reconciledReport.filtersApplied,
|
|
46708
46956
|
client,
|
|
46709
46957
|
customFields: schemaData.customFields,
|
|
46710
46958
|
getToken,
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -14453,9 +14453,15 @@ function convertCaseWhenToPivotData(column) {
|
|
|
14453
14453
|
return pivot;
|
|
14454
14454
|
}
|
|
14455
14455
|
function convertASTToPivotData(ast, columnInfo) {
|
|
14456
|
+
if (!ast) {
|
|
14457
|
+
return null;
|
|
14458
|
+
}
|
|
14456
14459
|
const newPivot = {};
|
|
14457
14460
|
const aliasMap = {};
|
|
14458
|
-
if (ast.columns === "*") {
|
|
14461
|
+
if (!ast.columns || ast.columns === "*") {
|
|
14462
|
+
return null;
|
|
14463
|
+
}
|
|
14464
|
+
if (!Array.isArray(ast.columns)) {
|
|
14459
14465
|
return null;
|
|
14460
14466
|
}
|
|
14461
14467
|
ast.columns.forEach((column) => {
|
|
@@ -14656,7 +14662,7 @@ var init_reportBuilder = __esm({
|
|
|
14656
14662
|
const schemaTable = schema.find((s) => s.name === table.name);
|
|
14657
14663
|
return schemaTable ? schemaTable.columns : [];
|
|
14658
14664
|
});
|
|
14659
|
-
const pivot = astGroupByToPivot(ast
|
|
14665
|
+
const pivot = astGroupByToPivot(ast, relevantColumns);
|
|
14660
14666
|
const sort = astOrderByToSort(ast.orderby);
|
|
14661
14667
|
const limit = astLimitToLimit(ast.limit);
|
|
14662
14668
|
const filterStack = generateFilterStack(
|
|
@@ -14683,11 +14689,11 @@ var init_reportBuilder = __esm({
|
|
|
14683
14689
|
};
|
|
14684
14690
|
});
|
|
14685
14691
|
};
|
|
14686
|
-
astGroupByToPivot = (
|
|
14687
|
-
if (!
|
|
14692
|
+
astGroupByToPivot = (ast, columnInfo) => {
|
|
14693
|
+
if (!ast || !ast.groupby) {
|
|
14688
14694
|
return null;
|
|
14689
14695
|
}
|
|
14690
|
-
return convertASTToPivotData(
|
|
14696
|
+
return convertASTToPivotData(ast, columnInfo);
|
|
14691
14697
|
};
|
|
14692
14698
|
astFromToTables = (node) => {
|
|
14693
14699
|
if (!node) {
|
|
@@ -24754,25 +24760,58 @@ import React3 from "react";
|
|
|
24754
24760
|
import { Pie, PieChart, ResponsiveContainer, Tooltip } from "recharts";
|
|
24755
24761
|
|
|
24756
24762
|
// src/utils/color.ts
|
|
24763
|
+
var DEFAULT_GRADIENT_COLORS = [
|
|
24764
|
+
"#4E80EE",
|
|
24765
|
+
// vivid indigo
|
|
24766
|
+
"#586FF4",
|
|
24767
|
+
"#6464FA",
|
|
24768
|
+
"#715AFE",
|
|
24769
|
+
"#8450FF",
|
|
24770
|
+
"#9B48FF",
|
|
24771
|
+
"#B33FFF",
|
|
24772
|
+
"#CA37F3",
|
|
24773
|
+
"#DE2FE1",
|
|
24774
|
+
"#F028CB",
|
|
24775
|
+
"#FF20B5"
|
|
24776
|
+
];
|
|
24757
24777
|
function generateArrayFromColor(colors, length) {
|
|
24778
|
+
if (length <= 0) {
|
|
24779
|
+
return [];
|
|
24780
|
+
}
|
|
24758
24781
|
if (typeof colors === "string") {
|
|
24759
|
-
|
|
24782
|
+
const trimmedColor = colors.trim();
|
|
24783
|
+
return monochromaticInterpolation(
|
|
24784
|
+
trimmedColor.length > 0 ? trimmedColor : DEFAULT_GRADIENT_COLORS[0],
|
|
24785
|
+
length
|
|
24786
|
+
);
|
|
24787
|
+
}
|
|
24788
|
+
const normalizedColors = colors.filter((color2) => typeof color2 === "string").map((color2) => color2.trim()).filter((color2) => color2.length > 0);
|
|
24789
|
+
const baseColors = normalizedColors.length > 0 ? normalizedColors : DEFAULT_GRADIENT_COLORS;
|
|
24790
|
+
if (baseColors.length === 1) {
|
|
24791
|
+
return monochromaticInterpolation(baseColors[0], length);
|
|
24760
24792
|
}
|
|
24761
|
-
if (
|
|
24762
|
-
return
|
|
24793
|
+
if (length <= baseColors.length) {
|
|
24794
|
+
return baseColors.slice(0, length);
|
|
24763
24795
|
}
|
|
24764
|
-
const pairs =
|
|
24765
|
-
|
|
24796
|
+
const pairs = baseColors.length - 1;
|
|
24797
|
+
if (pairs <= 0) {
|
|
24798
|
+
return [baseColors[0]];
|
|
24799
|
+
}
|
|
24800
|
+
const needed = length - baseColors.length;
|
|
24766
24801
|
const baseAmount = Math.floor(needed / pairs);
|
|
24767
24802
|
const extras = needed % pairs;
|
|
24768
24803
|
let result = [];
|
|
24769
24804
|
let i = 0;
|
|
24770
24805
|
let j = 1;
|
|
24771
|
-
while (j <
|
|
24806
|
+
while (j < baseColors.length) {
|
|
24772
24807
|
const additional = i < extras ? 1 : 0;
|
|
24773
24808
|
const interpLength = 2 + baseAmount + additional;
|
|
24774
|
-
const interp = interpolateBetween(
|
|
24775
|
-
|
|
24809
|
+
const interp = interpolateBetween(
|
|
24810
|
+
baseColors[i],
|
|
24811
|
+
baseColors[j],
|
|
24812
|
+
interpLength
|
|
24813
|
+
);
|
|
24814
|
+
const lastIndex = j === baseColors.length - 1 ? void 0 : -1;
|
|
24776
24815
|
result = result.concat(interp.slice(0, lastIndex));
|
|
24777
24816
|
i++;
|
|
24778
24817
|
j++;
|
|
@@ -25096,8 +25135,9 @@ var parseData2 = (data, colors, categoryKey, valueKey) => {
|
|
|
25096
25135
|
dataPoint[valueKey] = totalValue ? rawValue * 100 / totalValue : data.length > maxItems ? 100 / (maxItems + 1) : 100 / slicedData.length;
|
|
25097
25136
|
dataPoint[`raw_${valueKey}`] = parseFloat(rawValue.toFixed(2));
|
|
25098
25137
|
});
|
|
25138
|
+
const palette = colors.length >= maxItems ? colors.slice(0, maxItems) : generateArrayFromColor(colors, maxItems);
|
|
25099
25139
|
const parsedData = slicedData.map((dataPoint, idx) => {
|
|
25100
|
-
const baseColor =
|
|
25140
|
+
const baseColor = palette[idx % palette.length];
|
|
25101
25141
|
return {
|
|
25102
25142
|
...dataPoint,
|
|
25103
25143
|
color: baseColor,
|
|
@@ -25115,7 +25155,7 @@ var parseData2 = (data, colors, categoryKey, valueKey) => {
|
|
|
25115
25155
|
),
|
|
25116
25156
|
0
|
|
25117
25157
|
);
|
|
25118
|
-
const otherColor =
|
|
25158
|
+
const otherColor = palette[parsedData.length % palette.length] ?? palette[palette.length - 1];
|
|
25119
25159
|
const normalizedOtherSum = totalValue ? otherSum * 100 / totalValue : 100 / (maxItems + 1);
|
|
25120
25160
|
parsedData.push({
|
|
25121
25161
|
[categoryKey]: "Other",
|
|
@@ -25488,7 +25528,7 @@ var PieChartWrapper = React3.forwardRef(
|
|
|
25488
25528
|
(colorMap[category] && colorMap[category]["primary"] && generateArrayFromColor(
|
|
25489
25529
|
colorMap[category]["primary"],
|
|
25490
25530
|
data.length
|
|
25491
|
-
)) ?? (colors.length >= data.length ? colors : generateArrayFromColor(colors
|
|
25531
|
+
)) ?? (colors.length >= data.length ? colors : generateArrayFromColor(colors, data.length)),
|
|
25492
25532
|
index,
|
|
25493
25533
|
category
|
|
25494
25534
|
),
|
|
@@ -31887,7 +31927,16 @@ var MetricDisplay = ({
|
|
|
31887
31927
|
marginRight: "auto"
|
|
31888
31928
|
},
|
|
31889
31929
|
children: [
|
|
31890
|
-
/* @__PURE__ */ jsx43(
|
|
31930
|
+
/* @__PURE__ */ jsx43(
|
|
31931
|
+
"div",
|
|
31932
|
+
{
|
|
31933
|
+
style: {
|
|
31934
|
+
display: "inline-block",
|
|
31935
|
+
lineHeight: 1.1
|
|
31936
|
+
},
|
|
31937
|
+
children
|
|
31938
|
+
}
|
|
31939
|
+
),
|
|
31891
31940
|
dateFilter?.comparison && /* @__PURE__ */ jsx43(
|
|
31892
31941
|
"span",
|
|
31893
31942
|
{
|
|
@@ -31916,13 +31965,15 @@ var MetricDisplay = ({
|
|
|
31916
31965
|
},
|
|
31917
31966
|
children: [
|
|
31918
31967
|
/* @__PURE__ */ jsx43(
|
|
31919
|
-
"
|
|
31968
|
+
"div",
|
|
31920
31969
|
{
|
|
31921
31970
|
style: {
|
|
31922
31971
|
fontSize: 28,
|
|
31923
31972
|
fontWeight: "500",
|
|
31924
31973
|
fontFamily: theme?.fontFamily,
|
|
31925
|
-
color: theme?.secondaryTextColor
|
|
31974
|
+
color: theme?.secondaryTextColor,
|
|
31975
|
+
display: "inline-block",
|
|
31976
|
+
lineHeight: 1.1
|
|
31926
31977
|
},
|
|
31927
31978
|
children
|
|
31928
31979
|
}
|
|
@@ -39224,7 +39275,7 @@ import {
|
|
|
39224
39275
|
useEffect as useEffect25,
|
|
39225
39276
|
useRef as useRef19,
|
|
39226
39277
|
useMemo as useMemo22,
|
|
39227
|
-
useCallback as
|
|
39278
|
+
useCallback as useCallback4
|
|
39228
39279
|
} from "react";
|
|
39229
39280
|
import MonacoEditor from "@monaco-editor/react";
|
|
39230
39281
|
|
|
@@ -39234,7 +39285,8 @@ import {
|
|
|
39234
39285
|
useRef as useRef18,
|
|
39235
39286
|
useState as useState29,
|
|
39236
39287
|
useContext as useContext26,
|
|
39237
|
-
useMemo as useMemo21
|
|
39288
|
+
useMemo as useMemo21,
|
|
39289
|
+
useCallback as useCallback3
|
|
39238
39290
|
} from "react";
|
|
39239
39291
|
import {
|
|
39240
39292
|
closestCenter,
|
|
@@ -39370,6 +39422,7 @@ var PivotCard = ({
|
|
|
39370
39422
|
}) => {
|
|
39371
39423
|
const defaultValueField = pivotTable.pivot && pivotTable.pivot.aggregationType === "count" ? "whole_number" : "two_decimal_places";
|
|
39372
39424
|
const maxRowsInPivotPeak = 5;
|
|
39425
|
+
const headerColumnCount = (pivotTable.pivot?.rowField ? 1 : 0) + (pivotTable.pivot?.columnField ? 1 : 0) + (!pivotTable.pivot?.columnField && pivotTable.pivot?.aggregations?.[0]?.valueField ? 1 : 0);
|
|
39373
39426
|
return /* @__PURE__ */ jsx61(
|
|
39374
39427
|
CardComponent,
|
|
39375
39428
|
{
|
|
@@ -39473,16 +39526,16 @@ var PivotCard = ({
|
|
|
39473
39526
|
pivotTable.pivot.aggregations?.[0]?.valueField
|
|
39474
39527
|
)
|
|
39475
39528
|
] }) }),
|
|
39476
|
-
/* @__PURE__ */ jsx61(
|
|
39529
|
+
/* @__PURE__ */ jsx61("tbody", { children: /* @__PURE__ */ jsx61(
|
|
39477
39530
|
"tr",
|
|
39478
39531
|
{
|
|
39479
39532
|
style: {
|
|
39480
39533
|
paddingLeft: "2px",
|
|
39481
39534
|
width: "100%"
|
|
39482
39535
|
},
|
|
39483
|
-
children: /* @__PURE__ */ jsx61(TextComponent, { label: "No results" })
|
|
39536
|
+
children: /* @__PURE__ */ jsx61("td", { colSpan: headerColumnCount || 1, children: /* @__PURE__ */ jsx61(TextComponent, { label: "No results" }) })
|
|
39484
39537
|
}
|
|
39485
|
-
)
|
|
39538
|
+
) })
|
|
39486
39539
|
] }) : /* @__PURE__ */ jsxs43("table", { children: [
|
|
39487
39540
|
/* @__PURE__ */ jsx61("thead", { children: /* @__PURE__ */ jsx61("tr", { children: pivotTable.columns.map((column) => /* @__PURE__ */ jsx61(
|
|
39488
39541
|
"th",
|
|
@@ -40852,7 +40905,7 @@ var PivotModal = ({
|
|
|
40852
40905
|
{
|
|
40853
40906
|
id: "pivot-row-field",
|
|
40854
40907
|
label: "Group rows by",
|
|
40855
|
-
value: pivotRowField,
|
|
40908
|
+
value: pivotRowField ?? "",
|
|
40856
40909
|
onChange: (e) => {
|
|
40857
40910
|
pivotFieldChange(
|
|
40858
40911
|
"rowField",
|
|
@@ -40879,7 +40932,7 @@ var PivotModal = ({
|
|
|
40879
40932
|
{
|
|
40880
40933
|
id: "pivot-column-field",
|
|
40881
40934
|
label: "Group columns by",
|
|
40882
|
-
value: pivotColumnField,
|
|
40935
|
+
value: pivotColumnField ?? "",
|
|
40883
40936
|
onChange: (e) => {
|
|
40884
40937
|
pivotFieldChange(
|
|
40885
40938
|
"columnField",
|
|
@@ -40924,7 +40977,7 @@ var PivotModal = ({
|
|
|
40924
40977
|
SelectComponent,
|
|
40925
40978
|
{
|
|
40926
40979
|
id: "pivot-aggregation-type",
|
|
40927
|
-
value: agg.aggregationType,
|
|
40980
|
+
value: agg.aggregationType ?? "",
|
|
40928
40981
|
onChange: (e) => {
|
|
40929
40982
|
const newAgg = [
|
|
40930
40983
|
...pivotAggregations.slice(0, index),
|
|
@@ -40956,7 +41009,7 @@ var PivotModal = ({
|
|
|
40956
41009
|
SelectComponent,
|
|
40957
41010
|
{
|
|
40958
41011
|
id: "pivot-value-field",
|
|
40959
|
-
value: agg.valueField,
|
|
41012
|
+
value: agg.valueField ?? "",
|
|
40960
41013
|
onChange: (e) => {
|
|
40961
41014
|
const newAgg = [
|
|
40962
41015
|
...pivotAggregations.slice(0, index),
|
|
@@ -42583,7 +42636,7 @@ var CHART_TO_LABELS = {
|
|
|
42583
42636
|
column: { xAxisLabel: "X-Axis", yAxisLabel: "Y-Axis" },
|
|
42584
42637
|
line: { xAxisLabel: "X-Axis", yAxisLabel: "Y-Axis" },
|
|
42585
42638
|
table: {},
|
|
42586
|
-
metric: {},
|
|
42639
|
+
metric: { xAxisLabel: "Value" },
|
|
42587
42640
|
bar: { xAxisLabel: "X-Axis", yAxisLabel: "Y-Axis" },
|
|
42588
42641
|
stacked: { xAxisLabel: "X-Axis", yAxisLabel: "Y-Axis" },
|
|
42589
42642
|
pie: { xAxisLabel: "Category", yAxisLabel: "Count" },
|
|
@@ -43013,7 +43066,7 @@ function ChartBuilder({
|
|
|
43013
43066
|
}
|
|
43014
43067
|
return columns2;
|
|
43015
43068
|
};
|
|
43016
|
-
const [
|
|
43069
|
+
const [columns, setColumns] = useState29(
|
|
43017
43070
|
processColumns(report?.columnInternal ?? [])
|
|
43018
43071
|
);
|
|
43019
43072
|
const [currentPage, setCurrentPage] = useState29(0);
|
|
@@ -43127,7 +43180,6 @@ function ChartBuilder({
|
|
|
43127
43180
|
pivotQuery: report.pivotQuery ?? "",
|
|
43128
43181
|
comparisonPivotQuery: report.comparisonPivotQuery
|
|
43129
43182
|
} : void 0;
|
|
43130
|
-
const columns = report?.columnInternal ?? [];
|
|
43131
43183
|
const destinationDashboardName = report?.dashboardName || destinationDashboard;
|
|
43132
43184
|
const query = report?.queryString;
|
|
43133
43185
|
const [loadingFormData, setLoadingFormData] = useState29(false);
|
|
@@ -43679,6 +43731,26 @@ function ChartBuilder({
|
|
|
43679
43731
|
) ?? {};
|
|
43680
43732
|
}, [client?.allTenantTypes]);
|
|
43681
43733
|
const [selectedPivotTable, setSelectedPivotTable] = useState29(pivotData);
|
|
43734
|
+
const getDefaultXAxisFormat = useCallback3(
|
|
43735
|
+
(form) => {
|
|
43736
|
+
if (form.pivot?.rowField) {
|
|
43737
|
+
if (isDateField(form.pivot.rowFieldType ?? "")) {
|
|
43738
|
+
return "string";
|
|
43739
|
+
}
|
|
43740
|
+
const pivotRowColumn = selectedPivotTable?.columns?.find(
|
|
43741
|
+
(col) => col.field === form.pivot?.rowField
|
|
43742
|
+
) ?? columns.find((col) => col.field === form.pivot?.rowField);
|
|
43743
|
+
if (pivotRowColumn?.format) {
|
|
43744
|
+
return pivotRowColumn.format;
|
|
43745
|
+
}
|
|
43746
|
+
}
|
|
43747
|
+
const currentXAxisColumn = (selectedPivotTable?.columns ?? columns).find(
|
|
43748
|
+
(c) => c.field === form.xAxisField
|
|
43749
|
+
);
|
|
43750
|
+
return currentXAxisColumn?.format ?? "string";
|
|
43751
|
+
},
|
|
43752
|
+
[columns, selectedPivotTable]
|
|
43753
|
+
);
|
|
43682
43754
|
const pivotCardTable = useMemo21(() => {
|
|
43683
43755
|
return {
|
|
43684
43756
|
pivot: formData.pivot,
|
|
@@ -43895,7 +43967,8 @@ function ChartBuilder({
|
|
|
43895
43967
|
});
|
|
43896
43968
|
setCurrentProcessing(processing);
|
|
43897
43969
|
setRows(tableInfo.rows);
|
|
43898
|
-
|
|
43970
|
+
const updatedColumns = processColumns(tableInfo.columns);
|
|
43971
|
+
setColumns(updatedColumns);
|
|
43899
43972
|
if (tableInfo.itemQuery) {
|
|
43900
43973
|
setItemQuery(tableInfo.itemQuery);
|
|
43901
43974
|
}
|
|
@@ -44112,6 +44185,7 @@ function ChartBuilder({
|
|
|
44112
44185
|
updatedForm = { ...updatedForm, [fieldName]: value };
|
|
44113
44186
|
}
|
|
44114
44187
|
if (fieldName === "chartType") {
|
|
44188
|
+
const previousChartType = formData.chartType;
|
|
44115
44189
|
if (value === "metric") {
|
|
44116
44190
|
updatedForm.xAxisFormat = "whole_number";
|
|
44117
44191
|
const currentXAxisColumn = (selectedPivotTable?.columns ?? columns).find((c) => c.field === updatedForm.xAxisField);
|
|
@@ -44128,6 +44202,16 @@ function ChartBuilder({
|
|
|
44128
44202
|
(c) => NUMBER_FORMAT_TYPES.includes(c.format)
|
|
44129
44203
|
)?.field ?? updatedForm.xAxisField;
|
|
44130
44204
|
}
|
|
44205
|
+
} else {
|
|
44206
|
+
if (previousChartType === "gauge" && updatedForm.xAxisFormat === "percent") {
|
|
44207
|
+
updatedForm.xAxisFormat = getDefaultXAxisFormat(updatedForm);
|
|
44208
|
+
}
|
|
44209
|
+
if (previousChartType === "metric" && updatedForm.xAxisFormat === "whole_number") {
|
|
44210
|
+
updatedForm.xAxisFormat = getDefaultXAxisFormat(updatedForm);
|
|
44211
|
+
}
|
|
44212
|
+
if (previousChartType === "gauge" && updatedForm.pivot?.rowField && updatedForm.xAxisField !== updatedForm.pivot.rowField) {
|
|
44213
|
+
updatedForm.xAxisField = updatedForm.pivot.rowField;
|
|
44214
|
+
}
|
|
44131
44215
|
}
|
|
44132
44216
|
}
|
|
44133
44217
|
let dashboardName = updatedForm.dashboardName;
|
|
@@ -44830,7 +44914,7 @@ function ChartBuilder({
|
|
|
44830
44914
|
setShowUpdatePivot: setIsEdittingPivot,
|
|
44831
44915
|
parentRef,
|
|
44832
44916
|
data: rows,
|
|
44833
|
-
columns
|
|
44917
|
+
columns,
|
|
44834
44918
|
triggerButtonText: "Add pivot +",
|
|
44835
44919
|
selectedPivotIndex,
|
|
44836
44920
|
setSelectedPivotIndex,
|
|
@@ -44904,7 +44988,7 @@ function ChartBuilder({
|
|
|
44904
44988
|
]
|
|
44905
44989
|
}
|
|
44906
44990
|
),
|
|
44907
|
-
!hideChartView && (formData.pivot || formData.chartType !== "table"
|
|
44991
|
+
!hideChartView && (formData.pivot || formData.chartType !== "table") && /* @__PURE__ */ jsxs47("div", { children: [
|
|
44908
44992
|
CHART_TO_LABELS[formData.chartType]?.xAxisLabel && /* @__PURE__ */ jsx65(
|
|
44909
44993
|
"div",
|
|
44910
44994
|
{
|
|
@@ -46471,6 +46555,166 @@ function setEditorTheme(_editor, monaco, schema, databaseType, clientName, event
|
|
|
46471
46555
|
return null;
|
|
46472
46556
|
}
|
|
46473
46557
|
}
|
|
46558
|
+
function reconcileReportWithColumns(report, columns, previousReport) {
|
|
46559
|
+
const safeColumns = columns ?? [];
|
|
46560
|
+
const fallbackForm = createInitialFormData(safeColumns);
|
|
46561
|
+
const columnFieldSet = new Set(
|
|
46562
|
+
safeColumns.map((column) => column.field).filter(Boolean)
|
|
46563
|
+
);
|
|
46564
|
+
const previousColumnsByField = new Map(
|
|
46565
|
+
(previousReport?.columns ?? []).map((column) => [column.field, column])
|
|
46566
|
+
);
|
|
46567
|
+
const previousColumnInternalByField = new Map(
|
|
46568
|
+
(previousReport?.columnInternal ?? []).map((column) => [
|
|
46569
|
+
column.field,
|
|
46570
|
+
column
|
|
46571
|
+
])
|
|
46572
|
+
);
|
|
46573
|
+
const existingColumnsByField = new Map(
|
|
46574
|
+
(report.columns ?? []).map((column) => [column.field, column])
|
|
46575
|
+
);
|
|
46576
|
+
const existingColumnInternalByField = new Map(
|
|
46577
|
+
(report.columnInternal ?? []).map((column) => [column.field, column])
|
|
46578
|
+
);
|
|
46579
|
+
const reconciledColumnInternal = safeColumns.map((column) => {
|
|
46580
|
+
const fallback = existingColumnInternalByField.get(column.field) ?? previousColumnInternalByField.get(column.field) ?? existingColumnsByField.get(column.field) ?? previousColumnsByField.get(column.field);
|
|
46581
|
+
return {
|
|
46582
|
+
...column,
|
|
46583
|
+
format: fallback?.format ?? column.format,
|
|
46584
|
+
label: fallback?.label ?? column.label
|
|
46585
|
+
};
|
|
46586
|
+
});
|
|
46587
|
+
const reconciledColumns = reconciledColumnInternal.map((column) => ({
|
|
46588
|
+
field: column.field,
|
|
46589
|
+
label: column.label,
|
|
46590
|
+
format: column.format
|
|
46591
|
+
}));
|
|
46592
|
+
const resolveXAxisField = () => {
|
|
46593
|
+
if (report.xAxisField && columnFieldSet.has(report.xAxisField)) {
|
|
46594
|
+
return report.xAxisField;
|
|
46595
|
+
}
|
|
46596
|
+
if (previousReport?.xAxisField && columnFieldSet.has(previousReport.xAxisField)) {
|
|
46597
|
+
return previousReport.xAxisField;
|
|
46598
|
+
}
|
|
46599
|
+
return fallbackForm.xAxisField;
|
|
46600
|
+
};
|
|
46601
|
+
const xAxisField = resolveXAxisField();
|
|
46602
|
+
const xAxisColumn = reconciledColumnInternal.find(
|
|
46603
|
+
(column) => column.field === xAxisField
|
|
46604
|
+
);
|
|
46605
|
+
const xAxisFormat = (report.xAxisField === xAxisField ? report.xAxisFormat : void 0) ?? (previousReport?.xAxisField === xAxisField ? previousReport.xAxisFormat : void 0) ?? xAxisColumn?.format ?? fallbackForm.xAxisFormat ?? "string";
|
|
46606
|
+
const xAxisLabel = report.xAxisField === xAxisField ? report.xAxisLabel : previousReport?.xAxisField === xAxisField ? previousReport.xAxisLabel : fallbackForm.xAxisLabel ?? "";
|
|
46607
|
+
const existingYAxisFields = report.yAxisFields ?? previousReport?.yAxisFields ?? [];
|
|
46608
|
+
let yAxisFields = existingYAxisFields.filter((axis) => axis?.field && columnFieldSet.has(axis.field)).map((axis) => {
|
|
46609
|
+
const column = reconciledColumnInternal.find(
|
|
46610
|
+
(col) => col.field === axis.field
|
|
46611
|
+
);
|
|
46612
|
+
return {
|
|
46613
|
+
field: axis.field,
|
|
46614
|
+
label: axis.label,
|
|
46615
|
+
format: axis.format ?? column?.format ?? "string"
|
|
46616
|
+
};
|
|
46617
|
+
});
|
|
46618
|
+
if (yAxisFields.length === 0) {
|
|
46619
|
+
yAxisFields = fallbackForm.yAxisFields;
|
|
46620
|
+
}
|
|
46621
|
+
const existingReferenceLines = report.referenceLines ?? previousReport?.referenceLines ?? [];
|
|
46622
|
+
const referenceLines = existingReferenceLines.filter((line) => {
|
|
46623
|
+
if (line.label === REFERENCE_LINE) {
|
|
46624
|
+
return true;
|
|
46625
|
+
}
|
|
46626
|
+
return typeof line.label === "string" && columnFieldSet.has(line.label);
|
|
46627
|
+
});
|
|
46628
|
+
const existingReferenceLineYValues = report.referenceLineYValues ?? previousReport?.referenceLineYValues ?? [];
|
|
46629
|
+
const referenceLineYValues = existingReferenceLineYValues.filter((line) => {
|
|
46630
|
+
if (line.label === REFERENCE_LINE) {
|
|
46631
|
+
return true;
|
|
46632
|
+
}
|
|
46633
|
+
return typeof line.label === "string" && columnFieldSet.has(line.label);
|
|
46634
|
+
});
|
|
46635
|
+
const existingColumnsWithCustomFields = report.columnsWithCustomFields ?? previousReport?.columnsWithCustomFields ?? [];
|
|
46636
|
+
const columnsWithCustomFields = existingColumnsWithCustomFields.filter(
|
|
46637
|
+
(column) => columnFieldSet.has(column.field)
|
|
46638
|
+
);
|
|
46639
|
+
const existingFilterMap = report.filterMap ?? previousReport?.filterMap;
|
|
46640
|
+
const filterMap = existingFilterMap ? Object.fromEntries(
|
|
46641
|
+
Object.entries(existingFilterMap).filter(([, value]) => {
|
|
46642
|
+
return value.field && columnFieldSet.has(value.field);
|
|
46643
|
+
})
|
|
46644
|
+
) : existingFilterMap;
|
|
46645
|
+
const existingFiltersApplied = report.filtersApplied ?? previousReport?.filtersApplied;
|
|
46646
|
+
const filtersApplied = existingFiltersApplied ? existingFiltersApplied.filter((filter) => {
|
|
46647
|
+
if (!filter.field) {
|
|
46648
|
+
return true;
|
|
46649
|
+
}
|
|
46650
|
+
return columnFieldSet.has(filter.field);
|
|
46651
|
+
}) : existingFiltersApplied;
|
|
46652
|
+
const existingSort = report.sort ?? previousReport?.sort;
|
|
46653
|
+
const sort = existingSort && columnFieldSet.has(existingSort.field) ? existingSort : void 0;
|
|
46654
|
+
let pivot = report.pivot ?? previousReport?.pivot ?? null;
|
|
46655
|
+
if (pivot) {
|
|
46656
|
+
const pivotFields = [];
|
|
46657
|
+
if (pivot.rowField) {
|
|
46658
|
+
pivotFields.push(pivot.rowField);
|
|
46659
|
+
}
|
|
46660
|
+
if (pivot.columnField) {
|
|
46661
|
+
pivotFields.push(pivot.columnField);
|
|
46662
|
+
}
|
|
46663
|
+
if ("aggregations" in pivot && Array.isArray(pivot.aggregations)) {
|
|
46664
|
+
pivot.aggregations.forEach((aggregation) => {
|
|
46665
|
+
if (aggregation.valueField) {
|
|
46666
|
+
pivotFields.push(aggregation.valueField);
|
|
46667
|
+
}
|
|
46668
|
+
if (aggregation.valueField2) {
|
|
46669
|
+
pivotFields.push(aggregation.valueField2);
|
|
46670
|
+
}
|
|
46671
|
+
});
|
|
46672
|
+
} else {
|
|
46673
|
+
const singleAggregation = pivot;
|
|
46674
|
+
if (singleAggregation.valueField) {
|
|
46675
|
+
pivotFields.push(singleAggregation.valueField);
|
|
46676
|
+
}
|
|
46677
|
+
if (singleAggregation.valueField2) {
|
|
46678
|
+
pivotFields.push(singleAggregation.valueField2);
|
|
46679
|
+
}
|
|
46680
|
+
}
|
|
46681
|
+
if (pivot.sortField) {
|
|
46682
|
+
pivotFields.push(pivot.sortField);
|
|
46683
|
+
}
|
|
46684
|
+
const missingPivotField = pivotFields.some(
|
|
46685
|
+
(field) => field && !columnFieldSet.has(field)
|
|
46686
|
+
);
|
|
46687
|
+
if (missingPivotField) {
|
|
46688
|
+
pivot = null;
|
|
46689
|
+
}
|
|
46690
|
+
}
|
|
46691
|
+
const pivotColumns = pivot ? (report.pivotColumns ?? previousReport?.pivotColumns)?.filter(
|
|
46692
|
+
(column) => columnFieldSet.has(column.field)
|
|
46693
|
+
) : void 0;
|
|
46694
|
+
const pivotRows = pivot ? report.pivotRows ?? previousReport?.pivotRows : void 0;
|
|
46695
|
+
const pivotRowCount = pivot ? report.pivotRowCount ?? previousReport?.pivotRowCount : void 0;
|
|
46696
|
+
return {
|
|
46697
|
+
...report,
|
|
46698
|
+
columns: reconciledColumns,
|
|
46699
|
+
columnInternal: reconciledColumnInternal,
|
|
46700
|
+
columnsWithCustomFields,
|
|
46701
|
+
xAxisField,
|
|
46702
|
+
xAxisFormat,
|
|
46703
|
+
xAxisLabel,
|
|
46704
|
+
yAxisFields,
|
|
46705
|
+
referenceLines,
|
|
46706
|
+
referenceLineYValues: referenceLineYValues.length ? referenceLineYValues : void 0,
|
|
46707
|
+
filterMap: filterMap && Object.keys(filterMap).length ? filterMap : void 0,
|
|
46708
|
+
filtersApplied: filtersApplied && filtersApplied.length ? filtersApplied : void 0,
|
|
46709
|
+
sort,
|
|
46710
|
+
pivot,
|
|
46711
|
+
pivotColumns,
|
|
46712
|
+
pivotRows,
|
|
46713
|
+
pivotRowCount,
|
|
46714
|
+
pivotQuery: pivot ? report.pivotQuery ?? previousReport?.pivotQuery : void 0,
|
|
46715
|
+
comparisonPivotQuery: pivot ? report.comparisonPivotQuery ?? previousReport?.comparisonPivotQuery : void 0
|
|
46716
|
+
};
|
|
46717
|
+
}
|
|
46474
46718
|
function SQLEditor({
|
|
46475
46719
|
ButtonComponent = MemoizedButton,
|
|
46476
46720
|
SecondaryButtonComponent = MemoizedSecondaryButton,
|
|
@@ -46693,7 +46937,7 @@ function SQLEditor({
|
|
|
46693
46937
|
onCloseChartBuilder && onCloseChartBuilder();
|
|
46694
46938
|
}
|
|
46695
46939
|
}, [isChartBuilderOpen]);
|
|
46696
|
-
const handleRunSqlPrompt =
|
|
46940
|
+
const handleRunSqlPrompt = useCallback4(async () => {
|
|
46697
46941
|
if (!client || sqlResponseLoading) {
|
|
46698
46942
|
return;
|
|
46699
46943
|
}
|
|
@@ -46712,7 +46956,7 @@ function SQLEditor({
|
|
|
46712
46956
|
setQuery(resp.message);
|
|
46713
46957
|
setSqlResponseLoading(false);
|
|
46714
46958
|
}, [sqlPrompt, sqlResponseLoading]);
|
|
46715
|
-
const debounceRunSqlPrompt =
|
|
46959
|
+
const debounceRunSqlPrompt = useCallback4(
|
|
46716
46960
|
createDebounce(handleRunSqlPrompt, 500),
|
|
46717
46961
|
[handleRunSqlPrompt]
|
|
46718
46962
|
);
|
|
@@ -46849,12 +47093,17 @@ function SQLEditor({
|
|
|
46849
47093
|
referencedTables: tableInfo.referencedTables,
|
|
46850
47094
|
queryString: query ?? tempReport.queryString ?? ""
|
|
46851
47095
|
};
|
|
47096
|
+
const reconciledReport = reconcileReportWithColumns(
|
|
47097
|
+
newReport,
|
|
47098
|
+
tableInfo.columns ?? [],
|
|
47099
|
+
tempReport
|
|
47100
|
+
);
|
|
46852
47101
|
if (reportId) {
|
|
46853
|
-
setTempReport(
|
|
47102
|
+
setTempReport(reconciledReport);
|
|
46854
47103
|
} else {
|
|
46855
47104
|
const cleaned = await cleanDashboardItem({
|
|
46856
|
-
item:
|
|
46857
|
-
dashboardFilters:
|
|
47105
|
+
item: reconciledReport,
|
|
47106
|
+
dashboardFilters: reconciledReport.filtersApplied,
|
|
46858
47107
|
client,
|
|
46859
47108
|
customFields: schemaData.customFields,
|
|
46860
47109
|
getToken,
|