@quillsql/react 2.6.1 → 2.6.3

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.
Files changed (56) hide show
  1. package/lib/AddToDashboardModal.js +136 -243
  2. package/lib/AddToDashboardModal.js.map +1 -1
  3. package/lib/Chart.js +106 -139
  4. package/lib/Chart.js.map +1 -1
  5. package/lib/ChartBuilder.d.ts +36 -0
  6. package/lib/ChartBuilder.js +612 -0
  7. package/lib/ChartBuilder.js.map +1 -0
  8. package/lib/ChartEditor.d.ts +20 -0
  9. package/lib/ChartEditor.js +75 -0
  10. package/lib/ChartEditor.js.map +1 -0
  11. package/lib/Dashboard.d.ts +1 -0
  12. package/lib/Dashboard.js +38 -67
  13. package/lib/Dashboard.js.map +1 -1
  14. package/lib/DateRangePicker/dateRangePickerUtils.d.ts +1 -0
  15. package/lib/DateRangePicker/dateRangePickerUtils.js +6 -1
  16. package/lib/DateRangePicker/dateRangePickerUtils.js.map +1 -1
  17. package/lib/QuillProvider.d.ts +1 -0
  18. package/lib/QuillProvider.js +1 -0
  19. package/lib/QuillProvider.js.map +1 -1
  20. package/lib/ReportBuilder.d.ts +24 -34
  21. package/lib/ReportBuilder.js +248 -893
  22. package/lib/ReportBuilder.js.map +1 -1
  23. package/lib/SQLEditor.d.ts +5 -1
  24. package/lib/SQLEditor.js +91 -163
  25. package/lib/SQLEditor.js.map +1 -1
  26. package/lib/Table.js +56 -108
  27. package/lib/Table.js.map +1 -1
  28. package/lib/assets/XIcon.d.ts +4 -0
  29. package/lib/assets/XIcon.js +6 -0
  30. package/lib/assets/XIcon.js.map +1 -0
  31. package/lib/assets/index.d.ts +4 -0
  32. package/lib/assets/index.js +9 -1
  33. package/lib/assets/index.js.map +1 -1
  34. package/lib/components/QuillCard.d.ts +5 -2
  35. package/lib/components/QuillCard.js +43 -5
  36. package/lib/components/QuillCard.js.map +1 -1
  37. package/lib/components/UiComponents.d.ts +112 -0
  38. package/lib/components/UiComponents.js +255 -0
  39. package/lib/components/UiComponents.js.map +1 -0
  40. package/lib/hooks/useQuill.d.ts +1 -0
  41. package/lib/hooks/useQuill.js +15 -59
  42. package/lib/hooks/useQuill.js.map +1 -1
  43. package/lib/index.d.ts +2 -0
  44. package/lib/index.js +5 -1
  45. package/lib/index.js.map +1 -1
  46. package/lib/internals/ReportBuilder/PivotList.d.ts +27 -3
  47. package/lib/internals/ReportBuilder/PivotList.js +49 -39
  48. package/lib/internals/ReportBuilder/PivotList.js.map +1 -1
  49. package/lib/internals/ReportBuilder/PivotModal.d.ts +33 -3
  50. package/lib/internals/ReportBuilder/PivotModal.js +318 -226
  51. package/lib/internals/ReportBuilder/PivotModal.js.map +1 -1
  52. package/lib/internals/ReportBuilder/PivotModal.spec.js +19 -0
  53. package/lib/internals/ReportBuilder/PivotModal.spec.js.map +1 -1
  54. package/lib/utils/aggregate.js +1 -0
  55. package/lib/utils/aggregate.js.map +1 -1
  56. package/package.json +6 -3
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.getPostgresBasicType = void 0;
4
7
  const jsx_runtime_1 = require("react/jsx-runtime");
@@ -8,27 +11,13 @@ const react_1 = require("react");
8
11
  const Context_1 = require("./Context");
9
12
  const SQLEditor_1 = require("./SQLEditor");
10
13
  const date_fns_1 = require("date-fns");
11
- const assets_1 = require("./assets");
12
- function QuillModal({ children, isOpen, onClose, title, theme }) {
13
- if (!isOpen) {
14
- return null;
15
- }
16
- return ((0, jsx_runtime_1.jsx)("div", { style: {
17
- position: 'absolute',
18
- top: 45,
19
- minWidth: 300,
20
- left: 0,
21
- backgroundColor: theme.backgroundColor || 'white',
22
- padding: '20px',
23
- zIndex: '1000',
24
- borderRadius: 8,
25
- boxShadow: '0 1px 8px 0 rgba(0,0,0,.09)',
26
- borderWidth: theme.borderWidth,
27
- borderStyle: 'solid',
28
- borderColor: theme.borderColor,
29
- }, children: children }));
30
- }
31
- function ReportBuilder({ onChangeQuery, onChangeData, onChangeColumns, onChangeLoading, onError, SelectComponent, ButtonComponent, ModalComponent, ModalTriggerComponent, TextInputComponent, tagStyle, }) {
14
+ const PivotModal_1 = require("./internals/ReportBuilder/PivotModal");
15
+ const dataFetcher_1 = require("./utils/dataFetcher");
16
+ const dateRangePickerUtils_1 = require("./DateRangePicker/dateRangePickerUtils");
17
+ const Table_1 = __importDefault(require("./Table"));
18
+ const ChartBuilder_1 = __importDefault(require("./ChartBuilder"));
19
+ const UiComponents_1 = require("./components/UiComponents");
20
+ function ReportBuilder({ onChangeQuery, onChangeData, onChangeColumns, onChangeLoading, onChangePivot, onDateFilterChange, onChangeFields, onError, TextInput = UiComponents_1.MemoizedTextInput, containerStyle, Select = UiComponents_1.MemoizedSelect, Button = UiComponents_1.MemoizedButton, SecondaryButton = UiComponents_1.MemoizedSecondaryButton, Header = UiComponents_1.MemoizedHeader, Label = UiComponents_1.MemoizedLabel, DeleteButton = UiComponents_1.MemoizedDeleteButton, Text = UiComponents_1.MemoizedText, Modal = UiComponents_1.MemoizedModal, Popover = UiComponents_1.MemoizedPopover, showTableFormatOptions = false, showDateFieldOptions = false, showAccessControlOptions = false, tagStyle, tableName, dateColumn, selectedTagBorderColor, chartBuilderEnabled = false, }) {
32
21
  const [data, setData] = (0, react_1.useState)([]);
33
22
  const [client] = (0, react_1.useContext)(Context_1.ClientContext);
34
23
  const [schema, setSchema] = (0, react_1.useContext)(Context_1.SchemaContext);
@@ -36,72 +25,15 @@ function ReportBuilder({ onChangeQuery, onChangeData, onChangeColumns, onChangeL
36
25
  const [columns, setColumns] = (0, react_1.useState)([]);
37
26
  const [fields, setFields] = (0, react_1.useState)([]);
38
27
  const [loading, setLoading] = (0, react_1.useState)(false);
39
- (0, react_1.useEffect)(() => {
40
- async function getData(schema) {
41
- if (schema.length && !data.length) {
42
- const { publicKey, customerId, environment } = client;
43
- // const response = await axios.post(
44
- // `https://quill-344421.uc.r.appspot.com/dashquery`,
45
- // {
46
- // query: `select * from ${schema[0].displayName} limit 10;`,
47
- // },
48
- // {
49
- // params: {
50
- // orgId: customerId,
51
- // publicKey,
52
- // },
53
- // headers: {
54
- // Authorization: `Bearer `,
55
- // environment: environment || undefined,
56
- // },
57
- // }
58
- // );
59
- const url = new URL('https://quill-344421.uc.r.appspot.com/dashquery');
60
- url.searchParams.append('orgId', customerId);
61
- url.searchParams.append('publicKey', publicKey);
62
- const requestOptions = {
63
- method: 'POST',
64
- headers: {
65
- Authorization: 'Bearer ',
66
- ...(environment ? { environment } : {}),
67
- 'Content-Type': 'application/json',
68
- },
69
- body: JSON.stringify({
70
- query: `select * from ${schema[0].displayName} limit 10;`,
71
- }),
72
- };
73
- const response = await fetch(url.toString(), requestOptions);
74
- const responseData = await response.json();
75
- setData(responseData.rows);
76
- }
77
- }
78
- getData(schema);
79
- }, [schema]);
28
+ const [selectedPivot, setSelectedPivot] = (0, react_1.useState)(null);
29
+ const defaultDateRange = (0, dateRangePickerUtils_1.getRangeFromPreset)('90d');
30
+ const [dateRange, setDateRange] = (0, react_1.useState)(defaultDateRange);
80
31
  (0, react_1.useEffect)(() => {
81
32
  let isSubscribed = true;
82
33
  async function getSchema() {
83
- const { publicKey, environment } = client;
84
- // const response3 = await axios.get(
85
- // `https://quill-344421.uc.r.appspot.com/schema2/${publicKey}/`,
86
- // {
87
- // headers: {
88
- // Authorization: `Bearer `,
89
- // environment: environment || undefined,
90
- // },
91
- // }
92
- // );
93
- const url = `https://quill-344421.uc.r.appspot.com/schema2/${publicKey}/`;
94
- const requestOptions = {
95
- method: 'GET',
96
- headers: {
97
- Authorization: 'Bearer ',
98
- ...(environment ? { environment } : {}),
99
- },
100
- };
101
- const response = await fetch(url, requestOptions);
102
- const responseData = await response.json();
34
+ const resp = await (0, dataFetcher_1.getDataFromCloud)(client, `schema2/${client.publicKey}/`, null, 'GET');
103
35
  if (isSubscribed) {
104
- setSchema(responseData.tables);
36
+ setSchema(resp.tables);
105
37
  }
106
38
  }
107
39
  if (isSubscribed) {
@@ -111,191 +43,80 @@ function ReportBuilder({ onChangeQuery, onChangeData, onChangeColumns, onChangeL
111
43
  isSubscribed = false;
112
44
  };
113
45
  }, []);
114
- const runQuery = async (query) => {
115
- const { publicKey, customerId, environment, queryEndpoint, queryHeaders, withCredentials, } = client;
116
- let response;
117
- let responseData;
118
- if (queryEndpoint) {
119
- // response = await axios.post(
120
- // queryEndpoint,
121
- // { metadata: { query, task: 'query' } },
122
- // { headers: queryHeaders, withCredentials }
123
- // );
124
- const requestOptions = {
125
- method: 'POST',
126
- headers: {
127
- ...queryHeaders,
128
- 'Content-Type': 'application/json',
129
- },
130
- credentials: withCredentials ? 'include' : 'same-origin',
131
- body: JSON.stringify({
132
- metadata: customerId
133
- ? { query, task: 'query', orgId: customerId }
134
- : { query, task: 'query' },
135
- }),
136
- };
137
- setLoading(true);
138
- response = await fetch(queryEndpoint, requestOptions);
139
- responseData = await response.json();
46
+ (0, react_1.useEffect)(() => {
47
+ if (onDateFilterChange) {
48
+ onDateFilterChange(dateRange);
140
49
  }
141
- else {
142
- // response = await axios.post(
143
- // `https://quill-344421.uc.r.appspot.com/dashquery`,
144
- // {
145
- // query,
146
- // },
147
- // {
148
- // params: {
149
- // orgId: customerId,
150
- // publicKey,
151
- // },
152
- // headers: {
153
- // Authorization: `Bearer `,
154
- // environment: environment || undefined,
155
- // },
156
- // }
157
- // );
158
- const url = new URL('https://quill-344421.uc.r.appspot.com/dashquery');
159
- url.searchParams.append('orgId', customerId);
160
- url.searchParams.append('publicKey', publicKey);
161
- const requestOptions = {
162
- method: 'POST',
163
- headers: {
164
- Authorization: 'Bearer ',
165
- ...(environment ? { environment } : {}),
166
- 'Content-Type': 'application/json',
167
- },
168
- body: JSON.stringify({ query }),
169
- };
170
- setLoading(true);
171
- response = await fetch(url.toString(), requestOptions);
172
- responseData = await response.json();
50
+ }, [dateRange]);
51
+ (0, react_1.useEffect)(() => {
52
+ if (onDateFilterChange) {
53
+ onDateFilterChange(defaultDateRange);
173
54
  }
174
- if (response && responseData && responseData.errorMessage) {
175
- onError(responseData.errorMessage);
55
+ }, []);
56
+ (0, react_1.useEffect)(() => {
57
+ setColumns([]);
58
+ }, [tableName]);
59
+ const runQuery = async (query) => {
60
+ setLoading(true);
61
+ const hostedBody = {
62
+ metadata: client.customerId
63
+ ? { query, task: 'query', orgId: client.customerId }
64
+ : { query, task: 'query' },
65
+ };
66
+ const cloudBody = { query };
67
+ const resp = await (0, dataFetcher_1.getData)(client, 'dashquery', 'same-origin', hostedBody, cloudBody);
68
+ if (resp && resp.errorMessage) {
69
+ onError(resp.errorMessage);
176
70
  setData([]);
177
- onChangeData([]);
71
+ // onChangeData([]);
178
72
  setColumns([]);
179
- onChangeColumns([]);
73
+ // onChangeColumns([]);
180
74
  setFields([]);
75
+ if (onChangeFields) {
76
+ onChangeFields([]);
77
+ }
181
78
  setLoading(false);
182
79
  return;
183
80
  }
184
- setData(responseData.rows);
185
- onChangeData(responseData.rows);
186
- setColumns(responseData.fields.map(elem => (0, SQLEditor_1.convertPostgresColumn)(elem)));
187
- onChangeColumns(responseData.fields.map(elem => (0, SQLEditor_1.convertPostgresColumn)(elem)));
188
- setFields(responseData.fields);
81
+ setData(resp.rows);
82
+ setColumns(resp.fields.map(elem => (0, SQLEditor_1.convertPostgresColumn)(elem)));
83
+ if (selectedPivot) {
84
+ const { rows, columns } = (0, PivotModal_1.generatePivotTable)(selectedPivot, resp.rows, dateRange);
85
+ if (onChangePivot) {
86
+ onChangePivot(selectedPivot, columns, rows);
87
+ }
88
+ }
89
+ else {
90
+ if (onChangeData) {
91
+ onChangeData(resp.rows);
92
+ }
93
+ if (onChangeColumns) {
94
+ onChangeColumns(resp.fields.map(elem => (0, SQLEditor_1.convertPostgresColumn)(elem)));
95
+ }
96
+ }
97
+ setFields(resp.fields);
98
+ if (onChangeFields) {
99
+ onChangeFields(resp.fields);
100
+ }
189
101
  setLoading(false);
190
102
  };
191
103
  (0, react_1.useEffect)(() => {
192
104
  if (onChangeLoading) {
193
105
  onChangeLoading(loading);
194
106
  }
195
- }, [loading, onChangeLoading]);
196
- if (!schema.length) {
107
+ }, [loading]);
108
+ if (!schema || !schema.length || !tableName) {
197
109
  return null;
198
110
  }
199
- return ((0, jsx_runtime_1.jsx)(ReportingTool, { theme: theme, data: data, schema: schema, onChangeQuery: onChangeQuery, runQuery: runQuery, SelectComponent: SelectComponent
200
- ? SelectComponent
201
- : ({ onChange, value, options }) => {
202
- return ((0, jsx_runtime_1.jsxs)("div", { style: { position: 'relative' }, children: [(0, jsx_runtime_1.jsx)("select", { onChange: event => onChange(event.target.value), value: value, id: 'reportbuilderdropdown', style: {
203
- width: '100%',
204
- minWidth: 230,
205
- WebkitAppearance: 'none',
206
- outline: 'none',
207
- textAlign: 'left',
208
- whiteSpace: 'nowrap',
209
- overflow: 'hidden',
210
- textOverflow: 'ellipsis',
211
- borderRadius: 6,
212
- paddingLeft: 12,
213
- paddingRight: 12,
214
- height: 38,
215
- borderWidth: theme.borderWidth,
216
- borderColor: theme.borderColor,
217
- background: theme.backgroundColor,
218
- color: theme.primaryTextColor,
219
- boxShadow: '0 1px 2px 0 rgba(0,0,0,.05)',
220
- fontFamily: theme.fontFamily,
221
- }, children: options.map((option, index) => ((0, jsx_runtime_1.jsx)("option", { value: option.value, children: option.label }, option.label + index))) }), (0, jsx_runtime_1.jsx)(assets_1.ArrowDownHeadIcon, { style: {
222
- height: '20px',
223
- width: '20px',
224
- flex: 'none',
225
- position: 'absolute',
226
- right: 8,
227
- top: 9,
228
- color: theme?.secondaryTextColor,
229
- }, "aria-hidden": "true" })] }));
230
- }, ButtonComponent: ButtonComponent
231
- ? ButtonComponent
232
- : ({ onClick, label }) => {
233
- return ((0, jsx_runtime_1.jsx)("div", { style: {
234
- height: 38,
235
- background: theme.primaryButtonColor,
236
- borderWidth: theme.borderWidth,
237
- borderColor: theme.borderColor,
238
- color: theme.backgroundColor,
239
- display: 'flex',
240
- borderRadius: 6,
241
- alignItems: 'center',
242
- justifyContent: 'center',
243
- maxWidth: 200,
244
- outline: 'none',
245
- cursor: 'pointer',
246
- fontFamily: theme.fontFamily,
247
- fontWeight: theme.buttonFontWeight || 500,
248
- fontSize: 14,
249
- }, onClick: onClick, children: label }));
250
- }, ModalComponent: ModalComponent
251
- ? ModalComponent
252
- : ({ children, isOpen, onClose, title }) => {
253
- return ((0, jsx_runtime_1.jsx)(QuillModal, { isOpen: isOpen, theme: theme, onClose: onClose, title: title, children: children }));
254
- }, ModalTriggerComponent: ModalTriggerComponent
255
- ? ModalTriggerComponent
256
- : ({ onClick, label }) => {
257
- return ((0, jsx_runtime_1.jsx)("div", { style: {
258
- height: 32,
259
- background: theme.backgroundColor,
260
- borderWidth: theme.borderWidth,
261
- borderColor: theme.borderColor,
262
- borderStyle: 'solid',
263
- outline: 'none',
264
- cursor: 'pointer',
265
- display: 'flex',
266
- borderRadius: 6,
267
- alignItems: 'center',
268
- justifyContent: 'center',
269
- boxShadow: '0 1px 2px 0 rgba(0,0,0,.05)',
270
- paddingRight: 12,
271
- paddingLeft: 12,
272
- fontSize: 14,
273
- color: theme.primaryTextColor,
274
- fontWeight: theme.buttonFontWeight || 600,
275
- fontFamily: theme.fontFamily,
276
- }, onClick: onClick, children: label }));
277
- }, TextInputComponent: TextInputComponent
278
- ? TextInputComponent
279
- : ({ onChange, value, id }) => {
280
- return ((0, jsx_runtime_1.jsx)("input", { style: {
281
- outline: 'none',
282
- textAlign: 'left',
283
- whiteSpace: 'nowrap',
284
- overflow: 'hidden',
285
- textOverflow: 'ellipsis',
286
- borderRadius: 6,
287
- paddingLeft: 12,
288
- paddingRight: 12,
289
- height: 38,
290
- borderWidth: theme.borderWidth,
291
- borderColor: theme.borderColor,
292
- borderStyle: 'solid',
293
- background: theme.backgroundColor,
294
- color: theme.primaryTextColor,
295
- boxShadow: '0 1px 2px 0 rgba(0,0,0,.05)',
296
- fontFamily: theme.fontFamily,
297
- }, id: id, onChange: onChange, value: value }));
298
- }, tagStyle: tagStyle }));
111
+ return ((0, jsx_runtime_1.jsx)(ReportingTool, { containerStyle: containerStyle, theme: theme, data: data, columns: columns, fields: fields, onChangeData: onChangeData, onChangeColumns: onChangeColumns, onChangePivot: onChangePivot, selectedPivot: selectedPivot, setSelectedPivot: pivot => {
112
+ setSelectedPivot(pivot);
113
+ if (onChangePivot) {
114
+ const table = pivot
115
+ ? (0, PivotModal_1.generatePivotTable)(pivot, data, dateRange)
116
+ : { rows: null, columns: null };
117
+ onChangePivot(pivot, table.columns, table.rows);
118
+ }
119
+ }, schema: schema, tableName: tableName, dateColumn: dateColumn, selectedTagBorderColor: selectedTagBorderColor, onChangeQuery: onChangeQuery, runQuery: runQuery, dateRange: dateRange, setDateRange: setDateRange, defaultDateRange: defaultDateRange, chartBuilderEnabled: chartBuilderEnabled, HeaderComponent: Header, LabelComponent: Label, SelectComponent: Select, TextComponent: Text, ButtonComponent: Button, ModalComponent: Modal, PopoverComponent: Popover, TextInputComponent: TextInput, tagStyle: tagStyle, showTableFormatOptions: showTableFormatOptions, showDateFieldOptions: showDateFieldOptions, showAccessControlOptions: showAccessControlOptions }));
299
120
  }
300
121
  exports.default = ReportBuilder;
301
122
  function getPostgresBasicType(column) {
@@ -347,9 +168,34 @@ function getPostgresBasicType(column) {
347
168
  return format;
348
169
  }
349
170
  exports.getPostgresBasicType = getPostgresBasicType;
350
- function ReportingTool({ schema, data, runQuery, SelectComponent, ButtonComponent, onChangeQuery, theme, ModalComponent, ModalTriggerComponent, TextInputComponent, tagStyle, }) {
351
- const [selectedTable, setSelectedTable] = (0, react_1.useState)(schema[0]);
352
- const [selectedColumn, setSelectedColumn] = (0, react_1.useState)(schema[0].columns[0]);
171
+ const newDateWhereAST = (column, dateRange) => {
172
+ return {
173
+ type: 'binary_expr',
174
+ operator: 'BETWEEN',
175
+ left: {
176
+ type: 'column_ref',
177
+ table: null,
178
+ column: column,
179
+ },
180
+ right: {
181
+ type: 'expr_list',
182
+ value: [
183
+ {
184
+ type: 'single_quote_string',
185
+ value: (0, date_fns_1.format)(new Date(dateRange[0]), 'MM/dd/yyyy'),
186
+ },
187
+ {
188
+ type: 'single_quote_string',
189
+ value: (0, date_fns_1.format)(new Date(dateRange[1]), 'MM/dd/yyyy'),
190
+ },
191
+ ],
192
+ },
193
+ };
194
+ };
195
+ function ReportingTool({ schema, data, columns, runQuery, SelectComponent, ButtonComponent, onChangeQuery, onChangePivot, selectedPivot, setSelectedPivot, theme, ModalComponent, HeaderComponent, PopoverComponent, TextComponent, TextInputComponent, LabelComponent, tagStyle, tableName, dateColumn, selectedTagBorderColor, dateRange, setDateRange, defaultDateRange, chartBuilderEnabled, fields, containerStyle, showTableFormatOptions = false, showDateFieldOptions = false, showAccessControlOptions = false, }) {
196
+ const selectedTable = (0, react_1.useMemo)(() => schema.find(t => t.displayName === tableName), [schema, tableName]);
197
+ const [selectedColumn, setSelectedColumn] = (0, react_1.useState)(schema[0].columns.find(elem => elem.name !== 'id'));
198
+ const parentRef = (0, react_1.useRef)();
353
199
  const [filters, setFilters] = (0, react_1.useState)([]);
354
200
  const [AST, setAST] = (0, react_1.useState)({
355
201
  with: null,
@@ -358,8 +204,8 @@ function ReportingTool({ schema, data, runQuery, SelectComponent, ButtonComponen
358
204
  distinct: { type: null },
359
205
  columns: '*',
360
206
  into: { position: null },
361
- from: [{ db: null, table: schema[0].displayName, as: null }],
362
- where: null,
207
+ from: [{ db: null, table: selectedTable.displayName, as: null }],
208
+ where: newDateWhereAST(dateColumn, defaultDateRange),
363
209
  groupby: null,
364
210
  having: null,
365
211
  orderby: null,
@@ -374,111 +220,27 @@ function ReportingTool({ schema, data, runQuery, SelectComponent, ButtonComponen
374
220
  const [stringFilterValues, setStringFilterValues] = (0, react_1.useState)([]);
375
221
  const [columnType, setColumnType] = (0, react_1.useState)(getPostgresBasicType(schema[0].columns[0]));
376
222
  const [sqlQuery, setSqlQuery] = (0, react_1.useState)('');
377
- // month | week | day | quarter
378
- const [dateBucket, setDateBucket] = (0, react_1.useState)('month');
379
223
  const [indexBeingEdited, setIndexBeingEdited] = (0, react_1.useState)(-1);
380
- const [groupBys, setGroupBys] = (0, react_1.useState)([]);
381
- const [aggregations, setAggregations] = (0, react_1.useState)([]);
382
- const [selectedGroupByColumn, setSelectedGroupByColumn] = (0, react_1.useState)(schema[0].columns[0]);
383
- const [groupByColumnType, setGroupByColumnType] = (0, react_1.useState)(getPostgresBasicType(schema[0].columns[0]));
384
- const [selectedSortByColumn, setSelectedSortByColumn] = (0, react_1.useState)(schema[0].columns[0].name);
385
- const [sortBys, setSortBys] = (0, react_1.useState)([]);
386
- const [selectedSortByDirection, setSelectedSortByDirection] = (0, react_1.useState)('ascending');
387
- const [groupByIndexBeingEdited, setGroupByIndexBeingEdited] = (0, react_1.useState)(-1);
388
- const [sortByIndexBeingEdited, setSortByIndexBeingEdited] = (0, react_1.useState)(-1);
389
- const [sortableColumns, setSortableColumns] = (0, react_1.useState)(schema[0].columns.map(col => col.name));
390
224
  const [isAddFilterModalOpen, setIsAddFilterModalOpen] = (0, react_1.useState)(false);
391
- const [isGroupByModalOpen, setIsGroupByModalOpen] = (0, react_1.useState)(false);
392
- const [isSortByModalOpen, setIsSortByModalOpen] = (0, react_1.useState)(false);
393
- const addGroupBy = () => {
394
- if (selectedGroupByColumn && groupByColumnType) {
395
- if (groupByColumnType === 'string') {
396
- setGroupBys(groupBys => {
397
- return [
398
- ...groupBys,
399
- {
400
- column: selectedGroupByColumn.name,
401
- columnType: groupByColumnType,
402
- tag: selectedGroupByColumn.name,
403
- },
404
- ];
405
- });
406
- return;
407
- }
408
- else if (groupByColumnType === 'number') {
409
- // is this possible lmao
410
- return;
411
- }
412
- else if (groupByColumnType === 'date') {
413
- setGroupBys(groupBys => {
414
- return [
415
- ...groupBys,
416
- {
417
- column: selectedGroupByColumn.name,
418
- columnType: groupByColumnType,
419
- bucket: dateBucket,
420
- tag: dateBucket,
421
- },
422
- ];
423
- });
424
- return;
425
- }
426
- }
427
- };
428
- const addSortBy = () => {
429
- setSortBys(sortBys => {
430
- return [
431
- ...sortBys,
432
- {
433
- column: selectedSortByColumn,
434
- direction: selectedSortByDirection,
435
- },
436
- ];
437
- });
438
- };
439
- const removeSortBy = index => {
440
- setSortBys(oldSortBys => {
441
- const newSortBys = [...oldSortBys];
442
- newSortBys.splice(index, 1);
443
- return newSortBys;
444
- });
445
- setSortByIndexBeingEdited(-1);
446
- };
447
- const removeGroupBy = index => {
448
- const columnBeingDeleted = groupBys[index].tag;
449
- setSortBys(oldSortBys => {
450
- const newSortBys = [
451
- ...oldSortBys.filter(sortBy => sortBy.column !== columnBeingDeleted),
452
- ];
453
- return newSortBys;
454
- });
455
- setGroupBys(oldGroupBys => {
456
- const newGroupBys = [...oldGroupBys];
457
- newGroupBys.splice(index, 1);
458
- return newGroupBys;
459
- });
460
- setGroupByIndexBeingEdited(-1);
461
- };
462
- const updateSortBy = index => {
463
- if (selectedSortByColumn && selectedSortByDirection) {
464
- setSortBys(sortBys => {
465
- const newSortBys = [...sortBys];
466
- newSortBys[index] = {
467
- column: selectedSortByColumn,
468
- direction: selectedSortByDirection,
469
- };
470
- return newSortBys;
471
- });
472
- setSortByIndexBeingEdited(-1);
473
- return;
474
- }
475
- };
225
+ const [isEdittingPivot, setIsEdittingPivot] = (0, react_1.useState)(false);
226
+ const [isPivotModalOpen, setIsPivotModalOpen] = (0, react_1.useState)(false);
227
+ const [isChartBuilderOpen, setIsChartBuilderOpen] = (0, react_1.useState)(false);
228
+ const [selectedPivotIndex, setSelectedPivotIndex] = (0, react_1.useState)(-1);
229
+ const [createdPivots, setCreatedPivots] = (0, react_1.useState)([]);
230
+ const [recommendedPivots, setRecommendedPivots] = (0, react_1.useState)([]);
231
+ const [pivotRowField, setPivotRowField] = (0, react_1.useState)(undefined);
232
+ const [pivotColumnField, setPivotColumnField] = (0, react_1.useState)(undefined);
233
+ const [pivotValueField, setPivotValueField] = (0, react_1.useState)(undefined);
234
+ const [pivotAggregation, setPivotAggregation] = (0, react_1.useState)(undefined);
235
+ const [pivotPopUpTitle, setPivotPopUpTitle] = (0, react_1.useState)('Add Pivot');
476
236
  (0, react_1.useEffect)(() => {
477
237
  setColumnType(getPostgresBasicType(selectedColumn));
478
238
  }, [selectedColumn]);
479
239
  (0, react_1.useEffect)(() => {
480
- setGroupByColumnType(getPostgresBasicType(selectedGroupByColumn));
481
- }, [selectedGroupByColumn]);
240
+ removePivot();
241
+ setCreatedPivots([]);
242
+ setRecommendedPivots([]);
243
+ }, [selectedTable]);
482
244
  const selectFilter = index => {
483
245
  const filter = filters[index];
484
246
  const matchingColumn = selectedTable.columns.find(column => column.name === filter.column);
@@ -498,58 +260,27 @@ function ReportingTool({ schema, data, runQuery, SelectComponent, ButtonComponen
498
260
  setIndexBeingEdited(index);
499
261
  }
500
262
  };
501
- const selectSortBy = index => {
502
- const sortBy = sortBys[index];
503
- setSelectedSortByColumn(sortBy.column);
504
- setSelectedSortByDirection(sortBy.direction);
505
- setSortByIndexBeingEdited(index);
506
- };
507
- const selectGroupBy = index => {
508
- const groupBy = groupBys[index];
509
- const matchingColumn = selectedTable.columns.find(column => column.name === groupBy.column);
510
- setSelectedGroupByColumn(matchingColumn);
511
- if (groupBy.bucket) {
512
- setDateBucket(groupBy.bucket);
263
+ const selectedPivotTable = (0, react_1.useMemo)(() => {
264
+ if (selectedPivot && data) {
265
+ return (0, PivotModal_1.generatePivotTable)(selectedPivot, data, dateRange);
266
+ }
267
+ else {
268
+ return {};
269
+ }
270
+ }, [selectedPivot, data, dateRange]);
271
+ const removePivot = () => {
272
+ setSelectedPivotIndex(-1);
273
+ setSelectedPivot(null);
274
+ if (onChangePivot) {
275
+ onChangePivot(null, null, null);
513
276
  }
514
- setGroupByIndexBeingEdited(index);
515
277
  };
516
- const updateGroupBy = index => {
517
- if (selectedGroupByColumn && groupByColumnType) {
518
- // if column changed, then auto delete the sort using that column
519
- const columnBeingDeleted = selectedGroupByColumn.name !== groupBys[index].column
520
- ? groupBys[index].tag
521
- : 'nocolumnbeingdeleted';
522
- setSortBys(oldSortBys => {
523
- const newSortBys = [
524
- ...oldSortBys.filter(sortBy => sortBy.column !== columnBeingDeleted),
525
- ];
526
- return newSortBys;
527
- });
528
- if (groupByColumnType === 'date') {
529
- setGroupBys(groupBys => {
530
- const newGroupBys = [...groupBys];
531
- newGroupBys[index] = {
532
- column: selectedGroupByColumn.name,
533
- columnType: groupByColumnType,
534
- bucket: dateBucket,
535
- tag: dateBucket,
536
- };
537
- return newGroupBys;
538
- });
539
- }
540
- else {
541
- setGroupBys(groupBys => {
542
- const newGroupBys = [...groupBys];
543
- newGroupBys[index] = {
544
- column: selectedGroupByColumn.name,
545
- columnType: groupByColumnType,
546
- tag: selectedGroupByColumn.name,
547
- };
548
- return newGroupBys;
549
- });
550
- }
551
- setGroupByIndexBeingEdited(-1);
552
- return;
278
+ const selectPivot = (pivot, index) => {
279
+ setSelectedPivotIndex(index);
280
+ setSelectedPivot(pivot);
281
+ const pivotTable = (0, PivotModal_1.generatePivotTable)(pivot, data, dateRange);
282
+ if (onChangePivot) {
283
+ onChangePivot(pivot, pivotTable.columns, pivotTable.rows);
553
284
  }
554
285
  };
555
286
  const updateFilter = index => {
@@ -666,98 +397,51 @@ function ReportingTool({ schema, data, runQuery, SelectComponent, ButtonComponen
666
397
  }
667
398
  }
668
399
  };
669
- const setAggregationColumn = (column, index) => {
670
- // ex
671
- setAggregations(aggregations => {
672
- const newAggregations = [...aggregations];
673
- newAggregations[index] = {
674
- ...newAggregations[index],
675
- column: column,
676
- };
677
- return newAggregations;
678
- });
679
- };
680
- const setAggregationType = (aggregationType, index) => {
681
- // ex
682
- setAggregations(aggregations => {
683
- const newAggregations = [...aggregations];
684
- newAggregations[index] = {
685
- ...newAggregations[index],
686
- aggregationType: aggregationType,
687
- };
688
- return newAggregations;
689
- });
690
- };
691
- const addAggregation = () => {
692
- // setAggregations([
693
- // {
694
- // column: selectedTable.columns.filter(
695
- // (col) => getPostgresBasicType(col) === "number"
696
- // )[0],
697
- // aggregationType: "sum",
698
- // },
699
- // ]);
700
- setAggregations(aggregations => {
701
- const newAggregations = [
702
- ...aggregations,
703
- {
704
- column: selectedTable.columns.filter(col => getPostgresBasicType(col) === 'number' &&
705
- !aggregations.map(elem => elem.name).includes(col.name))[0],
706
- aggregationType: 'sum',
707
- },
708
- ];
709
- return newAggregations;
710
- });
711
- };
712
- // useEffect(() => {
713
- // if (sqlQuery && sqlQuery.length &&) {
714
- // runQuery(sqlQuery);
715
- // }
716
- // }, [sqlQuery]);
717
- const handleRunQuery = () => {
718
- if (sqlQuery && sqlQuery.length) {
719
- runQuery(sqlQuery);
400
+ const handleRunQuery = (newSqlQuery) => {
401
+ const queryToUse = newSqlQuery || sqlQuery;
402
+ if (queryToUse && queryToUse.length) {
403
+ runQuery(queryToUse);
720
404
  }
721
405
  };
722
406
  (0, react_1.useEffect)(() => {
723
407
  // if selected table changes, clear everything
724
408
  if (selectedTable.displayName !== AST.from.table) {
725
- setSelectedColumn(selectedTable.columns[0]);
726
- setSortableColumns(selectedTable.columns.map(col => col.name));
727
- setGroupBys([]);
728
- setSortBys([]);
409
+ setSelectedColumn(selectedTable.columns.find(elem => elem.name !== 'id'));
729
410
  setFilters([]);
730
- // setAST((AST) => {
731
- // return {
732
- // with: null,
733
- // type: "select",
734
- // options: null,
735
- // distinct: { type: null },
736
- // columns: "*",
737
- // into: { position: null },
738
- // where: null,
739
- // groupby: null,
740
- // having: null,
741
- // orderby: null,
742
- // limit: { seperator: "", value: [] },
743
- // window: null,
744
- // from: [{ db: null, table: selectedTable.displayName, as: null }],
745
- // };
746
- // });
411
+ removePivot();
412
+ setAST(AST => {
413
+ return {
414
+ with: null,
415
+ type: 'select',
416
+ options: null,
417
+ distinct: { type: null },
418
+ columns: '*',
419
+ into: { position: null },
420
+ // where: newDateWhereAST(dateColumn, defaultDateRange),
421
+ where: null,
422
+ groupby: null,
423
+ having: null,
424
+ orderby: null,
425
+ limit: { seperator: '', value: [] },
426
+ window: null,
427
+ from: [{ db: null, table: selectedTable.displayName, as: null }],
428
+ };
429
+ });
747
430
  return;
748
431
  }
749
432
  }, [selectedTable]);
750
433
  // USE EFFECT HOOK THAT TRANSFORMS "FILTERS ARRAY INTO AST"
751
434
  (0, react_1.useEffect)(() => {
752
- if (filters.length || groupBys.length || aggregations.length) {
435
+ if (filters.length || dateRange) {
753
436
  const newAST = {
754
437
  with: null,
755
438
  type: 'select',
756
439
  options: null,
757
440
  distinct: null,
758
- columns: null,
441
+ columns: '*',
759
442
  into: { position: null },
760
443
  from: [{ db: null, table: selectedTable.displayName, as: null }],
444
+ // where: newDateWhereAST(dateColumn, dateRange || defaultDateRange),
761
445
  where: null,
762
446
  groupby: null,
763
447
  having: null,
@@ -807,28 +491,7 @@ function ReportingTool({ schema, data, runQuery, SelectComponent, ButtonComponen
807
491
  };
808
492
  }
809
493
  else if (columnType === 'date') {
810
- newCondition = {
811
- type: 'binary_expr',
812
- operator: 'BETWEEN',
813
- left: {
814
- type: 'column_ref',
815
- table: null,
816
- column: column,
817
- },
818
- right: {
819
- type: 'expr_list',
820
- value: [
821
- {
822
- type: 'single_quote_string',
823
- value: (0, date_fns_1.format)(new Date(dateStart), 'MM/dd/yyyy'),
824
- },
825
- {
826
- type: 'single_quote_string',
827
- value: (0, date_fns_1.format)(new Date(dateEnd), 'MM/dd/yyyy'),
828
- },
829
- ],
830
- },
831
- };
494
+ newCondition = newDateWhereAST(column, [dateStart, dateEnd]);
832
495
  }
833
496
  if (!newAST.where) {
834
497
  newAST.where = newCondition;
@@ -842,144 +505,9 @@ function ReportingTool({ schema, data, runQuery, SelectComponent, ButtonComponen
842
505
  };
843
506
  }
844
507
  }
845
- // GROUP BYS and AGGREGATIONS
846
- // if (groupBys.length > 0) {
847
- // newAST.groupby = groupBys.map(groupBy => ({
848
- // type: 'column_ref',
849
- // table: null,
850
- // column: groupBy.column,
851
- // }));
852
- // if (aggregations.length > 0) {
853
- // newAST.columns = [
854
- // ...groupBys.map(groupBy => ({
855
- // expr: {
856
- // type: 'column_ref',
857
- // table: null,
858
- // column: groupBy.column,
859
- // },
860
- // as: null,
861
- // })),
862
- // ...aggregations.map(aggregation => ({
863
- // expr: {
864
- // type: 'aggr_func',
865
- // name: aggregation.aggregationType.toUpperCase(),
866
- // args: {
867
- // expr: {
868
- // type: 'column_ref',
869
- // table: null,
870
- // column: aggregation.column.name,
871
- // },
872
- // },
873
- // over: null,
874
- // },
875
- // as: null,
876
- // })),
877
- // ];
878
- // } else {
879
- // newAST.columns = groupBys.map(groupBy => ({
880
- // expr: {
881
- // type: 'column_ref',
882
- // table: null,
883
- // column: groupBy.column,
884
- // },
885
- // as: null,
886
- // }));
887
- // }
888
- // } else {
889
- // newAST.columns = '*';
890
- // newAST.groupby = null;
891
- // }
892
- // GROUP BYS
893
- if (groupBys.length > 0) {
894
- newAST.columns = [];
895
- newAST.groupby = [];
896
- for (let i = 0; i < groupBys.length; i++) {
897
- const groupBy = groupBys[i];
898
- if (groupBy.columnType === 'date') {
899
- newAST.columns.push({
900
- expr: {
901
- type: 'function',
902
- name: 'date_trunc',
903
- args: {
904
- type: 'expr_list',
905
- value: [
906
- {
907
- type: 'single_quote_string',
908
- value: groupBy.bucket,
909
- },
910
- {
911
- type: 'column_ref',
912
- table: null,
913
- column: groupBy.column,
914
- },
915
- ],
916
- },
917
- over: null,
918
- },
919
- as: groupBy.bucket,
920
- });
921
- newAST.groupby.push({
922
- type: 'column_ref',
923
- table: null,
924
- column: groupBy.bucket,
925
- });
926
- }
927
- else {
928
- newAST.columns.push({
929
- expr: {
930
- type: 'column_ref',
931
- table: null,
932
- column: groupBy.column,
933
- },
934
- as: null,
935
- });
936
- newAST.groupby.push({
937
- type: 'column_ref',
938
- table: null,
939
- column: groupBy.column,
940
- });
941
- }
942
- }
943
- // AGGREGATIONS
944
- if (aggregations.length > 0) {
945
- for (let i = 0; i < aggregations.length; i++) {
946
- const aggregation = aggregations[i];
947
- newAST.columns.push({
948
- expr: {
949
- type: 'aggr_func',
950
- name: aggregation.aggregationType.toUpperCase(),
951
- args: {
952
- expr: {
953
- type: 'column_ref',
954
- table: null,
955
- column: aggregation.column.name,
956
- },
957
- },
958
- over: null,
959
- },
960
- as: null,
961
- });
962
- }
963
- }
964
- }
965
- else {
966
- newAST.columns = '*';
967
- newAST.groupby = null;
968
- }
969
- if (sortBys.length > 0) {
970
- newAST.orderby = [];
971
- for (let i = 0; i < sortBys.length; i++) {
972
- const sortBy = sortBys[i];
973
- newAST.orderby.push({
974
- expr: { type: 'column_ref', table: null, column: sortBy.column },
975
- type: sortBy.direction === 'descending' ? 'DESC' : 'ASC',
976
- });
977
- }
978
- // "orderby":[{"expr":{"type":"column_ref","table":null,"column":"amount"},"type":"DESC"},{"expr":{"type":"column_ref","table":null,"column":"month"},"type":"ASC"}]
979
- }
980
508
  setAST(newAST);
981
509
  }
982
- }, [filters, groupBys, aggregations, sortBys]);
510
+ }, [filters, dateRange]);
983
511
  const removeFilter = index => {
984
512
  setFilters(oldFilters => {
985
513
  const newFilters = [...oldFilters];
@@ -989,7 +517,9 @@ function ReportingTool({ schema, data, runQuery, SelectComponent, ButtonComponen
989
517
  setIndexBeingEdited(-1);
990
518
  };
991
519
  const computeStats = (0, react_1.useCallback)(column => {
992
- if (!computedColumns[column.name] && data) {
520
+ if ((!computedColumns[column.name] ||
521
+ computedColumns[column.name].length === 0) &&
522
+ data) {
993
523
  const basicType = getPostgresBasicType(column);
994
524
  let result;
995
525
  if (basicType === 'number') {
@@ -1026,7 +556,7 @@ function ReportingTool({ schema, data, runQuery, SelectComponent, ButtonComponen
1026
556
  // Call this function whenever the selected column changes
1027
557
  (0, react_1.useEffect)(() => {
1028
558
  computeStats(selectedColumn);
1029
- }, [selectedColumn]);
559
+ }, [selectedColumn, data]);
1030
560
  // Use the results directly in your component
1031
561
  const columnStats = computedColumns[selectedColumn.name];
1032
562
  // useEffect(() => {
@@ -1039,45 +569,16 @@ function ReportingTool({ schema, data, runQuery, SelectComponent, ButtonComponen
1039
569
  // }
1040
570
  // }
1041
571
  // }, [AST]);
1042
- (0, react_1.useEffect)(() => {
1043
- if (!aggregations.length) {
1044
- setAggregations([
1045
- {
1046
- column: selectedTable.columns.filter(col => getPostgresBasicType(col) === 'number')[0],
1047
- aggregationType: 'sum',
1048
- },
1049
- ]);
1050
- }
1051
- }, [selectedGroupByColumn]);
1052
572
  (0, react_1.useEffect)(() => {
1053
573
  const getSqlQueryFromAST = async () => {
1054
574
  try {
1055
575
  if (AST && AST.from[0].table) {
1056
- // const response = await axios.post(
1057
- // 'https://quill-344421.uc.r.appspot.com/sqlify',
1058
- // { ast: AST }
1059
- // );
1060
- const url = 'https://quill-344421.uc.r.appspot.com/sqlify';
1061
- const requestOptions = {
1062
- method: 'POST',
1063
- headers: {
1064
- 'Content-Type': 'application/json',
1065
- },
1066
- body: JSON.stringify({ ast: AST }),
1067
- };
1068
- const response = await fetch(url, requestOptions);
1069
- const responseData = await response.json();
1070
- const sqlQuery = responseData.query; // assuming the response contains the SQL query
1071
- // alert(sqlQuery);
1072
- if (sqlQuery) {
1073
- onChangeQuery(sqlQuery);
1074
- setSqlQuery(sqlQuery);
1075
- if (AST.columns === '*') {
1076
- setSortableColumns(selectedTable.columns.map(col => col.name));
1077
- }
1078
- else if (AST.columns.length) {
1079
- setSortableColumns(AST.columns.map(elem => elem.as || elem.expr.name));
1080
- }
576
+ const resp = await (0, dataFetcher_1.getDataFromCloud)(null, 'sqlify', { ast: AST });
577
+ const newSqlQuery = resp.query; // assuming the response contains the SQL query
578
+ if (newSqlQuery && newSqlQuery !== sqlQuery) {
579
+ onChangeQuery(newSqlQuery);
580
+ setSqlQuery(newSqlQuery);
581
+ handleRunQuery(newSqlQuery);
1081
582
  }
1082
583
  }
1083
584
  }
@@ -1087,30 +588,28 @@ function ReportingTool({ schema, data, runQuery, SelectComponent, ButtonComponen
1087
588
  };
1088
589
  getSqlQueryFromAST();
1089
590
  }, [AST]);
1090
- (0, react_1.useEffect)(() => {
1091
- if (sortableColumns.length) {
1092
- setSelectedSortByColumn(sortableColumns[0]);
1093
- }
1094
- }, [sortableColumns]);
1095
591
  if (!schema || !schema.length) {
1096
592
  return null;
1097
593
  }
1098
- return ((0, jsx_runtime_1.jsxs)("div", { style: { marginLeft: '25px' }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { maxWidth: 245 }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
1099
- fontSize: 14,
1100
- marginBottom: '6px',
1101
- fontWeight: '600',
1102
- color: theme.secondaryTextColor,
1103
- fontFamily: theme?.fontFamily,
1104
- }, children: "Table" }), (0, jsx_runtime_1.jsx)(SelectComponent, { label: "Table", value: selectedTable.displayName, onChange: e => {
1105
- const table = schema.find(t => t.displayName === e);
1106
- setSelectedTable(table);
1107
- }, options: schema?.length
1108
- ? schema.map(elem => {
1109
- return { label: elem.displayName, value: elem.displayName };
1110
- })
1111
- : [] })] }), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column', marginTop: '12px' }, children: [(0, jsx_runtime_1.jsx)(AddFilterModal2, { filters: filters, selectedColumn: selectedColumn, numberStart: numberStart, numberEnd: numberEnd, dateStart: dateStart, setDateStart: setDateStart, columnStats: columnStats, stringFilterValues: stringFilterValues, setStringFilterValues: setStringFilterValues, addFilter: addFilter, setSelectedColumn: setSelectedColumn, setNumberStart: setNumberStart, setNumberEnd: setNumberEnd, selectedTable: selectedTable, columnType: columnType, dateEnd: dateEnd, setDateEnd: setDateEnd, removeFilter: removeFilter, selectFilter: selectFilter, indexBeingEdited: indexBeingEdited, updateFilter: updateFilter, SelectComponent: SelectComponent, ButtonComponent: ButtonComponent, ModalComponent: ModalComponent, ModalTriggerComponent: ModalTriggerComponent, TextInputComponent: TextInputComponent, tagStyle: tagStyle, theme: theme, setIsOpen: setIsAddFilterModalOpen, isOpen: isAddFilterModalOpen }), (0, jsx_runtime_1.jsx)(GroupByModal2, { selectedTable: selectedTable, groupBys: groupBys, selectedGroupByColumn: selectedGroupByColumn, setSelectedGroupByColumn: setSelectedGroupByColumn, addGroupBy: addGroupBy, groupByColumnType: groupByColumnType, removeGroupBy: removeGroupBy, selectGroupBy: selectGroupBy, groupByIndexBeingEdited: groupByIndexBeingEdited, updateGroupBy: updateGroupBy, aggregations: aggregations, setAggregationColumn: setAggregationColumn, setAggregationType: setAggregationType, SelectComponent: SelectComponent, ButtonComponent: ButtonComponent, ModalComponent: ModalComponent, ModalTriggerComponent: ModalTriggerComponent, TextInputComponent: TextInputComponent, tagStyle: tagStyle, addAggregation: addAggregation, dateBucket: dateBucket, setDateBucket: setDateBucket, theme: theme, setIsOpen: setIsGroupByModalOpen, isOpen: isGroupByModalOpen }), (0, jsx_runtime_1.jsx)(SortByModal, { selectedTable: selectedTable, sortableColumns: sortableColumns, sortBys: sortBys, selectedSortByColumn: selectedSortByColumn, setSelectedSortByColumn: setSelectedSortByColumn, selectedSortByDirection: selectedSortByDirection, setSelectedSortByDirection: setSelectedSortByDirection, addSortBy: addSortBy, removeSortBy: removeSortBy, selectSortBy: selectSortBy, sortByIndexBeingEdited: sortByIndexBeingEdited, updateSortBy: updateSortBy, SelectComponent: SelectComponent, ButtonComponent: ButtonComponent, ModalComponent: ModalComponent, ModalTriggerComponent: ModalTriggerComponent, tagStyle: tagStyle, theme: theme, setIsOpen: setIsSortByModalOpen, isOpen: isSortByModalOpen }), (0, jsx_runtime_1.jsx)("div", { style: { height: 12 } }), (0, jsx_runtime_1.jsx)(ButtonComponent, { id: "run-report-button", onClick: handleRunQuery, label: 'Run report' })] })] }));
594
+ return ((0, jsx_runtime_1.jsxs)("div", { style: { fontFamily: theme?.fontFamily, ...containerStyle }, ref: parentRef, children: [(0, jsx_runtime_1.jsx)("div", { style: {
595
+ display: 'flex',
596
+ // marginLeft: '25px',
597
+ // marginRight: '25px',
598
+ justifyContent: 'end',
599
+ }, children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'row', gap: '12px' }, children: [(0, jsx_runtime_1.jsx)(AddFilterModal2, { filters: filters, selectedColumn: selectedColumn, numberStart: numberStart, numberEnd: numberEnd, dateStart: dateStart, setDateStart: setDateStart, columnStats: columnStats, stringFilterValues: stringFilterValues, setStringFilterValues: setStringFilterValues, addFilter: addFilter, parentRef: parentRef, setSelectedColumn: setSelectedColumn, setNumberStart: setNumberStart, setNumberEnd: setNumberEnd, selectedTable: selectedTable, columnType: columnType, dateEnd: dateEnd, setDateEnd: setDateEnd, removeFilter: removeFilter, selectFilter: selectFilter, indexBeingEdited: indexBeingEdited, updateFilter: updateFilter, SelectComponent: SelectComponent, ButtonComponent: ButtonComponent, PopoverComponent: PopoverComponent, TextInputComponent: TextInputComponent, LabelComponent: LabelComponent, tagStyle: tagStyle, theme: theme, setIsOpen: setIsAddFilterModalOpen, isOpen: isAddFilterModalOpen, selectedTagBorderColor: selectedTagBorderColor }), (0, jsx_runtime_1.jsx)(PivotModal_1.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, selectedTable: selectedTable, SelectComponent: SelectComponent, ButtonComponent: ButtonComponent, PopoverComponent: PopoverComponent, LabelComponent: LabelComponent, HeaderComponent: HeaderComponent, TextComponent: TextComponent, popUpTitle: pivotPopUpTitle, setPopUpTitle: setPivotPopUpTitle, theme: theme, data: data, parentRef: parentRef, columns: columns, setIsOpen: setIsPivotModalOpen, isOpen: isPivotModalOpen, showUpdatePivot: isEdittingPivot, setShowUpdatePivot: setIsEdittingPivot, selectedPivotIndex: selectedPivotIndex, setSelectedPivotIndex: setSelectedPivotIndex, removePivot: removePivot, selectPivot: selectPivot, dateRange: dateRange, rightAlign: true })] }) }), (0, jsx_runtime_1.jsx)(Table_1.default, { rows: selectedPivotTable?.rows || data, columns: selectedPivotTable?.columns || columns, containerStyle: {
600
+ height: 400,
601
+ marginTop: 10,
602
+ } }), chartBuilderEnabled && columns.length > 0 && ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { style: {
603
+ display: 'flex',
604
+ flexDirection: 'row',
605
+ alignItems: 'center',
606
+ justifyContent: 'flex-end',
607
+ width: '100%',
608
+ height: '70px',
609
+ gap: '8px',
610
+ }, children: (0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: () => setIsChartBuilderOpen(true), label: "Add to dashboard" }) }), (0, jsx_runtime_1.jsx)(ChartBuilder_1.default, { rows: data, columns: columns, fields: fields, query: sqlQuery, pivot: selectedPivot, isOpen: isChartBuilderOpen, setIsOpen: setIsChartBuilderOpen, showTableFormatOptions: showTableFormatOptions, showDateFieldOptions: showDateFieldOptions, showAccessControlOptions: showAccessControlOptions, dateRange: dateRange, recommendedPivots: recommendedPivots })] }))] }));
1112
611
  }
1113
- function FilterTag({ id, label, removeFilter, index, setIsOpen, selectFilter, theme, tagStyle, }) {
612
+ function FilterTag({ Label, id, label, removeFilter, isSelected, index, setIsOpen, selectFilter, theme, tagStyle, selectedTagBorderColor, }) {
1114
613
  const handleRemoveFilter = () => {
1115
614
  removeFilter(index);
1116
615
  };
@@ -1118,26 +617,34 @@ function FilterTag({ id, label, removeFilter, index, setIsOpen, selectFilter, th
1118
617
  selectFilter(index);
1119
618
  setIsOpen(true);
1120
619
  };
1121
- return ((0, jsx_runtime_1.jsxs)("div", { id: id, onClick: handleSelectFilter, style: tagStyle || {
1122
- marginLeft: '12px',
1123
- cursor: 'pointer',
1124
- borderRadius: 8,
1125
- backgroundColor: '#EFF0FC',
1126
- paddingLeft: '12px',
1127
- paddingRight: '8px',
1128
- height: 30,
1129
- display: 'flex',
1130
- alignItems: 'center',
1131
- fontSize: 13,
1132
- fontWeight: 'medium',
1133
- color: theme?.primaryTextColor,
1134
- fontFamily: theme?.fontFamily,
1135
- outline: 'none',
1136
- }, children: [(0, jsx_runtime_1.jsx)("div", { id: id, style: {
620
+ const styles = tagStyle || {
621
+ cursor: 'pointer',
622
+ borderRadius: 8,
623
+ border: '1px solid',
624
+ backgroundColor: '#EFF0FC',
625
+ paddingLeft: '12px',
626
+ paddingRight: '8px',
627
+ height: 30,
628
+ display: 'flex',
629
+ alignItems: 'center',
630
+ fontSize: 13,
631
+ fontWeight: 'medium',
632
+ color: theme?.primaryTextColor,
633
+ fontFamily: theme?.fontFamily,
634
+ whiteSpace: 'nowrap',
635
+ textOverflow: 'ellipsis',
636
+ outline: 'none',
637
+ maxWidth: 120,
638
+ };
639
+ const borderColor = {
640
+ borderColor: isSelected
641
+ ? selectedTagBorderColor || '#B3B4BD'
642
+ : styles.borderColor || '#EFF0FC',
643
+ };
644
+ return ((0, jsx_runtime_1.jsxs)("div", { id: id, onClick: handleSelectFilter, style: { ...styles, ...borderColor }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
1137
645
  textOverflow: 'ellipsis',
1138
646
  whiteSpace: 'nowrap',
1139
647
  overflow: 'hidden',
1140
- maxWidth: '80px',
1141
648
  }, children: label }), (0, jsx_runtime_1.jsx)("div", {
1142
649
  // onClick={handleRemoveFilter}
1143
650
  onClick: e => {
@@ -1151,172 +658,44 @@ function FilterTag({ id, label, removeFilter, index, setIsOpen, selectFilter, th
1151
658
  paddingLeft: '6px',
1152
659
  }, children: (0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: tagStyle?.color || theme?.primaryTextColor, height: "20", width: "20", children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", d: "M5.47 5.47a.75.75 0 011.06 0L12 10.94l5.47-5.47a.75.75 0 111.06 1.06L13.06 12l5.47 5.47a.75.75 0 11-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 01-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 010-1.06z", clipRule: "evenodd" }) }) })] }));
1153
660
  }
1154
- const SortByModal = ({ selectedSortByColumn, selectedSortByDirection, setSelectedSortByColumn, setSelectedSortByDirection, selectedTable, sortableColumns, removeSortBy, selectSortBy, updateSortBy, addSortBy, sortBys, SelectComponent, ButtonComponent, ModalComponent, tagStyle, ModalTriggerComponent, sortByIndexBeingEdited, theme, }) => {
1155
- const [isOpen, setIsOpen] = (0, react_1.useState)(false);
1156
- return ((0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flexDirection: 'column', marginTop: 12 }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
1157
- position: 'relative',
1158
- display: 'inline-block',
1159
- textAlign: 'left',
1160
- }, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
1161
- display: 'flex',
1162
- flexDirection: 'row',
1163
- alignItems: 'center',
1164
- }, children: [(0, jsx_runtime_1.jsx)(ModalTriggerComponent, { onClick: () => setIsOpen(isOpen => !isOpen), label: "Sort" }), (0, jsx_runtime_1.jsx)("div", { style: {
1165
- overflowX: 'scroll',
1166
- display: 'flex',
1167
- flexDirection: 'row',
1168
- alignItems: 'center',
1169
- }, children: sortBys.map((elem, index) => ((0, jsx_runtime_1.jsx)(FilterTag, { id: "sort-tag", label: elem.column, removeFilter: removeSortBy, selectFilter: selectSortBy, setIsOpen: setIsOpen, index: index, theme: theme, tagStyle: tagStyle }, 'sort' + index))) })] }), (0, jsx_runtime_1.jsx)(ModalComponent, { isOpen: isOpen, onClose: () => setIsOpen(false), title: "Add sort", children: (0, jsx_runtime_1.jsxs)("div", { style: {
1170
- display: 'flex',
1171
- flexDirection: 'column',
1172
- }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
1173
- fontSize: '14px',
1174
- marginBottom: '6px',
1175
- fontWeight: '600',
1176
- color: theme.secondaryTextColor,
1177
- fontFamily: theme?.fontFamily,
1178
- }, children: "Column" }), (0, jsx_runtime_1.jsx)(SelectComponent, { value: selectedSortByColumn, onChange: e => {
1179
- setSelectedSortByColumn(e);
1180
- }, options: sortableColumns.map(elem => {
1181
- return { label: elem, value: elem };
1182
- }) })] }), (0, jsx_runtime_1.jsx)("div", { style: {
1183
- fontSize: '14px',
1184
- marginBottom: '6px',
1185
- fontWeight: '600',
1186
- color: theme.secondaryTextColor,
1187
- fontFamily: theme?.fontFamily,
1188
- marginTop: 20,
1189
- }, children: "Direction" }), (0, jsx_runtime_1.jsx)(SelectComponent, { value: selectedSortByDirection, onChange: e => {
1190
- setSelectedSortByDirection(e);
1191
- }, options: [
1192
- { label: 'ascending', value: 'ascending' },
1193
- { label: 'descending', value: 'descending' },
1194
- ] }), (0, jsx_runtime_1.jsx)("div", { style: { height: 20 } }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(ButtonComponent, { id: "custom-button", onClick: () => {
1195
- if (sortByIndexBeingEdited > -1) {
1196
- updateSortBy(sortByIndexBeingEdited);
1197
- setIsOpen(false);
1198
- // close();
1199
- return;
1200
- }
1201
- addSortBy();
1202
- setIsOpen(false);
1203
- // close();
1204
- }, label: sortByIndexBeingEdited > -1 ? 'Edit sort' : 'Add sort' }) })] }) })] }) }));
1205
- };
1206
- const GroupByModal2 = ({ selectedGroupByColumn, addGroupBy, setSelectedGroupByColumn, selectedTable, groupByColumnType, groupByIndexBeingEdited, updateGroupBy, groupBys, removeGroupBy, selectGroupBy, SelectComponent, ButtonComponent, aggregations, setAggregationColumn, setAggregationType, addAggregation, dateBucket, setDateBucket, ModalComponent, theme, ModalTriggerComponent, TextInputComponent, tagStyle, }) => {
1207
- const [isOpen, setIsOpen] = (0, react_1.useState)(false);
1208
- return ((0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flexDirection: 'column' }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
1209
- position: 'relative',
1210
- display: 'inline-block',
1211
- textAlign: 'left',
1212
- }, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
1213
- display: 'flex',
1214
- flexDirection: 'row',
1215
- alignItems: 'center',
1216
- }, children: [(0, jsx_runtime_1.jsx)(ModalTriggerComponent, { onClick: () => {
1217
- setIsOpen(isOpen => !isOpen);
1218
- }, label: "Group by" }), (0, jsx_runtime_1.jsx)("div", { style: {
1219
- overflowX: 'scroll',
1220
- display: 'flex',
1221
- flexDirection: 'row',
1222
- alignItems: 'center',
1223
- }, children: groupBys.map((elem, index) => ((0, jsx_runtime_1.jsx)(FilterTag, { id: "group-tag", label: elem.tag, removeFilter: removeGroupBy, selectFilter: selectGroupBy, setIsOpen: setIsOpen, index: index, theme: theme, tagStyle: tagStyle }, 'groupby' + index))) })] }), (0, jsx_runtime_1.jsx)(ModalComponent, { isOpen: isOpen, onClose: () => {
1224
- setIsOpen(false);
1225
- }, title: "Add group by", children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
1226
- fontSize: '14px',
1227
- marginBottom: '6px',
1228
- fontWeight: '600',
1229
- fontFamily: theme?.fontFamily,
1230
- color: theme.secondaryTextColor,
1231
- }, children: "Column" }), (0, jsx_runtime_1.jsx)(SelectComponent, { label: "Column", value: selectedGroupByColumn.name, onChange: e => {
1232
- const column = selectedTable.columns.find(c => c.name === e);
1233
- setSelectedGroupByColumn(column);
1234
- }, options: selectedTable.columns.map(elem => {
1235
- return { label: elem.name, value: elem.name };
1236
- }) })] }), groupByColumnType === 'date' && ((0, jsx_runtime_1.jsxs)("div", { style: {
1237
- display: 'flex',
1238
- flexDirection: 'column',
1239
- // marginLeft: 12,
1240
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
1241
- fontSize: '14px',
1242
- marginBottom: '6px',
1243
- fontWeight: '600',
1244
- color: theme.secondaryTextColor,
1245
- fontFamily: theme?.fontFamily,
1246
- marginTop: 20,
1247
- }, children: "Bucket" }), (0, jsx_runtime_1.jsx)(SelectComponent, { label: "Bucket", value: dateBucket, onChange: e => {
1248
- setDateBucket(e);
1249
- }, options: [
1250
- { label: 'month', value: 'month' },
1251
- { label: 'day', value: 'day' },
1252
- { label: 'week', value: 'week' },
1253
- ] })] })), (0, jsx_runtime_1.jsx)("div", { style: {
1254
- fontSize: 14,
1255
- marginBottom: '6px',
1256
- fontWeight: '600',
1257
- marginTop: 20,
1258
- color: theme.secondaryTextColor,
1259
- fontFamily: theme?.fontFamily,
1260
- }, children: "Aggregations" }), aggregations.map((aggregation, index) => (
1261
- // setAggregationType
1262
- (0, jsx_runtime_1.jsxs)("div", { style: {
1263
- display: 'flex',
1264
- flexDirection: 'row',
1265
- alignItems: 'center',
1266
- }, children: [(0, jsx_runtime_1.jsx)(SelectComponent, { value: aggregation.column?.name, onChange: e => {
1267
- const column = selectedTable.columns.find(c => c.name === e);
1268
- setAggregationColumn(column, index);
1269
- }, options: selectedTable.columns.map(elem => {
1270
- return { label: elem.name, value: elem.name };
1271
- }) }), (0, jsx_runtime_1.jsx)("div", { style: { width: 16 } }), (0, jsx_runtime_1.jsx)(SelectComponent, { value: aggregation.aggregationType, onChange: e => {
1272
- setAggregationType(e, index);
1273
- }, options: [
1274
- { label: 'sum', value: 'sum' },
1275
- { label: 'average', value: 'average' },
1276
- { label: 'count', value: 'count' },
1277
- ] })] }, 'agg' + index))), (0, jsx_runtime_1.jsx)("div", { style: { height: 20 } }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(ButtonComponent, { id: "custom-button", onClick: () => {
1278
- if (groupByIndexBeingEdited > -1) {
1279
- updateGroupBy(groupByIndexBeingEdited);
1280
- setIsOpen(false);
1281
- // close();
1282
- return;
1283
- }
1284
- addGroupBy();
1285
- setIsOpen(false);
1286
- // close();
1287
- }, label: groupByIndexBeingEdited > -1
1288
- ? 'Edit group by'
1289
- : 'Add group by' }) })] }) })] }) }));
1290
- };
1291
- const AddFilterModal2 = ({ filters, selectedColumn, numberStart, numberEnd, dateStart, setDateStart, columnStats, stringFilterValues, setStringFilterValues, addFilter, setSelectedColumn, setNumberStart, setNumberEnd, selectedTable, columnType, setDateEnd, dateEnd, removeFilter, selectFilter, indexBeingEdited, updateFilter, SelectComponent, ButtonComponent, ModalComponent, theme, ModalTriggerComponent, TextInputComponent, tagStyle, }) => {
661
+ const AddFilterModal2 = ({ filters, selectedColumn, numberStart, numberEnd, dateStart, setDateStart, columnStats, stringFilterValues, setStringFilterValues, addFilter, setSelectedColumn, setNumberStart, setNumberEnd, selectedTable, columnType, setDateEnd, dateEnd, removeFilter, selectFilter, indexBeingEdited, updateFilter, SelectComponent, ButtonComponent, PopoverComponent, LabelComponent, theme, TextInputComponent, tagStyle, selectedTagBorderColor, parentRef, }) => {
1292
662
  const [isOpen, setIsOpen] = (0, react_1.useState)(false);
1293
663
  return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
1294
664
  position: 'relative',
1295
665
  display: 'inline-block',
1296
666
  textAlign: 'left',
1297
- }, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
667
+ }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
1298
668
  display: 'flex',
1299
669
  flexDirection: 'row',
1300
670
  alignItems: 'center',
1301
- }, children: [(0, jsx_runtime_1.jsx)(ModalTriggerComponent, { onClick: () => setIsOpen(isOpen => !isOpen), label: "Filter" }), (0, jsx_runtime_1.jsx)("div", { style: {
1302
- overflowX: 'scroll',
1303
- display: 'flex',
1304
- flexDirection: 'row',
1305
- alignItems: 'center',
1306
- }, children: filters.map((elem, index) => ((0, jsx_runtime_1.jsx)(FilterTag, { id: "filter-tag", label: elem.tag, removeFilter: removeFilter, selectFilter: selectFilter, index: index, theme: theme, setIsOpen: setIsOpen, tagStyle: tagStyle }, 'filter' + index))) })] }), (0, jsx_runtime_1.jsx)(ModalComponent, { isOpen: isOpen, onClose: () => setIsOpen(false), title: "Add filter", children: (0, jsx_runtime_1.jsxs)("div", { style: {
671
+ }, children: filters.length > 0 && ((0, jsx_runtime_1.jsx)("span", { style: {
672
+ height: 10,
673
+ width: 10,
674
+ backgroundColor: theme.primaryButtonColor,
675
+ borderRadius: '50%',
676
+ position: 'absolute',
677
+ top: -2,
678
+ right: -2,
679
+ } })) }), (0, jsx_runtime_1.jsx)(PopoverComponent, { parentRef: parentRef, label: "Add filter", style: { right: 0, minWidth: 400 }, isOpen: isOpen, onClose: () => setIsOpen(false), title: "Add filter", style: { right: 0, minWidth: 400 }, setIsOpen: setIsOpen, children: (0, jsx_runtime_1.jsxs)("div", { style: {
1307
680
  backgroundColor: 'rgb(255, 255, 255)',
1308
681
  display: 'flex',
1309
682
  flexDirection: 'column',
1310
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
1311
- fontSize: 14,
1312
- marginBottom: '6px',
1313
- fontWeight: '600',
1314
- color: theme.secondaryTextColor,
1315
- fontFamily: theme?.fontFamily,
1316
- }, children: "Column" }), (0, jsx_runtime_1.jsx)(SelectComponent, { id: "custom-select", value: selectedColumn.name, onChange: e => {
683
+ }, children: [filters.length > 0 && ((0, jsx_runtime_1.jsx)("div", { style: { paddingBottom: 20 }, children: (0, jsx_runtime_1.jsx)("div", { style: {
684
+ overflowY: 'scroll',
685
+ maxHeight: '300px',
686
+ display: 'flex',
687
+ gap: '5px',
688
+ flexDirection: 'row',
689
+ flexWrap: 'wrap',
690
+ alignItems: 'center',
691
+ }, children: filters.map((elem, index) => ((0, jsx_runtime_1.jsx)(FilterTag, { id: "filter-tag", Label: LabelComponent, label: elem.tag, removeFilter: removeFilter, selectFilter: selectFilter, isSelected: index === indexBeingEdited, index: index, theme: theme, setIsOpen: setIsOpen, tagStyle: tagStyle, selectedTagBorderColor: selectedTagBorderColor }, 'filter' + index))) }) })), (0, jsx_runtime_1.jsx)(LabelComponent, { children: "Column" }), (0, jsx_runtime_1.jsx)(SelectComponent, { label: 'Column', id: "custom-select", value: selectedColumn.name, onChange: e => {
1317
692
  const column = selectedTable.columns.find(c => c.name === e);
1318
693
  setSelectedColumn(column);
1319
- }, options: selectedTable.columns.map(elem => {
694
+ }, options: selectedTable.columns
695
+ .filter(elem => !(elem.name === 'id' ||
696
+ elem.name.endsWith('_id') ||
697
+ (0, PivotModal_1.isDateField)(elem.fieldType)))
698
+ .map(elem => {
1320
699
  return { label: elem.name, value: elem.name };
1321
700
  }) }), columnType === 'number' && ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("div", { style: {
1322
701
  display: 'flex',
@@ -1327,23 +706,11 @@ const AddFilterModal2 = ({ filters, selectedColumn, numberStart, numberEnd, date
1327
706
  display: 'flex',
1328
707
  flexDirection: 'column',
1329
708
  marginTop: '20px',
1330
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
1331
- fontSize: '14px',
1332
- fontWeight: '600',
1333
- color: theme.secondaryTextColor,
1334
- fontFamily: theme?.fontFamily,
1335
- marginBottom: 6,
1336
- }, children: "Minimum" }), (0, jsx_runtime_1.jsx)(TextInputComponent, { id: "min-input", value: numberStart, onChange: e => setNumberStart(e.target.value) })] }), (0, jsx_runtime_1.jsx)("div", { style: { width: 16 } }), (0, jsx_runtime_1.jsxs)("div", { style: {
709
+ }, children: [(0, jsx_runtime_1.jsx)(LabelComponent, { children: "Minimum" }), (0, jsx_runtime_1.jsx)(TextInputComponent, { id: "min-input", value: numberStart, placeholder: "Minimum", onChange: value => setNumberStart(value) })] }), (0, jsx_runtime_1.jsx)("div", { style: { width: 16 } }), (0, jsx_runtime_1.jsxs)("div", { style: {
1337
710
  display: 'flex',
1338
711
  flexDirection: 'column',
1339
712
  marginTop: '20px',
1340
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
1341
- fontSize: '14px',
1342
- fontWeight: '600',
1343
- color: theme.secondaryTextColor,
1344
- fontFamily: theme?.fontFamily,
1345
- marginBottom: 6,
1346
- }, children: "Maximum" }), (0, jsx_runtime_1.jsx)(TextInputComponent, { id: "max-input", value: numberEnd, onChange: e => setNumberEnd(e.target.value) })] })] }) })), columnType === 'date' && ((0, jsx_runtime_1.jsxs)("div", { style: {
713
+ }, children: [(0, jsx_runtime_1.jsx)(LabelComponent, { children: "Maximum" }), (0, jsx_runtime_1.jsx)(TextInputComponent, { id: "max-input", placeholder: "Maximum", value: numberEnd, onChange: value => setNumberEnd(value) })] })] }) })), columnType === 'date' && ((0, jsx_runtime_1.jsxs)("div", { style: {
1347
714
  display: 'flex',
1348
715
  flexDirection: 'row',
1349
716
  alignItems: 'center',
@@ -1352,21 +719,11 @@ const AddFilterModal2 = ({ filters, selectedColumn, numberStart, numberEnd, date
1352
719
  display: 'flex',
1353
720
  flexDirection: 'column',
1354
721
  marginTop: '20px',
1355
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
1356
- fontSize: 14,
1357
- fontWeight: '600',
1358
- color: 'rgba(56, 65, 81, 0.7)',
1359
- fontFamily: theme?.fontFamily,
1360
- }, children: "Start date" }), (0, jsx_runtime_1.jsx)("input", { type: "date", value: dateStart, onChange: e => setDateStart(e.target.value), placeholder: "Start date" })] }), (0, jsx_runtime_1.jsxs)("div", { style: {
722
+ }, children: [(0, jsx_runtime_1.jsx)(LabelComponent, { children: "Start date" }), (0, jsx_runtime_1.jsx)("input", { type: "date", value: dateStart, onChange: e => setDateStart(e.target.value), placeholder: "Start date" })] }), (0, jsx_runtime_1.jsxs)("div", { style: {
1361
723
  display: 'flex',
1362
724
  flexDirection: 'column',
1363
725
  marginTop: '20px',
1364
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
1365
- fontSize: 14,
1366
- fontWeight: '600',
1367
- color: 'rgba(56, 65, 81, 0.7)',
1368
- fontFamily: theme?.fontFamily,
1369
- }, children: "End date" }), (0, jsx_runtime_1.jsx)("input", { type: "date", value: dateEnd, onChange: e => setDateEnd(e.target.value), placeholder: "End date" })] })] })), columnType === 'string' &&
726
+ }, children: [(0, jsx_runtime_1.jsx)(LabelComponent, { children: "End date" }), (0, jsx_runtime_1.jsx)("input", { type: "date", value: dateEnd, onChange: e => setDateEnd(e.target.value), placeholder: "End date" })] })] })), columnType === 'string' &&
1370
727
  columnStats &&
1371
728
  columnStats.length > 0 && ((0, jsx_runtime_1.jsx)("div", { style: {
1372
729
  flex: 'flex',
@@ -1401,11 +758,9 @@ const AddFilterModal2 = ({ filters, selectedColumn, numberStart, numberEnd, date
1401
758
  }
1402
759
  if (indexBeingEdited > -1) {
1403
760
  updateFilter(indexBeingEdited);
1404
- setIsOpen(false);
1405
761
  return;
1406
762
  }
1407
763
  addFilter();
1408
- setIsOpen(false);
1409
764
  }, label: indexBeingEdited > -1 ? 'Edit filter' : 'Add filter' }) })] }) })] }), (0, jsx_runtime_1.jsx)("div", { style: { height: '12px' } })] }));
1410
765
  };
1411
766
  const DivCheckbox = ({ onChange, checked, theme }) => {