@quillsql/react 2.11.15 → 2.11.16
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/ChartBuilder.d.ts +7 -4
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +11 -10
- package/dist/cjs/Dashboard.d.ts +1 -0
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +3 -3
- package/dist/cjs/ReportBuilder.d.ts +18 -10
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +125 -72
- package/dist/cjs/SQLEditor.d.ts +1 -7
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +19 -4
- package/dist/cjs/components/ReportBuilder/AddColumnPopover.d.ts +24 -1
- package/dist/cjs/components/ReportBuilder/AddColumnPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddColumnPopover.js +26 -9
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.d.ts +13 -2
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.js +18 -8
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts +2 -2
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddSortPopover.js +7 -7
- package/dist/cjs/components/ReportBuilder/ui.d.ts +0 -1
- package/dist/cjs/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/ui.js +17 -22
- package/dist/cjs/components/ReportBuilder/util.d.ts +1 -0
- package/dist/cjs/components/ReportBuilder/util.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/util.js +20 -1
- package/dist/cjs/components/UiComponents.d.ts +15 -14
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +14 -9
- package/dist/cjs/utils/width.d.ts +12 -0
- package/dist/cjs/utils/width.d.ts.map +1 -0
- package/dist/cjs/utils/width.js +25 -0
- package/dist/esm/ChartBuilder.d.ts +7 -4
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +11 -10
- package/dist/esm/Dashboard.d.ts +1 -0
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +3 -3
- package/dist/esm/ReportBuilder.d.ts +18 -10
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +127 -74
- package/dist/esm/SQLEditor.d.ts +1 -7
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +19 -4
- package/dist/esm/components/ReportBuilder/AddColumnPopover.d.ts +24 -1
- package/dist/esm/components/ReportBuilder/AddColumnPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddColumnPopover.js +27 -10
- package/dist/esm/components/ReportBuilder/AddLimitPopover.d.ts +13 -2
- package/dist/esm/components/ReportBuilder/AddLimitPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddLimitPopover.js +19 -9
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts +2 -2
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddSortPopover.js +7 -7
- package/dist/esm/components/ReportBuilder/ui.d.ts +0 -1
- package/dist/esm/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/ui.js +17 -21
- package/dist/esm/components/ReportBuilder/util.d.ts +1 -0
- package/dist/esm/components/ReportBuilder/util.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/util.js +18 -0
- package/dist/esm/components/UiComponents.d.ts +15 -14
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +14 -9
- package/dist/esm/utils/width.d.ts +12 -0
- package/dist/esm/utils/width.d.ts.map +1 -0
- package/dist/esm/utils/width.js +21 -0
- package/package.json +1 -1
|
@@ -13,6 +13,7 @@ const date_fns_1 = require("date-fns");
|
|
|
13
13
|
const Context_1 = require("./Context");
|
|
14
14
|
const ast_1 = require("./components/ReportBuilder/ast");
|
|
15
15
|
const ChartBuilder_1 = require("./ChartBuilder");
|
|
16
|
+
const UiComponents_2 = require("./components/UiComponents");
|
|
16
17
|
const ui_1 = require("./components/ReportBuilder/ui");
|
|
17
18
|
const postgres_1 = require("./components/ReportBuilder/postgres");
|
|
18
19
|
const convert_1 = require("./components/ReportBuilder/convert");
|
|
@@ -28,6 +29,7 @@ const QuillTable_1 = __importDefault(require("./components/QuillTable"));
|
|
|
28
29
|
const QuillSelect_1 = require("./components/QuillSelect");
|
|
29
30
|
const textProcessing_1 = require("./utils/textProcessing");
|
|
30
31
|
const AddLimitPopover_1 = require("./components/ReportBuilder/AddLimitPopover");
|
|
32
|
+
const width_1 = require("./utils/width");
|
|
31
33
|
/**
|
|
32
34
|
* Quill Report Builder
|
|
33
35
|
*
|
|
@@ -36,7 +38,7 @@ const AddLimitPopover_1 = require("./components/ReportBuilder/AddLimitPopover");
|
|
|
36
38
|
* they can click a button and add that report to their dashboard or export it
|
|
37
39
|
* as a CSV.
|
|
38
40
|
*/
|
|
39
|
-
function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () => void null, destinationDashboard = undefined, organizationName = '', Button = UiComponents_1.MemoizedButton, SecondaryButton = UiComponents_1.MemoizedSecondaryButton, TextInput =
|
|
41
|
+
function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () => void null, destinationDashboard = undefined, organizationName = '', Button = UiComponents_1.MemoizedButton, SecondaryButton = UiComponents_1.MemoizedSecondaryButton, DeleteButton = UiComponents_1.MemoizedDeleteButton, TextInput = UiComponents_2.QuillTextInput, Select = QuillSelect_1.QuillSelectComponent, Table = QuillTable_1.default, Popover = ui_1.QuillPopover, Tabs = ui_1.QuillTabs, Checkbox = UiComponents_1.MemoizedCheckbox, Sidebar = ui_1.QuillSidebar, Container = ui_1.CustomContainer, HandleButton = ui_1.QuillHandleButton, SelectColumn = ui_1.QuillSelectColumn, DraggableColumn = ui_1.QuillDraggableColumn, ButtonLoadingState = ui_1.QuillButtonLoadingState, TableLoadingState = ui_1.QuillTableLoadingState, SidebarHeading = ui_1.QuillSidebarHeading, SidebarSubHeading = ui_1.QuillSidebarSubHeading, FilterPopover = ui_1.QuillFilterPopover, SortPopover = ui_1.QuillSortPopover, Label = UiComponents_1.MemoizedLabel, Header = UiComponents_1.MemoizedHeader, Text = UiComponents_1.MemoizedText, PivotPopover = UiComponents_1.MemoizedPopover, admin = false, hideAi = false, containerStyle, }) {
|
|
40
42
|
const [aiPrompt, setAiPrompt] = (0, react_1.useState)('');
|
|
41
43
|
const [errorMessage, setErrorMessage] = (0, react_1.useState)('');
|
|
42
44
|
const [baseAst, setBaseAst] = (0, react_1.useState)(null);
|
|
@@ -49,6 +51,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
49
51
|
const [activePath, setActivePath] = (0, react_1.useState)(null);
|
|
50
52
|
const [openPopover, setOpenPopover] = (0, react_1.useState)(null);
|
|
51
53
|
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
54
|
+
const [loadingSchema, setLoadingSchema] = (0, react_1.useState)(false);
|
|
52
55
|
const [isChartBuilderOpen, setIsChartBuilderOpen] = (0, react_1.useState)(false);
|
|
53
56
|
const [isPending, setIsPending] = (0, react_1.useState)(false);
|
|
54
57
|
const [isCopying, setIsCopying] = (0, react_1.useState)(false);
|
|
@@ -68,6 +71,10 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
68
71
|
const [initialLoad, setInitialLoad] = (0, react_1.useState)(true);
|
|
69
72
|
const [currentTable, setCurrentTable] = (0, react_1.useState)(initialTableName || '');
|
|
70
73
|
const parentRef = (0, react_1.useRef)(null);
|
|
74
|
+
const askAIContainerRef = (0, react_1.useRef)(null);
|
|
75
|
+
const askAILoadingContainerRef = (0, react_1.useRef)(null);
|
|
76
|
+
const [askAIInputWidth, setAskAIInputWidth] = (0, react_1.useState)(200);
|
|
77
|
+
const [askAILoadingContainerWidth, setAskAILoadingContainerWidth] = (0, react_1.useState)(200);
|
|
71
78
|
const [theme] = (0, react_1.useContext)(Context_1.ThemeContext);
|
|
72
79
|
const [pivotRowField, setPivotRowField] = (0, react_1.useState)(undefined);
|
|
73
80
|
const [pivotColumnField, setPivotColumnField] = (0, react_1.useState)(undefined);
|
|
@@ -75,6 +82,19 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
75
82
|
const [pivotAggregation, setPivotAggregation] = (0, react_1.useState)(undefined);
|
|
76
83
|
// eslint-disable-next-line no-unused-vars
|
|
77
84
|
const [client, _setClient] = (0, react_1.useContext)(Context_1.ClientContext);
|
|
85
|
+
(0, react_1.useEffect)(() => {
|
|
86
|
+
// Since the TextInput component takes a required numeric width parameter,
|
|
87
|
+
// we dynamically calculate the width of this component here.
|
|
88
|
+
function handleResize() {
|
|
89
|
+
(0, width_1.updateFirstChildWidth)(askAIContainerRef, setAskAIInputWidth, { gap: 12 });
|
|
90
|
+
(0, width_1.updateFirstChildWidth)(askAILoadingContainerRef, setAskAILoadingContainerWidth, { gap: 12 });
|
|
91
|
+
}
|
|
92
|
+
handleResize();
|
|
93
|
+
window.addEventListener('resize', handleResize);
|
|
94
|
+
return () => {
|
|
95
|
+
window.removeEventListener('resize', handleResize);
|
|
96
|
+
};
|
|
97
|
+
}, [baseAst, loading]);
|
|
78
98
|
const enforceOrderOnColumns = (columnNames) => {
|
|
79
99
|
if (pivot) {
|
|
80
100
|
const rowName = pivot.rowField;
|
|
@@ -262,6 +282,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
262
282
|
(0, react_1.useEffect)(() => {
|
|
263
283
|
const fetchSchema = async () => {
|
|
264
284
|
try {
|
|
285
|
+
setLoadingSchema(true);
|
|
265
286
|
const response = await fetch(`${client.queryEndpoint}`, {
|
|
266
287
|
method: 'POST',
|
|
267
288
|
headers: {
|
|
@@ -301,6 +322,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
301
322
|
?.columns.map((c) => c.name);
|
|
302
323
|
await handleAsk(`get ${columnsForTable} from ${initialTableName}`);
|
|
303
324
|
}
|
|
325
|
+
setLoadingSchema(false);
|
|
304
326
|
}
|
|
305
327
|
catch (error) {
|
|
306
328
|
console.error(error);
|
|
@@ -716,7 +738,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
716
738
|
// see onChange callback handleChange
|
|
717
739
|
// eslint-disable-next-line no-unused-vars
|
|
718
740
|
dateColumnPath, dateFilterType, intervalCount, intervalType, intervalPaths, } = (0, util_1.getDateFilterInfo)(node);
|
|
719
|
-
const isPlural = intervalCount
|
|
741
|
+
const isPlural = intervalCount !== 1 ? 's' : '';
|
|
720
742
|
// Pull off the string literal date for "equals" comparisons
|
|
721
743
|
const rawDateStringEquals = node.right?.value ??
|
|
722
744
|
node.right?.args?.value[1]?.column ??
|
|
@@ -783,11 +805,15 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
783
805
|
{ label: 'in the previous', value: 'in the previous' },
|
|
784
806
|
{ label: 'in the current', value: 'in the current' },
|
|
785
807
|
{ label: 'equals', value: 'equals' },
|
|
786
|
-
] }), !['in the current', 'equals'].includes(dateFilterType) && ((0, jsx_runtime_1.jsx)(TextInput, {
|
|
787
|
-
|
|
808
|
+
] }), !['in the current', 'equals'].includes(dateFilterType) && ((0, jsx_runtime_1.jsx)(TextInput, { id: "date_filter_interval_count", value: intervalCount, width: 70, onChange: (e) => {
|
|
809
|
+
if (Number.isNaN(parseFloat(e.target.value || '0'))) {
|
|
810
|
+
alert('Please input a number.');
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
const isPluralNow = parseFloat(e.target.value || '0') !== 1 ? 's' : '';
|
|
788
814
|
intervalPaths.forEach((intervalPath) => handleChangeText([
|
|
789
815
|
{
|
|
790
|
-
value: `${e.target.value} ${intervalType}${isPluralNow}`,
|
|
816
|
+
value: `${e.target.value || 0} ${intervalType}${isPluralNow}`,
|
|
791
817
|
path: keyPrefix + intervalPath,
|
|
792
818
|
},
|
|
793
819
|
]));
|
|
@@ -825,7 +851,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
825
851
|
{ label: `week${isPlural}`, value: 'week' },
|
|
826
852
|
{ label: `day${isPlural}`, value: 'day' },
|
|
827
853
|
{ label: `hour${isPlural}`, value: 'hour' },
|
|
828
|
-
] }), dateFilterType === 'equals' && ((0, jsx_runtime_1.jsx)(TextInput, {
|
|
854
|
+
] }), dateFilterType === 'equals' && ((0, jsx_runtime_1.jsx)(TextInput, { id: "date_filter_equals_raw_date", value: rawDateStringEquals, width: 120, onChange: (e) => {
|
|
829
855
|
handleChangeText([
|
|
830
856
|
{
|
|
831
857
|
value: e.target.value,
|
|
@@ -840,36 +866,38 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
840
866
|
label: (0, textProcessing_1.snakeCaseToTitleCase)(column.displayName),
|
|
841
867
|
value: column.name,
|
|
842
868
|
}));
|
|
843
|
-
const plural = node.right.args.value[1].expr.value
|
|
869
|
+
const plural = node.right.args.value[1].expr.value !== 1 ? 's' : '';
|
|
844
870
|
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
845
871
|
display: 'flex',
|
|
846
872
|
flexDirection: 'row',
|
|
847
873
|
alignItems: 'center',
|
|
848
874
|
gap: 20,
|
|
849
|
-
}, children: [(0, jsx_runtime_1.jsx)(
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
875
|
+
}, children: [(0, jsx_runtime_1.jsx)(Select, { theme: theme, value: node.left.column, onChange: (value) => {
|
|
876
|
+
const columnType = getColumnTypeByName(value);
|
|
877
|
+
if ((0, ast_1.isDateishColumnType)(columnType)) {
|
|
878
|
+
// handleChange(value, keyPrefix + dateColumnPath, "text");
|
|
879
|
+
handleOperatorChange('IN_THE_LAST', node, keyPrefix, value);
|
|
880
|
+
}
|
|
881
|
+
else if ((0, ast_1.isNumericColumnType)(columnType)) {
|
|
882
|
+
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultNumericComparison);
|
|
883
|
+
newSubtree.left.column = value;
|
|
884
|
+
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
885
|
+
}
|
|
886
|
+
else {
|
|
887
|
+
const newSubtree = (0, util_1.deepCopy)(constants_1.defaultEntry);
|
|
888
|
+
newSubtree.left.args.value[0].column = value;
|
|
889
|
+
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
890
|
+
}
|
|
891
|
+
}, options: options }), (0, jsx_runtime_1.jsx)(Select, { theme: theme, value: 'IN_THE_LAST', onChange: (value) => {
|
|
866
892
|
handleOperatorChange(value, node, keyPrefix, dateColumn);
|
|
867
893
|
}, options: [
|
|
868
894
|
{ label: 'in the last', value: 'IN_THE_LAST' },
|
|
869
895
|
{ label: 'in the previous', value: 'IN_THE_PREVIOUS' },
|
|
870
896
|
{ label: 'in the current', value: 'IN_THE_CURRENT' },
|
|
897
|
+
{ label: 'is not null', value: 'IS NOT' },
|
|
898
|
+
{ label: 'is null', value: 'IS' },
|
|
871
899
|
// { label: 'equals', value: 'equals' },
|
|
872
|
-
] }), (0, jsx_runtime_1.jsx)(TextInput, {
|
|
900
|
+
] }), (0, jsx_runtime_1.jsx)(TextInput, { id: 'date_window_interval_count', value: node.right.args.value[1].expr.value, width: 120, onChange: (e) => {
|
|
873
901
|
handleChange([
|
|
874
902
|
{
|
|
875
903
|
value: e.target.value,
|
|
@@ -918,6 +946,8 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
918
946
|
{ label: 'in the last', value: 'IN_THE_LAST' },
|
|
919
947
|
{ label: 'in the previous', value: 'IN_THE_PREVIOUS' },
|
|
920
948
|
{ label: 'in the current', value: 'IN_THE_CURRENT' },
|
|
949
|
+
{ label: 'is not null', value: 'IS NOT' },
|
|
950
|
+
{ label: 'is null', value: 'IS' },
|
|
921
951
|
// { label: 'equals', value: 'equals' },
|
|
922
952
|
] }), (0, jsx_runtime_1.jsx)(Select, { theme: theme, value: node.left.args.value[1].column, onChange: (value) => {
|
|
923
953
|
handleChange([
|
|
@@ -957,12 +987,14 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
957
987
|
newSubtree.left.args.value[0].column = value;
|
|
958
988
|
handleReplaceSubtree(keyPrefix, newSubtree);
|
|
959
989
|
}
|
|
960
|
-
},
|
|
990
|
+
}, options: options }), (0, jsx_runtime_1.jsx)(Select, { theme: theme, value: 'IN_THE_PREVIOUS', onChange: (value) => {
|
|
961
991
|
handleOperatorChange(value, node, keyPrefix, node.left.column);
|
|
962
992
|
}, options: [
|
|
963
993
|
{ label: 'in the last', value: 'IN_THE_LAST' },
|
|
964
994
|
{ label: 'in the previous', value: 'IN_THE_PREVIOUS' },
|
|
965
995
|
{ label: 'in the current', value: 'IN_THE_CURRENT' },
|
|
996
|
+
{ label: 'is not null', value: 'IS NOT' },
|
|
997
|
+
{ label: 'is null', value: 'IS' },
|
|
966
998
|
// { label: 'equals', value: 'equals' },
|
|
967
999
|
] }), (0, jsx_runtime_1.jsx)(Select, { theme: theme, value: node.left.args.value[1].column, onChange: (value) => {
|
|
968
1000
|
const dayConversion = {
|
|
@@ -1006,7 +1038,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1006
1038
|
const tables = (0, ast_1.getTableNames)(baseAst);
|
|
1007
1039
|
const table = tables.length === 1 ? tables[0] : initialTableName;
|
|
1008
1040
|
const columnType = column?.fieldType;
|
|
1009
|
-
|
|
1041
|
+
let operatorOptions = [
|
|
1010
1042
|
...((0, ast_1.isNumericColumnType)(columnType)
|
|
1011
1043
|
? [
|
|
1012
1044
|
{ label: 'equal to', value: '=' },
|
|
@@ -1043,6 +1075,10 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1043
1075
|
]
|
|
1044
1076
|
: []),
|
|
1045
1077
|
];
|
|
1078
|
+
if (client.databaseType === 'BigQuery' &&
|
|
1079
|
+
(0, ast_1.isDateishColumnType)(columnType)) {
|
|
1080
|
+
operatorOptions = operatorOptions.filter((option) => option.value !== 'equals');
|
|
1081
|
+
}
|
|
1046
1082
|
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
1047
1083
|
display: 'flex',
|
|
1048
1084
|
gap: 12,
|
|
@@ -1155,11 +1191,9 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1155
1191
|
const len = node.value.length;
|
|
1156
1192
|
return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'row', gap: 12 }, children: [node.value.map((elem, index) => {
|
|
1157
1193
|
if (elem.value) {
|
|
1158
|
-
return ((0, jsx_runtime_1.jsx)(TextInput, {
|
|
1194
|
+
return ((0, jsx_runtime_1.jsx)(TextInput, { id: `expr_list_${index}`, width: 200, value: elem.value, onChange: (e) => handleChange([
|
|
1159
1195
|
{
|
|
1160
|
-
value:
|
|
1161
|
-
? parseFloat(e.target.value)
|
|
1162
|
-
: e.target.value,
|
|
1196
|
+
value: e.target.value,
|
|
1163
1197
|
path: keyPrefix + `value.${index}.`,
|
|
1164
1198
|
},
|
|
1165
1199
|
]) }, `input_${index}`));
|
|
@@ -1169,23 +1203,19 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1169
1203
|
}
|
|
1170
1204
|
case 'double_quote_string':
|
|
1171
1205
|
case 'single_quote_string':
|
|
1172
|
-
return ((0, jsx_runtime_1.jsx)(TextInput, {
|
|
1206
|
+
return ((0, jsx_runtime_1.jsx)(TextInput, { id: 'quoted_string', value: node.value.replaceAll('%', ''), width: 120, onChange: (e) => handleChange([
|
|
1173
1207
|
{
|
|
1174
|
-
value:
|
|
1175
|
-
? parseFloat(e.target.value)
|
|
1176
|
-
: e.target.value,
|
|
1208
|
+
value: e.target.value,
|
|
1177
1209
|
path: keyPrefix + 'value',
|
|
1178
1210
|
},
|
|
1179
1211
|
]) }));
|
|
1180
1212
|
case 'null':
|
|
1181
1213
|
return (0, jsx_runtime_1.jsx)("div", {});
|
|
1182
1214
|
case 'number':
|
|
1183
|
-
return ((0, jsx_runtime_1.jsx)(TextInput, {
|
|
1215
|
+
return ((0, jsx_runtime_1.jsx)(TextInput, { id: "quill_number_input", value: node.value, width: 120, onChange: (e) => {
|
|
1184
1216
|
handleChange([
|
|
1185
1217
|
{
|
|
1186
|
-
value:
|
|
1187
|
-
? parseFloat(e.target.value)
|
|
1188
|
-
: e.target.value,
|
|
1218
|
+
value: e.target.value,
|
|
1189
1219
|
path: keyPrefix + 'value',
|
|
1190
1220
|
},
|
|
1191
1221
|
]);
|
|
@@ -1212,6 +1242,22 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1212
1242
|
return null;
|
|
1213
1243
|
}
|
|
1214
1244
|
};
|
|
1245
|
+
const isValidPivot = (fields) => {
|
|
1246
|
+
let validPivot = true;
|
|
1247
|
+
if (pivot.rowField &&
|
|
1248
|
+
!fields.find((field) => field.name === pivot.rowField)) {
|
|
1249
|
+
validPivot = false;
|
|
1250
|
+
}
|
|
1251
|
+
if (pivot.valueField &&
|
|
1252
|
+
!fields.find((field) => field.name === pivot.valueField)) {
|
|
1253
|
+
validPivot = false;
|
|
1254
|
+
}
|
|
1255
|
+
if (pivot.columnField &&
|
|
1256
|
+
!fields.find((field) => field.name === pivot.columnField)) {
|
|
1257
|
+
validPivot = false;
|
|
1258
|
+
}
|
|
1259
|
+
return validPivot;
|
|
1260
|
+
};
|
|
1215
1261
|
const renderSentence = (formData, node, keyPrefix = '',
|
|
1216
1262
|
// @depreciated TODO: remove next update
|
|
1217
1263
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -1415,26 +1461,24 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1415
1461
|
orgId: client.customerId,
|
|
1416
1462
|
}),
|
|
1417
1463
|
});
|
|
1464
|
+
const tables = (0, ast_1.getTableNames)(baseAst);
|
|
1465
|
+
const table = tables.length >= 1 ? tables[0] : initialTableName;
|
|
1466
|
+
if (table !== currentTable) {
|
|
1467
|
+
await getDistinctValues(table);
|
|
1468
|
+
setCurrentTable(table);
|
|
1469
|
+
}
|
|
1418
1470
|
const data2 = await res2.json();
|
|
1419
1471
|
if (data2.rows && data2.rows.length) {
|
|
1420
1472
|
const tables = (0, ast_1.getTableNames)(baseAst);
|
|
1421
|
-
const table = tables.length >= 1 ? tables[0] : initialTableName;
|
|
1422
|
-
if (table !== currentTable) {
|
|
1423
|
-
getDistinctValues(table);
|
|
1424
|
-
setCurrentTable(table);
|
|
1425
|
-
}
|
|
1426
|
-
const sortedFields = data2.fields.sort((a, b) => {
|
|
1427
|
-
const aIsId = a.name.toLowerCase() === 'id' ||
|
|
1428
|
-
a.name.toLowerCase().endsWith('_id');
|
|
1429
|
-
const bIsId = b.name.toLowerCase() === 'id' ||
|
|
1430
|
-
b.name.toLowerCase().endsWith('_id');
|
|
1431
|
-
if (aIsId && !bIsId)
|
|
1432
|
-
return 1;
|
|
1433
|
-
if (bIsId && !aIsId)
|
|
1434
|
-
return -1;
|
|
1435
|
-
return 0;
|
|
1436
|
-
});
|
|
1437
1473
|
if (pivot) {
|
|
1474
|
+
// check if any of the pivot fields aren't in the data2.fields array
|
|
1475
|
+
if (!isValidPivot(data2.fields)) {
|
|
1476
|
+
setPivot(null);
|
|
1477
|
+
setPivotData(null);
|
|
1478
|
+
setRows(data2.rows);
|
|
1479
|
+
setFields(data2.fields);
|
|
1480
|
+
return;
|
|
1481
|
+
}
|
|
1438
1482
|
// Do all of this to make sure we have the right unique columns when applying a pivot
|
|
1439
1483
|
let uniqueFormatted = {};
|
|
1440
1484
|
const uniqueRecords = Array.from(new Set(data2.rows.map((row) => row[pivot.columnField]))).reduce((acc, curr) => {
|
|
@@ -1663,7 +1707,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1663
1707
|
// newAst = convertDateComparison(newAst); // TODO
|
|
1664
1708
|
ast = newAst; // so we fetch data for newAst later.
|
|
1665
1709
|
if (table !== currentTable) {
|
|
1666
|
-
getDistinctValues(table);
|
|
1710
|
+
await getDistinctValues(table);
|
|
1667
1711
|
setCurrentTable(table);
|
|
1668
1712
|
}
|
|
1669
1713
|
setPivotRowField(groupByPivot?.rowField);
|
|
@@ -1852,6 +1896,8 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1852
1896
|
height: '100%',
|
|
1853
1897
|
...containerStyle,
|
|
1854
1898
|
}, ref: parentRef, children: [(0, jsx_runtime_1.jsxs)(Sidebar, { children: [(0, jsx_runtime_1.jsx)(SidebarHeading, { label: "Columns" }), (0, jsx_runtime_1.jsx)("div", { style: { height: 4, width: '100%' } }), (0, jsx_runtime_1.jsx)(DraggableColumns, {}), (0, jsx_runtime_1.jsx)(Popover, { isOpen: openPopover === 'AddColumnPopover', trigger: (0, jsx_runtime_1.jsx)(SecondaryButton, { onClick: () => {
|
|
1899
|
+
if (loadingSchema)
|
|
1900
|
+
return;
|
|
1855
1901
|
if (!openPopover) {
|
|
1856
1902
|
setOpenPopover('AddColumnPopover');
|
|
1857
1903
|
}
|
|
@@ -1878,7 +1924,9 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
1878
1924
|
gap: 2.5,
|
|
1879
1925
|
alignItems: 'flex-start',
|
|
1880
1926
|
}, children: [(0, jsx_runtime_1.jsx)(Popover, { isOpen: openPopover === 'AddFilterPopover', title: 'Add filter', trigger: (0, jsx_runtime_1.jsx)(SecondaryButton, { onClick: () => {
|
|
1881
|
-
if (!selectedColumns ||
|
|
1927
|
+
if (!selectedColumns ||
|
|
1928
|
+
selectedColumns.length === 0 ||
|
|
1929
|
+
loading) {
|
|
1882
1930
|
return;
|
|
1883
1931
|
}
|
|
1884
1932
|
if (!openPopover) {
|
|
@@ -2015,7 +2063,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2015
2063
|
if (!pivot) {
|
|
2016
2064
|
fetchSqlQuery(baseAst);
|
|
2017
2065
|
}
|
|
2018
|
-
} }, `sort-sentence-pivot`) })), baseAst && baseAst.orderby && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
2066
|
+
}, Select: Select, Button: Button, SecondaryButton: SecondaryButton }, `sort-sentence-pivot`) })), baseAst && baseAst.orderby && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
2019
2067
|
display: 'flex',
|
|
2020
2068
|
flexDirection: 'column',
|
|
2021
2069
|
gap: 8,
|
|
@@ -2049,7 +2097,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2049
2097
|
if (!pivot) {
|
|
2050
2098
|
fetchSqlQuery(newAst);
|
|
2051
2099
|
}
|
|
2052
|
-
} }, `sort-sentence-${id}`))) })), (0, jsx_runtime_1.jsx)(Popover, { isOpen: openPopover === 'AddSortPopover', setIsOpen: () => { }, trigger: (0, jsx_runtime_1.jsx)(SecondaryButton, { onClick: () => {
|
|
2100
|
+
}, Select: Select, Button: Button, SecondaryButton: SecondaryButton }, `sort-sentence-${id}`))) })), (0, jsx_runtime_1.jsx)(Popover, { isOpen: openPopover === 'AddSortPopover', setIsOpen: () => { }, trigger: (0, jsx_runtime_1.jsx)(SecondaryButton, { onClick: () => {
|
|
2053
2101
|
if (!selectedColumns || selectedColumns.length === 0) {
|
|
2054
2102
|
return;
|
|
2055
2103
|
}
|
|
@@ -2085,7 +2133,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2085
2133
|
setOpenPopover(null);
|
|
2086
2134
|
setBaseAst((0, util_1.deepCopy)(newAst));
|
|
2087
2135
|
fetchSqlQuery(newAst);
|
|
2088
|
-
} }) })) : ((0, jsx_runtime_1.jsx)(Popover, { isOpen: openPopover === 'AddLimitPopover', setIsOpen: () => { }, trigger: (0, jsx_runtime_1.jsx)(SecondaryButton, { onClick: () => {
|
|
2136
|
+
}, TextInput: TextInput, Button: Button, SecondaryButton: SecondaryButton }) })) : ((0, jsx_runtime_1.jsx)(Popover, { isOpen: openPopover === 'AddLimitPopover', setIsOpen: () => { }, trigger: (0, jsx_runtime_1.jsx)(SecondaryButton, { onClick: () => {
|
|
2089
2137
|
if (!openPopover) {
|
|
2090
2138
|
setOpenPopover('AddLimitPopover');
|
|
2091
2139
|
}
|
|
@@ -2094,14 +2142,14 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2094
2142
|
setActiveEditItem(null);
|
|
2095
2143
|
setActivePath(null);
|
|
2096
2144
|
setOpenPopover(null);
|
|
2097
|
-
}, children: (0, jsx_runtime_1.jsx)(TextInput, {
|
|
2145
|
+
}, children: (0, jsx_runtime_1.jsx)(TextInput, { id: "loading_input_limit", value: 0, width: 120, onChange: () => { } }) }))] }), (0, jsx_runtime_1.jsxs)(Container, { children: [!hideAi && ((0, jsx_runtime_1.jsxs)("form", { ref: askAILoadingContainerRef, onSubmit: (event) => {
|
|
2098
2146
|
event.preventDefault();
|
|
2099
2147
|
}, style: {
|
|
2100
2148
|
display: 'flex',
|
|
2101
2149
|
flexDirection: 'row',
|
|
2102
2150
|
gap: 12,
|
|
2103
2151
|
padding: 1,
|
|
2104
|
-
}, children: [(0, jsx_runtime_1.jsx)(TextInput, { placeholder: baseAst ? 'Ask a follow-up question...' : 'Ask a question...',
|
|
2152
|
+
}, children: [(0, jsx_runtime_1.jsx)(TextInput, { id: "ask_ai_loading_bar", placeholder: baseAst ? 'Ask a follow-up question...' : 'Ask a question...', width: askAILoadingContainerWidth, value: aiPrompt, onChange: () => { } }), (0, jsx_runtime_1.jsx)(Button, { onClick: () => { }, label: "Ask AI" }), baseAst && ((0, jsx_runtime_1.jsx)(SecondaryButton, { onClick: clearAllState, label: "New report" }))] })), (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(TableLoadingState, {}), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
2105
2153
|
display: 'flex',
|
|
2106
2154
|
flexDirection: 'row',
|
|
2107
2155
|
gap: '12px',
|
|
@@ -2144,7 +2192,9 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2144
2192
|
gap: 2.5,
|
|
2145
2193
|
alignItems: 'flex-start',
|
|
2146
2194
|
}, children: [(0, jsx_runtime_1.jsx)(Popover, { title: 'Add filter', isOpen: openPopover === 'AddFilterPopover', trigger: (0, jsx_runtime_1.jsx)(SecondaryButton, { onClick: () => {
|
|
2147
|
-
if (!selectedColumns ||
|
|
2195
|
+
if (!selectedColumns ||
|
|
2196
|
+
selectedColumns.length === 0 ||
|
|
2197
|
+
loading) {
|
|
2148
2198
|
return;
|
|
2149
2199
|
}
|
|
2150
2200
|
if (!openPopover) {
|
|
@@ -2291,7 +2341,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2291
2341
|
setOpenPopover(null);
|
|
2292
2342
|
setBaseAst((0, util_1.deepCopy)(baseAst));
|
|
2293
2343
|
fetchSqlQuery((0, util_1.deepCopy)(baseAst));
|
|
2294
|
-
} }, `sort-sentence-pivot`) })), baseAst && baseAst.orderby && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
2344
|
+
}, Select: Select, Button: Button, SecondaryButton: SecondaryButton }, `sort-sentence-pivot`) })), baseAst && baseAst.orderby && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
2295
2345
|
display: 'flex',
|
|
2296
2346
|
flexDirection: 'column',
|
|
2297
2347
|
gap: 8,
|
|
@@ -2333,7 +2383,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2333
2383
|
setOpenPopover(null);
|
|
2334
2384
|
setBaseAst((0, util_1.deepCopy)(newAst));
|
|
2335
2385
|
fetchSqlQuery((0, util_1.deepCopy)(newAst));
|
|
2336
|
-
} }, `sort-sentence-${id}`))) })), (0, jsx_runtime_1.jsx)(Popover, { isOpen: openPopover === 'AddSortPopover', trigger: (0, jsx_runtime_1.jsx)(SecondaryButton, { onClick: () => {
|
|
2386
|
+
}, Select: Select, Button: Button, SecondaryButton: SecondaryButton }, `sort-sentence-${id}`))) })), (0, jsx_runtime_1.jsx)(Popover, { isOpen: openPopover === 'AddSortPopover', trigger: (0, jsx_runtime_1.jsx)(SecondaryButton, { onClick: () => {
|
|
2337
2387
|
if (!selectedColumns || selectedColumns.length === 0) {
|
|
2338
2388
|
return;
|
|
2339
2389
|
}
|
|
@@ -2345,7 +2395,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2345
2395
|
setActiveEditItem(null);
|
|
2346
2396
|
setActivePath(null);
|
|
2347
2397
|
setOpenPopover(null);
|
|
2348
|
-
}, children: (0, jsx_runtime_1.jsx)(AddSortPopover_1.AddSortPopover, { columns: pivot ? [`.${pivot.rowField}`] : selectedColumns, Select: Select, Button: Button, onSave: (column, direction) => {
|
|
2398
|
+
}, children: (0, jsx_runtime_1.jsx)(AddSortPopover_1.AddSortPopover, { columns: pivot ? [`.${pivot.rowField}`] : selectedColumns, Select: Select, Button: Button, SecondaryButton: SecondaryButton, onSave: (column, direction) => {
|
|
2349
2399
|
if (column === '')
|
|
2350
2400
|
return;
|
|
2351
2401
|
if (pivot) {
|
|
@@ -2393,7 +2443,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2393
2443
|
setOpenPopover(null);
|
|
2394
2444
|
setBaseAst((0, util_1.deepCopy)(newAst));
|
|
2395
2445
|
fetchSqlQuery((0, util_1.deepCopy)(newAst));
|
|
2396
|
-
} }) })) : ((0, jsx_runtime_1.jsx)(Popover, { isOpen: openPopover === 'AddLimitPopover', setIsOpen: () => { }, trigger: (0, jsx_runtime_1.jsx)(SecondaryButton, { onClick: () => {
|
|
2446
|
+
}, TextInput: TextInput, Button: Button, SecondaryButton: SecondaryButton }) })) : ((0, jsx_runtime_1.jsx)(Popover, { isOpen: openPopover === 'AddLimitPopover', setIsOpen: () => { }, trigger: (0, jsx_runtime_1.jsx)(SecondaryButton, { onClick: () => {
|
|
2397
2447
|
if (!selectedColumns || selectedColumns.length === 0) {
|
|
2398
2448
|
return;
|
|
2399
2449
|
}
|
|
@@ -2408,7 +2458,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2408
2458
|
setActiveEditItem(null);
|
|
2409
2459
|
setActivePath(null);
|
|
2410
2460
|
setOpenPopover(null);
|
|
2411
|
-
}, children: (0, jsx_runtime_1.jsx)(AddLimitPopover_1.AddLimitPopover, { TextInput: TextInput, onSave: (limit) => {
|
|
2461
|
+
}, children: (0, jsx_runtime_1.jsx)(AddLimitPopover_1.AddLimitPopover, { TextInput: TextInput, Button: Button, SecondaryButton: SecondaryButton, onSave: (limit) => {
|
|
2412
2462
|
const newAst = { ...baseAst };
|
|
2413
2463
|
newAst.limit = {
|
|
2414
2464
|
seperator: '',
|
|
@@ -2422,7 +2472,7 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2422
2472
|
setOpenPopover(null);
|
|
2423
2473
|
setBaseAst((0, util_1.deepCopy)(newAst));
|
|
2424
2474
|
fetchSqlQuery((0, util_1.deepCopy)(newAst));
|
|
2425
|
-
} }) }))] }), (0, jsx_runtime_1.jsxs)(Container, { children: [!hideAi && ((0, jsx_runtime_1.jsxs)("form", { onSubmit: (event) => {
|
|
2475
|
+
} }) }))] }), (0, jsx_runtime_1.jsxs)(Container, { children: [!hideAi && ((0, jsx_runtime_1.jsxs)("form", { ref: askAIContainerRef, onSubmit: (event) => {
|
|
2426
2476
|
event.preventDefault();
|
|
2427
2477
|
handleAsk();
|
|
2428
2478
|
}, style: {
|
|
@@ -2430,14 +2480,14 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2430
2480
|
flexDirection: 'row',
|
|
2431
2481
|
gap: 12,
|
|
2432
2482
|
padding: 1,
|
|
2433
|
-
}, children: [(0, jsx_runtime_1.jsx)(TextInput, {
|
|
2483
|
+
}, children: [(0, jsx_runtime_1.jsx)(TextInput, { id: "ask_ai_input_bar", value: aiPrompt, width: askAIInputWidth, onChange: (e) => setAiPrompt(e.target.value), placeholder: baseAst ? 'Ask a follow-up question...' : 'Ask a question...' }), (0, jsx_runtime_1.jsx)(Button, { onClick: handleAsk, label: 'Ask AI' }), baseAst && ((0, jsx_runtime_1.jsx)(SecondaryButton, { label: 'New report', onClick: clearAllState }))] })), baseAst && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: loading && errorMessage.length === 0 ? ((0, jsx_runtime_1.jsx)(TableLoadingState, {})) : ((0, jsx_runtime_1.jsx)(Table, { rows: applyFormatting({
|
|
2434
2484
|
rows: pivotData?.rows || rows,
|
|
2435
2485
|
fields: pivotData?.fields || fields,
|
|
2436
2486
|
}, baseAst?.columns ?? []), columns: pivot
|
|
2437
2487
|
? pivotData?.columns || emptyPivotColumns()
|
|
2438
2488
|
: enforceOrderOnColumns(Object.keys(rows[0] ?? {})).map((c) => {
|
|
2439
2489
|
return { label: (0, textProcessing_1.snakeCaseToTitleCase)(c), field: c };
|
|
2440
|
-
}),
|
|
2490
|
+
}), rowsPerPage: 20 })) })), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
2441
2491
|
display: 'flex',
|
|
2442
2492
|
flexDirection: 'row',
|
|
2443
2493
|
gap: '12px',
|
|
@@ -2448,6 +2498,9 @@ function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () =>
|
|
|
2448
2498
|
whiteSpace: 'nowrap',
|
|
2449
2499
|
}, children: errorMessage })), (0, jsx_runtime_1.jsx)("div", { style: { width: '100%' } }), baseAst && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SecondaryButton, { label: isCopying ? '✅ Copied' : 'Copy SQL', onClick: () => copyToClipboard(activeQuery) }), (0, jsx_runtime_1.jsx)(Button, { onClick: () => {
|
|
2450
2500
|
setIsChartBuilderOpen(true);
|
|
2451
|
-
}, label: 'Add to dashboard' })] }))] })] }), (0, jsx_runtime_1.jsx)("style", { children: `body{margin:0;}` }), (0, jsx_runtime_1.jsx)(ChartBuilder_1.ChartBuilderWithModal, { rows: applyFormatting({ rows, fields }, baseAst?.columns ?? []), columns: processColumnsForChartBuilder(Object.keys(rows[0] ?? {})), fields: fields, pivot: pivot, query: activeQuery, showTableFormatOptions: admin ? true : false, showDateFieldOptions: admin ? true : false, showAccessControlOptions: admin ? true : false, title: "Add to dashboard", isEditMode: true, isOpen: isChartBuilderOpen, setIsOpen: setIsChartBuilderOpen, onAddToDashboardComplete: onAddToDashboardComplete, destinationDashboard: destinationDashboard, organizationName: organizationName, pivotData: pivotData
|
|
2501
|
+
}, label: 'Add to dashboard' })] }))] })] }), (0, jsx_runtime_1.jsx)("style", { children: `body{margin:0;}` }), (0, jsx_runtime_1.jsx)(ChartBuilder_1.ChartBuilderWithModal, { rows: applyFormatting({ rows, fields }, baseAst?.columns ?? []), columns: processColumnsForChartBuilder(Object.keys(rows[0] ?? {})), fields: fields, pivot: pivot, query: activeQuery, showTableFormatOptions: admin ? true : false, showDateFieldOptions: admin ? true : false, showAccessControlOptions: admin ? true : false, title: "Add to dashboard", isEditMode: true, isOpen: isChartBuilderOpen, setIsOpen: setIsChartBuilderOpen, onAddToDashboardComplete: onAddToDashboardComplete, destinationDashboard: destinationDashboard, organizationName: organizationName, pivotData: pivotData, Select: Select, TextInput: TextInput, Button: Button, SecondaryButton: SecondaryButton, Header: Header, Label: Label, Text: Text,
|
|
2502
|
+
// TODO: Modal={Modal}
|
|
2503
|
+
// TODO: Popover={Popover}
|
|
2504
|
+
DeleteButton: DeleteButton })] }));
|
|
2452
2505
|
}
|
|
2453
2506
|
exports.default = ReportBuilder;
|
package/dist/cjs/SQLEditor.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ModalComponentProps, TableComponentProps } from './components/UiComponents';
|
|
2
|
+
import { ModalComponentProps, TableComponentProps, TextInputComponentProps } from './components/UiComponents';
|
|
3
3
|
export declare function convertPostgresColumn(column: any): {
|
|
4
4
|
label: any;
|
|
5
5
|
field: any;
|
|
@@ -38,12 +38,6 @@ interface SQLEditorProps {
|
|
|
38
38
|
organizationName?: string;
|
|
39
39
|
chartBuilderHorizontalView?: boolean;
|
|
40
40
|
}
|
|
41
|
-
interface TextInputComponentProps {
|
|
42
|
-
onChange: (e: any) => void;
|
|
43
|
-
value: string;
|
|
44
|
-
id: string;
|
|
45
|
-
placeholder?: string;
|
|
46
|
-
}
|
|
47
41
|
export default function QueryEditor({ containerStyle, ButtonComponent, SecondaryButtonComponent, TextInputComponent, TableComponent, newQueryEnabled, LoadingComponent, ModalComponent, defaultQuery, onChangeQuery, onChangeData, onChangeColumns, onChangeFields, isEditMode, chartBuilderEnabled, showTableFormatOptions, showDateFieldOptions, showAccessControlOptions, destinationDashboard, chartBuilderTitle, chartBuilderButtonLabel, onAddToDashboardComplete, addToDashboardButtonLabel, dashboardItem, organizationName, chartBuilderHorizontalView, }: SQLEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
48
42
|
export declare const SchemaListComponent: ({ schema, theme, loading, LoadingComponent, width, onClick, }: {
|
|
49
43
|
schema: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SQLEditor.d.ts","sourceRoot":"","sources":["../../src/SQLEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"SQLEditor.d.ts","sourceRoot":"","sources":["../../src/SQLEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAON,MAAM,OAAO,CAAC;AAQf,OAAO,EAGL,mBAAmB,EACnB,mBAAmB,EAEnB,uBAAuB,EACxB,MAAM,2BAA2B,CAAC;AAKnC,wBAAgB,qBAAqB,CAAC,MAAM,KAAA;;;;;EAwE3C;AA2BD,UAAU,oBAAoB;IAC5B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,cAAc;IACtB,cAAc,EAAE,KAAK,CAAC,aAAa,CAAC;IAEpC,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,GAAG,CAAC,OAAO,CAAC;IAC/D,wBAAwB,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,GAAG,CAAC,OAAO,CAAC;IAExE,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,GAAG,CAAC,OAAO,CAAC;IACrE,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,GAAG,CAAC,OAAO,CAAC;IAC7D,gBAAgB,CAAC,EAAE,MAAM,GAAG,CAAC,OAAO,CAAC;IACrC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,GAAG,CAAC,OAAO,CAAC;IAC9D,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACxC,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC9C,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,wBAAwB,CAAC,EAAE,MAAM,IAAI,CAAC;IACtC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACtC;AA6CD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,cAAoC,EACpC,eAAgC,EAChC,wBAAkD,EAClD,kBAAmC,EACnC,cAA2B,EAC3B,eAAuB,EACvB,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,eAAe,EACf,cAAc,EACd,UAAkB,EAClB,mBAA2B,EAC3B,sBAA8B,EAC9B,oBAA4B,EAC5B,wBAAgC,EAChC,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,yBAA8C,EAC9C,aAAyB,EACzB,gBAA4B,EAC5B,0BAAkC,GACnC,EAAE,cAAc,2CAgYhB;AA6JD,eAAO,MAAM,mBAAmB;;;;;;;6CAuG/B,CAAC"}
|
package/dist/cjs/SQLEditor.js
CHANGED
|
@@ -15,7 +15,8 @@ const QuillTable_1 = __importDefault(require("./components/QuillTable"));
|
|
|
15
15
|
const dataFetcher_1 = require("./utils/dataFetcher");
|
|
16
16
|
const ChartBuilder_1 = require("./ChartBuilder");
|
|
17
17
|
const UiComponents_1 = require("./components/UiComponents");
|
|
18
|
-
const
|
|
18
|
+
const UiComponents_2 = require("./components/UiComponents");
|
|
19
|
+
const width_1 = require("./utils/width");
|
|
19
20
|
function convertPostgresColumn(column) {
|
|
20
21
|
let format;
|
|
21
22
|
let fieldType;
|
|
@@ -131,7 +132,7 @@ const QuillButton = ({ onClick, label, theme, secondary, }) => ((0, jsx_runtime_
|
|
|
131
132
|
fontFamily: theme?.fontFamily,
|
|
132
133
|
height: 38,
|
|
133
134
|
}, onClick: onClick, children: label }));
|
|
134
|
-
function QueryEditor({ containerStyle = { height: '100vh' }, ButtonComponent = UiComponents_1.MemoizedButton, SecondaryButtonComponent = UiComponents_1.MemoizedSecondaryButton, TextInputComponent =
|
|
135
|
+
function QueryEditor({ containerStyle = { height: '100vh' }, ButtonComponent = UiComponents_1.MemoizedButton, SecondaryButtonComponent = UiComponents_1.MemoizedSecondaryButton, TextInputComponent = UiComponents_2.QuillTextInput, TableComponent = QuillTable_1.default, newQueryEnabled = false, LoadingComponent, ModalComponent, defaultQuery, onChangeQuery, onChangeData, onChangeColumns, onChangeFields, isEditMode = false, chartBuilderEnabled = false, showTableFormatOptions = false, showDateFieldOptions = false, showAccessControlOptions = false, destinationDashboard, chartBuilderTitle, chartBuilderButtonLabel, onAddToDashboardComplete, addToDashboardButtonLabel = 'Add to dashboard', dashboardItem = undefined, organizationName = undefined, chartBuilderHorizontalView = false, }) {
|
|
135
136
|
const [sqlPrompt, setSqlPrompt] = (0, react_1.useState)('');
|
|
136
137
|
const [client] = (0, react_1.useContext)(Context_1.ClientContext);
|
|
137
138
|
const [theme] = (0, react_1.useContext)(Context_1.ThemeContext);
|
|
@@ -146,6 +147,20 @@ function QueryEditor({ containerStyle = { height: '100vh' }, ButtonComponent = U
|
|
|
146
147
|
const [schemaLoading, setSchemaLoading] = (0, react_1.useState)(false);
|
|
147
148
|
const [isChartBuilderOpen, setIsChartBuilderOpen] = (0, react_1.useState)(false);
|
|
148
149
|
const [displayTable, setDisplayTable] = (0, react_1.useState)(false);
|
|
150
|
+
const formRef = (0, react_1.useRef)(null);
|
|
151
|
+
const [searchBarWidth, setSearchBarWidth] = (0, react_1.useState)(200);
|
|
152
|
+
(0, react_1.useEffect)(() => {
|
|
153
|
+
// Since the TextInput component takes a required numeric width parameter,
|
|
154
|
+
// we dynamically calculate the width of this component here.
|
|
155
|
+
function handleResize() {
|
|
156
|
+
(0, width_1.updateFirstChildWidth)(formRef, setSearchBarWidth, { gap: 12 });
|
|
157
|
+
}
|
|
158
|
+
handleResize();
|
|
159
|
+
window.addEventListener('resize', handleResize);
|
|
160
|
+
return () => {
|
|
161
|
+
window.removeEventListener('resize', handleResize);
|
|
162
|
+
};
|
|
163
|
+
}, []);
|
|
149
164
|
const getSchema = async (isSubscribed) => {
|
|
150
165
|
setSchemaLoading(true);
|
|
151
166
|
const { queryEndpoint, queryHeaders, publicKey } = client;
|
|
@@ -295,7 +310,7 @@ function QueryEditor({ containerStyle = { height: '100vh' }, ButtonComponent = U
|
|
|
295
310
|
width: 'calc(100% - 290px)',
|
|
296
311
|
height: '100%',
|
|
297
312
|
overflowX: 'hidden',
|
|
298
|
-
}, children: [(0, jsx_runtime_1.jsxs)("form", { onSubmit: (e) => {
|
|
313
|
+
}, children: [(0, jsx_runtime_1.jsxs)("form", { ref: formRef, onSubmit: (e) => {
|
|
299
314
|
e.preventDefault();
|
|
300
315
|
handleRunSqlPrompt();
|
|
301
316
|
}, style: {
|
|
@@ -304,7 +319,7 @@ function QueryEditor({ containerStyle = { height: '100vh' }, ButtonComponent = U
|
|
|
304
319
|
gap: 12,
|
|
305
320
|
paddingTop: 16,
|
|
306
321
|
paddingBottom: 16,
|
|
307
|
-
}, children: [(0, jsx_runtime_1.jsx)(TextInputComponent, { id: "ai-search", value: sqlPrompt,
|
|
322
|
+
}, children: [(0, jsx_runtime_1.jsx)(TextInputComponent, { id: "ai-search", value: sqlPrompt, width: searchBarWidth, onChange: (e) => setSqlPrompt(e.target.value), placeholder: "Ask a question..." }), (ButtonComponent && ((0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: handleRunSqlPrompt, label: "Ask AI" }))) || ((0, jsx_runtime_1.jsx)(QuillButton, { theme: theme, onClick: handleRunSqlPrompt, label: "Ask AI" }))] }), (0, jsx_runtime_1.jsx)("div", { style: { height: 'calc(50% - 40px)' }, children: (0, jsx_runtime_1.jsx)(SQLEditorComponent, { query: query, setQuery: setQuery, handleRunQuery: handleRunQuery, handleFixWithAI: handleFixWithAI, newQueryEnabled: newQueryEnabled, handleClearQuery: handleClearQuery, theme: theme, defineEditorTheme: defineEditorTheme, setEditorTheme: setEditorTheme, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, loading: sqlResponseLoading, LoadingComponent: LoadingComponent }) }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
308
323
|
display: 'flex',
|
|
309
324
|
flexDirection: 'column',
|
|
310
325
|
height: 'calc(50% - 108px)',
|
|
@@ -1,2 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TextInputComponentProps } from '../UiComponents';
|
|
3
|
+
export default function AddColumnPopover({ onSave, orderedColumnNames, setOrderedColumnNames, selectedColumns, setSelectedColumns, isSelectedAllColumns, clearAllState, nameToColumn, baseAst, setBaseAst, pivot, initialTableName, defaultAST, defaultTable, setPivot, TextInput, SelectColumn, SecondaryButton, Button, HandleButton, }: {
|
|
4
|
+
onSave: any;
|
|
5
|
+
orderedColumnNames: any;
|
|
6
|
+
setOrderedColumnNames: any;
|
|
7
|
+
selectedColumns: any;
|
|
8
|
+
setSelectedColumns: any;
|
|
9
|
+
isSelectedAllColumns: any;
|
|
10
|
+
clearAllState: any;
|
|
11
|
+
nameToColumn: any;
|
|
12
|
+
baseAst: any;
|
|
13
|
+
setBaseAst: any;
|
|
14
|
+
pivot: any;
|
|
15
|
+
initialTableName: any;
|
|
16
|
+
defaultAST: any;
|
|
17
|
+
defaultTable: any;
|
|
18
|
+
setPivot: any;
|
|
19
|
+
TextInput: (props: TextInputComponentProps) => JSX.Element;
|
|
20
|
+
SelectColumn: any;
|
|
21
|
+
SecondaryButton: any;
|
|
22
|
+
Button: any;
|
|
23
|
+
HandleButton: any;
|
|
24
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
2
25
|
//# sourceMappingURL=AddColumnPopover.d.ts.map
|