@quillsql/react 2.10.4 → 2.10.6
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/cjs/Chart.d.ts +2 -2
- package/dist/cjs/Chart.d.ts.map +1 -1
- package/dist/cjs/Chart.js +22 -30
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +18 -9
- package/dist/cjs/ChartEditor.js +1 -1
- package/dist/cjs/Context.d.ts +22 -39
- package/dist/cjs/Context.d.ts.map +1 -1
- package/dist/cjs/Context.js +11 -9
- package/dist/cjs/Dashboard.d.ts +116 -26
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +92 -402
- package/dist/cjs/DateRangePicker/dateRangePickerUtils.d.ts +18 -1
- package/dist/cjs/DateRangePicker/dateRangePickerUtils.d.ts.map +1 -1
- package/dist/cjs/DateRangePicker/dateRangePickerUtils.js +9 -9
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +2 -4
- package/dist/cjs/Table.d.ts.map +1 -1
- package/dist/cjs/Table.js +12 -2
- package/dist/cjs/components/Chart/BarChart.d.ts +2 -2
- package/dist/cjs/components/Chart/BarChart.js +2 -2
- package/dist/cjs/components/Chart/ChartError.d.ts +3 -0
- package/dist/cjs/components/Chart/ChartError.d.ts.map +1 -0
- package/dist/cjs/components/Chart/ChartError.js +29 -0
- package/dist/cjs/components/Chart/ChartSkeleton.d.ts +3 -0
- package/dist/cjs/components/Chart/ChartSkeleton.d.ts.map +1 -0
- package/dist/cjs/components/Chart/ChartSkeleton.js +20 -0
- package/dist/cjs/components/Chart/ChartTooltipFrame.d.ts.map +1 -1
- package/dist/cjs/components/Chart/ChartTooltipFrame.js +1 -0
- package/dist/cjs/components/Chart/LineChart.d.ts +2 -2
- package/dist/cjs/components/Chart/LineChart.js +2 -2
- package/dist/cjs/components/Dashboard/DashboardGroup.d.ts +3 -0
- package/dist/cjs/components/Dashboard/DashboardGroup.d.ts.map +1 -0
- package/dist/cjs/components/Dashboard/DashboardGroup.js +16 -0
- package/dist/cjs/components/Dashboard/DashboardItem.d.ts +3 -0
- package/dist/cjs/components/Dashboard/DashboardItem.d.ts.map +1 -0
- package/dist/cjs/components/Dashboard/DashboardItem.js +64 -0
- package/dist/cjs/components/Dashboard/DashboardSection.d.ts +3 -0
- package/dist/cjs/components/Dashboard/DashboardSection.d.ts.map +1 -0
- package/dist/cjs/components/Dashboard/DashboardSection.js +7 -0
- package/dist/cjs/hooks/useQuill.d.ts.map +1 -1
- package/dist/cjs/hooks/useQuill.js +15 -9
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +1 -1
- package/dist/cjs/utils/axisFormatter.d.ts.map +1 -1
- package/dist/cjs/utils/axisFormatter.js +7 -18
- package/dist/cjs/utils/dashboard.d.ts +12 -0
- package/dist/cjs/utils/dashboard.d.ts.map +1 -0
- package/dist/cjs/utils/dashboard.js +150 -0
- package/dist/cjs/utils/styles.d.ts +17 -0
- package/dist/cjs/utils/styles.d.ts.map +1 -0
- package/dist/cjs/utils/styles.js +20 -0
- package/dist/cjs/utils/valueFormatter.d.ts +1 -1
- package/dist/cjs/utils/valueFormatter.d.ts.map +1 -1
- package/dist/cjs/utils/valueFormatter.js +7 -18
- package/dist/cjs/utils/valueFormatterCSV.d.ts.map +1 -1
- package/dist/cjs/utils/valueFormatterCSV.js +7 -15
- package/dist/esm/Chart.d.ts +2 -2
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +23 -31
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +18 -9
- package/dist/esm/ChartEditor.js +1 -1
- package/dist/esm/Context.d.ts +22 -39
- package/dist/esm/Context.d.ts.map +1 -1
- package/dist/esm/Context.js +11 -9
- package/dist/esm/Dashboard.d.ts +116 -26
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +89 -376
- package/dist/esm/DateRangePicker/dateRangePickerUtils.d.ts +18 -1
- package/dist/esm/DateRangePicker/dateRangePickerUtils.d.ts.map +1 -1
- package/dist/esm/DateRangePicker/dateRangePickerUtils.js +9 -9
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +2 -4
- package/dist/esm/Table.d.ts.map +1 -1
- package/dist/esm/Table.js +12 -2
- package/dist/esm/components/Chart/BarChart.d.ts +2 -2
- package/dist/esm/components/Chart/BarChart.js +2 -2
- package/dist/esm/components/Chart/ChartError.d.ts +3 -0
- package/dist/esm/components/Chart/ChartError.d.ts.map +1 -0
- package/dist/esm/components/Chart/ChartError.js +26 -0
- package/dist/esm/components/Chart/ChartSkeleton.d.ts +3 -0
- package/dist/esm/components/Chart/ChartSkeleton.d.ts.map +1 -0
- package/dist/esm/components/Chart/ChartSkeleton.js +17 -0
- package/dist/esm/components/Chart/ChartTooltipFrame.d.ts.map +1 -1
- package/dist/esm/components/Chart/ChartTooltipFrame.js +1 -0
- package/dist/esm/components/Chart/LineChart.d.ts +2 -2
- package/dist/esm/components/Chart/LineChart.js +2 -2
- package/dist/esm/components/Dashboard/DashboardGroup.d.ts +3 -0
- package/dist/esm/components/Dashboard/DashboardGroup.d.ts.map +1 -0
- package/dist/esm/components/Dashboard/DashboardGroup.js +13 -0
- package/dist/esm/components/Dashboard/DashboardItem.d.ts +3 -0
- package/dist/esm/components/Dashboard/DashboardItem.d.ts.map +1 -0
- package/dist/esm/components/Dashboard/DashboardItem.js +61 -0
- package/dist/esm/components/Dashboard/DashboardSection.d.ts +3 -0
- package/dist/esm/components/Dashboard/DashboardSection.d.ts.map +1 -0
- package/dist/esm/components/Dashboard/DashboardSection.js +4 -0
- package/dist/esm/hooks/useQuill.d.ts.map +1 -1
- package/dist/esm/hooks/useQuill.js +16 -10
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +1 -1
- package/dist/esm/utils/axisFormatter.d.ts.map +1 -1
- package/dist/esm/utils/axisFormatter.js +7 -18
- package/dist/esm/utils/dashboard.d.ts +12 -0
- package/dist/esm/utils/dashboard.d.ts.map +1 -0
- package/dist/esm/utils/dashboard.js +146 -0
- package/dist/esm/utils/styles.d.ts +17 -0
- package/dist/esm/utils/styles.d.ts.map +1 -0
- package/dist/esm/utils/styles.js +16 -0
- package/dist/esm/utils/valueFormatter.d.ts +1 -1
- package/dist/esm/utils/valueFormatter.d.ts.map +1 -1
- package/dist/esm/utils/valueFormatter.js +7 -18
- package/dist/esm/utils/valueFormatterCSV.d.ts.map +1 -1
- package/dist/esm/utils/valueFormatterCSV.js +7 -15
- package/package.json +2 -5
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cleanDashboardItem = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const valueFormatter_1 = require("./valueFormatter");
|
|
6
|
+
const PivotModal_1 = require("../internals/ReportBuilder/PivotModal");
|
|
7
|
+
const Context_1 = require("../Context");
|
|
8
|
+
/**
|
|
9
|
+
* Returns a cleaned version of the dashboard item we store in state. We clean
|
|
10
|
+
* the dashboard item so that we aren't exposing unnecessary details to the
|
|
11
|
+
* client and also so that we can give the developer using our items a stable
|
|
12
|
+
* interface to build amazing dashboards on top of.
|
|
13
|
+
* @param item
|
|
14
|
+
*/
|
|
15
|
+
function cleanDashboardItem(item) {
|
|
16
|
+
if (!item)
|
|
17
|
+
return undefined;
|
|
18
|
+
const pivotTable = getPivotTable(item);
|
|
19
|
+
const { primaryAggregation, comparisonAggregation, aggregationPercentChange, } = getAggragations(pivotTable, item);
|
|
20
|
+
return {
|
|
21
|
+
id: item._id,
|
|
22
|
+
name: item.name,
|
|
23
|
+
dashboardName: item.dashboardName,
|
|
24
|
+
rows: item.rows,
|
|
25
|
+
compareRows: item.compareRows,
|
|
26
|
+
columns: item.columns,
|
|
27
|
+
chartType: item.chartType,
|
|
28
|
+
dateField: item.dateField,
|
|
29
|
+
pivot: item.pivot,
|
|
30
|
+
primaryAggregation,
|
|
31
|
+
comparisonAggregation,
|
|
32
|
+
aggregationPercentChange,
|
|
33
|
+
yAxisFields: extractPivotedYAxis(pivotTable, item),
|
|
34
|
+
xAxisLabel: item.xAxisLabel,
|
|
35
|
+
xAxisField: item.xAxisField,
|
|
36
|
+
xAxisFormat: item.xAxisFormat,
|
|
37
|
+
order: item.order,
|
|
38
|
+
filtersApplied: item.filtersApplied,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
exports.cleanDashboardItem = cleanDashboardItem;
|
|
42
|
+
/**
|
|
43
|
+
* Extracts the aggregations from the item, if any.
|
|
44
|
+
*/
|
|
45
|
+
function getAggragations(pivotTable, item) {
|
|
46
|
+
const yAxisFields = extractPivotedYAxis(pivotTable, item);
|
|
47
|
+
const rows = extractPivotedData(pivotTable, item);
|
|
48
|
+
// extract the aggragation for the primary range.
|
|
49
|
+
const mainKey = yAxisFields[0]?.field ?? item.pivot?.valueField;
|
|
50
|
+
const primary = mainKey
|
|
51
|
+
? rows.reduce((sum, row) => sum + parseFloat(row[mainKey]), 0)
|
|
52
|
+
: 0;
|
|
53
|
+
// extract the aggragation for the comparison range, if applicable.
|
|
54
|
+
const compKey = yAxisFields[1]?.field ?? item.pivot?.valueField;
|
|
55
|
+
const comparison = compKey
|
|
56
|
+
? rows.reduce((sum, row) => sum + parseFloat(row[compKey]), 0)
|
|
57
|
+
: 0;
|
|
58
|
+
return {
|
|
59
|
+
primaryAggregation: formatAggragation(item, primary),
|
|
60
|
+
comparisonAggregation: formatAggragation(item, comparison),
|
|
61
|
+
aggregationPercentChange: formatPercentageWithSign(comparison, primary),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Applies a valueFormatter to the given value based on the format in the item.
|
|
66
|
+
*/
|
|
67
|
+
function formatAggragation(item, value) {
|
|
68
|
+
if (!value)
|
|
69
|
+
return undefined;
|
|
70
|
+
return (0, valueFormatter_1.valueFormatter)({
|
|
71
|
+
value,
|
|
72
|
+
field: item.pivot?.valueField,
|
|
73
|
+
fields: item.yAxisFields,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Formats the percentage change from a to b with the sign included.
|
|
78
|
+
*/
|
|
79
|
+
function formatPercentageWithSign(a, b) {
|
|
80
|
+
const formatter = new Intl.NumberFormat('en-US', {
|
|
81
|
+
style: 'percent',
|
|
82
|
+
signDisplay: 'exceptZero',
|
|
83
|
+
minimumFractionDigits: 2,
|
|
84
|
+
maximumFractionDigits: 2,
|
|
85
|
+
});
|
|
86
|
+
return formatter.format(Number(b - a));
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Extract and transform the data from itemInfo.
|
|
90
|
+
*/
|
|
91
|
+
function getPivotTable(itemInfo, config = undefined) {
|
|
92
|
+
if (!itemInfo)
|
|
93
|
+
return [];
|
|
94
|
+
const { dashboardFilters } = (0, react_1.useContext)(Context_1.DashboardFiltersContext);
|
|
95
|
+
const dateFilter = Object.values(dashboardFilters ?? {}).find((filter) => filter.filterType == 'date_range');
|
|
96
|
+
const pivot = itemInfo?.pivot || config?.pivot;
|
|
97
|
+
const data = itemInfo ? itemInfo : config;
|
|
98
|
+
return pivot && data?.rows
|
|
99
|
+
? (0, PivotModal_1.generatePivotTable)(pivot, JSON.parse(JSON.stringify(data.rows)), // deep copy
|
|
100
|
+
dateFilter?.startDate
|
|
101
|
+
? [dateFilter?.startDate, dateFilter?.endDate, null]
|
|
102
|
+
: [null, null, null], Boolean(dateFilter?.comparisonRange?.startDate), -1, dateFilter?.comparisonRange?.startDate
|
|
103
|
+
? [
|
|
104
|
+
dateFilter?.comparisonRange.startDate,
|
|
105
|
+
dateFilter?.comparisonRange.endDate,
|
|
106
|
+
null,
|
|
107
|
+
]
|
|
108
|
+
: [null, null, null])
|
|
109
|
+
: null;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Returns the data list based on whether the table is pivoted and if there is
|
|
113
|
+
* a config value passed into this component.
|
|
114
|
+
*/
|
|
115
|
+
function extractPivotedData(pivotTable, item, config = undefined) {
|
|
116
|
+
if (pivotTable)
|
|
117
|
+
return pivotTable.rows;
|
|
118
|
+
if (config) {
|
|
119
|
+
if (config.bucketedRows.length > 0)
|
|
120
|
+
return config.bucketedRows;
|
|
121
|
+
return config.rows;
|
|
122
|
+
}
|
|
123
|
+
return item.rows;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Extracts the yAxis from the pivot table, if one exists.
|
|
127
|
+
*/
|
|
128
|
+
function extractPivotedYAxis(pivotTable, itemInfo, config = undefined) {
|
|
129
|
+
if (!pivotTable)
|
|
130
|
+
return [];
|
|
131
|
+
const pivot = itemInfo?.pivot || config?.pivot;
|
|
132
|
+
const yAxisFields = config ? config.yAxisFields : itemInfo?.yAxisFields;
|
|
133
|
+
const pivotTableYAxis = yAxisFields
|
|
134
|
+
? (0, PivotModal_1.generatePivotTableYAxis)(pivot, pivotTable.columns, yAxisFields?.[0]?.format)
|
|
135
|
+
: null;
|
|
136
|
+
const fields = pivotTableYAxis
|
|
137
|
+
? pivotTableYAxis
|
|
138
|
+
: config
|
|
139
|
+
? config.yAxisFields
|
|
140
|
+
: itemInfo.yAxisFields;
|
|
141
|
+
if (fields.length == 1) {
|
|
142
|
+
const sampleField = fields[0];
|
|
143
|
+
fields[fields.length] = {
|
|
144
|
+
...sampleField,
|
|
145
|
+
field: `comparison_${sampleField.field}`,
|
|
146
|
+
label: `comparison ${sampleField.label}`,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
return fields;
|
|
150
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
export type StyleInput = string | CSSProperties | undefined;
|
|
3
|
+
export type StyleProps = {
|
|
4
|
+
className: string;
|
|
5
|
+
} | {
|
|
6
|
+
style: CSSProperties;
|
|
7
|
+
} | {};
|
|
8
|
+
/**
|
|
9
|
+
* Converts the given styles to a props object that can be passed directly into
|
|
10
|
+
* a jsx/tsx component. Converts to className if styles is a string, otherwise
|
|
11
|
+
* treats it as CSSProperties.
|
|
12
|
+
*
|
|
13
|
+
* Example:
|
|
14
|
+
* <div {...styleToProps(containerStyle)}>...</div>
|
|
15
|
+
*/
|
|
16
|
+
export declare function styleToProps(styles: StyleInput): StyleProps;
|
|
17
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/utils/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,aAAa,GAAG,SAAS,CAAC;AAC5D,MAAM,MAAM,UAAU,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,aAAa,CAAA;CAAE,GAAG,EAAE,CAAC;AAE/E;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAO3D"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.styleToProps = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Converts the given styles to a props object that can be passed directly into
|
|
6
|
+
* a jsx/tsx component. Converts to className if styles is a string, otherwise
|
|
7
|
+
* treats it as CSSProperties.
|
|
8
|
+
*
|
|
9
|
+
* Example:
|
|
10
|
+
* <div {...styleToProps(containerStyle)}>...</div>
|
|
11
|
+
*/
|
|
12
|
+
function styleToProps(styles) {
|
|
13
|
+
if (!styles)
|
|
14
|
+
return {};
|
|
15
|
+
if (typeof styles === 'string') {
|
|
16
|
+
return { className: styles };
|
|
17
|
+
}
|
|
18
|
+
return { style: styles };
|
|
19
|
+
}
|
|
20
|
+
exports.styleToProps = styleToProps;
|
|
@@ -12,6 +12,6 @@ type Props = {
|
|
|
12
12
|
/**
|
|
13
13
|
* Pretty-prints the given values to their nice-looking string form.
|
|
14
14
|
*/
|
|
15
|
-
export declare const valueFormatter: ({ value, field, fields, }: Props) => string
|
|
15
|
+
export declare const valueFormatter: ({ value, field, fields, }: Props) => string;
|
|
16
16
|
export {};
|
|
17
17
|
//# sourceMappingURL=valueFormatter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"valueFormatter.d.ts","sourceRoot":"","sources":["../../../src/utils/valueFormatter.ts"],"names":[],"mappings":"AAGA,KAAK,KAAK,GAAG;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC;IACpD,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IACjC,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,8BAIxB,KAAK,KAAG,
|
|
1
|
+
{"version":3,"file":"valueFormatter.d.ts","sourceRoot":"","sources":["../../../src/utils/valueFormatter.ts"],"names":[],"mappings":"AAGA,KAAK,KAAK,GAAG;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC;IACpD,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IACjC,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,8BAIxB,KAAK,KAAG,MA+BV,CAAC"}
|
|
@@ -22,7 +22,6 @@ const valueFormatter = ({ value, field, fields, }) => {
|
|
|
22
22
|
one_decimal_place: formatOneDecimalPlace,
|
|
23
23
|
two_decimal_places: formatTwoDecimalPlaces,
|
|
24
24
|
string: formatString,
|
|
25
|
-
interval: formatInterval,
|
|
26
25
|
yyyy: format_YYYY,
|
|
27
26
|
MMM_yyyy: format_MMM_yyyy,
|
|
28
27
|
MMM_dd_yyyy: format_MMM_dd_yyyy,
|
|
@@ -36,7 +35,7 @@ const valueFormatter = ({ value, field, fields, }) => {
|
|
|
36
35
|
if (Object.keys(HANDLERS).includes(formatType)) {
|
|
37
36
|
return HANDLERS[formatType](value);
|
|
38
37
|
}
|
|
39
|
-
return value
|
|
38
|
+
return formatString(value); // by default make this value a string
|
|
40
39
|
};
|
|
41
40
|
exports.valueFormatter = valueFormatter;
|
|
42
41
|
/**
|
|
@@ -45,22 +44,12 @@ exports.valueFormatter = valueFormatter;
|
|
|
45
44
|
/**
|
|
46
45
|
* Formats the value as a string using the built-in converstion.
|
|
47
46
|
*/
|
|
48
|
-
const formatString = (value) =>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
'months',
|
|
55
|
-
'days',
|
|
56
|
-
'hours',
|
|
57
|
-
'minutes',
|
|
58
|
-
'seconds',
|
|
59
|
-
];
|
|
60
|
-
const formatInterval = (interval) => INTERVALS.map((component) => interval[component])
|
|
61
|
-
.filter((value) => value !== undefined && value !== null)
|
|
62
|
-
.map((value, index) => `${value} ${INTERVALS[index]}`)
|
|
63
|
-
.join(', ');
|
|
47
|
+
const formatString = (value) => {
|
|
48
|
+
if (typeof value === 'object') {
|
|
49
|
+
return JSON.stringify(value);
|
|
50
|
+
}
|
|
51
|
+
return value.toString();
|
|
52
|
+
};
|
|
64
53
|
/**
|
|
65
54
|
* Formats the value as a (rounded) currency amount in dollars.
|
|
66
55
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"valueFormatterCSV.d.ts","sourceRoot":"","sources":["../../../src/utils/valueFormatterCSV.ts"],"names":[],"mappings":"AAGA,KAAK,KAAK,GAAG;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC;IACpD,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IACjC,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,8BAI3B,KAAK,KAAG,MAAM,GAAG,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"valueFormatterCSV.d.ts","sourceRoot":"","sources":["../../../src/utils/valueFormatterCSV.ts"],"names":[],"mappings":"AAGA,KAAK,KAAK,GAAG;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC;IACpD,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IACjC,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,8BAI3B,KAAK,KAAG,MAAM,GAAG,MAAM,GAAG,OA+B5B,CAAC"}
|
|
@@ -22,7 +22,6 @@ const valueFormatterCSV = ({ value, field, fields, }) => {
|
|
|
22
22
|
one_decimal_place: formatOneDecimalPlace,
|
|
23
23
|
two_decimal_places: formatTwoDecimalPlaces,
|
|
24
24
|
string: formatString,
|
|
25
|
-
interval: formatInterval,
|
|
26
25
|
yyyy: format_YYYY,
|
|
27
26
|
MMM_yyyy: format_MMM_yyyy,
|
|
28
27
|
MMM_dd_yyyy: format_MMM_dd_yyyy,
|
|
@@ -36,13 +35,18 @@ const valueFormatterCSV = ({ value, field, fields, }) => {
|
|
|
36
35
|
if (Object.keys(HANDLERS).includes(formatType)) {
|
|
37
36
|
return HANDLERS[formatType](value);
|
|
38
37
|
}
|
|
39
|
-
return value
|
|
38
|
+
return formatString(value); // by default make this value a string
|
|
40
39
|
};
|
|
41
40
|
exports.valueFormatterCSV = valueFormatterCSV;
|
|
42
41
|
/**
|
|
43
42
|
* HELPER FUNCTION DEFINITIONS
|
|
44
43
|
*/
|
|
45
|
-
const formatString = (value) =>
|
|
44
|
+
const formatString = (value) => {
|
|
45
|
+
if (typeof value === 'object') {
|
|
46
|
+
return JSON.stringify(value);
|
|
47
|
+
}
|
|
48
|
+
return value.toString();
|
|
49
|
+
};
|
|
46
50
|
const formatDollarAmount = (value) => Number(value ?? 0);
|
|
47
51
|
const formatDollarCents = (value) => Number(value ?? 0);
|
|
48
52
|
const formatWholeNumber = (value) => Math.round(Number(value));
|
|
@@ -93,15 +97,3 @@ const format_wo_yyyy = (value) => {
|
|
|
93
97
|
return 'Invalid date';
|
|
94
98
|
return `${(0, date_fns_1.getWeek)(utcDate)},${utcDate.getFullYear()}`;
|
|
95
99
|
};
|
|
96
|
-
const INTERVALS = [
|
|
97
|
-
'years',
|
|
98
|
-
'months',
|
|
99
|
-
'days',
|
|
100
|
-
'hours',
|
|
101
|
-
'minutes',
|
|
102
|
-
'seconds',
|
|
103
|
-
];
|
|
104
|
-
const formatInterval = (interval) => INTERVALS.map((component) => interval[component])
|
|
105
|
-
.filter((value) => value !== undefined && value !== null)
|
|
106
|
-
.map((value, index) => `${value} ${INTERVALS[index]}`)
|
|
107
|
-
.join(', ');
|
package/dist/esm/Chart.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ interface BaseChartProps {
|
|
|
8
8
|
isAnimationActive?: boolean;
|
|
9
9
|
hideXAxis?: boolean;
|
|
10
10
|
hideYAxis?: boolean;
|
|
11
|
-
|
|
11
|
+
hideCartesianGrid?: boolean;
|
|
12
12
|
}
|
|
13
13
|
interface WithChartId extends BaseChartProps {
|
|
14
14
|
chartId: string;
|
|
@@ -35,6 +35,6 @@ interface WithConfig extends BaseChartProps {
|
|
|
35
35
|
config: DashboardItem | any;
|
|
36
36
|
}
|
|
37
37
|
type ChartProps = WithChartId | WithConfig;
|
|
38
|
-
declare const Chart: ({ chartId, config, colors, containerStyle, query, SelectComponent, dateRangeFilterDisabled, isAnimationActive, hideXAxis, hideYAxis,
|
|
38
|
+
declare const Chart: ({ chartId, config, colors, containerStyle, query, SelectComponent, dateRangeFilterDisabled, isAnimationActive, hideXAxis, hideYAxis, hideCartesianGrid, }: ChartProps) => import("react/jsx-runtime").JSX.Element;
|
|
39
39
|
export default Chart;
|
|
40
40
|
//# sourceMappingURL=Chart.d.ts.map
|
package/dist/esm/Chart.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chart.d.ts","sourceRoot":"","sources":["../../src/Chart.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Chart.d.ts","sourceRoot":"","sources":["../../src/Chart.tsx"],"names":[],"mappings":";AA2BA,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC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|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
// @ts-nocheck
|
|
3
3
|
import { useState, useEffect, useContext, useMemo } from 'react';
|
|
4
4
|
import { aggregate } from './utils/aggregate';
|
|
@@ -14,6 +14,8 @@ import { valueFormatter } from './utils/valueFormatter';
|
|
|
14
14
|
import LineChart from './components/Chart/LineChart';
|
|
15
15
|
import BarChart from './components/Chart/BarChart';
|
|
16
16
|
import { mergeComparisonRange } from './utils/merge';
|
|
17
|
+
import ChartSkeleton from './components/Chart/ChartSkeleton';
|
|
18
|
+
import ChartError from './components/Chart/ChartError';
|
|
17
19
|
// @ts-ignore
|
|
18
20
|
function sumByKey(arr, key) {
|
|
19
21
|
// @ts-ignore
|
|
@@ -67,13 +69,7 @@ function didFiltersChange(dashboardItem, filters) {
|
|
|
67
69
|
}
|
|
68
70
|
return !isEquivalent(dashboardItem.filtersApplied, filters);
|
|
69
71
|
}
|
|
70
|
-
|
|
71
|
-
return s.split('').reduce(function (a, b) {
|
|
72
|
-
a = (a << 5) - a + b.charCodeAt(0);
|
|
73
|
-
return a & a;
|
|
74
|
-
}, 0);
|
|
75
|
-
}
|
|
76
|
-
const Chart = ({ chartId, config, colors, containerStyle, query, SelectComponent, dateRangeFilterDisabled = false, isAnimationActive = true, hideXAxis = false, hideYAxis = false, hideCartesionGrid = false, }) => {
|
|
72
|
+
const Chart = ({ chartId, config, colors, containerStyle, query, SelectComponent, dateRangeFilterDisabled = false, isAnimationActive = true, hideXAxis = false, hideYAxis = false, hideCartesianGrid = false, }) => {
|
|
77
73
|
const { dispatch, dashboard } = useContext(DashboardContext);
|
|
78
74
|
const { dashboardFilters } = useContext(DashboardFiltersContext);
|
|
79
75
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -86,9 +82,9 @@ const Chart = ({ chartId, config, colors, containerStyle, query, SelectComponent
|
|
|
86
82
|
? theme.chartColors
|
|
87
83
|
: ['#4E80EE', '#E14F62', '#55B5A6', '#E9A23B', '#6466E9', '#55B685'];
|
|
88
84
|
}, [colors]);
|
|
89
|
-
return (_jsx(ChartUpdater, { config: config, dispatch: dispatch, dashboard: dashboard, chartId: chartId, containerStyle: containerStyle, colors: chartColors, client: client, theme: theme, dashboardFilters: dashboardFilters, query: query, isAnimationActive: isAnimationActive, hideXAxis: hideXAxis, hideYAxis: hideYAxis,
|
|
85
|
+
return (_jsx(ChartUpdater, { config: config, dispatch: dispatch, dashboard: dashboard, chartId: chartId, containerStyle: containerStyle, colors: chartColors, client: client, theme: theme, dashboardFilters: dashboardFilters, query: query, isAnimationActive: isAnimationActive, hideXAxis: hideXAxis, hideYAxis: hideYAxis, hideCartesianGrid: hideCartesianGrid, dateRangeFilterDisabled: dateRangeFilterDisabled }));
|
|
90
86
|
};
|
|
91
|
-
const ChartUpdater = ({ colors, chartId, config, containerStyle, dashboard, dispatch, client, theme, dashboardFilters, isAnimationActive, hideXAxis, hideYAxis,
|
|
87
|
+
const ChartUpdater = ({ colors, chartId, config, containerStyle, dashboard, dispatch, client, theme, dashboardFilters, isAnimationActive, hideXAxis, hideYAxis, hideCartesianGrid, dateRangeFilterDisabled, }) => {
|
|
92
88
|
const [loading, setLoading] = useState(false);
|
|
93
89
|
const [isComparison, setIsComparison] = useState(false);
|
|
94
90
|
const [bucketData, setBucketData] = useState(null);
|
|
@@ -100,13 +96,14 @@ const ChartUpdater = ({ colors, chartId, config, containerStyle, dashboard, disp
|
|
|
100
96
|
}
|
|
101
97
|
try {
|
|
102
98
|
setLoading(true);
|
|
103
|
-
|
|
99
|
+
// Remove extra fields on each filter so we don't confuse the backend.
|
|
100
|
+
const allowDateRange = !dateRangeFilterDisabled;
|
|
101
|
+
const minimalFilters = Object.values(dashboardFilters).length
|
|
104
102
|
? Object.values(dashboardFilters)
|
|
105
|
-
.filter((f) =>
|
|
103
|
+
.filter((f) => allowDateRange || f.filterType !== 'date_range')
|
|
106
104
|
.map((filter) => {
|
|
107
105
|
const newFilter = { ...filter };
|
|
108
106
|
if (newFilter.filterType === 'date_range') {
|
|
109
|
-
// filter.field = chartDateFilter?.field;
|
|
110
107
|
delete newFilter['field'];
|
|
111
108
|
delete newFilter['options'];
|
|
112
109
|
delete newFilter['selectedValue'];
|
|
@@ -120,16 +117,15 @@ const ChartUpdater = ({ colors, chartId, config, containerStyle, dashboard, disp
|
|
|
120
117
|
...(client.customerId && { orgId: client.customerId }),
|
|
121
118
|
clientId: client.publicKey,
|
|
122
119
|
task: 'item',
|
|
123
|
-
filters:
|
|
120
|
+
filters: minimalFilters,
|
|
124
121
|
},
|
|
125
122
|
};
|
|
126
123
|
const cloudBody = {
|
|
127
124
|
id: chartId,
|
|
128
|
-
filters:
|
|
125
|
+
filters: minimalFilters,
|
|
129
126
|
};
|
|
130
127
|
const resp = await getData(client, 'itempost', 'omit', hostedBody, cloudBody);
|
|
131
|
-
if (resp) {
|
|
132
|
-
setLoading(false);
|
|
128
|
+
if (resp && resp.name !== 'error') {
|
|
133
129
|
setIsComparison(!!resp.compareRows?.length);
|
|
134
130
|
if (resp.compareRows) {
|
|
135
131
|
mergeComparisonRange(resp);
|
|
@@ -143,6 +139,7 @@ const ChartUpdater = ({ colors, chartId, config, containerStyle, dashboard, disp
|
|
|
143
139
|
},
|
|
144
140
|
});
|
|
145
141
|
}
|
|
142
|
+
setLoading(false);
|
|
146
143
|
}
|
|
147
144
|
catch (e) {
|
|
148
145
|
console.log('Error fetching chart: ', e);
|
|
@@ -222,17 +219,12 @@ const ChartUpdater = ({ colors, chartId, config, containerStyle, dashboard, disp
|
|
|
222
219
|
: null;
|
|
223
220
|
}, [pivotTable]);
|
|
224
221
|
if (!config && (!dashboard[chartId] || loading)) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
width: '100%',
|
|
232
|
-
boxSizing: 'content-box',
|
|
233
|
-
borderRadius: 8,
|
|
234
|
-
overflow: 'hidden',
|
|
235
|
-
}, children: _jsxs("svg", { width: "100%", height: "100%", xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink", children: [_jsx("rect", { width: "100%", height: "100%", fill: theme?.loadingStateBackgroundColor || '#F9F9FA' }), _jsx("defs", { fill: theme?.loadingStateBackgroundColor || '#F9F9FA', children: _jsxs("linearGradient", { id: "skeletonGradient", x1: "0%", y1: "0%", x2: "10%", y2: "0%", gradientUnits: "userSpaceOnUse", children: [_jsx("stop", { offset: "0%", stopColor: "rgba(255,255,255,0)" }), _jsx("stop", { offset: "50%", stopColor: "#FEFEFE" }), _jsx("stop", { offset: "100%", stopColor: "rgba(255,255,255,0)" }), _jsx("animate", { attributeName: "x1", from: "-100%", to: "100%", dur: "2s", repeatCount: "indefinite" }), _jsx("animate", { attributeName: "x2", from: "-50%", to: "150%", dur: "2s", repeatCount: "indefinite" })] }) }), _jsx("rect", { width: "50%", height: "100%", fill: "url(#skeletonGradient)", children: _jsx("animate", { attributeName: "x", from: "-100%", to: "100%", dur: "2s", repeatCount: "indefinite" }) })] }) }) }));
|
|
222
|
+
if (loading) {
|
|
223
|
+
return _jsx(ChartSkeleton, { containerStyle: containerStyle });
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
return _jsx(ChartError, { containerStyle: containerStyle });
|
|
227
|
+
}
|
|
236
228
|
}
|
|
237
229
|
// TODO: Figure out if we can use ?? to coalesce these into the variable.
|
|
238
230
|
const chartTypes = [config?.chartType, dashboard[chartId]?.chartType];
|
|
@@ -260,7 +252,7 @@ const ChartUpdater = ({ colors, chartId, config, containerStyle, dashboard, disp
|
|
|
260
252
|
}
|
|
261
253
|
if (chartTypes.includes('table')) {
|
|
262
254
|
const data = dashboard[chartId] ? dashboard[chartId] : config;
|
|
263
|
-
return (_jsx(SpecialTable, { rows: pivotTable?.rows ?? data.rows ?? [], columns: pivotTable?.columns ?? data.
|
|
255
|
+
return (_jsx(SpecialTable, { rows: pivotTable?.rows ?? data.rows ?? [], columns: pivotTable?.columns ?? data.columns ?? data.yAxisFields, height: '400px', containerStyle: {
|
|
264
256
|
...containerStyle,
|
|
265
257
|
}, theme: theme, isTableChart: true, name: data.name }));
|
|
266
258
|
}
|
|
@@ -330,7 +322,7 @@ const ChartUpdater = ({ colors, chartId, config, containerStyle, dashboard, disp
|
|
|
330
322
|
? config.xAxisFormat
|
|
331
323
|
: bucketData
|
|
332
324
|
? bucketData.xAxisFormat
|
|
333
|
-
: dashboard[chartId].xAxisFormat, containerStyle: containerStyle, comparison: dateFilter?.comparison, isAnimationActive: isAnimationActive, hideXAxis: hideXAxis, hideYAxis: hideYAxis,
|
|
325
|
+
: dashboard[chartId].xAxisFormat, containerStyle: containerStyle, comparison: dateFilter?.comparison, isAnimationActive: isAnimationActive, hideXAxis: hideXAxis, hideYAxis: hideYAxis, hideCartesianGrid: hideCartesianGrid }));
|
|
334
326
|
}
|
|
335
327
|
if (chartTypes.includes('metric')) {
|
|
336
328
|
const data = dashboard[chartId] ? dashboard[chartId] : config;
|
|
@@ -373,6 +365,6 @@ const ChartUpdater = ({ colors, chartId, config, containerStyle, dashboard, disp
|
|
|
373
365
|
? config.xAxisFormat
|
|
374
366
|
: bucketData
|
|
375
367
|
? bucketData.xAxisFormat
|
|
376
|
-
: dashboard[chartId].xAxisFormat, containerStyle: containerStyle, theme: theme, comparison: dateFilter?.comparison, isAnimationActive: isAnimationActive, hideXAxis: hideXAxis, hideYAxis: hideYAxis,
|
|
368
|
+
: dashboard[chartId].xAxisFormat, containerStyle: containerStyle, theme: theme, comparison: dateFilter?.comparison, isAnimationActive: isAnimationActive, hideXAxis: hideXAxis, hideYAxis: hideYAxis, hideCartesianGrid: hideCartesianGrid }));
|
|
377
369
|
};
|
|
378
370
|
export default Chart;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartBuilder.d.ts","sourceRoot":"","sources":["../../src/ChartBuilder.tsx"],"names":[],"mappings":"AACA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAWhF,OA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AW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AACD,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,KAAK,EAAE,iBAAiB,2CA4B5D"}
|
package/dist/esm/ChartBuilder.js
CHANGED
|
@@ -30,13 +30,9 @@ const POSTGRES_DATE_TYPES = [
|
|
|
30
30
|
'time',
|
|
31
31
|
'timetz',
|
|
32
32
|
];
|
|
33
|
-
|
|
34
|
-
// const parser = new Parser();
|
|
33
|
+
function getTablesHelper(ast, allTables) {
|
|
35
34
|
const tables = [];
|
|
36
35
|
const withAliases = [];
|
|
37
|
-
const resp = await getDataFromCloud(client, `astify`, { query: sqlQuery });
|
|
38
|
-
let ast = resp.ast;
|
|
39
|
-
ast = ast.length ? ast[0] : ast;
|
|
40
36
|
if (ast.with && ast.with.length) {
|
|
41
37
|
for (let i = 0; i < ast.with.length; i++) {
|
|
42
38
|
withAliases.push(ast.with[i].name.value);
|
|
@@ -50,10 +46,19 @@ async function getReferencedTables(client, sqlQuery, dbTables) {
|
|
|
50
46
|
}
|
|
51
47
|
}
|
|
52
48
|
}
|
|
53
|
-
|
|
49
|
+
if (ast.from && ast.from.length) {
|
|
50
|
+
for (let i = 0; i < ast.from.length; i++) {
|
|
51
|
+
if (ast.from[i].expr && ast.from[i].expr.ast) {
|
|
52
|
+
const recursiveAST = ast.from[i].expr.ast;
|
|
53
|
+
const recursiveTables = getTablesHelper(recursiveAST, allTables);
|
|
54
|
+
tables.push(...recursiveTables.map((t) => t.name));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const astFrom = ast?.from?.filter((t) => t.table).map((elem) => elem.table) || [];
|
|
54
59
|
const astSelect = ast?.select?.from?.map((elem) => elem.table) || [];
|
|
55
60
|
const tablesInQuery = [...tables, ...astFrom, ...astSelect].filter((elem) => !withAliases.includes(elem));
|
|
56
|
-
return
|
|
61
|
+
return allTables
|
|
57
62
|
.filter((table) => tablesInQuery.includes(table.displayName))
|
|
58
63
|
.map((table) => {
|
|
59
64
|
return {
|
|
@@ -63,6 +68,10 @@ async function getReferencedTables(client, sqlQuery, dbTables) {
|
|
|
63
68
|
})
|
|
64
69
|
.filter((table) => table.columns.length > 0);
|
|
65
70
|
}
|
|
71
|
+
async function getReferencedTables(client, sqlQuery, dbTables) {
|
|
72
|
+
const resp = await getDataFromCloud(client, `astify`, { query: sqlQuery });
|
|
73
|
+
return getTablesHelper(resp.ast.length ? resp.ast[0] : resp.ast, dbTables);
|
|
74
|
+
}
|
|
66
75
|
const AGGREGATION_TYPES = [
|
|
67
76
|
{ label: 'sum', value: 'sum' },
|
|
68
77
|
{ label: 'count', value: 'count' },
|
|
@@ -220,7 +229,7 @@ function ChartBuilderForm({ TextInput = MemoizedTextInput, Select = MemoizedSele
|
|
|
220
229
|
};
|
|
221
230
|
const firstNumberColumn = columns?.find((col) => numberFormatOptions.includes(col.format));
|
|
222
231
|
const formEmptyState = {
|
|
223
|
-
name: '',
|
|
232
|
+
name: 'My Chart',
|
|
224
233
|
dashboardName: dashboardOptions?.[0]?.label,
|
|
225
234
|
columns: columns.map((col) => {
|
|
226
235
|
return { ...col, label: snakeCaseToTitleCase(col.label) };
|
|
@@ -458,7 +467,7 @@ function ChartBuilderForm({ TextInput = MemoizedTextInput, Select = MemoizedSele
|
|
|
458
467
|
}
|
|
459
468
|
: { clientId: publicKey }).toString();
|
|
460
469
|
const resp = await getData(client, `dashedit2?${searchParams}`, 'same-origin', hostedBody, cloudBody);
|
|
461
|
-
if (resp) {
|
|
470
|
+
if (resp && resp.name !== "error") {
|
|
462
471
|
if (resp.compareRows) {
|
|
463
472
|
mergeComparisonRange(resp);
|
|
464
473
|
}
|
package/dist/esm/ChartEditor.js
CHANGED
|
@@ -42,7 +42,7 @@ export default function ChartEditor({ isOpen, chartId, isEditMode, admin = false
|
|
|
42
42
|
filters: [],
|
|
43
43
|
};
|
|
44
44
|
const resp = await getData(client, 'itempost', 'omit', hostedBody, cloudBody);
|
|
45
|
-
if (resp) {
|
|
45
|
+
if (resp && resp.name !== "error") {
|
|
46
46
|
if (resp.compareRows) {
|
|
47
47
|
mergeComparisonRange(resp);
|
|
48
48
|
}
|
package/dist/esm/Context.d.ts
CHANGED
|
@@ -1,34 +1,29 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const
|
|
15
|
-
export declare const
|
|
16
|
-
export declare const
|
|
17
|
-
export declare const
|
|
18
|
-
export declare const
|
|
19
|
-
export declare const
|
|
20
|
-
export declare const
|
|
21
|
-
export declare const
|
|
22
|
-
export declare const ChartDateFiltersContext: React.Context<{}[]>;
|
|
2
|
+
export declare const DateFilterContext: React.Context<any>;
|
|
3
|
+
export declare const SchemaContext: React.Context<any>;
|
|
4
|
+
export declare const ColumnsContext: React.Context<any>;
|
|
5
|
+
export declare const RowsContext: React.Context<any>;
|
|
6
|
+
export declare const SelectedSidebarIndexContext: React.Context<any>;
|
|
7
|
+
export declare const HistoryContext: React.Context<any>;
|
|
8
|
+
export declare const SavedQueriesContext: React.Context<any>;
|
|
9
|
+
export declare const SaveQueryModalStatusContext: React.Context<any>;
|
|
10
|
+
export declare const EditorQueryContext: React.Context<any>;
|
|
11
|
+
export declare const ThemeContext: React.Context<any>;
|
|
12
|
+
export declare const ClientContext: React.Context<any>;
|
|
13
|
+
export declare const CreateVisualizationModalVisibleContext: React.Context<any>;
|
|
14
|
+
export declare const ActiveVisualizationContext: React.Context<any>;
|
|
15
|
+
export declare const QueryResultsLoadingContext: React.Context<any>;
|
|
16
|
+
export declare const EditVisualizationModalVisibleContext: React.Context<any>;
|
|
17
|
+
export declare const ReportBuilderQueryContext: React.Context<any>;
|
|
18
|
+
export declare const SavedReportsQueryContext: React.Context<any>;
|
|
19
|
+
export declare const DashboardContext: React.Context<any>;
|
|
20
|
+
export declare const DashboardFiltersContext: React.Context<any>;
|
|
21
|
+
export declare const ChartDateFiltersContext: React.Context<any>;
|
|
23
22
|
export declare const useChartDateFilters: () => {
|
|
24
23
|
getChartDateFilterById: (id: string) => any;
|
|
25
24
|
setChartDateFilter: (id: string, dateFilter: any) => void;
|
|
26
25
|
};
|
|
27
|
-
|
|
28
|
-
value: string;
|
|
29
|
-
text: string;
|
|
30
|
-
} | null;
|
|
31
|
-
export declare const ComparisonRangeContext: React.Context<ComparisonRangeContextType>;
|
|
26
|
+
export declare const ComparisonRangeContext: React.Context<any>;
|
|
32
27
|
export declare const useDateFilter: () => {
|
|
33
28
|
dateFilter: any;
|
|
34
29
|
setDateFilter: any;
|
|
@@ -37,17 +32,5 @@ export declare const useComparisonRange: () => {
|
|
|
37
32
|
comparisonRange: any;
|
|
38
33
|
setComparisonRange: any;
|
|
39
34
|
};
|
|
40
|
-
export declare const ContextProvider: ({ children, initialTheme, publicKey, environment, authToken, customerId, userId, queryEndpoint, queryHeaders, withCredentials, }:
|
|
41
|
-
children: any;
|
|
42
|
-
initialTheme: any;
|
|
43
|
-
publicKey: any;
|
|
44
|
-
environment: any;
|
|
45
|
-
authToken: any;
|
|
46
|
-
customerId: any;
|
|
47
|
-
userId: any;
|
|
48
|
-
queryEndpoint: any;
|
|
49
|
-
queryHeaders: any;
|
|
50
|
-
withCredentials: any;
|
|
51
|
-
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
52
|
-
export {};
|
|
35
|
+
export declare const ContextProvider: ({ children, initialTheme, publicKey, environment, authToken, customerId, userId, queryEndpoint, queryHeaders, withCredentials, }: any) => import("react/jsx-runtime").JSX.Element | null;
|
|
53
36
|
//# sourceMappingURL=Context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/Context.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/Context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAMN,MAAM,OAAO,CAAC;AAKf,eAAO,MAAM,iBAAiB,oBAAwC,CAAC;AACvE,eAAO,MAAM,aAAa,oBAAwC,CAAC;AACnE,eAAO,MAAM,cAAc,oBAA0C,CAAC;AACtE,eAAO,MAAM,WAAW,oBAA0C,CAAC;AACnE,eAAO,MAAM,2BAA2B,oBAAuC,CAAC;AAChF,eAAO,MAAM,cAAc,oBAAwC,CAAC;AACpE,eAAO,MAAM,mBAAmB,oBAAwC,CAAC;AACzE,eAAO,MAAM,2BAA2B,oBAGtC,CAAC;AACH,eAAO,MAAM,kBAAkB,oBAAwC,CAAC;AACxE,eAAO,MAAM,YAAY,oBAA0C,CAAC;AACpE,eAAO,MAAM,aAAa,oBAA0C,CAAC;AACrE,eAAO,MAAM,sCAAsC,oBAGjD,CAAC;AACH,eAAO,MAAM,0BAA0B,oBAGrC,CAAC;AACH,eAAO,MAAM,0BAA0B,oBAGrC,CAAC;AACH,eAAO,MAAM,oCAAoC,oBAG/C,CAAC;AACH,eAAO,MAAM,yBAAyB,oBAAwC,CAAC;AAC/E,eAAO,MAAM,wBAAwB,oBAAwC,CAAC;AAC9E,eAAO,MAAM,gBAAgB,oBAAwC,CAAC;AACtE,eAAO,MAAM,uBAAuB,oBAAwC,CAAC;AAC7E,eAAO,MAAM,uBAAuB,oBAAwC,CAAC;AAE7E,eAAO,MAAM,mBAAmB;iCAKM,MAAM;6BACV,MAAM,cAAc,GAAG;CAQxD,CAAC;AAEF,eAAO,MAAM,sBAAsB,oBAA2B,CAAC;AAE/D,eAAO,MAAM,aAAa;;;CAGzB,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;CAK9B,CAAC;AAuDF,eAAO,MAAM,eAAe,qIAWzB,GAAG,mDAqML,CAAC"}
|