@quillsql/react 2.10.38 → 2.11.0
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 +4 -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 +2026 -917
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +9 -0
- 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 +4 -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 +2028 -917
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +9 -0
- 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
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useContext, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { MemoizedSelect, MemoizedCheckbox, MemoizedHeader, MemoizedLabel, MemoizedTabs, LoadingSpinner, } from '../UiComponents';
|
|
4
|
+
import MemoizedQuillTable from '../QuillTable';
|
|
5
|
+
import { ThemeContext } from '../../Context';
|
|
6
|
+
import { isNodeEmptyCollection } from './util';
|
|
7
|
+
import { downloadCSV } from '../../utils/csv';
|
|
8
|
+
/**
|
|
9
|
+
* This file is a collection of basic UI components that conform to the shape
|
|
10
|
+
* expected by the Report Builder. Where possible, we use our existing
|
|
11
|
+
* components and wrap them in a thin shim to make the interface match if
|
|
12
|
+
* needed.
|
|
13
|
+
*/
|
|
14
|
+
export const QuillButton = ({ children, ...props }) => {
|
|
15
|
+
const [theme] = useContext(ThemeContext);
|
|
16
|
+
return (_jsx("button", { ...props, style: {
|
|
17
|
+
borderRadius: '6px',
|
|
18
|
+
backgroundColor: '#000000',
|
|
19
|
+
opacity: 1,
|
|
20
|
+
paddingLeft: '16px',
|
|
21
|
+
paddingRight: '16px',
|
|
22
|
+
fontSize: '14px',
|
|
23
|
+
fontWeight: 600,
|
|
24
|
+
color: '#FFFFFF',
|
|
25
|
+
cursor: 'pointer',
|
|
26
|
+
outline: 'none',
|
|
27
|
+
border: 'none',
|
|
28
|
+
fontFamily: theme?.fontFamily,
|
|
29
|
+
height: 38,
|
|
30
|
+
whiteSpace: 'nowrap',
|
|
31
|
+
...props.style,
|
|
32
|
+
}, children: children }));
|
|
33
|
+
};
|
|
34
|
+
export const QuillSecondaryButton = ({ children, ...props }) => {
|
|
35
|
+
const [theme] = useContext(ThemeContext);
|
|
36
|
+
return (_jsx("button", { ...props, style: {
|
|
37
|
+
borderRadius: '6px',
|
|
38
|
+
backgroundColor: theme?.secondaryButtonColor || '#F5F5F5',
|
|
39
|
+
opacity: 1,
|
|
40
|
+
paddingLeft: '16px',
|
|
41
|
+
paddingRight: '16px',
|
|
42
|
+
fontSize: '14px',
|
|
43
|
+
fontWeight: 600,
|
|
44
|
+
color: theme?.primaryTextColor,
|
|
45
|
+
cursor: 'pointer',
|
|
46
|
+
outline: 'none',
|
|
47
|
+
border: 'none',
|
|
48
|
+
fontFamily: theme?.fontFamily,
|
|
49
|
+
height: 38,
|
|
50
|
+
whiteSpace: 'nowrap',
|
|
51
|
+
...props.style,
|
|
52
|
+
}, children: children }));
|
|
53
|
+
};
|
|
54
|
+
export const QuillTextInput = (props) => {
|
|
55
|
+
const [theme] = useContext(ThemeContext);
|
|
56
|
+
return (_jsx("input", { ...props, style: {
|
|
57
|
+
color: theme?.primaryTextColor,
|
|
58
|
+
backgroundColor: theme?.backgroundColor || 'white',
|
|
59
|
+
fontFamily: theme?.fontFamily,
|
|
60
|
+
fontWeight: 'medium',
|
|
61
|
+
borderWidth: '1px',
|
|
62
|
+
borderColor: theme?.borderColor || '#E7E7E7',
|
|
63
|
+
borderStyle: 'solid',
|
|
64
|
+
borderRadius: '6px',
|
|
65
|
+
boxShadow: 'rgba(0, 0, 0, 0.1) 0px 1px 5px 0px',
|
|
66
|
+
padding: '0 12px',
|
|
67
|
+
display: 'block',
|
|
68
|
+
minHeight: 32,
|
|
69
|
+
...props.style,
|
|
70
|
+
} }));
|
|
71
|
+
};
|
|
72
|
+
export const QuillReportBuilderTable = ({ rows, columns, error, ...props }) => {
|
|
73
|
+
const reformattedColumns = columns.map((c) => ({ label: c, field: c }));
|
|
74
|
+
return (_jsx("div", { style: { height: '100%', overflow: 'auto' }, children: _jsx(MemoizedQuillTable, { rows: rows, columns: reformattedColumns, rowsPerPage: 10, showDownloadCSVButton: rows?.length > 0, downloadCSV: () => downloadCSV({ rows, fields: reformattedColumns, name: 'my_report' }), emptyStateLabel: error || 'No results', ...props }) }));
|
|
75
|
+
};
|
|
76
|
+
export const QuillTag = forwardRef(({ label, onClick, children, onClickDelete, hideDelete = false, ..._props }, forwardedRef) => {
|
|
77
|
+
const [theme] = useContext(ThemeContext);
|
|
78
|
+
return (_jsxs("div", { style: {
|
|
79
|
+
boxShadow: '0px 1px 4px #e2e8f005',
|
|
80
|
+
border: '1px solid #e2e8f0',
|
|
81
|
+
borderRadius: 6,
|
|
82
|
+
display: 'flex',
|
|
83
|
+
flexDirection: 'row',
|
|
84
|
+
width: '100%',
|
|
85
|
+
padding: '4px 8px',
|
|
86
|
+
alignItems: 'center',
|
|
87
|
+
backgroundColor: 'white',
|
|
88
|
+
fontSize: 14,
|
|
89
|
+
}, ref: forwardedRef, onClick: onClick, children: [label ?? children, !hideDelete && (_jsx("div", { style: {
|
|
90
|
+
marginLeft: 'auto',
|
|
91
|
+
marginRight: '8px',
|
|
92
|
+
display: 'flex',
|
|
93
|
+
flexDirection: 'column',
|
|
94
|
+
justifyContent: 'center',
|
|
95
|
+
}, children: _jsx("button", { onClick: onClickDelete, style: { margin: -4 }, children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", fill: theme?.secondaryButtonColor || 'currentColor', style: { width: 16, height: 16 }, children: _jsx("path", { d: "M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z" }) }) }) }))] }));
|
|
96
|
+
});
|
|
97
|
+
// A heading element in the sidebar (eg. "Filters")
|
|
98
|
+
export const QuillSidebarHeading = ({ label }) => (_jsx(MemoizedHeader, { children: label }));
|
|
99
|
+
// A sub-heading element in the sidebar (eg. "Filters")
|
|
100
|
+
export const QuillSidebarSubHeading = ({ label }) => (_jsx(MemoizedLabel, { children: label }));
|
|
101
|
+
// The gray thing on the left.
|
|
102
|
+
export const QuillSidebar = forwardRef(({ children, ...props }, forwardedRef) => (_jsx("div", { style: {
|
|
103
|
+
overflow: 'visible',
|
|
104
|
+
padding: '12px',
|
|
105
|
+
width: '25%',
|
|
106
|
+
height: '100%',
|
|
107
|
+
maxWidth: '300px',
|
|
108
|
+
}, ref: forwardedRef, ...props, children: children })));
|
|
109
|
+
// A big wrapper around the main content (ie. Input, Button, and Table)
|
|
110
|
+
export const CustomContainer = forwardRef(({ children, ...props }, forwardedRef) => (_jsx("div", { style: {
|
|
111
|
+
position: 'sticky',
|
|
112
|
+
top: 0,
|
|
113
|
+
display: 'flex',
|
|
114
|
+
flexDirection: 'column',
|
|
115
|
+
gap: '12px',
|
|
116
|
+
borderLeftWidth: '1px',
|
|
117
|
+
overflowY: 'auto',
|
|
118
|
+
padding: '1rem',
|
|
119
|
+
flexGrow: 1,
|
|
120
|
+
width: '75%',
|
|
121
|
+
height: '100%',
|
|
122
|
+
}, ref: forwardedRef, ...props, children: children })));
|
|
123
|
+
export const QuillSelect = ({ onChange, ...props }) => {
|
|
124
|
+
const handleOnChange = (value) => {
|
|
125
|
+
if (!onChange)
|
|
126
|
+
return;
|
|
127
|
+
const option = props.options.find((opt) => opt.value === value);
|
|
128
|
+
if (option) {
|
|
129
|
+
onChange(option.value);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
return _jsx(MemoizedSelect, { ...props, onChange: handleOnChange });
|
|
133
|
+
};
|
|
134
|
+
export function MemoizedPopover({ onClose, children, style = {}, trigger, isOpen, }) {
|
|
135
|
+
const modalRef = useRef(null);
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
const listener = (event) => {
|
|
138
|
+
if (modalRef?.current && !modalRef?.current?.contains(event.target)) {
|
|
139
|
+
onClose(event);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
document.addEventListener('mousedown', listener);
|
|
143
|
+
return () => {
|
|
144
|
+
document.removeEventListener('mousedown', listener);
|
|
145
|
+
};
|
|
146
|
+
}, [modalRef, onClose]);
|
|
147
|
+
return (_jsxs("div", { children: [trigger, isOpen && (_jsx("div", { id: "quill-popover-modal", ref: modalRef, style: { position: 'relative' }, children: _jsx("div", { style: {
|
|
148
|
+
background: 'white',
|
|
149
|
+
position: 'absolute',
|
|
150
|
+
boxShadow: '0px 1px 12px 0px rgba(56, 65, 81, 0.1)',
|
|
151
|
+
border: '1px solid #e7e7e7',
|
|
152
|
+
boxSizing: 'content-box',
|
|
153
|
+
zIndex: 999,
|
|
154
|
+
top: 12,
|
|
155
|
+
borderRadius: 6,
|
|
156
|
+
padding: 20,
|
|
157
|
+
overflow: 'auto',
|
|
158
|
+
...style,
|
|
159
|
+
}, children: children }) }))] }));
|
|
160
|
+
}
|
|
161
|
+
export const QuillPopover = forwardRef(({ children, trigger, isOpen, onClose = () => { }, title = undefined }, ref) => {
|
|
162
|
+
return (_jsxs(MemoizedPopover, { isOpen: isOpen, onClose: onClose, trigger: trigger, parentRef: ref, ref: ref, children: [title && (_jsx("h1", { style: {
|
|
163
|
+
fontWeight: '600',
|
|
164
|
+
fontSize: 18,
|
|
165
|
+
margin: 0,
|
|
166
|
+
textAlign: 'left',
|
|
167
|
+
paddingBottom: 12,
|
|
168
|
+
}, children: title })), children] }));
|
|
169
|
+
});
|
|
170
|
+
// The six-dot grab-handle icon.
|
|
171
|
+
export const QuillHandleButton = () => {
|
|
172
|
+
return (_jsxs("div", { style: {
|
|
173
|
+
display: 'flex',
|
|
174
|
+
gap: 2,
|
|
175
|
+
flexDirection: 'row',
|
|
176
|
+
paddingTop: 8,
|
|
177
|
+
paddingBottom: 8,
|
|
178
|
+
paddingLeft: 8,
|
|
179
|
+
paddingRight: 8,
|
|
180
|
+
borderRadius: 4,
|
|
181
|
+
}, className: "handle", children: [_jsx("style", { children: `.handle{background:white;} .handle:hover{background:rgba(0,0,0,0.03);}` }), _jsxs("div", { style: { display: 'flex', gap: 2, flexDirection: 'column' }, children: [_jsx("div", { style: {
|
|
182
|
+
width: 3,
|
|
183
|
+
height: 3,
|
|
184
|
+
borderRadius: 3,
|
|
185
|
+
background: '#9CA0A7',
|
|
186
|
+
} }), _jsx("div", { style: {
|
|
187
|
+
width: 3,
|
|
188
|
+
height: 3,
|
|
189
|
+
borderRadius: 3,
|
|
190
|
+
background: '#9CA0A7',
|
|
191
|
+
} }), _jsx("div", { style: {
|
|
192
|
+
width: 3,
|
|
193
|
+
height: 3,
|
|
194
|
+
borderRadius: 3,
|
|
195
|
+
background: '#9CA0A7',
|
|
196
|
+
} })] }), _jsxs("div", { style: { display: 'flex', gap: 2, flexDirection: 'column' }, children: [_jsx("div", { style: {
|
|
197
|
+
width: 3,
|
|
198
|
+
height: 3,
|
|
199
|
+
borderRadius: 3,
|
|
200
|
+
background: '#9CA0A7',
|
|
201
|
+
} }), _jsx("div", { style: {
|
|
202
|
+
width: 3,
|
|
203
|
+
height: 3,
|
|
204
|
+
borderRadius: 3,
|
|
205
|
+
background: '#9CA0A7',
|
|
206
|
+
} }), _jsx("div", { style: {
|
|
207
|
+
width: 3,
|
|
208
|
+
height: 3,
|
|
209
|
+
borderRadius: 3,
|
|
210
|
+
background: '#9CA0A7',
|
|
211
|
+
} })] })] }));
|
|
212
|
+
};
|
|
213
|
+
export const QuillSelectColumn = ({ label, selected, setSelected, children, }) => {
|
|
214
|
+
return (_jsxs("div", { title: label, style: {
|
|
215
|
+
boxShadow: '0px 1px 4px #e2e8f005',
|
|
216
|
+
paddingTop: 4,
|
|
217
|
+
paddingBottom: 4,
|
|
218
|
+
paddingLeft: 5,
|
|
219
|
+
border: '1px solid #e2e8f0',
|
|
220
|
+
borderRadius: 4,
|
|
221
|
+
display: 'flex',
|
|
222
|
+
alignItems: 'center',
|
|
223
|
+
backgroundColor: 'white',
|
|
224
|
+
}, children: [_jsx("div", { children: children }), _jsxs("label", { style: {
|
|
225
|
+
display: 'flex',
|
|
226
|
+
gap: 2,
|
|
227
|
+
whiteSpace: 'nowrap',
|
|
228
|
+
textOverflow: 'ellipsis',
|
|
229
|
+
overflow: 'hidden',
|
|
230
|
+
}, children: [_jsx(MemoizedCheckbox, { checked: selected, onChange: () => setSelected() }), _jsx("span", { style: {
|
|
231
|
+
marginLeft: 6,
|
|
232
|
+
display: 'block',
|
|
233
|
+
whiteSpace: 'nowrap',
|
|
234
|
+
textOverflow: 'ellipsis',
|
|
235
|
+
overflow: 'hidden',
|
|
236
|
+
}, children: label })] })] }));
|
|
237
|
+
};
|
|
238
|
+
// A draggable card with a grab-handle and a column name
|
|
239
|
+
export const QuillDraggableColumn = ({ label, children, onDelete }) => {
|
|
240
|
+
const [theme] = useContext(ThemeContext);
|
|
241
|
+
return (_jsxs("div", { style: {
|
|
242
|
+
boxShadow: '0px 1px 4px #e2e8f005',
|
|
243
|
+
border: '1px solid #e2e8f0',
|
|
244
|
+
borderRadius: 6,
|
|
245
|
+
display: 'flex',
|
|
246
|
+
alignItems: 'center',
|
|
247
|
+
backgroundColor: 'white',
|
|
248
|
+
}, children: [_jsx("div", { children: children }), _jsx("div", { style: {
|
|
249
|
+
marginLeft: 2,
|
|
250
|
+
marginRight: 'auto',
|
|
251
|
+
fontSize: 14,
|
|
252
|
+
display: 'block',
|
|
253
|
+
whiteSpace: 'nowrap',
|
|
254
|
+
textOverflow: 'ellipsis',
|
|
255
|
+
}, children: label }), _jsx("button", { onClick: onDelete, style: { paddingRight: 8, margin: -4 }, children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", fill: theme?.secondaryButtonColor || 'currentColor', style: { width: 16, height: 16 }, children: _jsx("path", { d: "M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z" }) }) })] }));
|
|
256
|
+
};
|
|
257
|
+
// Three dots animated bouncing
|
|
258
|
+
export const QuillButtonLoadingState = () => {
|
|
259
|
+
return _jsx(QuillButton, { children: "Loading..." });
|
|
260
|
+
};
|
|
261
|
+
// Loading state for the table
|
|
262
|
+
export const QuillTableLoadingState = () => {
|
|
263
|
+
return (_jsx("div", { style: { display: 'flex', flexDirection: 'column', margin: 'auto' }, children: _jsx(LoadingSpinner, {}) }));
|
|
264
|
+
};
|
|
265
|
+
export const DEFAULT_TAB_OPTIONS = [
|
|
266
|
+
{ label: 'or', value: 'OR' },
|
|
267
|
+
{ label: 'and', value: 'AND' },
|
|
268
|
+
];
|
|
269
|
+
export const QuillTabs = forwardRef(({ options = DEFAULT_TAB_OPTIONS, ...props }, ref) => (_jsx(MemoizedTabs, { ref: ref, options: options, ...props })));
|
|
270
|
+
export const EditPopover = ({ onSave, onDelete, Button, renderNode, activeEditItem, }) => {
|
|
271
|
+
return (_jsxs("div", { style: {
|
|
272
|
+
display: 'flex',
|
|
273
|
+
flexDirection: 'column',
|
|
274
|
+
gap: 12,
|
|
275
|
+
}, children: [activeEditItem && renderNode(activeEditItem), _jsxs("div", { style: {
|
|
276
|
+
display: 'flex',
|
|
277
|
+
flexDirection: 'row',
|
|
278
|
+
justifyContent: 'end',
|
|
279
|
+
gap: 8,
|
|
280
|
+
width: '100%',
|
|
281
|
+
}, children: [_jsx(QuillSecondaryButton, { onClick: onDelete, children: "Delete" }), _jsx(Button, { onClick: onSave, children: "Save" })] })] }));
|
|
282
|
+
};
|
|
283
|
+
export const QuillFilterPopover = ({ filterLabel, onClickDeleteFilter, popoverTitle, popoverChildren, isOpen, setIsOpen, }) => {
|
|
284
|
+
return (_jsx(QuillPopover, { isOpen: isOpen, title: popoverTitle, trigger: _jsx(QuillTag, { label: filterLabel, onClickDelete: onClickDeleteFilter, onClick: () => {
|
|
285
|
+
setIsOpen((isOpen) => !isOpen);
|
|
286
|
+
} }), onClose: () => {
|
|
287
|
+
setIsOpen(false);
|
|
288
|
+
}, children: popoverChildren }));
|
|
289
|
+
};
|
|
290
|
+
export const TagWrapper = ({ isCard, isRow, editPopoverKey, keyPrefix, formData, activeEditItem, setEditPopoverKey, setActiveEditItem, setActivePath, setOpenPopover, setIsPending, clearCheckboxes, fetchSqlQuery, handleDelete, setCheckboxes, handleReplaceSubtree, FilterPopover, getByKey, EditPopover, Button, renderNode, children, }) => {
|
|
291
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
292
|
+
useEffect(() => {
|
|
293
|
+
if (isOpen) {
|
|
294
|
+
// open
|
|
295
|
+
setActiveEditItem(getByKey(formData, keyPrefix));
|
|
296
|
+
setActivePath(keyPrefix);
|
|
297
|
+
setIsPending(true);
|
|
298
|
+
setEditPopoverKey(keyPrefix);
|
|
299
|
+
setCheckboxes(getByKey(formData, keyPrefix));
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
// closed
|
|
303
|
+
setEditPopoverKey(null);
|
|
304
|
+
setIsPending(false);
|
|
305
|
+
setActiveEditItem(null);
|
|
306
|
+
setActivePath(null);
|
|
307
|
+
setOpenPopover(null);
|
|
308
|
+
clearCheckboxes();
|
|
309
|
+
}
|
|
310
|
+
}, [isOpen]);
|
|
311
|
+
if (isCard && isRow) {
|
|
312
|
+
const handleClickDelete = (e) => {
|
|
313
|
+
e.stopPropagation(); // don't call onClick handler
|
|
314
|
+
setIsPending(false);
|
|
315
|
+
handleDelete(keyPrefix);
|
|
316
|
+
setActiveEditItem(null);
|
|
317
|
+
setActivePath(null);
|
|
318
|
+
setOpenPopover(null);
|
|
319
|
+
setEditPopoverKey(null);
|
|
320
|
+
clearCheckboxes();
|
|
321
|
+
};
|
|
322
|
+
return (_jsx("div", { style: { width: '100%' }, children: _jsx(FilterPopover, { isOpen: editPopoverKey === keyPrefix, popoverTitle: "Edit Filter", filterLabel: children, onClickDeleteFilter: handleClickDelete, setIsOpen: setIsOpen, popoverChildren: _jsx(EditPopover, { Button: Button, renderNode: renderNode, activeEditItem: activeEditItem, onSave: () => {
|
|
323
|
+
if (isNodeEmptyCollection(activeEditItem)) {
|
|
324
|
+
setIsPending(false);
|
|
325
|
+
setActiveEditItem(null);
|
|
326
|
+
setActivePath(null);
|
|
327
|
+
setOpenPopover(null);
|
|
328
|
+
setEditPopoverKey(null);
|
|
329
|
+
handleDelete(keyPrefix);
|
|
330
|
+
fetchSqlQuery();
|
|
331
|
+
clearCheckboxes();
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
setEditPopoverKey(null);
|
|
335
|
+
setIsPending(false);
|
|
336
|
+
handleReplaceSubtree(keyPrefix, activeEditItem, false);
|
|
337
|
+
setActiveEditItem(null);
|
|
338
|
+
setActivePath(null);
|
|
339
|
+
setOpenPopover(null);
|
|
340
|
+
clearCheckboxes();
|
|
341
|
+
}
|
|
342
|
+
}, onDelete: () => {
|
|
343
|
+
setIsPending(false);
|
|
344
|
+
setActiveEditItem(null);
|
|
345
|
+
setActivePath(null);
|
|
346
|
+
setOpenPopover(null);
|
|
347
|
+
setEditPopoverKey(null);
|
|
348
|
+
handleDelete(keyPrefix);
|
|
349
|
+
fetchSqlQuery();
|
|
350
|
+
clearCheckboxes();
|
|
351
|
+
} }) }) })); // Make sure to close the <Tag> correctly
|
|
352
|
+
}
|
|
353
|
+
else if (isRow) {
|
|
354
|
+
return _jsx("div", { children: children });
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
return _jsx(_Fragment, { children: children });
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
export const AddFilterPopover = ({ onSave, Button, renderNode, activeEditItem, }) => {
|
|
361
|
+
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 12 }, children: [activeEditItem && renderNode(activeEditItem), _jsx("div", { style: {
|
|
362
|
+
display: 'flex',
|
|
363
|
+
flexDirection: 'row',
|
|
364
|
+
justifyContent: 'end',
|
|
365
|
+
}, children: _jsx(Button, { onMouseUp: onSave, children: "Add filter" }) })] }));
|
|
366
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A node that is "in" or "not in" where none of the variants are selected.
|
|
3
|
+
*/
|
|
4
|
+
export declare const isNodeEmptyCollection: (node: any) => boolean;
|
|
5
|
+
export declare function isTopLevelBoolean(node: any): boolean;
|
|
6
|
+
export declare function hasTopLevelOrBoolean(ast: any): boolean;
|
|
7
|
+
export declare const isDateTrunc: (node: any) => boolean;
|
|
8
|
+
export declare const isColumnReferenceish: (node: any) => any;
|
|
9
|
+
export declare function generateColumnExpr(name: any): {
|
|
10
|
+
type: string;
|
|
11
|
+
expr: {
|
|
12
|
+
type: string;
|
|
13
|
+
table: null;
|
|
14
|
+
column: any;
|
|
15
|
+
};
|
|
16
|
+
as: null;
|
|
17
|
+
};
|
|
18
|
+
export declare const isColumnDateish: (col: any) => any;
|
|
19
|
+
export declare function areObjectsEqualish(left: any, right: any): boolean;
|
|
20
|
+
export declare function formatDateComparisonNode(node: any): string | null;
|
|
21
|
+
export declare function getInTheCurrentIntervalSentence(node: any, databaseType: string): string | null;
|
|
22
|
+
export declare function getInTheLastIntervalSentence(node: any, databaseType: string): string | null;
|
|
23
|
+
export declare function getInThePreviousIntervalSentence(node: any, databaseType: string): string | null;
|
|
24
|
+
export declare const isInTheLastInterval: (node: any, databaseType: string) => boolean;
|
|
25
|
+
export declare const isInTheLastIntervalBigQuery: (node: any) => boolean;
|
|
26
|
+
export declare const isTheCurrentInterval: (node: any, databaseType: string) => boolean;
|
|
27
|
+
export declare const isThePreviousInterval: (node: any, databaseType: string) => any;
|
|
28
|
+
export declare const isTheCurrentIntervalBigQuery: (node: any) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Returns whether this node is the root of a binary expression
|
|
31
|
+
* where the left child is a string but really should be
|
|
32
|
+
* interpreted as a column name.
|
|
33
|
+
*/
|
|
34
|
+
export declare const isColumnComparison: (node: any) => any;
|
|
35
|
+
export declare const newUTCDate: (dateString: string) => Date;
|
|
36
|
+
/**
|
|
37
|
+
* Takes the right side of a dateTruncEquals expression (ie. the suffix)
|
|
38
|
+
* and returns a pretty string representation of what that value means.
|
|
39
|
+
*
|
|
40
|
+
* eg. date_trunc('year', TIMESTAMP '2023-01-01') would be "in 2023"
|
|
41
|
+
* eg. date_trunc('month', TIMESTAMP '2023-01-01') would be "in Jan 2023"
|
|
42
|
+
* eg. date_trunc('quarter', TIMESTAMP '2023-01-01') would be "in Q1 2023"
|
|
43
|
+
*/
|
|
44
|
+
export declare function dateTruncSuffixToString(node: any, databaseType?: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Takes an extract binary expression and returns a string version
|
|
47
|
+
* of what the AST means.
|
|
48
|
+
*
|
|
49
|
+
* eg. extract(YEAR FROM "created_at") = 2023 would be "in 2023"
|
|
50
|
+
* eg. extract(MONTH FROM "created_at") = 1 would be "in January"
|
|
51
|
+
* eg. TODO: add more variants as they come up
|
|
52
|
+
*/
|
|
53
|
+
export declare function extractSuffixToString(node: any): string;
|
|
54
|
+
export declare function tryConvertDateEquality(node: any, databaseType?: string): string | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Returns whether this node is an equality of a date column with a
|
|
57
|
+
* date trunc.
|
|
58
|
+
*/
|
|
59
|
+
export declare const isDateTruncEquals: (node: any) => boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Returns whether this node is an equality of a date column with extract.
|
|
62
|
+
*/
|
|
63
|
+
export declare const isExtractEquals: (node: any) => boolean;
|
|
64
|
+
export declare function showNodeAsRow(node: any, ast: any): boolean;
|
|
65
|
+
export declare function getPostgresBasicType(column: any): 'string' | 'number' | 'date' | undefined;
|
|
66
|
+
export declare const deepCopy: (obj: any) => any;
|
|
67
|
+
export declare const trimEndS: (s: string) => string;
|
|
68
|
+
export declare const getDateFilterInfo: (node: any) => {
|
|
69
|
+
dateColumn: any;
|
|
70
|
+
dateColumnPath: string;
|
|
71
|
+
dateFilterType: string;
|
|
72
|
+
intervalCount: number | null | undefined;
|
|
73
|
+
intervalType: any;
|
|
74
|
+
intervalPaths: any;
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../src/components/ReportBuilder/util.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,eAAO,MAAM,qBAAqB,SAAU,GAAG,YAW9C,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,GAAG,WAa1C;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,GAAG,WAK5C;AAGD,eAAO,MAAM,WAAW,SAAU,GAAG,YAuBpC,CAAC;AAKF,eAAO,MAAM,oBAAoB,SAAU,GAAG,QAE7C,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG;;;;;;;;EAU3C;AAKD,eAAO,MAAM,eAAe,QAAS,GAAG,QAMvC,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,WAiBvD;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,GAAG,iBAQjD;AAED,wBAAgB,+BAA+B,CAC7C,IAAI,EAAE,GAAG,EACT,YAAY,EAAE,MAAM,GACnB,MAAM,GAAG,IAAI,CAOf;AAQD,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,GAAG,EACT,YAAY,EAAE,MAAM,GACnB,MAAM,GAAG,IAAI,CAWf;AAED,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,GAAG,EACT,YAAY,EAAE,MAAM,GACnB,MAAM,GAAG,IAAI,CAOf;AAMD,eAAO,MAAM,mBAAmB,SAAU,GAAG,gBAAgB,MAAM,YA4BlE,CAAC;AAIF,eAAO,MAAM,2BAA2B,SAAU,GAAG,YAUpD,CAAC;AAIF,eAAO,MAAM,oBAAoB,SACzB,GAAG,gBACK,MAAM,KACnB,OAmBF,CAAC;AAEF,eAAO,MAAM,qBAAqB,SAAU,GAAG,gBAAgB,MAAM,QAYpE,CAAC;AAEF,eAAO,MAAM,4BAA4B,SAAU,GAAG,KAAG,OAUxD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,SAAU,GAAG,QA4B3C,CAAC;AAGF,eAAO,MAAM,UAAU,eAAgB,MAAM,SAe5C,CAAC;AAmBF;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,GAAG,EAAE,YAAY,CAAC,EAAE,MAAM,UAsBvE;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,GAAG,UAgB9C;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,GAAG,EAAE,YAAY,CAAC,EAAE,MAAM,sBAetE;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,SAAU,GAAG,YAU1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,SAAU,GAAG,YAOxC,CAAC;AAEF,wBAAgB,aAAa,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,WAehD;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,GAAG,GACV,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAyB1C;AAED,eAAO,MAAM,QAAQ,QAAS,GAAG,QAAoC,CAAC;AAEtE,eAAO,MAAM,QAAQ,MAAO,MAAM,WAA2C,CAAC;AA4L9E,eAAO,MAAM,iBAAiB,SAAU,GAAG;;;;;;;CAc1C,CAAC"}
|