@quillsql/react 2.11.7 → 2.11.9
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/BarList.d.ts +1 -0
- package/dist/cjs/BarList.d.ts.map +1 -1
- package/dist/cjs/BarList.js +55 -46
- package/dist/cjs/Chart.d.ts +4 -0
- package/dist/cjs/Chart.d.ts.map +1 -1
- package/dist/cjs/Chart.js +25 -19
- package/dist/cjs/ChartBuilder.d.ts +5 -3
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +236 -196
- package/dist/cjs/ChartEditor.d.ts +3 -1
- package/dist/cjs/ChartEditor.d.ts.map +1 -1
- package/dist/cjs/ChartEditor.js +17 -2
- package/dist/cjs/Dashboard.d.ts +2 -1
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +4 -4
- package/dist/cjs/PieChart.d.ts +1 -1
- package/dist/cjs/PieChart.d.ts.map +1 -1
- package/dist/cjs/PieChart.js +95 -357
- package/dist/cjs/ReportBuilder.d.ts +11 -3
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +224 -99
- package/dist/cjs/SQLEditor.d.ts +4 -2
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +9 -6
- package/dist/cjs/components/Chart/BarChart.d.ts +2 -1
- package/dist/cjs/components/Chart/BarChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/BarChart.js +9 -5
- package/dist/cjs/components/Chart/ChartError.js +1 -1
- package/dist/cjs/components/Chart/ChartSkeleton.js +2 -2
- package/dist/cjs/components/Chart/LineChart.d.ts +2 -1
- package/dist/cjs/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/LineChart.js +10 -3
- package/dist/cjs/components/Dashboard/TableComponent.d.ts +1 -1
- package/dist/cjs/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/TableComponent.js +1 -1
- package/dist/cjs/components/QuillTable.js +1 -1
- package/dist/cjs/components/ReportBuilder/AddColumnPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddColumnPopover.js +2 -2
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts +3 -0
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts.map +1 -0
- package/dist/cjs/components/ReportBuilder/AddSortPopover.js +62 -0
- package/dist/cjs/components/ReportBuilder/convert.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/convert.js +3 -2
- package/dist/cjs/components/ReportBuilder/ui.d.ts +1 -0
- package/dist/cjs/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/ui.js +11 -3
- package/dist/cjs/components/UiComponents.d.ts +12 -2
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +7 -6
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts +2 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +47 -56
- package/dist/cjs/utils/aggregate.js +2 -2
- package/dist/cjs/utils/color.d.ts +25 -0
- package/dist/cjs/utils/color.d.ts.map +1 -1
- package/dist/cjs/utils/color.js +164 -1
- package/dist/esm/BarList.d.ts +1 -0
- package/dist/esm/BarList.d.ts.map +1 -1
- package/dist/esm/BarList.js +55 -46
- package/dist/esm/Chart.d.ts +4 -0
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +25 -19
- package/dist/esm/ChartBuilder.d.ts +5 -3
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +234 -195
- package/dist/esm/ChartEditor.d.ts +3 -1
- package/dist/esm/ChartEditor.d.ts.map +1 -1
- package/dist/esm/ChartEditor.js +19 -4
- package/dist/esm/Dashboard.d.ts +2 -1
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +4 -4
- package/dist/esm/PieChart.d.ts +1 -1
- package/dist/esm/PieChart.d.ts.map +1 -1
- package/dist/esm/PieChart.js +93 -334
- package/dist/esm/ReportBuilder.d.ts +11 -3
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +229 -104
- package/dist/esm/SQLEditor.d.ts +4 -2
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +9 -6
- package/dist/esm/components/Chart/BarChart.d.ts +2 -1
- package/dist/esm/components/Chart/BarChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/BarChart.js +9 -5
- package/dist/esm/components/Chart/ChartError.js +1 -1
- package/dist/esm/components/Chart/ChartSkeleton.js +2 -2
- package/dist/esm/components/Chart/LineChart.d.ts +2 -1
- package/dist/esm/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/LineChart.js +10 -3
- package/dist/esm/components/Dashboard/TableComponent.d.ts +1 -1
- package/dist/esm/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/TableComponent.js +1 -1
- package/dist/esm/components/QuillTable.js +1 -1
- package/dist/esm/components/ReportBuilder/AddColumnPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddColumnPopover.js +2 -2
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts +3 -0
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts.map +1 -0
- package/dist/esm/components/ReportBuilder/AddSortPopover.js +57 -0
- package/dist/esm/components/ReportBuilder/convert.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/convert.js +3 -2
- package/dist/esm/components/ReportBuilder/ui.d.ts +1 -0
- package/dist/esm/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/ui.js +10 -3
- package/dist/esm/components/UiComponents.d.ts +12 -2
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +7 -6
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts +2 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +47 -56
- package/dist/esm/utils/aggregate.js +2 -2
- package/dist/esm/utils/color.d.ts +25 -0
- package/dist/esm/utils/color.d.ts.map +1 -1
- package/dist/esm/utils/color.js +160 -0
- package/package.json +1 -1
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useContext, useEffect, useState } from 'react';
|
|
3
|
-
import { MemoizedCheckbox } from './components/UiComponents';
|
|
2
|
+
import { useContext, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { MemoizedButton, MemoizedCheckbox, MemoizedHeader, MemoizedLabel, MemoizedPopover, MemoizedSecondaryButton, MemoizedText, } from './components/UiComponents';
|
|
4
4
|
import { DndContext, closestCenter, KeyboardSensor, PointerSensor, useSensor, useSensors, } from '@dnd-kit/core';
|
|
5
5
|
import { arrayMove, SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy, useSortable, } from '@dnd-kit/sortable';
|
|
6
6
|
import { CSS as DND_CSS } from '@dnd-kit/utilities';
|
|
7
7
|
import { getQuarter } from 'date-fns';
|
|
8
|
-
import { ClientContext } from './Context';
|
|
8
|
+
import { ClientContext, ThemeContext } from './Context';
|
|
9
9
|
import { getTableNames, isDateishColumnType, isNumericColumnType, isTextColumnType, } from './components/ReportBuilder/ast';
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
10
|
+
import { ChartBuilderWithModal } from './ChartBuilder';
|
|
11
|
+
import { QuillPopover, QuillSelect, QuillTabs, QuillTextInput, QuillSidebar, CustomContainer, QuillHandleButton, QuillSelectColumn, QuillDraggableColumn, QuillButtonLoadingState, QuillTableLoadingState, QuillSidebarHeading, QuillSidebarSubHeading, QuillFilterPopover, QuillSortPopover, DEFAULT_TAB_OPTIONS, TagWrapper, EditPopover, AddFilterPopover, } from './components/ReportBuilder/ui';
|
|
12
12
|
import { generateCurrentPeriodPostgres, generateEqualsPostgres, generateLastNPeriodsPostgres, generatePreviousPeriodPostgres, } from './components/ReportBuilder/postgres';
|
|
13
|
-
import {
|
|
13
|
+
import { convertBigQuery, convertGroupBy, convertRemoveSimpleParentheses, convertStringComparison, convertWildcardColumns, } from './components/ReportBuilder/convert';
|
|
14
14
|
import { deepCopy, formatDateComparisonNode, getDateFilterInfo, getInTheCurrentIntervalSentence, getInTheLastIntervalSentence, getInThePreviousIntervalSentence, getPostgresBasicType, isColumnComparison, isDateTruncEquals, isInTheLastInterval, isNodeEmptyCollection, isTheCurrentInterval, isThePreviousInterval, isTopLevelBoolean, showNodeAsRow, tryConvertDateEquality, } from './components/ReportBuilder/util';
|
|
15
15
|
import { getDefaultOperatorSubtrees, OPERATOR_GROUPS, } from './components/ReportBuilder/operators';
|
|
16
16
|
import { hashCode } from './utils/crypto';
|
|
17
17
|
import { DATE_FMT, DAY_OF_WEEK, defaultAST, defaultColumn, defaultEntry, defaultNumericComparison, defaultTable, defaultVariant, MONTH_OF_YEAR, } from './components/ReportBuilder/constants';
|
|
18
18
|
import AddColumnPopover from './components/ReportBuilder/AddColumnPopover';
|
|
19
|
+
import { AddSortPopover, SortSentence, } from './components/ReportBuilder/AddSortPopover';
|
|
20
|
+
import { PivotModal, generatePivotTable, } from './internals/ReportBuilder/PivotModal';
|
|
21
|
+
import { PivotCard } from './internals/ReportBuilder/PivotList';
|
|
22
|
+
import QuillTable from './components/QuillTable';
|
|
19
23
|
/**
|
|
20
24
|
* Quill Report Builder
|
|
21
25
|
*
|
|
@@ -24,7 +28,7 @@ import AddColumnPopover from './components/ReportBuilder/AddColumnPopover';
|
|
|
24
28
|
* they can click a button and add that report to their dashboard or export it
|
|
25
29
|
* as a CSV.
|
|
26
30
|
*/
|
|
27
|
-
export default function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () => void null, destinationDashboard = undefined, organizationName = '', Button =
|
|
31
|
+
export default function ReportBuilder({ initialTableName = '', onAddToDashboardComplete = () => void null, destinationDashboard = undefined, organizationName = '', Button = MemoizedButton, SecondaryButton = MemoizedSecondaryButton, TextInput = QuillTextInput, Select = QuillSelect, Table = QuillTable, Popover = QuillPopover, Tabs = QuillTabs, Checkbox = MemoizedCheckbox, Sidebar = QuillSidebar, Container = CustomContainer, HandleButton = QuillHandleButton, SelectColumn = QuillSelectColumn, DraggableColumn = QuillDraggableColumn, ButtonLoadingState = QuillButtonLoadingState, TableLoadingState = QuillTableLoadingState, SidebarHeading = QuillSidebarHeading, SidebarSubHeading = QuillSidebarSubHeading, FilterPopover = QuillFilterPopover, SortPopover = QuillSortPopover, Label = MemoizedLabel, Header = MemoizedHeader, Text = MemoizedText, PivotPopover = MemoizedPopover, admin = false, hideAi = false, }) {
|
|
28
32
|
const [aiPrompt, setAiPrompt] = useState('');
|
|
29
33
|
const [errorMessage, setErrorMessage] = useState('');
|
|
30
34
|
const [baseAst, setBaseAst] = useState(null);
|
|
@@ -47,6 +51,18 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
47
51
|
const [uniqueValues, setUniqueValues] = useState({});
|
|
48
52
|
const [pivot, setPivot] = useState(null);
|
|
49
53
|
const [pivotData, setPivotData] = useState(null);
|
|
54
|
+
const [createdPivots, setCreatedPivots] = useState([]);
|
|
55
|
+
const [recommendedPivots, setRecommendedPivots] = useState([]);
|
|
56
|
+
const [pivotPopUpTitle, setPivotPopUpTitle] = useState('Add Pivot');
|
|
57
|
+
const [showPivotPopover, setShowPivotPopover] = useState(false);
|
|
58
|
+
const [isEdittingPivot, setIsEdittingPivot] = useState(false);
|
|
59
|
+
const [selectedPivotIndex, setSelectedPivotIndex] = useState(-1);
|
|
60
|
+
const parentRef = useRef(null);
|
|
61
|
+
const [theme] = useContext(ThemeContext);
|
|
62
|
+
const [pivotRowField, setPivotRowField] = useState(undefined);
|
|
63
|
+
const [pivotColumnField, setPivotColumnField] = useState(undefined);
|
|
64
|
+
const [pivotValueField, setPivotValueField] = useState(undefined);
|
|
65
|
+
const [pivotAggregation, setPivotAggregation] = useState(undefined);
|
|
50
66
|
// eslint-disable-next-line no-unused-vars
|
|
51
67
|
const [client, _setClient] = useContext(ClientContext);
|
|
52
68
|
const enforceOrderOnColumns = (columnNames) => {
|
|
@@ -1125,7 +1141,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1125
1141
|
]) }, `input_${index}`));
|
|
1126
1142
|
}
|
|
1127
1143
|
return renderNode(elem, keyPrefix + `value.${index}.`);
|
|
1128
|
-
}), len > 1 && (_jsx(SecondaryButton, { onClick: () => handleDeleteVariant(keyPrefix + 'value')
|
|
1144
|
+
}), len > 1 && (_jsx(SecondaryButton, { label: '-', onClick: () => handleDeleteVariant(keyPrefix + 'value') })), _jsx(SecondaryButton, { onClick: () => handleInsertVariant(keyPrefix + 'value'), label: '+' })] }, keyPrefix));
|
|
1129
1145
|
}
|
|
1130
1146
|
case 'double_quote_string':
|
|
1131
1147
|
case 'single_quote_string':
|
|
@@ -1391,7 +1407,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1391
1407
|
flexDirection: 'row',
|
|
1392
1408
|
gap: 8,
|
|
1393
1409
|
justifyContent: 'end',
|
|
1394
|
-
}, children: _jsx(Button, {
|
|
1410
|
+
}, children: _jsx(Button, { onClick: onSave, label: 'Add condition' }) })] }));
|
|
1395
1411
|
};
|
|
1396
1412
|
const fetchUponChange = async () => {
|
|
1397
1413
|
if ((formData || baseAst) && !loading) {
|
|
@@ -1420,7 +1436,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1420
1436
|
return acc;
|
|
1421
1437
|
}, {});
|
|
1422
1438
|
uniqueFormatted[pivot.columnField] = uniqueRecords;
|
|
1423
|
-
const pivotedData =
|
|
1439
|
+
const pivotedData = generatePivotTable(pivot, data2.rows, [null, null, null], false);
|
|
1424
1440
|
console.info(`%c[Pivot]: ${JSON.stringify(pivot)}`, 'color: dimgray');
|
|
1425
1441
|
setPivotData(pivotedData);
|
|
1426
1442
|
}
|
|
@@ -1435,6 +1451,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1435
1451
|
else {
|
|
1436
1452
|
setRows([]);
|
|
1437
1453
|
setFields([]);
|
|
1454
|
+
setPivotData(null);
|
|
1438
1455
|
}
|
|
1439
1456
|
}
|
|
1440
1457
|
catch (e) {
|
|
@@ -1614,7 +1631,12 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1614
1631
|
}
|
|
1615
1632
|
return `${table}.${column.expr.value}`;
|
|
1616
1633
|
}));
|
|
1617
|
-
|
|
1634
|
+
if (groupByPivot) {
|
|
1635
|
+
setBaseAst(deepCopy({ ...newAst, orderby: null }));
|
|
1636
|
+
}
|
|
1637
|
+
else {
|
|
1638
|
+
setBaseAst(deepCopy({ ...newAst }));
|
|
1639
|
+
}
|
|
1618
1640
|
setFormData(deepCopy(newAst.where));
|
|
1619
1641
|
setTopLevelBinaryOperator(
|
|
1620
1642
|
// @ts-ignore
|
|
@@ -1638,7 +1660,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1638
1660
|
const tables = getTableNames(newAst);
|
|
1639
1661
|
const table = tables.length >= 1 ? tables[0] : initialTableName;
|
|
1640
1662
|
if (groupByPivot) {
|
|
1641
|
-
const pivotedData =
|
|
1663
|
+
const pivotedData = generatePivotTable(pivot, data2.rows, [null, null, null], false);
|
|
1642
1664
|
console.info(`%c[Pivot]: ${JSON.stringify(groupByPivot)}`, 'color: dimgray');
|
|
1643
1665
|
setPivotData(pivotedData);
|
|
1644
1666
|
}
|
|
@@ -1778,11 +1800,11 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1778
1800
|
value: column.name,
|
|
1779
1801
|
}));
|
|
1780
1802
|
if (loading) {
|
|
1781
|
-
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'row', height: '100%' }, children: [_jsxs(Sidebar, { children: [_jsx(SidebarHeading, { label: "Columns" }), _jsx("div", { style: { height: 4, width: '100%' } }), _jsx(DraggableColumns, {}), _jsx(Popover, { isOpen: openPopover === 'AddColumnPopover', trigger: _jsx(SecondaryButton, { onClick: () => {
|
|
1803
|
+
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'row', height: '100%' }, ref: parentRef, children: [_jsxs(Sidebar, { children: [_jsx(SidebarHeading, { label: "Columns" }), _jsx("div", { style: { height: 4, width: '100%' } }), _jsx(DraggableColumns, {}), _jsx(Popover, { isOpen: openPopover === 'AddColumnPopover', trigger: _jsx(SecondaryButton, { onClick: () => {
|
|
1782
1804
|
if (!openPopover) {
|
|
1783
1805
|
setOpenPopover('AddColumnPopover');
|
|
1784
1806
|
}
|
|
1785
|
-
},
|
|
1807
|
+
}, label: 'Select columns' }), title: "Select columns", onClose: () => {
|
|
1786
1808
|
setIsPending(false);
|
|
1787
1809
|
setActiveEditItem(null);
|
|
1788
1810
|
setActivePath(null);
|
|
@@ -1820,7 +1842,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1820
1842
|
setActivePath('');
|
|
1821
1843
|
setIsPending(true);
|
|
1822
1844
|
}
|
|
1823
|
-
},
|
|
1845
|
+
}, label: 'Add filter' }), onClose: () => {
|
|
1824
1846
|
setIsPending(false);
|
|
1825
1847
|
setActivePath(null);
|
|
1826
1848
|
setOpenPopover(null);
|
|
@@ -1857,7 +1879,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1857
1879
|
setActivePath('');
|
|
1858
1880
|
setIsPending(true);
|
|
1859
1881
|
}
|
|
1860
|
-
},
|
|
1882
|
+
}, label: 'Add condition' }), onClose: () => {
|
|
1861
1883
|
setIsPending(false);
|
|
1862
1884
|
setTimeout(() => {
|
|
1863
1885
|
setActiveEditItem(null);
|
|
@@ -1885,35 +1907,96 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1885
1907
|
setOpenPopover(null);
|
|
1886
1908
|
clearCheckboxes();
|
|
1887
1909
|
}
|
|
1888
|
-
} }) }))] }), _jsx("div", { style: { height: 28, width: '100%' } }), _jsx(SidebarHeading, { label: "Pivot" }), _jsx("div", { style: { height: 4, width: '100%' } }),
|
|
1910
|
+
} }) }))] }), _jsx("div", { style: { height: 28, width: '100%' } }), _jsx(SidebarHeading, { label: "Pivot" }), _jsx("div", { style: { height: 4, width: '100%' } }), _jsx(PivotModal, { pivotRowField: pivotRowField, setPivotRowField: setPivotRowField, pivotColumnField: pivotColumnField, setPivotColumnField: setPivotColumnField, pivotValueField: pivotValueField, setPivotValueField: setPivotValueField, pivotAggregation: pivotAggregation, setPivotAggregation: setPivotAggregation, createdPivots: createdPivots, setCreatedPivots: setCreatedPivots, recommendedPivots: recommendedPivots, setRecommendedPivots: setRecommendedPivots, popUpTitle: pivotPopUpTitle, setPopUpTitle: setPivotPopUpTitle, selectedTable: initialTableName, SelectComponent: Select, ButtonComponent: Button, PopoverComponent: PivotPopover, TextComponent: Text, isOpen: showPivotPopover, setIsOpen: setShowPivotPopover, showUpdatePivot: isEdittingPivot, setShowUpdatePivot: setIsEdittingPivot, parentRef: parentRef, data: rows, columns: processColumnsForChartBuilder(Object.keys(rows[0] ?? {})), triggerButtonText: 'Add pivot', selectedPivotIndex: selectedPivotIndex, setSelectedPivotIndex: setSelectedPivotIndex, removePivot: () => {
|
|
1911
|
+
setPivot(null);
|
|
1912
|
+
setPivotData(null);
|
|
1913
|
+
}, selectPivot: (pivot) => {
|
|
1914
|
+
if (!pivot)
|
|
1915
|
+
return;
|
|
1916
|
+
const newAst = { ...baseAst };
|
|
1917
|
+
newAst.orderby = null;
|
|
1918
|
+
setBaseAst(newAst); // trigger refetch
|
|
1919
|
+
setPivot(pivot);
|
|
1920
|
+
}, selectPivotOnEdit: true, showTrigger: !pivot, theme: theme, LabelComponent: Label, HeaderComponent: Header, dateRange: [null, null, null], recommendPivotCount: 3 }), pivot && (_jsx(PivotCard, { pivotTable: {
|
|
1921
|
+
pivot: pivot,
|
|
1922
|
+
rows: pivotData?.rows || [],
|
|
1923
|
+
columns: pivotData?.columns || [],
|
|
1924
|
+
}, theme: theme, index: 0, onSelectPivot: () => {
|
|
1925
|
+
setIsEdittingPivot(true);
|
|
1926
|
+
setShowPivotPopover(true);
|
|
1927
|
+
setPivotRowField(pivot?.rowField);
|
|
1928
|
+
setPivotColumnField(pivot?.columnField);
|
|
1929
|
+
setPivotValueField(pivot?.valueField);
|
|
1930
|
+
setPivotAggregation(pivot?.aggregationType);
|
|
1931
|
+
setPivotPopUpTitle('Edit Pivot');
|
|
1932
|
+
}, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent: Button, HeaderComponent: Header, showEdit: false, onClose: () => {
|
|
1933
|
+
setPivot(null);
|
|
1934
|
+
setPivotData(null);
|
|
1935
|
+
setBaseAst(deepCopy(baseAst)); // trigger refetch
|
|
1936
|
+
}, minHeight: 180, LabelComponent: Label, TextComponent: Text })), _jsx("div", { style: { height: 28, width: '100%' } }), _jsx(SidebarHeading, { label: "Sort" }), _jsx("div", { style: { height: 4, width: '100%' } }), pivot && pivot.sort && (_jsx("div", { style: {
|
|
1889
1937
|
display: 'flex',
|
|
1890
1938
|
flexDirection: 'column',
|
|
1891
|
-
gap:
|
|
1939
|
+
gap: 8,
|
|
1892
1940
|
marginBottom: 12,
|
|
1893
|
-
}, children:
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1941
|
+
}, children: _jsx(SortSentence, { sortData: {
|
|
1942
|
+
type: pivot.sortDirection,
|
|
1943
|
+
expr: { type: 'column_ref', column: pivot.rowField },
|
|
1944
|
+
}, columns: selectedColumns, setIsPending: setIsPending, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setOpenPopover: setOpenPopover, SortPopover: SortPopover, EditPopover: AddSortPopover, handleDelete: () => {
|
|
1945
|
+
setPivot({ ...pivot, sort: false });
|
|
1946
|
+
setBaseAst(deepCopy(baseAst));
|
|
1947
|
+
}, onSave: (column, direction) => {
|
|
1948
|
+
setPivot({ ...pivot, sort: true, sortDirection: direction });
|
|
1949
|
+
setOpenPopover(null);
|
|
1950
|
+
setBaseAst(deepCopy(baseAst));
|
|
1951
|
+
} }, `sort-sentence-pivot`) })), baseAst && baseAst.orderby && (_jsx("div", { style: {
|
|
1952
|
+
display: 'flex',
|
|
1953
|
+
flexDirection: 'column',
|
|
1954
|
+
gap: 8,
|
|
1955
|
+
marginBottom: 12,
|
|
1956
|
+
}, children: baseAst.orderby.map((sortData, id) => (_jsx(SortSentence, { sortData: sortData, columns: selectedColumns, onSave: (column, direction) => {
|
|
1957
|
+
setIsPending(false);
|
|
1958
|
+
setActiveEditItem(null);
|
|
1959
|
+
setOpenPopover(null);
|
|
1960
|
+
if (column === '')
|
|
1961
|
+
return;
|
|
1962
|
+
const newAst = { ...baseAst };
|
|
1963
|
+
newAst.orderby[id] = {
|
|
1964
|
+
expr: {
|
|
1965
|
+
type: 'column_ref',
|
|
1966
|
+
table: null,
|
|
1967
|
+
column: column,
|
|
1968
|
+
},
|
|
1969
|
+
type: direction,
|
|
1970
|
+
};
|
|
1971
|
+
// look through the columns
|
|
1972
|
+
setActivePath(null);
|
|
1973
|
+
setOpenPopover(null);
|
|
1974
|
+
setBaseAst(deepCopy(newAst));
|
|
1975
|
+
}, setIsPending: setIsPending, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setOpenPopover: setOpenPopover, SortPopover: SortPopover, EditPopover: AddSortPopover, handleDelete: () => {
|
|
1976
|
+
const newAst = { ...baseAst };
|
|
1977
|
+
newAst.orderby.splice(id, 1);
|
|
1978
|
+
setBaseAst(deepCopy(newAst));
|
|
1979
|
+
} }, `sort-sentence-${id}`))) })), _jsx(Popover, { isOpen: openPopover === 'AddSortPopover', trigger: _jsx(SecondaryButton, { onClick: () => {
|
|
1980
|
+
if (!openPopover) {
|
|
1981
|
+
setOpenPopover('AddSortPopover');
|
|
1982
|
+
}
|
|
1983
|
+
}, label: 'Add sort' }), title: "Sort By", onClose: () => {
|
|
1984
|
+
setIsPending(false);
|
|
1985
|
+
setActiveEditItem(null);
|
|
1986
|
+
setActivePath(null);
|
|
1987
|
+
setOpenPopover(null);
|
|
1988
|
+
}, children: _jsx(AddSortPopover, { columns: selectedColumns, Select: Select, Button: Button, onSave: () => { } }) })] }), _jsxs(Container, { children: [_jsxs("form", { style: {
|
|
1906
1989
|
display: 'flex',
|
|
1907
1990
|
flexDirection: 'row',
|
|
1908
1991
|
gap: 12,
|
|
1909
1992
|
padding: 1,
|
|
1910
|
-
}, children: [_jsx(TextInput, { placeholder: "Ask a question...", type: "text", style: { width: '100%', fontSize: 14 }, value: aiPrompt }), _jsx(ButtonLoadingState, {}), baseAst && (_jsx(SecondaryButton, {
|
|
1993
|
+
}, children: [_jsx(TextInput, { placeholder: "Ask a question...", type: "text", style: { width: '100%', fontSize: 14 }, value: aiPrompt }), _jsx(ButtonLoadingState, {}), baseAst && (_jsx(SecondaryButton, { onClick: clearAllState, label: "New report" }))] }), baseAst && (_jsxs(_Fragment, { children: [_jsx(TableLoadingState, {}), _jsxs("div", { style: {
|
|
1911
1994
|
display: 'flex',
|
|
1912
1995
|
flexDirection: 'row',
|
|
1913
1996
|
gap: '12px',
|
|
1914
|
-
}, children: [_jsx("div", { style: { width: '100%' } }), _jsx(SecondaryButton, {
|
|
1997
|
+
}, children: [_jsx("div", { style: { width: '100%' } }), _jsx(SecondaryButton, { onClick: () => copyToClipboard(activeQuery), label: isCopying ? '✅ Copied' : 'Copy SQL' }), _jsx(Button, { label: 'Add to dashboard', onClick: () => { } })] })] }))] }), _jsx("style", { children: `body{margin:0;}` })] }));
|
|
1915
1998
|
}
|
|
1916
|
-
return (_jsxs("div", { style: {
|
|
1999
|
+
return (_jsxs("div", { ref: parentRef, style: {
|
|
1917
2000
|
display: 'flex',
|
|
1918
2001
|
flexDirection: 'row',
|
|
1919
2002
|
height: '100%',
|
|
@@ -1922,7 +2005,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1922
2005
|
if (!openPopover) {
|
|
1923
2006
|
setOpenPopover('AddColumnPopover');
|
|
1924
2007
|
}
|
|
1925
|
-
},
|
|
2008
|
+
}, label: 'Select columns' }), onClose: () => {
|
|
1926
2009
|
// delay onClose callback so onClick no-ops
|
|
1927
2010
|
setTimeout(() => {
|
|
1928
2011
|
setIsPending(false);
|
|
@@ -1944,7 +2027,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1944
2027
|
flexDirection: 'column',
|
|
1945
2028
|
gap: 2.5,
|
|
1946
2029
|
alignItems: 'flex-start',
|
|
1947
|
-
}, children: [_jsx(Popover, { title: 'Add filter', isOpen: openPopover === 'AddFilterPopover', trigger: _jsx(SecondaryButton, { onClick: (
|
|
2030
|
+
}, children: [_jsx(Popover, { title: 'Add filter', isOpen: openPopover === 'AddFilterPopover', trigger: _jsx(SecondaryButton, { onClick: () => {
|
|
1948
2031
|
if (!openPopover) {
|
|
1949
2032
|
const value = orderedColumnNames[0];
|
|
1950
2033
|
const [_table, column] = value.split('.');
|
|
@@ -1963,7 +2046,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
1963
2046
|
setActivePath('');
|
|
1964
2047
|
setIsPending(true);
|
|
1965
2048
|
}
|
|
1966
|
-
},
|
|
2049
|
+
}, label: 'Add filter' }), onClose: () => {
|
|
1967
2050
|
// delay onClose callback so onClick no-ops
|
|
1968
2051
|
setTimeout(() => {
|
|
1969
2052
|
setIsPending(false);
|
|
@@ -2001,7 +2084,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
2001
2084
|
setActivePath('');
|
|
2002
2085
|
setIsPending(true);
|
|
2003
2086
|
}
|
|
2004
|
-
},
|
|
2087
|
+
}, label: 'Add condition' }), onClose: () => {
|
|
2005
2088
|
// delay onClose callback so onClick no-ops
|
|
2006
2089
|
setTimeout(() => {
|
|
2007
2090
|
setIsPending(false);
|
|
@@ -2030,87 +2113,129 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
2030
2113
|
setOpenPopover(null);
|
|
2031
2114
|
clearCheckboxes();
|
|
2032
2115
|
}
|
|
2033
|
-
} }) }))] }), _jsx("div", { style: { height: 28, width: '100%' } }), _jsx(SidebarHeading, { label: "Pivot" }), _jsx("div", { style: { height: 4, width: '100%' } }),
|
|
2116
|
+
} }) }))] }), _jsx("div", { style: { height: 28, width: '100%' } }), _jsx(SidebarHeading, { label: "Pivot" }), _jsx("div", { style: { height: 4, width: '100%' } }), _jsx(PivotModal, { pivotRowField: pivotRowField, setPivotRowField: setPivotRowField, pivotColumnField: pivotColumnField, setPivotColumnField: setPivotColumnField, pivotValueField: pivotValueField, setPivotValueField: setPivotValueField, pivotAggregation: pivotAggregation, setPivotAggregation: setPivotAggregation, createdPivots: createdPivots, setCreatedPivots: setCreatedPivots, recommendedPivots: recommendedPivots, setRecommendedPivots: setRecommendedPivots, popUpTitle: pivotPopUpTitle, setPopUpTitle: setPivotPopUpTitle, selectedTable: initialTableName, SelectComponent: Select, ButtonComponent: Button, PopoverComponent: PivotPopover, TextComponent: Text, isOpen: showPivotPopover, setIsOpen: setShowPivotPopover, showUpdatePivot: isEdittingPivot, setShowUpdatePivot: setIsEdittingPivot, parentRef: parentRef, data: rows, columns: processColumnsForChartBuilder(Object.keys(rows[0] ?? {})), triggerButtonText: 'Add pivot', selectedPivotIndex: selectedPivotIndex, setSelectedPivotIndex: setSelectedPivotIndex, removePivot: () => {
|
|
2117
|
+
setPivot(null);
|
|
2118
|
+
setPivotData(null);
|
|
2119
|
+
}, selectPivot: (pivot) => {
|
|
2120
|
+
if (!pivot)
|
|
2121
|
+
return;
|
|
2122
|
+
const newAst = { ...baseAst };
|
|
2123
|
+
newAst.orderby = null;
|
|
2124
|
+
setBaseAst(newAst); // trigger refetch
|
|
2125
|
+
setPivot(pivot);
|
|
2126
|
+
}, selectPivotOnEdit: true, showTrigger: !pivot, theme: theme, LabelComponent: Label, HeaderComponent: Header, dateRange: [null, null, null], recommendPivotCount: 3 }), pivot && (_jsx(PivotCard, { pivotTable: {
|
|
2127
|
+
pivot: pivot,
|
|
2128
|
+
rows: pivotData?.rows || [],
|
|
2129
|
+
columns: pivotData?.columns || [],
|
|
2130
|
+
}, theme: theme, index: 0, onSelectPivot: () => {
|
|
2131
|
+
setIsEdittingPivot(true);
|
|
2132
|
+
setShowPivotPopover(true);
|
|
2133
|
+
setPivotRowField(pivot?.rowField);
|
|
2134
|
+
setPivotColumnField(pivot?.columnField);
|
|
2135
|
+
setPivotValueField(pivot?.valueField);
|
|
2136
|
+
setPivotAggregation(pivot?.aggregationType);
|
|
2137
|
+
setPivotPopUpTitle('Edit Pivot');
|
|
2138
|
+
}, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent: Button, HeaderComponent: Header, showEdit: false, onClose: () => {
|
|
2139
|
+
setPivot(null);
|
|
2140
|
+
setPivotData(null);
|
|
2141
|
+
setBaseAst(deepCopy(baseAst)); // trigger refetch
|
|
2142
|
+
}, minHeight: 180, LabelComponent: Label, TextComponent: Text })), _jsx("div", { style: { height: 28, width: '100%' } }), _jsx(SidebarHeading, { label: "Sort" }), _jsx("div", { style: { height: 4, width: '100%' } }), pivot && pivot.sort && (_jsx("div", { style: {
|
|
2034
2143
|
display: 'flex',
|
|
2035
2144
|
flexDirection: 'column',
|
|
2036
|
-
gap:
|
|
2145
|
+
gap: 8,
|
|
2037
2146
|
marginBottom: 12,
|
|
2038
|
-
}, children:
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
{ label: 'avg', value: 'avg' },
|
|
2044
|
-
{ label: 'min', value: 'min' },
|
|
2045
|
-
{ label: 'max', value: 'max' },
|
|
2046
|
-
{ label: 'count', value: 'count' },
|
|
2047
|
-
] })] }), _jsxs("div", { children: [_jsx(SidebarSubHeading, { label: "Value field" }), _jsx(Select, { value: pivot.valueField, onChange: (value) => {
|
|
2048
|
-
setBaseAst(deepCopy(baseAst)); // trigger refetch
|
|
2049
|
-
setPivot({ ...pivot, valueField: value });
|
|
2050
|
-
}, options: [{ label: 'Select', value: '' }, ...allNumericColumns] })] }), _jsxs("div", { children: [_jsx(SidebarSubHeading, { label: "Group rows by" }), _jsx(Select, { value: pivot.rowField ?? '', onChange: (value) => {
|
|
2051
|
-
setBaseAst(deepCopy(baseAst)); // trigger refetch
|
|
2052
|
-
setPivot({
|
|
2053
|
-
...pivot,
|
|
2054
|
-
rowField: value === '' ? undefined : value,
|
|
2055
|
-
});
|
|
2056
|
-
}, options: [
|
|
2057
|
-
{ label: 'Select', value: '' },
|
|
2058
|
-
...allNonNumericColumns,
|
|
2059
|
-
] })] }), _jsxs("div", { children: [_jsx(SidebarSubHeading, { label: "Group columns by" }), _jsx(Select, { value: pivot.columnField ?? '', onChange: (value) => {
|
|
2060
|
-
setBaseAst(deepCopy(baseAst)); // trigger refetch
|
|
2061
|
-
setPivot({
|
|
2062
|
-
...pivot,
|
|
2063
|
-
columnField: value === '' ? undefined : value,
|
|
2064
|
-
});
|
|
2065
|
-
}, options: [
|
|
2066
|
-
{ label: 'Select', value: '' },
|
|
2067
|
-
...allStringColumns,
|
|
2068
|
-
].filter((option) => option.value !== pivot.rowField) })] })] })), _jsx(SecondaryButton, { onClick: () => {
|
|
2069
|
-
if (pivot) {
|
|
2147
|
+
}, children: _jsx(SortSentence, { sortData: {
|
|
2148
|
+
type: pivot.sortDirection,
|
|
2149
|
+
expr: { type: 'column_ref', column: pivot.rowField },
|
|
2150
|
+
}, columns: selectedColumns, setIsPending: setIsPending, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setOpenPopover: setOpenPopover, SortPopover: SortPopover, EditPopover: AddSortPopover, handleDelete: () => {
|
|
2151
|
+
setPivot({ ...pivot, sort: false });
|
|
2070
2152
|
setBaseAst(deepCopy(baseAst));
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2153
|
+
}, onSave: (column, direction) => {
|
|
2154
|
+
setPivot({ ...pivot, sort: true, sortDirection: direction });
|
|
2155
|
+
setOpenPopover(null);
|
|
2156
|
+
setBaseAst(deepCopy(baseAst));
|
|
2157
|
+
} }, `sort-sentence-pivot`) })), baseAst && baseAst.orderby && (_jsx("div", { style: {
|
|
2158
|
+
display: 'flex',
|
|
2159
|
+
flexDirection: 'column',
|
|
2160
|
+
gap: 8,
|
|
2161
|
+
marginBottom: 12,
|
|
2162
|
+
}, children: baseAst.orderby.map((sortData, id) => (_jsx(SortSentence, { sortData: sortData, columns: selectedColumns, setIsPending: setIsPending, setEditPopoverKey: setEditPopoverKey, setActiveEditItem: setActiveEditItem, setOpenPopover: setOpenPopover, SortPopover: SortPopover, EditPopover: AddSortPopover, handleDelete: () => {
|
|
2163
|
+
if (pivot) {
|
|
2164
|
+
setPivot({ ...pivot, sort: false });
|
|
2077
2165
|
return;
|
|
2078
2166
|
}
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
}),
|
|
2089
|
-
from: [{ ...defaultTable, table: initialTableName }],
|
|
2090
|
-
where: null,
|
|
2167
|
+
const newAst = { ...baseAst };
|
|
2168
|
+
newAst.orderby.splice(id, 1);
|
|
2169
|
+
setBaseAst(deepCopy(newAst));
|
|
2170
|
+
}, onSave: (column, direction) => {
|
|
2171
|
+
if (pivot) {
|
|
2172
|
+
setPivot({
|
|
2173
|
+
...pivot,
|
|
2174
|
+
sort: true,
|
|
2175
|
+
sortDirection: direction,
|
|
2091
2176
|
});
|
|
2092
|
-
|
|
2093
|
-
setBaseAst(ast);
|
|
2177
|
+
return;
|
|
2094
2178
|
}
|
|
2095
|
-
|
|
2179
|
+
setIsPending(false);
|
|
2180
|
+
setActiveEditItem(null);
|
|
2181
|
+
setOpenPopover(null);
|
|
2182
|
+
if (column === '')
|
|
2183
|
+
return;
|
|
2184
|
+
const newAst = { ...baseAst };
|
|
2185
|
+
newAst.orderby[id] = {
|
|
2186
|
+
expr: {
|
|
2187
|
+
type: 'column_ref',
|
|
2188
|
+
table: null,
|
|
2189
|
+
column: column,
|
|
2190
|
+
},
|
|
2191
|
+
type: direction,
|
|
2192
|
+
};
|
|
2193
|
+
// look through the columns
|
|
2194
|
+
setActivePath(null);
|
|
2195
|
+
setOpenPopover(null);
|
|
2196
|
+
setBaseAst(deepCopy(newAst));
|
|
2197
|
+
} }, `sort-sentence-${id}`))) })), _jsx(Popover, { isOpen: openPopover === 'AddSortPopover', trigger: _jsx(SecondaryButton, { onClick: () => {
|
|
2198
|
+
if (!openPopover) {
|
|
2199
|
+
setOpenPopover('AddSortPopover');
|
|
2200
|
+
}
|
|
2201
|
+
}, label: 'Add sort' }), title: "Sort by", onClose: () => {
|
|
2202
|
+
setIsPending(false);
|
|
2203
|
+
setActiveEditItem(null);
|
|
2204
|
+
setActivePath(null);
|
|
2205
|
+
setOpenPopover(null);
|
|
2206
|
+
}, children: _jsx(AddSortPopover, { columns: pivot ? [`.${pivot.rowField}`] : selectedColumns, Select: Select, Button: Button, onSave: (column, direction) => {
|
|
2207
|
+
if (column === '')
|
|
2208
|
+
return;
|
|
2209
|
+
if (pivot) {
|
|
2210
|
+
setPivot({ ...pivot, sort: true, sortDirection: direction });
|
|
2211
|
+
setActivePath(null);
|
|
2212
|
+
setOpenPopover(null);
|
|
2096
2213
|
setBaseAst(deepCopy(baseAst));
|
|
2214
|
+
return;
|
|
2097
2215
|
}
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2216
|
+
const newAst = { ...baseAst };
|
|
2217
|
+
if (!newAst.orderby)
|
|
2218
|
+
newAst.orderby = [];
|
|
2219
|
+
newAst.orderby.push({
|
|
2220
|
+
expr: { type: 'column_ref', column },
|
|
2221
|
+
type: direction,
|
|
2103
2222
|
});
|
|
2104
|
-
|
|
2105
|
-
|
|
2223
|
+
// look through the columns
|
|
2224
|
+
setActivePath(null);
|
|
2225
|
+
setOpenPopover(null);
|
|
2226
|
+
setBaseAst(deepCopy(newAst));
|
|
2227
|
+
} }) })] }), _jsxs(Container, { children: [!hideAi && (_jsxs("form", { onSubmit: handleAsk, style: {
|
|
2106
2228
|
display: 'flex',
|
|
2107
2229
|
flexDirection: 'row',
|
|
2108
2230
|
gap: 12,
|
|
2109
2231
|
padding: 1,
|
|
2110
|
-
}, children: [_jsx(TextInput, { type: "text", value: aiPrompt, style: { width: '100%', fontSize: 14 }, onChange: (e) => setAiPrompt(e.target.value), placeholder: baseAst ? 'Ask a follow-up question...' : 'Ask a question...' }), _jsx(Button, {
|
|
2232
|
+
}, children: [_jsx(TextInput, { type: "text", value: aiPrompt, style: { width: '100%', fontSize: 14 }, onChange: (e) => setAiPrompt(e.target.value), placeholder: baseAst ? 'Ask a follow-up question...' : 'Ask a question...' }), _jsx(Button, { onClick: handleAsk, label: 'Ask AI' }), baseAst && (_jsx(SecondaryButton, { label: 'New report', onClick: clearAllState }))] })), baseAst && (_jsxs(_Fragment, { children: [loading && errorMessage.length === 0 ? (_jsx(TableLoadingState, {})) : (_jsx(Table, { rows: applyFormatting({
|
|
2111
2233
|
rows: pivotData?.rows || rows,
|
|
2112
2234
|
fields: pivotData?.fields || fields,
|
|
2113
|
-
}, baseAst?.columns ?? []), columns:
|
|
2235
|
+
}, baseAst?.columns ?? []), columns: pivotData?.columns ||
|
|
2236
|
+
enforceOrderOnColumns(Object.keys(rows[0] ?? {})).map((c) => {
|
|
2237
|
+
return { label: c, field: c };
|
|
2238
|
+
}), error: errorMessage, rowsPerPage: 20 })), _jsxs("div", { style: {
|
|
2114
2239
|
display: 'flex',
|
|
2115
2240
|
flexDirection: 'row',
|
|
2116
2241
|
gap: '12px',
|
|
@@ -2119,7 +2244,7 @@ export default function ReportBuilder({ initialTableName = '', onAddToDashboardC
|
|
|
2119
2244
|
fontSize: 14,
|
|
2120
2245
|
padding: '12px',
|
|
2121
2246
|
whiteSpace: 'nowrap',
|
|
2122
|
-
}, children: errorMessage })), _jsx("div", { style: { width: '100%' } }), _jsx(SecondaryButton, {
|
|
2247
|
+
}, children: errorMessage })), _jsx("div", { style: { width: '100%' } }), _jsx(SecondaryButton, { label: isCopying ? '✅ Copied' : 'Copy SQL', onClick: () => copyToClipboard(activeQuery) }), _jsx(Button, { onClick: () => {
|
|
2123
2248
|
setIsChartBuilderOpen(true);
|
|
2124
|
-
},
|
|
2249
|
+
}, label: 'Add to dashboard' })] })] }))] }), _jsx("style", { children: `body{margin:0;}` }), _jsx(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 })] }));
|
|
2125
2250
|
}
|
package/dist/esm/SQLEditor.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { TableComponentProps } from './components/UiComponents';
|
|
2
|
+
import { ModalComponentProps, TableComponentProps } from './components/UiComponents';
|
|
3
3
|
export declare function convertPostgresColumn(column: any): {
|
|
4
4
|
label: any;
|
|
5
5
|
field: any;
|
|
@@ -17,6 +17,7 @@ interface SQLEditorProps {
|
|
|
17
17
|
TextInputComponent?: (props: TextInputComponentProps) => JSX.Element;
|
|
18
18
|
TableComponent?: (props: TableComponentProps) => JSX.Element;
|
|
19
19
|
LoadingComponent?: () => JSX.Element;
|
|
20
|
+
ModalComponent?: (_props: ModalComponentProps) => JSX.Element;
|
|
20
21
|
onChangeQuery?: (query: string) => void;
|
|
21
22
|
onChangeData?: (data: object[]) => void;
|
|
22
23
|
onChangeColumns?: (columns: object[]) => void;
|
|
@@ -35,6 +36,7 @@ interface SQLEditorProps {
|
|
|
35
36
|
addToDashboardButtonLabel?: string;
|
|
36
37
|
onAddToDashboardComplete?: () => void;
|
|
37
38
|
organizationName?: string;
|
|
39
|
+
chartBuilderHorizontalView?: boolean;
|
|
38
40
|
}
|
|
39
41
|
interface TextInputComponentProps {
|
|
40
42
|
onChange: (e: any) => void;
|
|
@@ -42,7 +44,7 @@ interface TextInputComponentProps {
|
|
|
42
44
|
id: string;
|
|
43
45
|
placeholder?: string;
|
|
44
46
|
}
|
|
45
|
-
export default function QueryEditor({ containerStyle, ButtonComponent, SecondaryButtonComponent, TextInputComponent, TableComponent, newQueryEnabled, LoadingComponent, defaultQuery, onChangeQuery, onChangeData, onChangeColumns, onChangeFields, isEditMode, chartBuilderEnabled, showTableFormatOptions, showDateFieldOptions, showAccessControlOptions, destinationDashboard, chartBuilderTitle, chartBuilderButtonLabel, onAddToDashboardComplete, addToDashboardButtonLabel, dashboardItem, organizationName, }: SQLEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
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;
|
|
46
48
|
export declare const SchemaListComponent: ({ schema, theme, loading, LoadingComponent, width, }: {
|
|
47
49
|
schema: any;
|
|
48
50
|
theme: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SQLEditor.d.ts","sourceRoot":"","sources":["../../src/SQLEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAQxE,OAAO,
|
|
1
|
+
{"version":3,"file":"SQLEditor.d.ts","sourceRoot":"","sources":["../../src/SQLEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAQxE,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,2BAA2B,CAAC;AAGnC,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;AAQD,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAkFD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,cAAoC,EACpC,eAAe,EACf,wBAAwB,EACxB,kBAAkB,EAClB,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,2CA2VhB;AA8LD,eAAO,MAAM,mBAAmB;;;;;;6CAqG/B,CAAC"}
|