@quillsql/react 2.10.39 → 2.11.1
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 +4 -0
- package/dist/cjs/Chart.d.ts.map +1 -1
- package/dist/cjs/Chart.js +5 -5
- package/dist/cjs/ChartBuilder.js +2 -2
- package/dist/cjs/Context.d.ts +1 -1
- package/dist/cjs/Context.d.ts.map +1 -1
- package/dist/cjs/Context.js +3 -1
- package/dist/cjs/Dashboard.d.ts +3 -1
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +4 -4
- package/dist/cjs/QuillProvider.d.ts +3 -1
- package/dist/cjs/QuillProvider.d.ts.map +1 -1
- package/dist/cjs/QuillProvider.js +2 -2
- package/dist/cjs/ReportBuilder.d.ts +40 -40
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +2036 -909
- package/dist/cjs/components/Chart/LineChart.d.ts +5 -1
- package/dist/cjs/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/LineChart.js +18 -6
- package/dist/cjs/components/QuillTable.d.ts +1 -1
- package/dist/cjs/components/QuillTable.d.ts.map +1 -1
- package/dist/cjs/components/QuillTable.js +157 -157
- package/dist/cjs/components/ReportBuilder/AddColumnPopover.d.ts +2 -0
- package/dist/cjs/components/ReportBuilder/AddColumnPopover.d.ts.map +1 -0
- package/dist/cjs/components/ReportBuilder/AddColumnPopover.js +128 -0
- package/dist/cjs/components/ReportBuilder/ast.d.ts +512 -0
- package/dist/cjs/components/ReportBuilder/ast.d.ts.map +1 -0
- package/dist/cjs/components/ReportBuilder/ast.js +210 -0
- package/dist/cjs/components/ReportBuilder/bigDateMap.d.ts +7 -0
- package/dist/cjs/components/ReportBuilder/bigDateMap.d.ts.map +1 -0
- package/dist/cjs/components/ReportBuilder/bigDateMap.js +689 -0
- package/dist/cjs/components/ReportBuilder/constants.d.ts +89 -0
- package/dist/cjs/components/ReportBuilder/constants.d.ts.map +1 -0
- package/dist/cjs/components/ReportBuilder/constants.js +130 -0
- package/dist/cjs/components/ReportBuilder/convert.d.ts +41 -0
- package/dist/cjs/components/ReportBuilder/convert.d.ts.map +1 -0
- package/dist/cjs/components/ReportBuilder/convert.js +730 -0
- package/dist/cjs/components/ReportBuilder/operators.d.ts +445 -0
- package/dist/cjs/components/ReportBuilder/operators.d.ts.map +1 -0
- package/dist/cjs/components/ReportBuilder/operators.js +552 -0
- package/dist/cjs/components/ReportBuilder/pivot.d.ts +10 -0
- package/dist/cjs/components/ReportBuilder/pivot.d.ts.map +1 -0
- package/dist/cjs/components/ReportBuilder/pivot.js +2 -0
- package/dist/cjs/components/ReportBuilder/postgres.d.ts +150 -0
- package/dist/cjs/components/ReportBuilder/postgres.d.ts.map +1 -0
- package/dist/cjs/components/ReportBuilder/postgres.js +365 -0
- package/dist/cjs/components/ReportBuilder/schema.d.ts +23 -0
- package/dist/cjs/components/ReportBuilder/schema.d.ts.map +1 -0
- package/dist/cjs/components/ReportBuilder/schema.js +2 -0
- package/dist/cjs/components/ReportBuilder/ui.d.ts +34 -0
- package/dist/cjs/components/ReportBuilder/ui.d.ts.map +1 -0
- package/dist/cjs/components/ReportBuilder/ui.js +389 -0
- package/dist/cjs/components/ReportBuilder/util.d.ts +76 -0
- package/dist/cjs/components/ReportBuilder/util.d.ts.map +1 -0
- package/dist/cjs/components/ReportBuilder/util.js +648 -0
- package/dist/cjs/components/UiComponents.d.ts +15 -2
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +50 -3
- package/dist/cjs/utils/crypto.d.ts +1 -1
- package/dist/cjs/utils/crypto.d.ts.map +1 -1
- package/dist/cjs/utils/crypto.js +9 -5
- package/dist/esm/Chart.d.ts +4 -0
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +5 -5
- package/dist/esm/ChartBuilder.js +1 -1
- package/dist/esm/Context.d.ts +1 -1
- package/dist/esm/Context.d.ts.map +1 -1
- package/dist/esm/Context.js +3 -1
- package/dist/esm/Dashboard.d.ts +3 -1
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +4 -4
- package/dist/esm/QuillProvider.d.ts +3 -1
- package/dist/esm/QuillProvider.d.ts.map +1 -1
- package/dist/esm/QuillProvider.js +2 -2
- package/dist/esm/ReportBuilder.d.ts +40 -40
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +2038 -909
- package/dist/esm/components/Chart/LineChart.d.ts +5 -1
- package/dist/esm/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/LineChart.js +18 -6
- package/dist/esm/components/QuillTable.d.ts +1 -1
- package/dist/esm/components/QuillTable.d.ts.map +1 -1
- package/dist/esm/components/QuillTable.js +157 -157
- package/dist/esm/components/ReportBuilder/AddColumnPopover.d.ts +2 -0
- package/dist/esm/components/ReportBuilder/AddColumnPopover.d.ts.map +1 -0
- package/dist/esm/components/ReportBuilder/AddColumnPopover.js +125 -0
- package/dist/esm/components/ReportBuilder/ast.d.ts +512 -0
- package/dist/esm/components/ReportBuilder/ast.d.ts.map +1 -0
- package/dist/esm/components/ReportBuilder/ast.js +186 -0
- package/dist/esm/components/ReportBuilder/bigDateMap.d.ts +7 -0
- package/dist/esm/components/ReportBuilder/bigDateMap.d.ts.map +1 -0
- package/dist/esm/components/ReportBuilder/bigDateMap.js +686 -0
- package/dist/esm/components/ReportBuilder/constants.d.ts +89 -0
- package/dist/esm/components/ReportBuilder/constants.d.ts.map +1 -0
- package/dist/esm/components/ReportBuilder/constants.js +127 -0
- package/dist/esm/components/ReportBuilder/convert.d.ts +41 -0
- package/dist/esm/components/ReportBuilder/convert.d.ts.map +1 -0
- package/dist/esm/components/ReportBuilder/convert.js +719 -0
- package/dist/esm/components/ReportBuilder/operators.d.ts +445 -0
- package/dist/esm/components/ReportBuilder/operators.d.ts.map +1 -0
- package/dist/esm/components/ReportBuilder/operators.js +548 -0
- package/dist/esm/components/ReportBuilder/pivot.d.ts +10 -0
- package/dist/esm/components/ReportBuilder/pivot.d.ts.map +1 -0
- package/dist/esm/components/ReportBuilder/pivot.js +1 -0
- package/dist/esm/components/ReportBuilder/postgres.d.ts +150 -0
- package/dist/esm/components/ReportBuilder/postgres.d.ts.map +1 -0
- package/dist/esm/components/ReportBuilder/postgres.js +355 -0
- package/dist/esm/components/ReportBuilder/schema.d.ts +23 -0
- package/dist/esm/components/ReportBuilder/schema.d.ts.map +1 -0
- package/dist/esm/components/ReportBuilder/schema.js +1 -0
- package/dist/esm/components/ReportBuilder/ui.d.ts +34 -0
- package/dist/esm/components/ReportBuilder/ui.d.ts.map +1 -0
- package/dist/esm/components/ReportBuilder/ui.js +366 -0
- package/dist/esm/components/ReportBuilder/util.d.ts +76 -0
- package/dist/esm/components/ReportBuilder/util.d.ts.map +1 -0
- package/dist/esm/components/ReportBuilder/util.js +616 -0
- package/dist/esm/components/UiComponents.d.ts +15 -2
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +47 -2
- package/dist/esm/utils/crypto.d.ts +1 -1
- package/dist/esm/utils/crypto.d.ts.map +1 -1
- package/dist/esm/utils/crypto.js +9 -5
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export default function LineChart({ colors, yAxisFields, data, containerStyle, xAxisField, xAxisFormat, theme, comparison, isAnimationActive, hideXAxis, hideYAxis, hideCartesianGrid, }: {
|
|
2
|
+
export default function LineChart({ colors, yAxisFields, data, containerStyle, xAxisField, xAxisFormat, theme, comparison, isAnimationActive, hideXAxis, hideYAxis, hideCartesianGrid, dashedComparison, customPrimaryColor, customComparisonColor, singlePointStyle, }: {
|
|
3
3
|
colors?: string[];
|
|
4
4
|
yAxisFields: any[];
|
|
5
5
|
data: any[];
|
|
@@ -13,5 +13,9 @@ export default function LineChart({ colors, yAxisFields, data, containerStyle, x
|
|
|
13
13
|
hideXAxis: boolean;
|
|
14
14
|
hideYAxis: boolean;
|
|
15
15
|
hideCartesianGrid: boolean;
|
|
16
|
+
dashedComparison: boolean;
|
|
17
|
+
customPrimaryColor: string | undefined;
|
|
18
|
+
customComparisonColor: string | undefined;
|
|
19
|
+
singlePointStyle: 'dot' | 'line';
|
|
16
20
|
}): import("react/jsx-runtime").JSX.Element | null;
|
|
17
21
|
//# sourceMappingURL=LineChart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/LineChart.tsx"],"names":[],"mappings":";AAiBA,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,MAAM,EACN,WAAW,EACX,IAAI,EACJ,cAAc,EACd,UAAU,EACV,WAAW,EACX,KAAK,EACL,UAAU,EACV,iBAAwB,EACxB,SAAiB,EACjB,SAAiB,EACjB,iBAAyB,
|
|
1
|
+
{"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/LineChart.tsx"],"names":[],"mappings":";AAiBA,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,MAAM,EACN,WAAW,EACX,IAAI,EACJ,cAAc,EACd,UAAU,EACV,WAAW,EACX,KAAK,EACL,UAAU,EACV,iBAAwB,EACxB,SAAiB,EACjB,SAAiB,EACjB,iBAAyB,EACzB,gBAAwB,EACxB,kBAA8B,EAC9B,qBAAiC,EACjC,gBAAwB,GACzB,EAAE;IACD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,GAAG,EAAE,CAAC;IACnB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,GAAG,CAAC;IACX,UAAU,EAAE,GAAG,CAAC;IAChB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,qBAAqB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,gBAAgB,EAAE,KAAK,GAAG,MAAM,CAAC;CAClC,kDAyNA"}
|
|
@@ -7,7 +7,7 @@ import { selectColor } from '../../utils/color';
|
|
|
7
7
|
import ChartTooltip from '../../components/Chart/ChartTooltip';
|
|
8
8
|
import getDomain from '../../utils/getDomain';
|
|
9
9
|
import { useEffect, useState } from 'react';
|
|
10
|
-
export default function LineChart({ colors, yAxisFields, data, containerStyle, xAxisField, xAxisFormat, theme, comparison, isAnimationActive = true, hideXAxis = false, hideYAxis = false, hideCartesianGrid = false, }) {
|
|
10
|
+
export default function LineChart({ colors, yAxisFields, data, containerStyle, xAxisField, xAxisFormat, theme, comparison, isAnimationActive = true, hideXAxis = false, hideYAxis = false, hideCartesianGrid = false, dashedComparison = false, customPrimaryColor = undefined, customComparisonColor = undefined, singlePointStyle = 'dot', }) {
|
|
11
11
|
const [formattedData, setFormattedData] = useState([]);
|
|
12
12
|
if (!yAxisFields || !yAxisFields.length) {
|
|
13
13
|
return null;
|
|
@@ -16,8 +16,9 @@ export default function LineChart({ colors, yAxisFields, data, containerStyle, x
|
|
|
16
16
|
if (!data || data.length === 0) {
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
+
let newData = data;
|
|
19
20
|
if (typeof data[0][xAxisField] === 'object') {
|
|
20
|
-
|
|
21
|
+
newData = data.map((d) => {
|
|
21
22
|
const formatted = { ...d };
|
|
22
23
|
// NEED TO FORMAT FOR BIG QUERY
|
|
23
24
|
if (d[xAxisField] && typeof d[xAxisField] === 'object') {
|
|
@@ -25,11 +26,12 @@ export default function LineChart({ colors, yAxisFields, data, containerStyle, x
|
|
|
25
26
|
}
|
|
26
27
|
return formatted;
|
|
27
28
|
});
|
|
28
|
-
setFormattedData(curData);
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
if (singlePointStyle === 'line' && newData.length == 1) {
|
|
31
|
+
const point = { ...newData[0] };
|
|
32
|
+
newData.push(point);
|
|
32
33
|
}
|
|
34
|
+
setFormattedData(newData);
|
|
33
35
|
}, [data]);
|
|
34
36
|
if (!data || data.length === 0) {
|
|
35
37
|
return (_jsx("div", { style: {
|
|
@@ -43,6 +45,16 @@ export default function LineChart({ colors, yAxisFields, data, containerStyle, x
|
|
|
43
45
|
color: theme.secondaryTextColor,
|
|
44
46
|
}, children: "No results found for specified time period." }));
|
|
45
47
|
}
|
|
48
|
+
// Allows the users to override the color scheme on a per-chart basis.
|
|
49
|
+
const getCustomColor = (index) => {
|
|
50
|
+
if (index === 0 && customPrimaryColor) {
|
|
51
|
+
return customPrimaryColor;
|
|
52
|
+
}
|
|
53
|
+
if (index === 1 && comparison && customComparisonColor) {
|
|
54
|
+
return customComparisonColor;
|
|
55
|
+
}
|
|
56
|
+
return undefined; // use the default colors from the theme
|
|
57
|
+
};
|
|
46
58
|
return (_jsx("div", { style: { ...containerStyle }, children: _jsx(ResponsiveContainer, { width: "100%", height: '100%', children: _jsxs(ReChartsAreaChart, { data: formattedData, children: [!hideCartesianGrid && (_jsx(CartesianGrid, { horizontal: true, vertical: false, stroke: "#e5e7eb" })), _jsx(XAxis, { dataKey: xAxisField, hide: hideXAxis, tick: { transform: 'translate(0, 6)' }, style: {
|
|
47
59
|
fontSize: '12px',
|
|
48
60
|
fontFamily: theme?.chartLabelFontFamily ||
|
|
@@ -87,5 +99,5 @@ export default function LineChart({ colors, yAxisFields, data, containerStyle, x
|
|
|
87
99
|
{ field: xAxisField, format: xAxisFormat },
|
|
88
100
|
],
|
|
89
101
|
}), xAxisFormat: xAxisFormat, xAxisField: xAxisField, colors: colors, theme: theme }));
|
|
90
|
-
}, position: { y: 0 } }), yAxisFields.map((elem, index) => (_jsx("defs", { children: _jsxs("linearGradient", { id: `gradient${index}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [_jsx("stop", { offset: "5%", stopColor: selectColor(elem, colors, index), stopOpacity: 0.4 }), _jsx("stop", { offset: "95%", stopColor: 'rgba(0,0,0,0)', stopOpacity: 0 })] }) }, `defs${elem.field + index}`))), yAxisFields.map((elem, index) => (_jsx(Area, { name: elem.label, type: "linear", dataKey: elem.field, stroke: selectColor(elem, colors, index), fill: `url(#gradient${index})`, strokeWidth: 2, dot: false, isAnimationActive: isAnimationActive }, elem.field)))] }) }) }));
|
|
102
|
+
}, position: { y: 0 } }), yAxisFields.map((elem, index) => (_jsx("defs", { children: _jsxs("linearGradient", { id: `gradient${index}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [_jsx("stop", { offset: "5%", stopColor: getCustomColor(index) ?? selectColor(elem, colors, index), stopOpacity: 0.4 }), _jsx("stop", { offset: "95%", stopColor: 'rgba(0,0,0,0)', stopOpacity: 0 })] }) }, `defs${elem.field + index}`))), yAxisFields.map((elem, index) => (_jsx(Area, { name: elem.label, type: "linear", dataKey: elem.field, stroke: getCustomColor(index) ?? selectColor(elem, colors, index), fill: `url(#gradient${index})`, strokeWidth: 2, dot: false, strokeDasharray: comparison && dashedComparison && index > 0 ? '5 5' : undefined, isAnimationActive: isAnimationActive }, elem.field)))] }) }) }));
|
|
91
103
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TableComponentProps } from './UiComponents';
|
|
2
|
-
export default function QuillTable({ rows, columns, loading, showDownloadCSVButton, downloadFileName, containerStyle,
|
|
2
|
+
export default function QuillTable({ rows, columns, loading, showDownloadCSVButton, downloadFileName, containerStyle, LoadingComponent, rowsPerPage, emptyStateLabel, downloadCSV, }: TableComponentProps): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
//# sourceMappingURL=QuillTable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuillTable.d.ts","sourceRoot":"","sources":["../../../src/components/QuillTable.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAMrD,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,IAAI,EACJ,OAAO,EACP,OAAO,EACP,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,EACd,
|
|
1
|
+
{"version":3,"file":"QuillTable.d.ts","sourceRoot":"","sources":["../../../src/components/QuillTable.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAMrD,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,IAAI,EACJ,OAAO,EACP,OAAO,EACP,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,EACd,gBAA0C,EAC1C,WAAgB,EAChB,eAAwC,EACxC,WAAW,GACZ,EAAE,mBAAmB,2CAsZrB"}
|
|
@@ -3,7 +3,7 @@ import { useContext, useEffect, useState } from 'react';
|
|
|
3
3
|
import { compareValues } from '../utils/valueFormatter';
|
|
4
4
|
import { ThemeContext } from '../Context';
|
|
5
5
|
import ChartSkeleton from './Chart/ChartSkeleton';
|
|
6
|
-
export default function QuillTable({ rows, columns, loading, showDownloadCSVButton, downloadFileName, containerStyle,
|
|
6
|
+
export default function QuillTable({ rows, columns, loading, showDownloadCSVButton, downloadFileName, containerStyle, LoadingComponent = () => _jsx(ChartSkeleton, {}), rowsPerPage = 10, emptyStateLabel = 'No results returned.', downloadCSV, }) {
|
|
7
7
|
const [activeRows, setActiveRows] = useState([]);
|
|
8
8
|
const [page, setPage] = useState(1);
|
|
9
9
|
const [maxPage, setMaxPage] = useState(1);
|
|
@@ -23,10 +23,10 @@ export default function QuillTable({ rows, columns, loading, showDownloadCSVButt
|
|
|
23
23
|
return sortDirection === 'asc' ? result : -result;
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
const start = (page - 1) *
|
|
27
|
-
const end = page *
|
|
26
|
+
const start = (page - 1) * rowsPerPage;
|
|
27
|
+
const end = page * rowsPerPage;
|
|
28
28
|
if (sortedRows && sortedRows.length) {
|
|
29
|
-
setMaxPage(Math.ceil(sortedRows.length /
|
|
29
|
+
setMaxPage(Math.ceil(sortedRows.length / rowsPerPage));
|
|
30
30
|
}
|
|
31
31
|
setActiveRows(sortedRows.slice(start, end));
|
|
32
32
|
setIsPaginating(false);
|
|
@@ -57,174 +57,174 @@ export default function QuillTable({ rows, columns, loading, showDownloadCSVButt
|
|
|
57
57
|
...containerStyle,
|
|
58
58
|
}, children: _jsx(LoadingComponent, {}) }));
|
|
59
59
|
}
|
|
60
|
-
return (
|
|
60
|
+
return (_jsx("div", { style: {
|
|
61
61
|
width: '100%',
|
|
62
62
|
height: '100%',
|
|
63
63
|
overflow: 'visible',
|
|
64
64
|
display: 'flex',
|
|
65
65
|
flexDirection: 'column',
|
|
66
66
|
...containerStyle,
|
|
67
|
-
}, children:
|
|
68
|
-
|
|
67
|
+
}, children: _jsx("div", { style: {
|
|
68
|
+
height: '100%',
|
|
69
|
+
width: '100%',
|
|
70
|
+
overflow: 'auto',
|
|
71
|
+
borderRadius: 6,
|
|
72
|
+
border: '1px solid rgb(229, 231, 235)',
|
|
73
|
+
padding: 0,
|
|
74
|
+
margin: 0,
|
|
75
|
+
boxSizing: 'border-box',
|
|
76
|
+
outline: 'none',
|
|
77
|
+
}, children: _jsxs("div", { role: "table", className: "table", style: {
|
|
78
|
+
display: 'flex',
|
|
79
|
+
flexDirection: 'column',
|
|
80
|
+
minWidth: '0px',
|
|
69
81
|
width: '100%',
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
border: '1px solid rgb(229, 231, 235)',
|
|
73
|
-
padding: 0,
|
|
74
|
-
margin: 0,
|
|
75
|
-
boxSizing: 'border-box',
|
|
76
|
-
outline: 'none',
|
|
77
|
-
}, children: _jsxs("div", { role: "table", className: "table", style: { minWidth: '0px', width: '100%', height: '100%' }, children: [_jsx("div", { className: "thead", children: _jsx("div", { role: "row", className: "tr", style: {
|
|
78
|
-
display: 'flex',
|
|
79
|
-
flex: '1 0 auto',
|
|
80
|
-
minWidth: '100px',
|
|
81
|
-
boxSizing: 'border-box',
|
|
82
|
-
}, children: columns && columns.map((column, index) => (_jsxs("div", { onClick: () => toggleSort(column), style: {
|
|
83
|
-
boxSizing: 'border-box',
|
|
84
|
-
flex: '150 0 auto',
|
|
85
|
-
minWidth: '50px',
|
|
86
|
-
width: '150px',
|
|
87
|
-
position: 'relative',
|
|
88
|
-
cursor: 'pointer',
|
|
89
|
-
background: 'rgb(249, 250, 251)',
|
|
90
|
-
borderRight: index + 1 === columns.length
|
|
91
|
-
? '0px solid rgb(229, 231, 235)'
|
|
92
|
-
: '1px solid rgb(229, 231, 235)',
|
|
93
|
-
borderBottom: '1px solid rgb(229, 231, 235)',
|
|
94
|
-
whiteSpace: 'nowrap',
|
|
95
|
-
alignItems: 'center',
|
|
96
|
-
overflowX: 'visible',
|
|
97
|
-
margin: '0px',
|
|
98
|
-
textOverflow: 'ellipsis',
|
|
99
|
-
minHeight: '36px',
|
|
100
|
-
userSelect: 'none',
|
|
101
|
-
paddingLeft: 16,
|
|
102
|
-
paddingRight: 16,
|
|
82
|
+
height: '100%',
|
|
83
|
+
}, children: [_jsxs("div", { style: { overflow: 'auto', flexGrow: 1 }, children: [_jsx("div", { className: "thead", children: _jsx("div", { role: "row", className: "tr", style: {
|
|
103
84
|
display: 'flex',
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
85
|
+
flex: '1 0 auto',
|
|
86
|
+
minWidth: '100px',
|
|
87
|
+
boxSizing: 'border-box',
|
|
88
|
+
}, children: columns &&
|
|
89
|
+
columns.map((column, index) => (_jsxs("div", { onClick: () => toggleSort(column), style: {
|
|
90
|
+
boxSizing: 'border-box',
|
|
91
|
+
flex: '150 0 auto',
|
|
92
|
+
minWidth: '50px',
|
|
93
|
+
width: '150px',
|
|
94
|
+
position: 'relative',
|
|
95
|
+
cursor: 'pointer',
|
|
96
|
+
background: 'rgb(249, 250, 251)',
|
|
97
|
+
borderRight: index + 1 === columns.length
|
|
98
|
+
? '0px solid rgb(229, 231, 235)'
|
|
99
|
+
: '1px solid rgb(229, 231, 235)',
|
|
100
|
+
borderBottom: '1px solid rgb(229, 231, 235)',
|
|
118
101
|
whiteSpace: 'nowrap',
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
102
|
+
alignItems: 'center',
|
|
103
|
+
overflowX: 'visible',
|
|
104
|
+
margin: '0px',
|
|
105
|
+
textOverflow: 'ellipsis',
|
|
106
|
+
minHeight: '36px',
|
|
107
|
+
userSelect: 'none',
|
|
108
|
+
paddingLeft: 16,
|
|
109
|
+
paddingRight: 16,
|
|
110
|
+
display: 'flex',
|
|
111
|
+
flexDirection: 'row',
|
|
112
|
+
justifyContent: 'space-between',
|
|
113
|
+
}, children: [_jsx("div", { "aria-haspopup": "dialog", "aria-expanded": "false", "aria-controls": "mantine-r6-dropdown", style: {
|
|
114
|
+
// fontFamily:
|
|
115
|
+
// 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',
|
|
116
|
+
WebkitTapHighlightColor: 'transparent',
|
|
117
|
+
fontFamily: theme?.fontFamily,
|
|
118
|
+
// color: 'rgb(55, 65, 81)',
|
|
119
|
+
color: theme?.primaryTextColor,
|
|
120
|
+
textDecoration: 'none',
|
|
121
|
+
fontSize: theme?.fontSizeSmall || '14px',
|
|
122
|
+
fontWeight: theme?.fontWeightMedium || '500',
|
|
123
|
+
lineHeight: '20px', // 1.25rem * 16px = 20px
|
|
124
|
+
textOverflow: 'ellipsis',
|
|
125
|
+
whiteSpace: 'nowrap',
|
|
126
|
+
overflow: 'hidden',
|
|
127
|
+
}, children: column.label || column.field }), column.field === sortColumn && (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", fill: theme?.primaryTextColor, height: "14px", width: "14px", style: {
|
|
128
|
+
transform: sortDirection === 'desc'
|
|
129
|
+
? 'rotate(180deg)'
|
|
130
|
+
: undefined,
|
|
131
|
+
}, children: _jsx("path", { fillRule: "evenodd", d: "M10 3a.75.75 0 01.75.75v10.638l3.96-4.158a.75.75 0 111.08 1.04l-5.25 5.5a.75.75 0 01-1.08 0l-5.25-5.5a.75.75 0 111.08-1.04l3.96 4.158V3.75A.75.75 0 0110 3z", clipRule: "evenodd" }) }))] }, 'sqlcol' + index))) }) }), (activeRows && activeRows.length === 0) ||
|
|
132
|
+
(columns && columns.length === 0) ? (_jsx("div", { style: {
|
|
133
|
+
padding: '60px 0',
|
|
134
134
|
display: 'flex',
|
|
135
135
|
flex: '1 0 auto',
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
display: 'flex',
|
|
144
|
-
margin: '0px',
|
|
145
|
-
textOverflow: 'ellipsis',
|
|
146
|
-
minHeight: '36px',
|
|
147
|
-
borderRight: columnIndex + 1 === columns.length
|
|
148
|
-
? '0px solid rgb(229, 231, 235)'
|
|
149
|
-
: '1px solid rgb(229, 231, 235)',
|
|
150
|
-
overflow: 'hidden',
|
|
151
|
-
borderTop: rowIndex > 0
|
|
152
|
-
? '1px solid rgb(229, 231, 235)'
|
|
153
|
-
: undefined,
|
|
154
|
-
borderBottom: rowIndex === rows.length - 1
|
|
155
|
-
? '1px solid rgb(229, 231, 235)'
|
|
156
|
-
: undefined,
|
|
157
|
-
userSelect: 'none',
|
|
158
|
-
}, children: _jsx("div", { style: {
|
|
159
|
-
lineHeight: '24px',
|
|
160
|
-
width: '100%',
|
|
136
|
+
margin: 'auto',
|
|
137
|
+
justifyContent: 'center',
|
|
138
|
+
alignItems: 'center',
|
|
139
|
+
fontSize: 13,
|
|
140
|
+
color: theme?.secondaryTextColor || 'rgb(55, 65, 81)',
|
|
141
|
+
}, children: emptyStateLabel })) : (_jsx("div", { role: "rowgroup", className: "tbody", children: activeRows &&
|
|
142
|
+
activeRows.map((row, rowIndex) => (_jsx("div", { role: "row", className: "tr", style: {
|
|
161
143
|
display: 'flex',
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
},
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
fontWeight: 400,
|
|
173
|
-
fontSize: theme?.fontSizeSmall || '14px',
|
|
174
|
-
lineHeight: '20px',
|
|
144
|
+
flex: '1 0 auto',
|
|
145
|
+
minWidth: '100px',
|
|
146
|
+
boxSizing: 'border-box',
|
|
147
|
+
}, children: columns.map((column, columnIndex) => (_jsx("div", { role: "cell", style: {
|
|
148
|
+
boxSizing: 'border-box',
|
|
149
|
+
flex: '150 0 auto',
|
|
150
|
+
minWidth: '50px',
|
|
151
|
+
width: '150px',
|
|
152
|
+
display: 'flex',
|
|
153
|
+
margin: '0px',
|
|
175
154
|
textOverflow: 'ellipsis',
|
|
176
|
-
|
|
155
|
+
minHeight: '36px',
|
|
156
|
+
borderRight: columnIndex + 1 === columns.length
|
|
157
|
+
? '0px solid rgb(229, 231, 235)'
|
|
158
|
+
: '1px solid rgb(229, 231, 235)',
|
|
177
159
|
overflow: 'hidden',
|
|
178
|
-
|
|
160
|
+
borderTop: rowIndex > 0
|
|
161
|
+
? '1px solid rgb(229, 231, 235)'
|
|
162
|
+
: undefined,
|
|
163
|
+
borderBottom: rowIndex === rows.length - 1
|
|
164
|
+
? '1px solid rgb(229, 231, 235)'
|
|
165
|
+
: undefined,
|
|
179
166
|
userSelect: 'none',
|
|
180
|
-
}, children:
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
167
|
+
}, children: _jsx("div", { style: {
|
|
168
|
+
lineHeight: '24px',
|
|
169
|
+
width: '100%',
|
|
170
|
+
display: 'flex',
|
|
171
|
+
cursor: 'default',
|
|
172
|
+
position: 'relative',
|
|
173
|
+
userSelect: 'none',
|
|
174
|
+
}, "data-testid": "static-cell", children: _jsx("div", { "aria-haspopup": "dialog", "aria-expanded": "false", style: {
|
|
175
|
+
fontFamily: theme?.fontFamily ||
|
|
176
|
+
'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',
|
|
177
|
+
WebkitTapHighlightColor: 'transparent',
|
|
178
|
+
// color: 'rgb(55, 65, 81)',
|
|
179
|
+
color: theme?.secondaryTextColor ||
|
|
180
|
+
'rgb(55, 65, 81)',
|
|
181
|
+
textDecoration: 'none',
|
|
182
|
+
fontWeight: 400,
|
|
183
|
+
fontSize: theme?.fontSizeSmall || '14px',
|
|
184
|
+
lineHeight: '20px',
|
|
185
|
+
textOverflow: 'ellipsis',
|
|
186
|
+
whiteSpace: 'nowrap',
|
|
187
|
+
overflow: 'hidden',
|
|
188
|
+
padding: '8px 16px',
|
|
189
|
+
userSelect: 'none',
|
|
190
|
+
}, children: row[column.field] }) }) }, 'sqlcell' + columnIndex))) }, 'sqlrow' + rowIndex))) }))] }), _jsx("div", { style: {
|
|
199
191
|
display: 'flex',
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
192
|
+
minWidth: '100px',
|
|
193
|
+
height: 38,
|
|
194
|
+
borderTop: '1px solid rgb(229, 231, 235)',
|
|
195
|
+
background: '#F9FAFB',
|
|
203
196
|
width: '100%',
|
|
204
|
-
}, children:
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
197
|
+
}, children: _jsxs("div", { style: {
|
|
198
|
+
display: 'flex',
|
|
199
|
+
flexDirection: 'row',
|
|
200
|
+
alignItems: 'center',
|
|
201
|
+
justifyContent: 'space-between',
|
|
202
|
+
width: '100%',
|
|
203
|
+
height: 37,
|
|
204
|
+
}, children: [showDownloadCSVButton ? (_jsx("button", { onClick: downloadCSV, style: {
|
|
205
|
+
fontSize: 14,
|
|
206
|
+
paddingLeft: 12,
|
|
207
|
+
fontFamily: theme?.fontFamily,
|
|
208
|
+
color: theme?.primaryTextColor,
|
|
209
|
+
background: 'transparent',
|
|
210
|
+
fontWeight: 500,
|
|
211
|
+
cursor: 'pointer',
|
|
212
|
+
border: 'none',
|
|
213
|
+
}, children: "Download CSV" })) : (_jsx("div", {})), _jsxs("div", { style: {
|
|
214
|
+
display: 'flex',
|
|
215
|
+
flexDirection: 'row',
|
|
216
|
+
alignItems: 'center',
|
|
217
|
+
}, children: [_jsxs("div", { style: {
|
|
218
|
+
fontSize: 12,
|
|
219
|
+
fontFamily: theme?.fontFamily,
|
|
220
|
+
color: theme?.primaryTextColor,
|
|
221
|
+
}, children: [page, ' of ', maxPage] }), _jsx("div", { style: { width: 8 } }), _jsx("button", { onClick: decreasePage, style: {
|
|
222
|
+
cursor: 'pointer',
|
|
223
|
+
border: 'none',
|
|
224
|
+
background: 'transparent',
|
|
225
|
+
}, children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", fill: theme?.chartLabelFontFamily || theme?.fontFamily, height: "16px", width: "16px", children: _jsx("path", { fillRule: "evenodd", d: "M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z", clipRule: "evenodd" }) }) }), _jsx("button", { onClick: increasePage, style: {
|
|
226
|
+
cursor: 'pointer',
|
|
227
|
+
border: 'none',
|
|
228
|
+
background: 'transparent',
|
|
229
|
+
}, children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", fill: theme?.chartLabelFontFamily || theme?.fontFamily, height: "16px", width: "16px", children: _jsx("path", { fillRule: "evenodd", d: "M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z", clipRule: "evenodd" }) }) }), _jsx("div", { style: { width: 12 } })] })] }) })] }) }) }));
|
|
230
230
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export default function AddColumnPopover({ onSave, orderedColumnNames, setOrderedColumnNames, selectedColumns, setSelectedColumns, isSelectedAllColumns, clearAllState, nameToColumn, baseAst, setBaseAst, pivot, initialTableName, defaultAST, defaultTable, setPivot, TextInput, SelectColumn, SecondaryButton, Button, HandleButton, }: any): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
//# sourceMappingURL=AddColumnPopover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AddColumnPopover.d.ts","sourceRoot":"","sources":["../../../../src/components/ReportBuilder/AddColumnPopover.tsx"],"names":[],"mappings":"AAkBA,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,MAAM,EACN,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,UAAU,EACV,KAAK,EACL,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,eAAe,EACf,MAAM,EACN,YAAY,GACb,EAAE,GAAG,2CA4LL"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { DndContext, closestCenter, KeyboardSensor, PointerSensor, useSensor, useSensors, } from '@dnd-kit/core';
|
|
4
|
+
import { arrayMove, SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy, useSortable, } from '@dnd-kit/sortable';
|
|
5
|
+
import { CSS as DND_CSS } from '@dnd-kit/utilities';
|
|
6
|
+
export default function AddColumnPopover({ onSave, orderedColumnNames, setOrderedColumnNames, selectedColumns, setSelectedColumns, isSelectedAllColumns, clearAllState, nameToColumn, baseAst, setBaseAst, pivot, initialTableName, defaultAST, defaultTable, setPivot, TextInput, SelectColumn, SecondaryButton, Button, HandleButton, }) {
|
|
7
|
+
const [search, setSearch] = useState('');
|
|
8
|
+
const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, {
|
|
9
|
+
coordinateGetter: sortableKeyboardCoordinates,
|
|
10
|
+
}));
|
|
11
|
+
// When a drag event ends, switch the item order.
|
|
12
|
+
function handleDragEnd(event) {
|
|
13
|
+
const { active, over } = event;
|
|
14
|
+
if (active.id !== over.id) {
|
|
15
|
+
setOrderedColumnNames((orderedColumnNames) => {
|
|
16
|
+
const oldIndex = orderedColumnNames.indexOf(active.id);
|
|
17
|
+
const newIndex = orderedColumnNames.indexOf(over.id);
|
|
18
|
+
return arrayMove(orderedColumnNames, oldIndex, newIndex);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const getColumnsInPivot = () => {
|
|
23
|
+
if (!pivot)
|
|
24
|
+
return [];
|
|
25
|
+
const { valueField, rowField, columnField } = pivot;
|
|
26
|
+
return [valueField, rowField, columnField].filter(Boolean);
|
|
27
|
+
};
|
|
28
|
+
const searchResults = orderedColumnNames
|
|
29
|
+
.filter((row) => {
|
|
30
|
+
const [table, _column] = row.split('.');
|
|
31
|
+
return (selectedColumns.length === 0 || selectedColumns[0].startsWith(table));
|
|
32
|
+
})
|
|
33
|
+
.filter((row) => search.length === 0 || row.includes(search));
|
|
34
|
+
return (_jsxs("div", { style: {
|
|
35
|
+
display: 'flex',
|
|
36
|
+
flexDirection: 'column',
|
|
37
|
+
gap: 2,
|
|
38
|
+
minWidth: 300,
|
|
39
|
+
maxHeight: 500,
|
|
40
|
+
}, children: [_jsx("div", { style: {
|
|
41
|
+
position: 'relative',
|
|
42
|
+
display: 'flex',
|
|
43
|
+
flexDirection: 'row',
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
marginTop: 2,
|
|
46
|
+
}, children: _jsx(TextInput, { type: "text", value: search, placeholder: 'Search...', style: { margin: '8px 0', width: '100%' }, onChange: (e) => setSearch(e.target.value) }) }), _jsx(DndContext, { sensors: sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd, children: _jsx(SortableContext, { items: orderedColumnNames, strategy: verticalListSortingStrategy, children: _jsxs("div", { style: {
|
|
47
|
+
display: 'flex',
|
|
48
|
+
flexDirection: 'column',
|
|
49
|
+
gap: 8,
|
|
50
|
+
overflowY: 'auto',
|
|
51
|
+
maxWidth: '300px',
|
|
52
|
+
}, children: [searchResults.map((value) => {
|
|
53
|
+
return (_jsx(SortableItem, { selectedColumns: selectedColumns, setSelectedColumns: setSelectedColumns, id: value, label: value.replace('.', ' '), SelectColumn: SelectColumn, HandleButton: HandleButton }, value));
|
|
54
|
+
}), search.length > 0 && searchResults.length === 0 && (_jsx("div", { children: "No results found" }))] }) }) }), _jsxs("div", { style: {
|
|
55
|
+
display: 'flex',
|
|
56
|
+
width: '100%',
|
|
57
|
+
flexDirection: 'row',
|
|
58
|
+
gap: 8,
|
|
59
|
+
justifyContent: 'end',
|
|
60
|
+
marginTop: 12,
|
|
61
|
+
}, children: [selectedColumns.length > 0 && !isSelectedAllColumns() && (_jsx(SecondaryButton, { onClick: () => setSelectedColumns(orderedColumnNames.filter((row) => {
|
|
62
|
+
const [table, _column] = row.split('.');
|
|
63
|
+
return selectedColumns[0].startsWith(table);
|
|
64
|
+
})), children: "Select all" })), selectedColumns.length > 0 && isSelectedAllColumns() && (_jsx(SecondaryButton, { onClick: () => setSelectedColumns([]), children: "Clear" })), _jsx(Button, { onMouseUp: () => {
|
|
65
|
+
// follow the ordering of the ordered column names
|
|
66
|
+
let tableName = initialTableName;
|
|
67
|
+
const orderedSelectedColumns = [];
|
|
68
|
+
for (const value of orderedColumnNames) {
|
|
69
|
+
const [table, column] = value.split('.');
|
|
70
|
+
if (selectedColumns.includes(value)) {
|
|
71
|
+
tableName = table;
|
|
72
|
+
orderedSelectedColumns.push(column);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (orderedSelectedColumns.length === 0) {
|
|
76
|
+
clearAllState();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
// If there is already an AST saved in state, only update the columns
|
|
80
|
+
// otherwise fill in the defaultAST shape and also update columns.
|
|
81
|
+
const fallbackAST = {
|
|
82
|
+
...defaultAST,
|
|
83
|
+
from: [{ ...defaultTable, table: tableName }],
|
|
84
|
+
columns: orderedSelectedColumns.map((name) => nameToColumn(name)),
|
|
85
|
+
};
|
|
86
|
+
const newBaseAst = {
|
|
87
|
+
...baseAst,
|
|
88
|
+
from: [{ ...defaultTable, table: tableName }],
|
|
89
|
+
columns: baseAst?.columns.length
|
|
90
|
+
? orderedSelectedColumns.map((name) => nameToColumn(name))
|
|
91
|
+
: baseAst?.columns,
|
|
92
|
+
};
|
|
93
|
+
const newAst = baseAst ? newBaseAst : fallbackAST;
|
|
94
|
+
setBaseAst(newAst);
|
|
95
|
+
// If the user deleted a column that was in the pivot, delete the Pivot
|
|
96
|
+
const columnInAST = (col) => newAst.columns.find((c) => c.expr?.value === col ||
|
|
97
|
+
c.expr?.column === col ||
|
|
98
|
+
c.as === col);
|
|
99
|
+
if (pivot &&
|
|
100
|
+
!getColumnsInPivot().every((c) => columnInAST(c))) {
|
|
101
|
+
setPivot(null);
|
|
102
|
+
}
|
|
103
|
+
onSave();
|
|
104
|
+
}, children: "Save" })] })] }));
|
|
105
|
+
}
|
|
106
|
+
const SortableItem = ({ id, label, setSelectedColumns, selectedColumns, SelectColumn, HandleButton, }) => {
|
|
107
|
+
const { attributes, listeners, setNodeRef, transform, transition } = useSortable({ id: id });
|
|
108
|
+
const style = {
|
|
109
|
+
transform: DND_CSS.Transform.toString(transform),
|
|
110
|
+
transition,
|
|
111
|
+
};
|
|
112
|
+
const handleSelect = () => {
|
|
113
|
+
setSelectedColumns((selectedColumns) => {
|
|
114
|
+
if (selectedColumns.includes(id)) {
|
|
115
|
+
return selectedColumns.filter((column) => column !== id);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
return [...selectedColumns, id];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
return (_jsx("div", { style: { userSelect: 'none', ...style }, ref: setNodeRef, children: _jsx(SelectColumn, { selected: selectedColumns?.includes(id), setSelected: handleSelect, label: label, children: _jsx("div", { style: {
|
|
123
|
+
cursor: 'grab',
|
|
124
|
+
}, ...attributes, ...listeners, children: _jsx(HandleButton, {}) }) }) }));
|
|
125
|
+
};
|