@quillsql/react 1.6.1 → 1.6.4

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 (71) hide show
  1. package/lib/AddToDashboardButton.d.ts +1 -0
  2. package/lib/AddToDashboardButton.js +2 -0
  3. package/lib/AddToDashboardButton.js.map +1 -0
  4. package/lib/AddToDashboardModal.d.ts +22 -0
  5. package/lib/AddToDashboardModal.js +638 -0
  6. package/lib/AddToDashboardModal.js.map +1 -0
  7. package/lib/BarList.js +28 -28
  8. package/lib/BarList.js.map +1 -1
  9. package/lib/Chart.js +30 -114
  10. package/lib/Chart.js.map +1 -1
  11. package/lib/Context.d.ts +3 -3
  12. package/lib/Context.js +3 -3
  13. package/lib/Context.js.map +1 -1
  14. package/lib/Dashboard.js +31 -16
  15. package/lib/Dashboard.js.map +1 -1
  16. package/lib/Dialog.d.ts +68 -0
  17. package/lib/Dialog.js +407 -0
  18. package/lib/Dialog.js.map +1 -0
  19. package/lib/Portal.d.ts +32 -0
  20. package/lib/Portal.js +171 -0
  21. package/lib/Portal.js.map +1 -0
  22. package/lib/Props.d.ts +0 -0
  23. package/lib/Props.js +2 -0
  24. package/lib/Props.js.map +1 -0
  25. package/lib/QuillProvider.d.ts +32 -14
  26. package/lib/QuillProvider.js +15 -2
  27. package/lib/QuillProvider.js.map +1 -1
  28. package/lib/ReportBuilder.d.ts +26 -2
  29. package/lib/ReportBuilder.js +210 -486
  30. package/lib/ReportBuilder.js.map +1 -1
  31. package/lib/SQLEditor.d.ts +38 -1
  32. package/lib/SQLEditor.js +385 -210
  33. package/lib/SQLEditor.js.map +1 -1
  34. package/lib/Table.js +12 -14
  35. package/lib/Table.js.map +1 -1
  36. package/lib/components/BigModal/BigModal.d.ts +14 -0
  37. package/lib/components/BigModal/BigModal.js +85 -0
  38. package/lib/components/BigModal/BigModal.js.map +1 -0
  39. package/lib/components/BigModal/Modal.d.ts +14 -0
  40. package/lib/components/BigModal/Modal.js +109 -0
  41. package/lib/components/BigModal/Modal.js.map +1 -0
  42. package/lib/components/Modal/Modal.d.ts +1 -1
  43. package/lib/hooks/useQuill.js +14 -24
  44. package/lib/hooks/useQuill.js.map +1 -1
  45. package/lib/hooks/useSyncRefs.d.ts +5 -0
  46. package/lib/hooks/useSyncRefs.js +38 -0
  47. package/lib/hooks/useSyncRefs.js.map +1 -0
  48. package/lib/index.d.ts +1 -0
  49. package/lib/index.js +1 -0
  50. package/lib/index.js.map +1 -1
  51. package/lib/types/Props.d.ts +0 -0
  52. package/lib/types/Props.js +2 -0
  53. package/lib/types/Props.js.map +1 -0
  54. package/lib/types.d.ts +27 -0
  55. package/lib/types.js +6 -0
  56. package/lib/types.js.map +1 -0
  57. package/package.json +2 -1
  58. package/src/AddToDashboardModal.tsx +1213 -0
  59. package/src/BarList.tsx +28 -28
  60. package/src/Chart.tsx +31 -107
  61. package/src/Context.tsx +8 -5
  62. package/src/Dashboard.tsx +29 -2
  63. package/src/QuillProvider.tsx +52 -10
  64. package/src/ReportBuilder.tsx +420 -649
  65. package/src/SQLEditor.tsx +805 -235
  66. package/src/Table.tsx +20 -26
  67. package/src/components/BigModal/BigModal.tsx +108 -0
  68. package/src/components/Modal/Modal.tsx +1 -1
  69. package/src/continue_logs.txt +75 -0
  70. package/src/hooks/useQuill.ts +2 -16
  71. package/src/index.ts +1 -0
package/lib/SQLEditor.js CHANGED
@@ -46,13 +46,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
46
46
  }
47
47
  };
48
48
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
49
- import { useState, useContext, useMemo, useEffect } from 'react';
49
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
50
+ // @ts-ignore
51
+ import { useState, useContext, useEffect } from 'react';
50
52
  import MonacoEditor from '@monaco-editor/react';
51
53
  // import './nightOwlLight.css';
52
54
  import axios from 'axios';
53
55
  import { TailSpin } from 'react-loader-spinner';
54
56
  import { ClientContext, SchemaContext, ThemeContext } from './Context';
55
- import { ChevronDownIcon, ChevronRightIcon, SparklesIcon, MagnifyingGlassIcon, } from '@heroicons/react/20/solid';
57
+ import { ChevronDownIcon, ChevronRightIcon, } from '@heroicons/react/20/solid';
56
58
  export function convertPostgresColumn(column) {
57
59
  var format;
58
60
  switch (column.dataTypeID) {
@@ -107,9 +109,49 @@ function setEditorTheme(editor, monaco) {
107
109
  console.log('ERROR: ', e);
108
110
  }
109
111
  }
112
+ var QuillButton = function (_a) {
113
+ var onClick = _a.onClick, label = _a.label, theme = _a.theme, secondary = _a.secondary;
114
+ return (_jsx("button", __assign({ style: {
115
+ borderRadius: '6px',
116
+ backgroundColor: secondary
117
+ ? (theme === null || theme === void 0 ? void 0 : theme.secondaryButtonColor) || '#FFFFFF'
118
+ : theme === null || theme === void 0 ? void 0 : theme.primaryButtonColor,
119
+ opacity: 1,
120
+ paddingLeft: '16px',
121
+ paddingRight: '16px',
122
+ paddingTop: '10px',
123
+ paddingBottom: '10px',
124
+ fontSize: '14px',
125
+ fontWeight: 600,
126
+ color: secondary ? theme === null || theme === void 0 ? void 0 : theme.primaryTextColor : '#FFFFFF',
127
+ cursor: 'pointer',
128
+ outline: 'none',
129
+ border: 'none',
130
+ fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
131
+ }, onClick: onClick }, { children: label })));
132
+ };
133
+ var QuillTextInput = function (_a) {
134
+ var onChange = _a.onChange, value = _a.value, id = _a.id, placeholder = _a.placeholder, theme = _a.theme;
135
+ return (_jsx("input", { style: {
136
+ display: 'flex',
137
+ flexDirection: 'row',
138
+ alignItems: 'center',
139
+ paddingLeft: '12px',
140
+ paddingRight: '12px',
141
+ fontWeight: 'medium',
142
+ height: 36,
143
+ boxShadow: 'rgba(0, 0, 0, 0.1) 0px 1px 5px 0px',
144
+ width: '445px',
145
+ backgroundColor: (theme === null || theme === void 0 ? void 0 : theme.backgroundColor) || 'white',
146
+ color: theme === null || theme === void 0 ? void 0 : theme.primaryTextColor,
147
+ borderWidth: '1px',
148
+ borderColor: (theme === null || theme === void 0 ? void 0 : theme.borderColor) || '#E7E7E7',
149
+ borderRadius: '6px',
150
+ }, id: id, onChange: onChange, value: value, placeholder: placeholder }));
151
+ };
110
152
  export default function QueryEditor(_a) {
111
153
  var _this = this;
112
- var _b = _a.containerStyle, containerStyle = _b === void 0 ? { height: '100vh' } : _b;
154
+ var _b = _a.containerStyle, containerStyle = _b === void 0 ? { height: '100vh' } : _b, ButtonComponent = _a.ButtonComponent, SecondaryButtonComponent = _a.SecondaryButtonComponent, TextInputComponent = _a.TextInputComponent, TableComponent = _a.TableComponent, AddToDashboardButton = _a.AddToDashboardButton, LoadingComponent = _a.LoadingComponent;
113
155
  var _c = useState(''), sqlPrompt = _c[0], setSqlPrompt = _c[1];
114
156
  var _d = useState(false), isOpen = _d[0], setIsOpen = _d[1];
115
157
  var client = useContext(ClientContext)[0];
@@ -121,6 +163,8 @@ export default function QueryEditor(_a) {
121
163
  var _j = useContext(SchemaContext), schema = _j[0], setSchema = _j[1];
122
164
  var _k = useState(''), errorMessage = _k[0], setErrorMessage = _k[1];
123
165
  var _l = useState(false), sqlResponseLoading = _l[0], setSqlResponseLoading = _l[1];
166
+ var _m = useState(false), sqlQueryLoading = _m[0], setSqlQueryLoading = _m[1];
167
+ var _o = useState(false), schemaLoading = _o[0], setSchemaLoading = _o[1];
124
168
  useEffect(function () {
125
169
  var isSubscribed = true;
126
170
  function getSchema() {
@@ -130,6 +174,7 @@ export default function QueryEditor(_a) {
130
174
  switch (_a.label) {
131
175
  case 0:
132
176
  publicKey = client.publicKey, environment = client.environment;
177
+ setSchemaLoading(true);
133
178
  return [4 /*yield*/, axios.get("https://quill-344421.uc.r.appspot.com/schema2/".concat(publicKey, "/"), {
134
179
  headers: {
135
180
  Authorization: "Bearer ",
@@ -140,6 +185,7 @@ export default function QueryEditor(_a) {
140
185
  response3 = _a.sent();
141
186
  if (isSubscribed) {
142
187
  setSchema(response3.data.tables);
188
+ setSchemaLoading(false);
143
189
  }
144
190
  return [2 /*return*/];
145
191
  }
@@ -178,54 +224,64 @@ export default function QueryEditor(_a) {
178
224
  });
179
225
  }); };
180
226
  var handleRunQuery = function () { return __awaiter(_this, void 0, void 0, function () {
181
- var publicKey, customerId, environment, response, e_1;
227
+ var publicKey, customerId, environment, queryEndpoint, queryHeaders, response, e_1;
182
228
  return __generator(this, function (_a) {
183
229
  switch (_a.label) {
184
230
  case 0:
185
- publicKey = client.publicKey, customerId = client.customerId, environment = client.environment;
231
+ publicKey = client.publicKey, customerId = client.customerId, environment = client.environment, queryEndpoint = client.queryEndpoint, queryHeaders = client.queryHeaders;
186
232
  _a.label = 1;
187
233
  case 1:
188
- _a.trys.push([1, 3, , 4]);
189
- return [4 /*yield*/, axios.post("https://quill-344421.uc.r.appspot.com/dashquery", {
190
- query: query,
191
- }, {
192
- params: {
193
- orgId: customerId,
194
- publicKey: publicKey,
195
- },
196
- headers: {
197
- Authorization: "Bearer ",
198
- environment: environment || undefined,
199
- },
200
- })];
234
+ _a.trys.push([1, 6, , 7]);
235
+ response = void 0;
236
+ setSqlQueryLoading(true);
237
+ if (!queryEndpoint) return [3 /*break*/, 3];
238
+ return [4 /*yield*/, axios.post(queryEndpoint, { metadata: { query: query, task: 'query' } }, { headers: queryHeaders })];
201
239
  case 2:
202
240
  response = _a.sent();
241
+ return [3 /*break*/, 5];
242
+ case 3: return [4 /*yield*/, axios.post("https://quill-344421.uc.r.appspot.com/dashquery", {
243
+ query: query,
244
+ }, {
245
+ params: {
246
+ orgId: customerId,
247
+ publicKey: publicKey,
248
+ },
249
+ headers: {
250
+ Authorization: "Bearer ",
251
+ environment: environment || undefined,
252
+ },
253
+ })];
254
+ case 4:
255
+ response = _a.sent();
256
+ _a.label = 5;
257
+ case 5:
203
258
  if (response && response.data && response.data.errorMessage) {
259
+ setSqlQueryLoading(false);
204
260
  setErrorMessage('Failed to run SQL query: ' + response.data.errorMessage);
205
261
  setRows([]);
206
262
  setColumns([]);
207
263
  setFields([]);
208
264
  return [2 /*return*/];
209
265
  }
266
+ setSqlQueryLoading(false);
210
267
  setErrorMessage('');
211
- setRows(response.data.rows);
268
+ setRows(response.data.rows && response.data.rows.length
269
+ ? response.data.rows
270
+ : []);
212
271
  setColumns(response.data.fields.map(function (elem) { return convertPostgresColumn(elem); }));
213
272
  setFields(response.data.fields);
214
- return [3 /*break*/, 4];
215
- case 3:
273
+ return [3 /*break*/, 7];
274
+ case 6:
216
275
  e_1 = _a.sent();
217
276
  console.log('ERROR: ', e_1);
218
277
  return [2 /*return*/];
219
- case 4: return [2 /*return*/];
278
+ case 7: return [2 /*return*/];
220
279
  }
221
280
  });
222
281
  }); };
223
282
  var handleAddToDashboard = function () {
224
283
  setIsOpen(true);
225
284
  };
226
- var newRows = useMemo(function () {
227
- return JSON.parse(JSON.stringify(rows));
228
- }, [rows]);
229
285
  /* all your useState and useContext calls and your useEffect hooks */
230
286
  var downloadCSV = function () {
231
287
  // report.rows
@@ -269,7 +325,7 @@ export default function QueryEditor(_a) {
269
325
  display: 'flex',
270
326
  height: '100%',
271
327
  flexDirection: 'row',
272
- } }, { children: [_jsx(SchemaListComponent, { schema: schema, theme: theme }), _jsxs("div", __assign({ style: {
328
+ } }, { children: [_jsx(SchemaListComponent, { schema: schema, theme: theme, LoadingComponent: LoadingComponent, loading: schemaLoading }), _jsxs("div", __assign({ style: {
273
329
  display: 'flex',
274
330
  flexDirection: 'column',
275
331
  width: 'calc(100% - 250px)',
@@ -280,79 +336,7 @@ export default function QueryEditor(_a) {
280
336
  display: 'flex',
281
337
  flexDirection: 'row',
282
338
  alignItems: 'center',
283
- } }, { children: [_jsxs("div", __assign({ style: {
284
- display: 'flex',
285
- flexDirection: 'row',
286
- alignItems: 'center',
287
- paddingLeft: '12px',
288
- paddingRight: '12px',
289
- height: 38,
290
- boxShadow: 'rgba(0, 0, 0, 0.1) 0px 1px 5px 0px',
291
- width: '445px',
292
- // TODO: change color
293
- borderColor: theme.borderColor,
294
- color: theme.primaryTextColor,
295
- borderWidth: '1px',
296
- // TODO: change color
297
- backgroundColor: 'white',
298
- borderRadius: 6,
299
- borderStyle: 'solid',
300
- outline: 'none',
301
- fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
302
- } }, { children: [_jsx(MagnifyingGlassIcon, { style: {
303
- height: 16,
304
- width: 16,
305
- color: theme.secondaryTextColor,
306
- }, "aria-hidden": "true" }), _jsx("input", { value: sqlPrompt, onChange: function (e) { return setSqlPrompt(e.target.value); }, style: {
307
- outline: 'none',
308
- marginLeft: 8,
309
- width: '100%',
310
- border: 'none',
311
- outline: 'none',
312
- fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
313
- } })] })), _jsx("button", __assign({ onClick: handleRunSqlPrompt, style: {
314
- // TODO: change color
315
- background: theme.primaryButtonColor,
316
- // TODO: change color
317
- color: theme.backgroundColor,
318
- height: 38,
319
- paddingLeft: 10,
320
- paddingRight: 12,
321
- width: 87,
322
- minWidth: 87,
323
- maxWidth: 87,
324
- marginLeft: 12,
325
- fontWeight: '400',
326
- borderRadius: '0.375rem',
327
- border: 'none',
328
- outline: 'none',
329
- cursor: 'pointer',
330
- fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
331
- } }, { children: sqlResponseLoading ? (_jsx("div", __assign({ style: {
332
- display: 'flex',
333
- flexDirection: 'row',
334
- alignItems: 'center',
335
- width: '100%',
336
- height: '100%',
337
- justifyContent: 'center',
338
- } }, { children: _jsx(TailSpin, { height: "20", width: "20",
339
- // TODO: change color
340
- color: theme.backgroundColor, ariaLabel: "loading-indicator" }) }))) : (_jsxs("div", __assign({ style: {
341
- display: 'flex',
342
- flexDirection: 'row',
343
- alignItems: 'center',
344
- } }, { children: [_jsx(SparklesIcon, { style: {
345
- height: 12,
346
- width: 12,
347
- marginRight: 4,
348
- // TODO: change color
349
- color: theme.backgroundColor,
350
- }, "aria-hidden": "true" }), _jsx("div", __assign({ style: {
351
- fontSize: 14,
352
- fontWeight: 600,
353
- fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
354
- color: theme.backgroundColor,
355
- } }, { children: "Ask AI" }))] }))) }))] })), _jsx("div", __assign({ style: { height: 'calc(50% - 40px)' } }, { children: _jsx(SQLEditorComponent, { query: query, setQuery: setQuery, handleRunQuery: handleRunQuery, theme: theme, defineEditorTheme: defineEditorTheme, setEditorTheme: setEditorTheme }) })), _jsxs("div", __assign({ style: {
339
+ } }, { children: [_jsx("div", __assign({ style: { minWidth: 440, marginRight: 10 } }, { children: (TextInputComponent && (_jsx(TextInputComponent, { id: "ai-search", value: sqlPrompt, onChange: function (e) { return setSqlPrompt(e.target.value); }, placeholder: "Ask a question..." }))) || (_jsx(QuillTextInput, { id: "ai-search", value: sqlPrompt, onChange: function (e) { return setSqlPrompt(e.target.value); }, placeholder: "Ask a question...", theme: theme })) })), (ButtonComponent && (_jsx(ButtonComponent, { onClick: handleRunSqlPrompt, label: "Ask AI" }))) || (_jsx(QuillButton, { theme: theme, onClick: handleRunSqlPrompt, label: "Ask AI" }))] })), _jsx("div", __assign({ style: { height: 'calc(50% - 40px)' } }, { children: _jsx(SQLEditorComponent, { query: query, setQuery: setQuery, handleRunQuery: handleRunQuery, theme: theme, defineEditorTheme: defineEditorTheme, setEditorTheme: setEditorTheme, ButtonComponent: ButtonComponent, loading: sqlResponseLoading, LoadingComponent: LoadingComponent }) })), _jsxs("div", __assign({ style: {
356
340
  height: 'calc(50% - 40px)',
357
341
  display: 'flex',
358
342
  flexDirection: 'column',
@@ -361,8 +345,8 @@ export default function QueryEditor(_a) {
361
345
  border: 'none',
362
346
  outline: 'none',
363
347
  } }, { children: [errorMessage && (_jsx("div", __assign({ style: {
364
- fontFamily: theme.fontFamily,
365
- color: theme.primaryTextColor,
348
+ fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
349
+ color: theme === null || theme === void 0 ? void 0 : theme.primaryTextColor,
366
350
  fontSize: 15,
367
351
  fontWeight: '400',
368
352
  } }, { children: _jsx("div", __assign({ style: {
@@ -372,105 +356,39 @@ export default function QueryEditor(_a) {
372
356
  display: 'inline-block',
373
357
  flex: 0,
374
358
  borderRadius: 6,
359
+ color: theme === null || theme === void 0 ? void 0 : theme.primaryTextColor,
375
360
  fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
376
- } }, { children: errorMessage })) }))), _jsx("div", __assign({ style: {
377
- height: 'calc(100% - 60px)',
378
- overflow: 'scroll',
379
- padding: 0,
380
- margin: 0,
381
- border: 'none',
382
- outline: 'none',
383
- } }, { children: _jsxs("table", __assign({ style: {
384
- padding: 0,
385
- margin: 0,
386
- border: 'none',
387
- outline: 'none',
388
- borderSpacing: 0,
389
- } }, { children: [_jsx("thead", __assign({ style: {
390
- position: 'sticky',
391
- // TODO: change color
392
- background: theme.backgroundColor,
393
- top: 0,
394
- height: 37,
395
- minHeight: 37,
396
- maxHeight: 37,
397
- } }, { children: _jsx("tr", __assign({ style: {
398
- outline: 'none',
399
- border: 'none',
400
- padding: 0,
401
- margin: 0,
402
- } }, { children: columns.map(function (column, index) { return (_jsx("th", __assign({ scope: "col", style: {
403
- textAlign: 'left',
404
- fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
405
- fontSize: 13,
406
- height: 37,
407
- minHeight: 37,
408
- maxHeight: 37,
409
- paddingLeft: 12,
410
- paddingRight: 12,
411
- paddingTop: 0,
412
- paddingBottom: 0,
413
- margin: 0,
414
- fontWeight: '500',
415
- // TODO: change color
416
- boxShadow: "inset 0 -1px 0 ".concat(theme.borderColor),
417
- // TODO: change color
418
- color: theme.primaryTextColor,
419
- outline: 'none',
420
- border: 'none',
421
- } }, { children: column.label }), index)); }) })) })), _jsx("tbody", __assign({ style: {
422
- // TODO: change color
423
- backgroundColor: theme.backgroundColor,
424
- } }, { children: newRows.map(function (row, rowIndex) { return (_jsx("tr", { children: columns.map(function (column, columnIndex) { return (_jsx("td", __assign({ style: {
425
- padding: 12,
426
- whiteSpace: 'nowrap',
427
- fontSize: 13,
428
- color: theme.secondaryTextColor,
429
- fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
430
- // TODO: change color
431
- // borderBottom: `1px solid ${theme.borderColor} !important`,
432
- boxShadow: "inset 0 -1px 0 ".concat(theme.borderColor),
433
- outline: 'none',
434
- } }, { children: typeof row[column.field] === 'object'
435
- ? JSON.stringify(row[column.field]).length > 55
436
- ? JSON.stringify(row[column.field]).substring(0, 52) + '...'
437
- : JSON.stringify(row[column.field])
438
- : row[column.field].length > 55
439
- ? row[column.field].substring(0, 52) + '...'
440
- : row[column.field] }), columnIndex)); }) }, rowIndex)); }) }))] })) })), _jsx("div", __assign({ style: {
441
- height: 60,
361
+ } }, { children: errorMessage })) }))), errorMessage
362
+ ? null
363
+ : (TableComponent && (_jsx(TableComponent, { rows: rows, columns: columns, height: "calc(100% - 70px)" }))) || (_jsx(SpecialTable, { rows: rows, columns: columns, height: "calc(100% - 70px)", LoadingComponent: LoadingComponent, loading: sqlQueryLoading })), _jsx("div", __assign({ style: {
364
+ height: 70,
442
365
  // TODO: change color
443
- background: theme.backgroundColor,
366
+ background: theme === null || theme === void 0 ? void 0 : theme.backgroundColor,
444
367
  } }, { children: rows.length ? (_jsxs("div", __assign({ style: {
445
368
  display: 'flex',
446
369
  flexDirection: 'column',
447
- height: 60,
370
+ height: 70,
448
371
  border: 'none',
449
372
  } }, { children: [_jsx("div", { style: {
450
373
  height: 1,
374
+ width: '100%',
451
375
  // TODO: change color
452
- background: theme.borderColor,
453
- } }), _jsxs("div", __assign({ style: { marginLeft: 0 } }, { children: [_jsx("button", __assign({ type: "button", onClick: downloadCSV, style: {
454
- borderRadius: 6,
455
- // TODO: change color
456
- backgroundColor: theme.primaryButtonColor,
457
- paddingLeft: '1rem',
458
- paddingRight: '1rem',
459
- paddingTop: '0.5rem',
460
- paddingBottom: '0.5rem',
461
- fontSize: '0.875rem',
462
- fontWeight: '600',
463
- // TODO: change color
464
- color: theme.backgroundColor,
465
- fontFamily: theme.fontFamily,
466
- outline: 'none',
467
- border: 'none',
468
- cursor: 'pointer',
469
- marginTop: 14,
470
- } }, { children: "Download CSV" })), _jsx("div", {})] }))] }))) : null }))] }))] }))] })) })) })) })));
376
+ // background: theme.borderColor,
377
+ } }), _jsxs("div", __assign({ style: {
378
+ marginLeft: 0,
379
+ height: 69,
380
+ display: 'flex',
381
+ alignItems: 'center',
382
+ justifyContent: 'flex-end',
383
+ paddingRight: 20,
384
+ } }, { children: [(SecondaryButtonComponent && (_jsx(SecondaryButtonComponent, { onClick: downloadCSV, label: "Download CSV" }))) || (_jsx(QuillButton, { theme: theme, onClick: downloadCSV, label: "Download CSV", secondary: true })), AddToDashboardButton && _jsx("div", { style: { width: 10 } }), AddToDashboardButton && (_jsx(AddToDashboardButton
385
+ // @ts-ignore
386
+ , {
387
+ // @ts-ignore
388
+ rows: rows, columns: columns, query: query })), _jsx("div", {})] }))] }))) : null }))] }))] }))] })) })) })) })));
471
389
  }
472
390
  var SQLEditorComponent = function (_a) {
473
- var query = _a.query, setQuery = _a.setQuery, handleRunQuery = _a.handleRunQuery, theme = _a.theme, defineEditorTheme = _a.defineEditorTheme, setEditorTheme = _a.setEditorTheme;
391
+ var query = _a.query, setQuery = _a.setQuery, handleRunQuery = _a.handleRunQuery, theme = _a.theme, defineEditorTheme = _a.defineEditorTheme, setEditorTheme = _a.setEditorTheme, ButtonComponent = _a.ButtonComponent, theme = _a.theme, loading = _a.loading, LoadingComponent = _a.LoadingComponent;
474
392
  return (_jsxs("div", __assign({ style: {
475
393
  background: theme.backgroundColor,
476
394
  // maxHeight: 700,
@@ -485,38 +403,295 @@ var SQLEditorComponent = function (_a) {
485
403
  borderTopRightRadius: 0,
486
404
  borderBottomRightRadius: 0,
487
405
  overflow: 'hidden',
488
- } }, { children: [_jsx(MonacoEditor, { height: "calc(100% - 50px)", width: "100%", defaultLanguage: "pgsql", defaultValue: "", value: query, loading: _jsx("div", {}), options: {
406
+ } }, { children: [loading ? (_jsxs("div", __assign({ style: {
407
+ height: 'calc(100% - 70px)',
408
+ width: '100%',
409
+ display: 'flex',
410
+ alignItems: 'center',
411
+ justifyContent: 'center',
412
+ background: '#F9F9F9',
413
+ } }, { children: [LoadingComponent && _jsx(LoadingComponent, {}), !LoadingComponent && (_jsx(TailSpin, { height: 36, width: 36, color: "#364153" }))] }))) : (_jsx(MonacoEditor, { height: "calc(100% - 70px)", width: "100%", defaultLanguage: "pgsql", defaultValue: "", value: query, loading: _jsx("div", {}), options: {
489
414
  wordWrap: 'on',
490
415
  minimap: {
491
416
  enabled: false,
492
417
  },
493
418
  padding: { top: 16 },
494
- }, onChange: function (query) { return setQuery(query); }, beforeMount: function (monaco) { return defineEditorTheme(monaco, theme); }, onMount: setEditorTheme }), _jsx("div", __assign({ style: {
419
+ }, onChange: function (query) { return setQuery(query); }, beforeMount: function (monaco) { return defineEditorTheme(monaco, theme); }, onMount: setEditorTheme })), _jsx("div", __assign({ style: {
495
420
  display: 'flex',
496
421
  flexDirection: 'row',
497
422
  alignItems: 'center',
498
- height: 50,
499
- } }, { children: _jsx("button", __assign({ type: "button", onClick: handleRunQuery, style: {
423
+ height: 70,
424
+ } }, { children: (ButtonComponent && (_jsx(ButtonComponent, { onClick: handleRunQuery, label: "Run query" }))) || (_jsx(QuillButton, { onClick: handleRunQuery, label: "Run query", theme: theme })) }))] })));
425
+ };
426
+ var styles = {
427
+ columnHeader: {
428
+ boxSizing: 'border-box',
429
+ flex: '150 0 auto',
430
+ minWidth: '50px',
431
+ width: '150px',
432
+ position: 'relative',
433
+ cursor: 'pointer',
434
+ background: 'rgb(249, 250, 251)',
435
+ borderRight: '1px solid rgb(229, 231, 235)',
436
+ whiteSpace: 'nowrap',
437
+ display: 'flex',
438
+ alignItems: 'center',
439
+ overflowX: 'visible',
440
+ margin: '0px',
441
+ textOverflow: 'ellipsis',
442
+ minHeight: '36px', // 2.25rem * 16px = 36px
443
+ },
444
+ columnHeaderLabel: {
445
+ fontFamily: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',
446
+ WebkitTapHighlightColor: 'transparent',
447
+ color: 'rgb(55, 65, 81)',
448
+ textDecoration: 'none',
449
+ fontWeight: 500,
450
+ fontSize: '14px',
451
+ lineHeight: '20px',
452
+ textOverflow: 'ellipsis',
453
+ whiteSpace: 'nowrap',
454
+ overflow: 'hidden',
455
+ },
456
+ };
457
+ export function SpecialTable(_a) {
458
+ var columns = _a.columns, rows = _a.rows, height = _a.height, containerStyle = _a.containerStyle, loading = _a.loading, LoadingComponent = _a.LoadingComponent, theme = _a.theme, showDownloadCsvButton = _a.showDownloadCsvButton, csvFilename = _a.csvFilename;
459
+ var downloadCSV = function () {
460
+ // report.rows
461
+ if (!rows.length) {
462
+ return;
463
+ }
464
+ var json = rows; // JSON data passed as a prop
465
+ var fields = Object.keys(json[0]); // Assumes all objects have same keys
466
+ var csvRows = [];
467
+ // Header row
468
+ csvRows.push(fields.join(','));
469
+ var _loop_2 = function (row) {
470
+ var values = fields.map(function (field) { return JSON.stringify(row[field] || ''); });
471
+ csvRows.push(values.join(','));
472
+ };
473
+ // Data rows
474
+ for (var _i = 0, json_2 = json; _i < json_2.length; _i++) {
475
+ var row = json_2[_i];
476
+ _loop_2(row);
477
+ }
478
+ // Create CSV string and create a 'blob' with it
479
+ var csvString = csvRows.join('\r\n');
480
+ var csvBlob = new Blob([csvString], { type: 'text/csv' });
481
+ // Create a download link and click it
482
+ var downloadLink = document.createElement('a');
483
+ downloadLink.download = "".concat(csvFilename, ".csv");
484
+ downloadLink.href = URL.createObjectURL(csvBlob);
485
+ downloadLink.style.display = 'none';
486
+ document.body.appendChild(downloadLink);
487
+ downloadLink.click();
488
+ document.body.removeChild(downloadLink);
489
+ };
490
+ if (loading) {
491
+ return (_jsx("div", __assign({ style: __assign(__assign({}, containerStyle), {
492
+ // paddingLeft: 25,
493
+ // paddingRight: 25,
494
+ // borderRadius: 8,
495
+ // marginTop: 25,
496
+ // overflow: 'visible',
497
+ width: '100%', height: height }) }, { children: _jsxs("div", __assign({ style: {
498
+ height: '100%',
499
+ overflow: 'scroll',
500
+ borderRadius: 6,
501
+ border: '1px solid rgb(229, 231, 235)',
502
+ padding: 0,
503
+ margin: 0,
504
+ // border: 'none',
505
+ boxSizing: 'border-box',
506
+ outline: 'none',
507
+ display: 'flex',
508
+ flexDirection: 'column',
509
+ justifyContent: 'center',
510
+ alignItems: 'center',
511
+ // maxHeight: 600,
512
+ } }, { children: [LoadingComponent && _jsx(LoadingComponent, {}), !LoadingComponent && (_jsx(TailSpin, { height: 36, width: 36, color: "#364153" }))] })) })));
513
+ }
514
+ if (!columns || !columns.length || !rows) {
515
+ return null;
516
+ }
517
+ if (showDownloadCsvButton) {
518
+ return (_jsxs("div", __assign({ style: __assign(__assign({}, containerStyle), {
519
+ // paddingLeft: 25,
520
+ // paddingRight: 25,
521
+ // borderRadius: 8,
522
+ // marginTop: 25,
523
+ overflow: 'visible', height: height }) }, { children: [_jsx("div", __assign({ style: { height: 50, background: 'white' }, className: "thead" }, { children: _jsx("div", __assign({ role: "row", className: "tr", style: {
524
+ display: 'flex',
525
+ flex: '1 0 auto',
526
+ minWidth: '100px',
527
+ boxSizing: 'border-box',
528
+ alignItems: 'center',
529
+ height: 50,
530
+ // position: 'absolute',
531
+ // bottom: 0,
532
+ } }, { children: _jsx("div", __assign({ onClick: downloadCSV, style: {
533
+ height: 40,
534
+ minHeight: 40,
535
+ color: theme === null || theme === void 0 ? void 0 : theme.primaryTextColor,
536
+ boxSizing: 'content-box',
537
+ fontFamily: (theme === null || theme === void 0 ? void 0 : theme.chartLabelFontFamily) || (theme === null || theme === void 0 ? void 0 : theme.fontFamily),
538
+ fontSize: (theme === null || theme === void 0 ? void 0 : theme.fontSizeSmall) || '14px',
539
+ fontWeight: (theme === null || theme === void 0 ? void 0 : theme.fontWeightMedium) || '500',
540
+ // marginTop: 8,
541
+ marginLeft: 20,
542
+ alignItems: 'center',
543
+ display: 'flex',
544
+ cursor: 'pointer',
545
+ } }, { children: "Download CSV" })) })) })), _jsx("div", __assign({ style: {
546
+ height: 'calc(100% - 50px)',
547
+ overflow: 'scroll',
500
548
  borderRadius: 6,
501
- backgroundColor: theme.primaryButtonColor,
502
- height: 32,
503
- width: 100,
504
- marginLeft: 0,
505
- // paddingLeft: '1rem',
506
- // paddingRight: '1rem',
507
- // paddingTop: '0.5rem',
508
- // paddingBottom: '0.5rem',
509
- fontSize: '0.875rem',
510
- fontWeight: '600',
511
- color: theme.backgroundColor,
512
- fontFamily: theme.fontFamily,
549
+ border: '1px solid rgb(229, 231, 235)',
550
+ padding: 0,
551
+ margin: 0,
552
+ // border: 'none',
553
+ boxSizing: 'border-box',
513
554
  outline: 'none',
514
- border: 'none',
515
- cursor: 'pointer',
516
- } }, { children: "Run query" })) }))] })));
517
- };
555
+ // maxHeight: 600,
556
+ } }, { children: _jsxs("div", __assign({ role: "table", className: "table", style: { minWidth: '0px' } }, { children: [_jsx("div", __assign({ className: "thead" }, { children: _jsx("div", __assign({ role: "row", className: "tr", style: {
557
+ display: 'flex',
558
+ flex: '1 0 auto',
559
+ minWidth: '100px',
560
+ boxSizing: 'border-box',
561
+ } }, { children: columns.map(function (column, index) { return (_jsxs("div", __assign({
562
+ // @ts-ignore
563
+ style: styles.columnHeader }, { children: [_jsx("div", { style: { width: 16 } }), _jsx("div", __assign({ "aria-haspopup": "dialog", "aria-expanded": "false", "aria-controls": "mantine-r6-dropdown",
564
+ // @ts-ignore
565
+ style: styles.columnHeaderLabel }, { children: column.label }))] }), 'sqlcol' + index)); }) })) })), _jsx("div", __assign({ role: "rowgroup", className: "tbody" }, { children: rows.map(function (row, rowIndex) { return (_jsx("div", __assign({ role: "row", className: "tr", style: {
566
+ display: 'flex',
567
+ flex: '1 0 auto',
568
+ minWidth: '100px',
569
+ boxSizing: 'border-box',
570
+ } }, { children: columns.map(function (column, columnIndex) { return (_jsx("div", __assign({ role: "cell", className: "td airplane-1h7muk6", style: {
571
+ boxSizing: 'border-box',
572
+ flex: '150 0 auto',
573
+ minWidth: '50px',
574
+ width: '150px',
575
+ display: 'flex',
576
+ margin: '0px',
577
+ textOverflow: 'ellipsis',
578
+ minHeight: '36px',
579
+ borderRight: '1px solid rgb(229, 231, 235)',
580
+ overflow: 'hidden',
581
+ borderTop: '1px solid rgb(229, 231, 235)',
582
+ } }, { children: _jsx("div", __assign({ style: {
583
+ lineHeight: '1.5rem',
584
+ width: '100%',
585
+ display: 'flex',
586
+ cursor: 'default',
587
+ position: 'relative',
588
+ }, className: "airplane-gowkln", "data-testid": "static-cell" }, { children: _jsx("div", __assign({ className: "airplane-Text-root airplane-mzqt6k", "aria-haspopup": "dialog", "aria-expanded": "false", "aria-controls": "mantine-r8-dropdown", id: "mantine-r8-target", style: {
589
+ fontFamily: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',
590
+ WebkitTapHighlightColor: 'transparent',
591
+ color: 'rgb(55, 65, 81)',
592
+ textDecoration: 'none',
593
+ fontWeight: 400,
594
+ fontSize: '14px',
595
+ lineHeight: '20px',
596
+ textOverflow: 'ellipsis',
597
+ whiteSpace: 'nowrap',
598
+ overflow: 'hidden',
599
+ padding: '8px 16px',
600
+ } }, { children: typeof row[column.field] === 'object'
601
+ ? JSON.stringify(row[column.field]).length > 55
602
+ ? JSON.stringify(row[column.field]).substring(0, 52) + '...'
603
+ : JSON.stringify(row[column.field])
604
+ : row[column.field].length > 55
605
+ ? row[column.field].substring(0, 52) + '...'
606
+ : row[column.field] })) })) }), 'sqlcell' + columnIndex)); }) }), 'sqlrow' + rowIndex)); }) }))] })) }))] })));
607
+ }
608
+ return (_jsx("div", __assign({ style: __assign(__assign({}, containerStyle), {
609
+ // paddingLeft: 25,
610
+ // paddingRight: 25,
611
+ // borderRadius: 8,
612
+ // marginTop: 25,
613
+ overflow: 'visible', height: height }) }, { children: _jsx("div", __assign({ style: {
614
+ height: '100%',
615
+ overflow: 'scroll',
616
+ borderRadius: 6,
617
+ border: '1px solid rgb(229, 231, 235)',
618
+ padding: 0,
619
+ margin: 0,
620
+ // border: 'none',
621
+ boxSizing: 'border-box',
622
+ outline: 'none',
623
+ // maxHeight: 600,
624
+ } }, { children: _jsxs("div", __assign({ role: "table", className: "table", style: { minWidth: '0px' } }, { children: [_jsx("div", __assign({ className: "thead" }, { children: _jsx("div", __assign({ role: "row", className: "tr", style: {
625
+ display: 'flex',
626
+ flex: '1 0 auto',
627
+ minWidth: '100px',
628
+ boxSizing: 'border-box',
629
+ } }, { children: columns.map(function (column, index) { return (_jsxs("div", __assign({
630
+ // @ts-ignore
631
+ style: styles.columnHeader }, { children: [_jsx("div", { style: { width: 16 } }), _jsx("div", __assign({ "aria-haspopup": "dialog", "aria-expanded": "false", "aria-controls": "mantine-r6-dropdown",
632
+ // @ts-ignore
633
+ style: styles.columnHeaderLabel }, { children: column.label }))] }), 'sqlcol' + index)); }) })) })), _jsx("div", __assign({ role: "rowgroup", className: "tbody" }, { children: rows.map(function (row, rowIndex) { return (_jsx("div", __assign({ role: "row", className: "tr", style: {
634
+ display: 'flex',
635
+ flex: '1 0 auto',
636
+ minWidth: '100px',
637
+ boxSizing: 'border-box',
638
+ } }, { children: columns.map(function (column, columnIndex) { return (_jsx("div", __assign({ role: "cell", className: "td airplane-1h7muk6", style: {
639
+ boxSizing: 'border-box',
640
+ flex: '150 0 auto',
641
+ minWidth: '50px',
642
+ width: '150px',
643
+ display: 'flex',
644
+ margin: '0px',
645
+ textOverflow: 'ellipsis',
646
+ minHeight: '36px',
647
+ borderRight: '1px solid rgb(229, 231, 235)',
648
+ overflow: 'hidden',
649
+ borderTop: '1px solid rgb(229, 231, 235)',
650
+ } }, { children: _jsx("div", __assign({ style: {
651
+ lineHeight: '1.5rem',
652
+ width: '100%',
653
+ display: 'flex',
654
+ cursor: 'default',
655
+ position: 'relative',
656
+ }, className: "airplane-gowkln", "data-testid": "static-cell" }, { children: _jsx("div", __assign({ className: "airplane-Text-root airplane-mzqt6k", "aria-haspopup": "dialog", "aria-expanded": "false", "aria-controls": "mantine-r8-dropdown", id: "mantine-r8-target", style: {
657
+ fontFamily: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',
658
+ WebkitTapHighlightColor: 'transparent',
659
+ color: 'rgb(55, 65, 81)',
660
+ textDecoration: 'none',
661
+ fontWeight: 400,
662
+ fontSize: '14px',
663
+ lineHeight: '20px',
664
+ textOverflow: 'ellipsis',
665
+ whiteSpace: 'nowrap',
666
+ overflow: 'hidden',
667
+ padding: '8px 16px',
668
+ } }, { children: typeof row[column.field] === 'object'
669
+ ? JSON.stringify(row[column.field]).length > 55
670
+ ? JSON.stringify(row[column.field]).substring(0, 52) + '...'
671
+ : JSON.stringify(row[column.field])
672
+ : row[column.field].length > 55
673
+ ? row[column.field].substring(0, 52) + '...'
674
+ : row[column.field] })) })) }), 'sqlcell' + columnIndex)); }) }), 'sqlrow' + rowIndex)); }) }))] })) })) })));
675
+ }
518
676
  var SchemaListComponent = function (_a) {
519
- var schema = _a.schema, theme = _a.theme;
677
+ var schema = _a.schema, theme = _a.theme, loading = _a.loading, LoadingComponent = _a.LoadingComponent;
678
+ if (loading) {
679
+ return (_jsxs("div", __assign({ style: {
680
+ background: theme.backgroundColor,
681
+ // maxHeight: 700,
682
+ width: 250,
683
+ minWidth: 250,
684
+ // overflowY: 'scroll',
685
+ height: '100%',
686
+ // maxHeight: "100%",
687
+ paddingLeft: 20,
688
+ paddingRight: 30,
689
+ paddingTop: 40,
690
+ display: 'flex',
691
+ // alignItems: 'center',
692
+ justifyContent: 'center',
693
+ } }, { children: [_jsx("div", { style: { height: 100 } }), LoadingComponent && _jsx(LoadingComponent, {}), !LoadingComponent && (_jsx(TailSpin, { height: 36, width: 36, color: "#364153" }))] })));
694
+ }
520
695
  return (_jsx("div", __assign({ style: {
521
696
  background: theme.backgroundColor,
522
697
  // maxHeight: 700,