@quillsql/react 1.7.1 → 1.7.2

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 (105) hide show
  1. package/lib/AddToDashboardModal.js +369 -249
  2. package/lib/AddToDashboardModal.js.map +1 -1
  3. package/lib/BarList.js +109 -92
  4. package/lib/BarList.js.map +1 -1
  5. package/lib/Chart.js +414 -364
  6. package/lib/Chart.js.map +1 -1
  7. package/lib/Context.js +84 -92
  8. package/lib/Context.js.map +1 -1
  9. package/lib/Dashboard.js +209 -181
  10. package/lib/Dashboard.js.map +1 -1
  11. package/lib/DateRangePicker/Calendar.js +91 -87
  12. package/lib/DateRangePicker/Calendar.js.map +1 -1
  13. package/lib/DateRangePicker/DateRangePicker.js +68 -70
  14. package/lib/DateRangePicker/DateRangePicker.js.map +1 -1
  15. package/lib/DateRangePicker/DateRangePickerButton.js +57 -46
  16. package/lib/DateRangePicker/DateRangePickerButton.js.map +1 -1
  17. package/lib/DateRangePicker/dateRangePickerUtils.js +99 -105
  18. package/lib/DateRangePicker/dateRangePickerUtils.js.map +1 -1
  19. package/lib/DateRangePicker/index.js +1 -8
  20. package/lib/DateRangePicker/index.js.map +1 -1
  21. package/lib/PieChart.js +225 -221
  22. package/lib/PieChart.js.map +1 -1
  23. package/lib/QuillProvider.js +18 -8
  24. package/lib/QuillProvider.js.map +1 -1
  25. package/lib/ReportBuilder.js +526 -430
  26. package/lib/ReportBuilder.js.map +1 -1
  27. package/lib/SQLEditor.js +268 -183
  28. package/lib/SQLEditor.js.map +1 -1
  29. package/lib/Table.js +256 -213
  30. package/lib/Table.js.map +1 -1
  31. package/lib/TableChart.js +75 -76
  32. package/lib/TableChart.js.map +1 -1
  33. package/lib/assets/ArrowDownHeadIcon.js +28 -5
  34. package/lib/assets/ArrowDownHeadIcon.js.map +1 -1
  35. package/lib/assets/ArrowDownIcon.js +28 -5
  36. package/lib/assets/ArrowDownIcon.js.map +1 -1
  37. package/lib/assets/ArrowDownRightIcon.js +28 -5
  38. package/lib/assets/ArrowDownRightIcon.js.map +1 -1
  39. package/lib/assets/ArrowLeftHeadIcon.js +28 -5
  40. package/lib/assets/ArrowLeftHeadIcon.js.map +1 -1
  41. package/lib/assets/ArrowRightHeadIcon.js +28 -5
  42. package/lib/assets/ArrowRightHeadIcon.js.map +1 -1
  43. package/lib/assets/ArrowRightIcon.js +28 -5
  44. package/lib/assets/ArrowRightIcon.js.map +1 -1
  45. package/lib/assets/ArrowUpHeadIcon.js +28 -5
  46. package/lib/assets/ArrowUpHeadIcon.js.map +1 -1
  47. package/lib/assets/ArrowUpIcon.js +28 -5
  48. package/lib/assets/ArrowUpIcon.js.map +1 -1
  49. package/lib/assets/ArrowUpRightIcon.js +28 -5
  50. package/lib/assets/ArrowUpRightIcon.js.map +1 -1
  51. package/lib/assets/CalendarIcon.js +28 -5
  52. package/lib/assets/CalendarIcon.js.map +1 -1
  53. package/lib/assets/DoubleArrowLeftHeadIcon.js +28 -5
  54. package/lib/assets/DoubleArrowLeftHeadIcon.js.map +1 -1
  55. package/lib/assets/DoubleArrowRightHeadIcon.js +28 -5
  56. package/lib/assets/DoubleArrowRightHeadIcon.js.map +1 -1
  57. package/lib/assets/ExclamationFilledIcon.js +28 -5
  58. package/lib/assets/ExclamationFilledIcon.js.map +1 -1
  59. package/lib/assets/LoadingSpinner.js +28 -5
  60. package/lib/assets/LoadingSpinner.js.map +1 -1
  61. package/lib/assets/SearchIcon.js +28 -5
  62. package/lib/assets/SearchIcon.js.map +1 -1
  63. package/lib/assets/XCircleIcon.js +28 -5
  64. package/lib/assets/XCircleIcon.js.map +1 -1
  65. package/lib/assets/index.js +16 -38
  66. package/lib/assets/index.js.map +1 -1
  67. package/lib/components/BigModal/BigModal.js +43 -45
  68. package/lib/components/BigModal/BigModal.js.map +1 -1
  69. package/lib/components/Dropdown/Dropdown.js +53 -57
  70. package/lib/components/Dropdown/Dropdown.js.map +1 -1
  71. package/lib/components/Dropdown/DropdownItem.js +40 -43
  72. package/lib/components/Dropdown/DropdownItem.js.map +1 -1
  73. package/lib/components/Dropdown/index.js +2 -10
  74. package/lib/components/Dropdown/index.js.map +1 -1
  75. package/lib/components/Modal/Modal.js +43 -45
  76. package/lib/components/Modal/Modal.js.map +1 -1
  77. package/lib/components/Modal/index.js +1 -8
  78. package/lib/components/Modal/index.js.map +1 -1
  79. package/lib/components/selectUtils.js +15 -20
  80. package/lib/components/selectUtils.js.map +1 -1
  81. package/lib/contexts/BaseColorContext.js +3 -5
  82. package/lib/contexts/BaseColorContext.js.map +1 -1
  83. package/lib/contexts/HoveredValueContext.js +3 -5
  84. package/lib/contexts/HoveredValueContext.js.map +1 -1
  85. package/lib/contexts/RootStylesContext.js +3 -5
  86. package/lib/contexts/RootStylesContext.js.map +1 -1
  87. package/lib/contexts/SelectedValueContext.js +3 -5
  88. package/lib/contexts/SelectedValueContext.js.map +1 -1
  89. package/lib/contexts/index.js +4 -14
  90. package/lib/contexts/index.js.map +1 -1
  91. package/lib/hooks/index.js +4 -14
  92. package/lib/hooks/index.js.map +1 -1
  93. package/lib/hooks/useInternalState.js +7 -9
  94. package/lib/hooks/useInternalState.js.map +1 -1
  95. package/lib/hooks/useOnClickOutside.js +6 -8
  96. package/lib/hooks/useOnClickOutside.js.map +1 -1
  97. package/lib/hooks/useOnWindowResize.js +7 -9
  98. package/lib/hooks/useOnWindowResize.js.map +1 -1
  99. package/lib/hooks/useQuill.js +111 -60
  100. package/lib/hooks/useQuill.js.map +1 -1
  101. package/lib/hooks/useSelectOnKeyDown.js +15 -17
  102. package/lib/hooks/useSelectOnKeyDown.js.map +1 -1
  103. package/lib/index.js +8 -22
  104. package/lib/index.js.map +1 -1
  105. package/package.json +1 -1
package/lib/SQLEditor.js CHANGED
@@ -1,22 +1,63 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
4
20
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.convertPostgresColumn = void 0;
7
- const jsx_runtime_1 = require("react/jsx-runtime");
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
49
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
9
50
  // @ts-ignore
10
- const react_1 = require("react");
11
- const react_2 = __importDefault(require("@monaco-editor/react"));
51
+ import { useState, useContext, useEffect } from 'react';
52
+ import MonacoEditor from '@monaco-editor/react';
12
53
  // import './nightOwlLight.css';
13
- const axios_1 = __importDefault(require("axios"));
14
- const Context_1 = require("./Context");
15
- const solid_1 = require("@heroicons/react/20/solid");
16
- const Table_1 = require("./Table");
17
- const react_loader_spinner_1 = require("react-loader-spinner");
18
- function convertPostgresColumn(column) {
19
- let format;
54
+ import axios from 'axios';
55
+ import { ClientContext, SchemaContext, ThemeContext } from './Context';
56
+ import { ChevronDownIcon, ChevronRightIcon, } from '@heroicons/react/20/solid';
57
+ import { SpecialTable } from './Table';
58
+ import { TailSpin } from 'react-loader-spinner';
59
+ export function convertPostgresColumn(column) {
60
+ var format;
20
61
  switch (column.dataTypeID) {
21
62
  case 20: // int8
22
63
  case 21: // int2
@@ -44,7 +85,6 @@ function convertPostgresColumn(column) {
44
85
  format: format,
45
86
  };
46
87
  }
47
- exports.convertPostgresColumn = convertPostgresColumn;
48
88
  function defineEditorTheme(monaco, theme) {
49
89
  monaco.editor.defineTheme('onedark', {
50
90
  base: theme.darkMode ? 'vs-dark' : 'vs',
@@ -70,26 +110,30 @@ function setEditorTheme(editor, monaco) {
70
110
  console.log('ERROR: ', e);
71
111
  }
72
112
  }
73
- const QuillButton = ({ onClick, label, theme, secondary, }) => ((0, jsx_runtime_1.jsx)("button", { style: {
74
- borderRadius: '6px',
75
- backgroundColor: secondary
76
- ? theme?.secondaryButtonColor || '#FFFFFF'
77
- : theme?.primaryButtonColor,
78
- opacity: 1,
79
- paddingLeft: '16px',
80
- paddingRight: '16px',
81
- paddingTop: '10px',
82
- paddingBottom: '10px',
83
- fontSize: '14px',
84
- fontWeight: 600,
85
- color: secondary ? theme?.primaryTextColor : '#FFFFFF',
86
- cursor: 'pointer',
87
- outline: 'none',
88
- border: 'none',
89
- fontFamily: theme?.fontFamily,
90
- }, onClick: onClick, children: label }));
91
- const QuillTextInput = ({ onChange, value, id, placeholder, theme, }) => {
92
- return ((0, jsx_runtime_1.jsx)("input", { style: {
113
+ var QuillButton = function (_a) {
114
+ var onClick = _a.onClick, label = _a.label, theme = _a.theme, secondary = _a.secondary;
115
+ return (_jsx("button", __assign({ style: {
116
+ borderRadius: '6px',
117
+ backgroundColor: secondary
118
+ ? (theme === null || theme === void 0 ? void 0 : theme.secondaryButtonColor) || '#FFFFFF'
119
+ : theme === null || theme === void 0 ? void 0 : theme.primaryButtonColor,
120
+ opacity: 1,
121
+ paddingLeft: '16px',
122
+ paddingRight: '16px',
123
+ paddingTop: '10px',
124
+ paddingBottom: '10px',
125
+ fontSize: '14px',
126
+ fontWeight: 600,
127
+ color: secondary ? theme === null || theme === void 0 ? void 0 : theme.primaryTextColor : '#FFFFFF',
128
+ cursor: 'pointer',
129
+ outline: 'none',
130
+ border: 'none',
131
+ fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
132
+ }, onClick: onClick }, { children: label })));
133
+ };
134
+ var QuillTextInput = function (_a) {
135
+ var onChange = _a.onChange, value = _a.value, id = _a.id, placeholder = _a.placeholder, theme = _a.theme;
136
+ return (_jsx("input", { style: {
93
137
  display: 'flex',
94
138
  flexDirection: 'row',
95
139
  alignItems: 'center',
@@ -99,134 +143,173 @@ const QuillTextInput = ({ onChange, value, id, placeholder, theme, }) => {
99
143
  height: 36,
100
144
  boxShadow: 'rgba(0, 0, 0, 0.1) 0px 1px 5px 0px',
101
145
  width: '445px',
102
- backgroundColor: theme?.backgroundColor || 'white',
103
- color: theme?.primaryTextColor,
146
+ backgroundColor: (theme === null || theme === void 0 ? void 0 : theme.backgroundColor) || 'white',
147
+ color: theme === null || theme === void 0 ? void 0 : theme.primaryTextColor,
104
148
  borderWidth: '1px',
105
- borderColor: theme?.borderColor || '#E7E7E7',
149
+ borderColor: (theme === null || theme === void 0 ? void 0 : theme.borderColor) || '#E7E7E7',
106
150
  borderStyle: 'solid',
107
151
  borderRadius: '6px',
108
152
  }, id: id, onChange: onChange, value: value, placeholder: placeholder }));
109
153
  };
110
- function QueryEditor({ containerStyle = { height: '100vh' }, ButtonComponent, SecondaryButtonComponent, TextInputComponent, TableComponent, AddToDashboardButton, LoadingComponent, }) {
111
- const [sqlPrompt, setSqlPrompt] = (0, react_1.useState)('');
112
- const [isOpen, setIsOpen] = (0, react_1.useState)(false);
113
- const [client] = (0, react_1.useContext)(Context_1.ClientContext);
114
- const [theme] = (0, react_1.useContext)(Context_1.ThemeContext);
115
- const [query, setQuery] = (0, react_1.useState)('');
116
- const [rows, setRows] = (0, react_1.useState)([]);
117
- const [columns, setColumns] = (0, react_1.useState)([]);
118
- const [fields, setFields] = (0, react_1.useState)([]);
119
- const [schema, setSchema] = (0, react_1.useContext)(Context_1.SchemaContext);
120
- const [errorMessage, setErrorMessage] = (0, react_1.useState)('');
121
- const [sqlResponseLoading, setSqlResponseLoading] = (0, react_1.useState)(false);
122
- const [sqlQueryLoading, setSqlQueryLoading] = (0, react_1.useState)(false);
123
- const [schemaLoading, setSchemaLoading] = (0, react_1.useState)(false);
124
- (0, react_1.useEffect)(() => {
125
- let isSubscribed = true;
126
- async function getSchema() {
127
- const { publicKey, environment } = client;
128
- setSchemaLoading(true);
129
- const response3 = await axios_1.default.get(`https://quill-344421.uc.r.appspot.com/schema2/${publicKey}/`, {
130
- headers: {
131
- Authorization: `Bearer `,
132
- environment: environment || undefined,
133
- },
154
+ export default function QueryEditor(_a) {
155
+ var _this = this;
156
+ 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;
157
+ var _c = useState(''), sqlPrompt = _c[0], setSqlPrompt = _c[1];
158
+ var _d = useState(false), isOpen = _d[0], setIsOpen = _d[1];
159
+ var client = useContext(ClientContext)[0];
160
+ var theme = useContext(ThemeContext)[0];
161
+ var _e = useState(''), query = _e[0], setQuery = _e[1];
162
+ var _f = useState([]), rows = _f[0], setRows = _f[1];
163
+ var _g = useState([]), columns = _g[0], setColumns = _g[1];
164
+ var _h = useState([]), fields = _h[0], setFields = _h[1];
165
+ var _j = useContext(SchemaContext), schema = _j[0], setSchema = _j[1];
166
+ var _k = useState(''), errorMessage = _k[0], setErrorMessage = _k[1];
167
+ var _l = useState(false), sqlResponseLoading = _l[0], setSqlResponseLoading = _l[1];
168
+ var _m = useState(false), sqlQueryLoading = _m[0], setSqlQueryLoading = _m[1];
169
+ var _o = useState(false), schemaLoading = _o[0], setSchemaLoading = _o[1];
170
+ useEffect(function () {
171
+ var isSubscribed = true;
172
+ function getSchema() {
173
+ return __awaiter(this, void 0, void 0, function () {
174
+ var publicKey, environment, response3;
175
+ return __generator(this, function (_a) {
176
+ switch (_a.label) {
177
+ case 0:
178
+ publicKey = client.publicKey, environment = client.environment;
179
+ setSchemaLoading(true);
180
+ return [4 /*yield*/, axios.get("https://quill-344421.uc.r.appspot.com/schema2/".concat(publicKey, "/"), {
181
+ headers: {
182
+ Authorization: "Bearer ",
183
+ environment: environment || undefined,
184
+ },
185
+ })];
186
+ case 1:
187
+ response3 = _a.sent();
188
+ if (isSubscribed) {
189
+ setSchema(response3.data.tables);
190
+ setSchemaLoading(false);
191
+ }
192
+ return [2 /*return*/];
193
+ }
194
+ });
134
195
  });
135
- if (isSubscribed) {
136
- setSchema(response3.data.tables);
137
- setSchemaLoading(false);
138
- }
139
196
  }
140
197
  if (isSubscribed) {
141
198
  getSchema();
142
199
  }
143
- return () => {
200
+ return function () {
144
201
  isSubscribed = false;
145
202
  };
146
203
  }, []);
147
- const handleRunSqlPrompt = async () => {
148
- const { publicKey, environment } = client;
149
- setSqlResponseLoading(true);
150
- const response = await axios_1.default.post(`https://quill-344421.uc.r.appspot.com/quillai`, {
151
- initialQuestion: sqlPrompt,
152
- publicKey: publicKey,
153
- }, {
154
- headers: {
155
- Authorization: `Bearer `,
156
- environment: environment || undefined,
157
- },
158
- });
159
- setQuery(response.data.message);
160
- setSqlResponseLoading(false);
161
- };
162
- const handleRunQuery = async () => {
163
- const { publicKey, customerId, environment, queryEndpoint, queryHeaders, withCredentials, } = client;
164
- try {
165
- let response;
166
- setSqlQueryLoading(true);
167
- if (queryEndpoint) {
168
- response = await axios_1.default.post(queryEndpoint, { metadata: { query, task: 'query' } }, { headers: queryHeaders, withCredentials });
204
+ var handleRunSqlPrompt = function () { return __awaiter(_this, void 0, void 0, function () {
205
+ var publicKey, environment, response;
206
+ return __generator(this, function (_a) {
207
+ switch (_a.label) {
208
+ case 0:
209
+ publicKey = client.publicKey, environment = client.environment;
210
+ setSqlResponseLoading(true);
211
+ return [4 /*yield*/, axios.post("https://quill-344421.uc.r.appspot.com/quillai", {
212
+ initialQuestion: sqlPrompt,
213
+ publicKey: publicKey,
214
+ }, {
215
+ headers: {
216
+ Authorization: "Bearer ",
217
+ environment: environment || undefined,
218
+ },
219
+ })];
220
+ case 1:
221
+ response = _a.sent();
222
+ setQuery(response.data.message);
223
+ setSqlResponseLoading(false);
224
+ return [2 /*return*/];
169
225
  }
170
- else {
171
- response = await axios_1.default.post(`https://quill-344421.uc.r.appspot.com/dashquery`, {
172
- query,
173
- }, {
174
- params: {
175
- orgId: customerId,
176
- publicKey: publicKey,
177
- },
178
- headers: {
179
- Authorization: `Bearer `,
180
- environment: environment || undefined,
181
- },
182
- });
183
- }
184
- if (response && response.data && response.data.errorMessage) {
185
- setSqlQueryLoading(false);
186
- setErrorMessage('Failed to run SQL query: ' + response.data.errorMessage);
187
- setRows([]);
188
- setColumns([]);
189
- setFields([]);
190
- return;
226
+ });
227
+ }); };
228
+ var handleRunQuery = function () { return __awaiter(_this, void 0, void 0, function () {
229
+ var publicKey, customerId, environment, queryEndpoint, queryHeaders, withCredentials, response, e_1;
230
+ return __generator(this, function (_a) {
231
+ switch (_a.label) {
232
+ case 0:
233
+ publicKey = client.publicKey, customerId = client.customerId, environment = client.environment, queryEndpoint = client.queryEndpoint, queryHeaders = client.queryHeaders, withCredentials = client.withCredentials;
234
+ _a.label = 1;
235
+ case 1:
236
+ _a.trys.push([1, 6, , 7]);
237
+ response = void 0;
238
+ setSqlQueryLoading(true);
239
+ if (!queryEndpoint) return [3 /*break*/, 3];
240
+ return [4 /*yield*/, axios.post(queryEndpoint, { metadata: { query: query, task: 'query' } }, { headers: queryHeaders, withCredentials: withCredentials })];
241
+ case 2:
242
+ response = _a.sent();
243
+ return [3 /*break*/, 5];
244
+ case 3: return [4 /*yield*/, axios.post("https://quill-344421.uc.r.appspot.com/dashquery", {
245
+ query: query,
246
+ }, {
247
+ params: {
248
+ orgId: customerId,
249
+ publicKey: publicKey,
250
+ },
251
+ headers: {
252
+ Authorization: "Bearer ",
253
+ environment: environment || undefined,
254
+ },
255
+ })];
256
+ case 4:
257
+ response = _a.sent();
258
+ _a.label = 5;
259
+ case 5:
260
+ if (response && response.data && response.data.errorMessage) {
261
+ setSqlQueryLoading(false);
262
+ setErrorMessage('Failed to run SQL query: ' + response.data.errorMessage);
263
+ setRows([]);
264
+ setColumns([]);
265
+ setFields([]);
266
+ return [2 /*return*/];
267
+ }
268
+ setSqlQueryLoading(false);
269
+ setErrorMessage('');
270
+ setRows(response.data.rows && response.data.rows.length
271
+ ? response.data.rows
272
+ : []);
273
+ setColumns(response.data.fields.map(function (elem) { return convertPostgresColumn(elem); }));
274
+ setFields(response.data.fields);
275
+ return [3 /*break*/, 7];
276
+ case 6:
277
+ e_1 = _a.sent();
278
+ console.log('ERROR: ', e_1);
279
+ return [2 /*return*/];
280
+ case 7: return [2 /*return*/];
191
281
  }
192
- setSqlQueryLoading(false);
193
- setErrorMessage('');
194
- setRows(response.data.rows && response.data.rows.length
195
- ? response.data.rows
196
- : []);
197
- setColumns(response.data.fields.map(elem => convertPostgresColumn(elem)));
198
- setFields(response.data.fields);
199
- }
200
- catch (e) {
201
- console.log('ERROR: ', e);
202
- return;
203
- }
204
- };
205
- const handleAddToDashboard = () => {
282
+ });
283
+ }); };
284
+ var handleAddToDashboard = function () {
206
285
  setIsOpen(true);
207
286
  };
208
287
  /* all your useState and useContext calls and your useEffect hooks */
209
- const downloadCSV = () => {
288
+ var downloadCSV = function () {
210
289
  // report.rows
211
290
  if (!rows.length) {
212
291
  return;
213
292
  }
214
- const json = rows; // JSON data passed as a prop
215
- const fields = Object.keys(json[0]); // Assumes all objects have same keys
216
- const csvRows = [];
293
+ var json = rows; // JSON data passed as a prop
294
+ var fields = Object.keys(json[0]); // Assumes all objects have same keys
295
+ var csvRows = [];
217
296
  // Header row
218
297
  csvRows.push(fields.join(','));
219
- // Data rows
220
- for (const row of json) {
221
- const values = fields.map(field => JSON.stringify(row[field] || ''));
298
+ var _loop_1 = function (row) {
299
+ var values = fields.map(function (field) { return JSON.stringify(row[field] || ''); });
222
300
  csvRows.push(values.join(','));
301
+ };
302
+ // Data rows
303
+ for (var _i = 0, json_1 = json; _i < json_1.length; _i++) {
304
+ var row = json_1[_i];
305
+ _loop_1(row);
223
306
  }
224
307
  // Create CSV string and create a 'blob' with it
225
- const csvString = csvRows.join('\r\n');
226
- const csvBlob = new Blob([csvString], { type: 'text/csv' });
308
+ var csvString = csvRows.join('\r\n');
309
+ var csvBlob = new Blob([csvString], { type: 'text/csv' });
227
310
  // Create a download link and click it
228
- const downloadLink = document.createElement('a');
229
- downloadLink.download = `${query}.csv`;
311
+ var downloadLink = document.createElement('a');
312
+ downloadLink.download = "".concat(query, ".csv");
230
313
  downloadLink.href = URL.createObjectURL(csvBlob);
231
314
  downloadLink.style.display = 'none';
232
315
  document.body.appendChild(downloadLink);
@@ -234,28 +317,28 @@ function QueryEditor({ containerStyle = { height: '100vh' }, ButtonComponent, Se
234
317
  document.body.removeChild(downloadLink);
235
318
  };
236
319
  /* rest of your methods */
237
- return ((0, jsx_runtime_1.jsx)("div", { style: containerStyle, children: (0, jsx_runtime_1.jsx)("div", { style: {
320
+ return (_jsx("div", __assign({ style: containerStyle }, { children: _jsx("div", __assign({ style: {
238
321
  height: 'calc(100%)',
239
322
  display: 'flex',
240
323
  flexDirection: 'column',
241
324
  padding: 0,
242
- }, children: (0, jsx_runtime_1.jsx)("div", { style: { height: '100%', display: 'flex', flexDirection: 'column' }, children: (0, jsx_runtime_1.jsxs)("div", { style: {
325
+ } }, { children: _jsx("div", __assign({ style: { height: '100%', display: 'flex', flexDirection: 'column' } }, { children: _jsxs("div", __assign({ style: {
243
326
  width: '100%',
244
327
  display: 'flex',
245
328
  height: '100%',
246
329
  flexDirection: 'row',
247
- }, children: [(0, jsx_runtime_1.jsx)(SchemaListComponent, { schema: schema, theme: theme, LoadingComponent: LoadingComponent, loading: schemaLoading }), (0, jsx_runtime_1.jsxs)("div", { style: {
330
+ } }, { children: [_jsx(SchemaListComponent, { schema: schema, theme: theme, LoadingComponent: LoadingComponent, loading: schemaLoading }), _jsxs("div", __assign({ style: {
248
331
  display: 'flex',
249
332
  flexDirection: 'column',
250
333
  width: 'calc(100% - 250px)',
251
- }, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
334
+ } }, { children: [_jsxs("div", __assign({ style: {
252
335
  // TODO: change color
253
336
  height: 80,
254
337
  background: 'white',
255
338
  display: 'flex',
256
339
  flexDirection: 'row',
257
340
  alignItems: 'center',
258
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: { minWidth: 440, marginRight: 10 }, children: (TextInputComponent && ((0, jsx_runtime_1.jsx)(TextInputComponent, { id: "ai-search", value: sqlPrompt, onChange: e => setSqlPrompt(e.target.value), placeholder: "Ask a question..." }))) || ((0, jsx_runtime_1.jsx)(QuillTextInput, { id: "ai-search", value: sqlPrompt, onChange: e => setSqlPrompt(e.target.value), placeholder: "Ask a question...", theme: theme })) }), (ButtonComponent && ((0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: handleRunSqlPrompt, label: "Ask AI" }))) || ((0, jsx_runtime_1.jsx)(QuillButton, { theme: theme, onClick: handleRunSqlPrompt, label: "Ask AI" }))] }), (0, jsx_runtime_1.jsx)("div", { style: { height: 'calc(50% - 40px)' }, children: (0, jsx_runtime_1.jsx)(SQLEditorComponent, { query: query, setQuery: setQuery, handleRunQuery: handleRunQuery, theme: theme, defineEditorTheme: defineEditorTheme, setEditorTheme: setEditorTheme, ButtonComponent: ButtonComponent, loading: sqlResponseLoading, LoadingComponent: LoadingComponent }) }), (0, jsx_runtime_1.jsxs)("div", { style: {
341
+ } }, { 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: {
259
342
  height: 'calc(50% - 40px)',
260
343
  display: 'flex',
261
344
  flexDirection: 'column',
@@ -263,52 +346,52 @@ function QueryEditor({ containerStyle = { height: '100vh' }, ButtonComponent, Se
263
346
  margin: 0,
264
347
  border: 'none',
265
348
  outline: 'none',
266
- }, children: [errorMessage && ((0, jsx_runtime_1.jsx)("div", { style: {
267
- fontFamily: theme?.fontFamily,
268
- color: theme?.primaryTextColor,
349
+ } }, { children: [errorMessage && (_jsx("div", __assign({ style: {
350
+ fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
351
+ color: theme === null || theme === void 0 ? void 0 : theme.primaryTextColor,
269
352
  fontSize: 15,
270
353
  fontWeight: '400',
271
- }, children: (0, jsx_runtime_1.jsx)("div", { style: {
354
+ } }, { children: _jsx("div", __assign({ style: {
272
355
  padding: 30,
273
356
  // TODO: change color
274
357
  background: 'rgba(0,0,0,0.02)',
275
358
  display: 'inline-block',
276
359
  flex: 0,
277
360
  borderRadius: 6,
278
- color: theme?.primaryTextColor,
279
- fontFamily: theme?.fontFamily,
280
- }, children: errorMessage }) })), errorMessage
361
+ color: theme === null || theme === void 0 ? void 0 : theme.primaryTextColor,
362
+ fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
363
+ } }, { children: errorMessage })) }))), errorMessage
281
364
  ? null
282
- : (TableComponent && ((0, jsx_runtime_1.jsx)(TableComponent, { rows: rows, columns: columns, height: "calc(100% - 70px)" }))) || ((0, jsx_runtime_1.jsx)(Table_1.SpecialTable, { rows: rows, columns: columns, height: "calc(100% - 70px)", LoadingComponent: LoadingComponent, loading: sqlQueryLoading, theme: theme })), (0, jsx_runtime_1.jsx)("div", { style: {
365
+ : (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, theme: theme })), _jsx("div", __assign({ style: {
283
366
  height: 70,
284
367
  // TODO: change color
285
- background: theme?.backgroundColor,
286
- }, children: rows.length ? ((0, jsx_runtime_1.jsxs)("div", { style: {
368
+ background: theme === null || theme === void 0 ? void 0 : theme.backgroundColor,
369
+ } }, { children: rows.length ? (_jsxs("div", __assign({ style: {
287
370
  display: 'flex',
288
371
  flexDirection: 'column',
289
372
  height: 70,
290
373
  border: 'none',
291
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
374
+ } }, { children: [_jsx("div", { style: {
292
375
  height: 1,
293
376
  width: '100%',
294
377
  // TODO: change color
295
378
  // background: theme.borderColor,
296
- } }), (0, jsx_runtime_1.jsxs)("div", { style: {
379
+ } }), _jsxs("div", __assign({ style: {
297
380
  marginLeft: 0,
298
381
  height: 69,
299
382
  display: 'flex',
300
383
  alignItems: 'center',
301
384
  justifyContent: 'flex-end',
302
385
  paddingRight: 20,
303
- }, children: [(SecondaryButtonComponent && ((0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: downloadCSV, label: "Download CSV" }))) || ((0, jsx_runtime_1.jsx)(QuillButton, { theme: theme, onClick: downloadCSV, label: "Download CSV", secondary: true })), AddToDashboardButton && (0, jsx_runtime_1.jsx)("div", { style: { width: 10 } }), AddToDashboardButton && ((0, jsx_runtime_1.jsx)(AddToDashboardButton
386
+ } }, { 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
304
387
  // @ts-ignore
305
388
  , {
306
389
  // @ts-ignore
307
- rows: rows, columns: columns, query: query })), (0, jsx_runtime_1.jsx)("div", {})] })] })) : null })] })] })] }) }) }) }));
390
+ rows: rows, columns: columns, query: query })), _jsx("div", {})] }))] }))) : null }))] }))] }))] })) })) })) })));
308
391
  }
309
- exports.default = QueryEditor;
310
- const SQLEditorComponent = ({ query, setQuery, handleRunQuery, defineEditorTheme, setEditorTheme, ButtonComponent, theme, loading, LoadingComponent, }) => {
311
- return ((0, jsx_runtime_1.jsxs)("div", { style: {
392
+ var SQLEditorComponent = function (_a) {
393
+ var query = _a.query, setQuery = _a.setQuery, handleRunQuery = _a.handleRunQuery, defineEditorTheme = _a.defineEditorTheme, setEditorTheme = _a.setEditorTheme, ButtonComponent = _a.ButtonComponent, theme = _a.theme, loading = _a.loading, LoadingComponent = _a.LoadingComponent;
394
+ return (_jsxs("div", __assign({ style: {
312
395
  background: theme.backgroundColor,
313
396
  // maxHeight: 700,
314
397
  width: '100%',
@@ -322,27 +405,27 @@ const SQLEditorComponent = ({ query, setQuery, handleRunQuery, defineEditorTheme
322
405
  borderTopRightRadius: 0,
323
406
  borderBottomRightRadius: 0,
324
407
  overflow: 'hidden',
325
- }, children: [loading ? ((0, jsx_runtime_1.jsxs)("div", { style: {
408
+ } }, { children: [loading ? (_jsxs("div", __assign({ style: {
326
409
  height: 'calc(100% - 70px)',
327
410
  width: '100%',
328
411
  display: 'flex',
329
412
  alignItems: 'center',
330
413
  justifyContent: 'center',
331
414
  background: '#F9F9F9',
332
- }, children: [LoadingComponent && (0, jsx_runtime_1.jsx)(LoadingComponent, {}), !LoadingComponent && ((0, jsx_runtime_1.jsx)(react_loader_spinner_1.TailSpin, { height: 36, width: 36, color: "#364153" }))] })) : ((0, jsx_runtime_1.jsx)(react_2.default, { height: "calc(100% - 70px)", width: "100%", defaultLanguage: "pgsql", defaultValue: "", value: query, loading: (0, jsx_runtime_1.jsx)("div", {}), options: {
415
+ } }, { 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: {
333
416
  wordWrap: 'on',
334
417
  minimap: {
335
418
  enabled: false,
336
419
  },
337
420
  padding: { top: 16 },
338
- }, onChange: query => setQuery(query), beforeMount: monaco => defineEditorTheme(monaco, theme), onMount: setEditorTheme })), (0, jsx_runtime_1.jsx)("div", { style: {
421
+ }, onChange: function (query) { return setQuery(query); }, beforeMount: function (monaco) { return defineEditorTheme(monaco, theme); }, onMount: setEditorTheme })), _jsx("div", __assign({ style: {
339
422
  display: 'flex',
340
423
  flexDirection: 'row',
341
424
  alignItems: 'center',
342
425
  height: 70,
343
- }, children: (ButtonComponent && ((0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: handleRunQuery, label: "Run query" }))) || ((0, jsx_runtime_1.jsx)(QuillButton, { onClick: handleRunQuery, label: "Run query", theme: theme })) })] }));
426
+ } }, { children: (ButtonComponent && (_jsx(ButtonComponent, { onClick: handleRunQuery, label: "Run query" }))) || (_jsx(QuillButton, { onClick: handleRunQuery, label: "Run query", theme: theme })) }))] })));
344
427
  };
345
- const styles = {
428
+ var styles = {
346
429
  columnHeader: {
347
430
  boxSizing: 'border-box',
348
431
  flex: '150 0 auto',
@@ -374,9 +457,10 @@ const styles = {
374
457
  overflow: 'hidden',
375
458
  },
376
459
  };
377
- const SchemaListComponent = ({ schema, theme, loading, LoadingComponent }) => {
460
+ var SchemaListComponent = function (_a) {
461
+ var schema = _a.schema, theme = _a.theme, loading = _a.loading, LoadingComponent = _a.LoadingComponent;
378
462
  if (loading) {
379
- return ((0, jsx_runtime_1.jsxs)("div", { style: {
463
+ return (_jsxs("div", __assign({ style: {
380
464
  background: theme.backgroundColor,
381
465
  // maxHeight: 700,
382
466
  width: 250,
@@ -390,9 +474,9 @@ const SchemaListComponent = ({ schema, theme, loading, LoadingComponent }) => {
390
474
  display: 'flex',
391
475
  // alignItems: 'center',
392
476
  justifyContent: 'center',
393
- }, children: [(0, jsx_runtime_1.jsx)("div", { style: { height: 100 } }), LoadingComponent && (0, jsx_runtime_1.jsx)(LoadingComponent, {}), !LoadingComponent && ((0, jsx_runtime_1.jsx)(react_loader_spinner_1.TailSpin, { height: 36, width: 36, color: "#364153" }))] }));
477
+ } }, { children: [_jsx("div", { style: { height: 100 } }), LoadingComponent && _jsx(LoadingComponent, {}), !LoadingComponent && (_jsx(TailSpin, { height: 36, width: 36, color: "#364153" }))] })));
394
478
  }
395
- return ((0, jsx_runtime_1.jsx)("div", { style: {
479
+ return (_jsx("div", __assign({ style: {
396
480
  background: theme.backgroundColor,
397
481
  // maxHeight: 700,
398
482
  width: 250,
@@ -402,11 +486,12 @@ const SchemaListComponent = ({ schema, theme, loading, LoadingComponent }) => {
402
486
  // maxHeight: "100%",
403
487
  paddingLeft: 20,
404
488
  paddingRight: 30,
405
- }, children: schema.map((elem, index) => ((0, jsx_runtime_1.jsx)(SchemaItem, { elem: elem, theme: theme, index: index }, elem.displayName + index))) }));
489
+ } }, { children: schema.map(function (elem, index) { return (_jsx(SchemaItem, { elem: elem, theme: theme, index: index }, elem.displayName + index)); }) })));
406
490
  };
407
- function SchemaItem({ elem, theme, index }) {
408
- const [isOpen, setIsOpen] = (0, react_1.useState)(index === 0);
409
- const schemaContainerStyle = {
491
+ function SchemaItem(_a) {
492
+ var elem = _a.elem, theme = _a.theme, index = _a.index;
493
+ var _b = useState(index === 0), isOpen = _b[0], setIsOpen = _b[1];
494
+ var schemaContainerStyle = {
410
495
  display: 'flex',
411
496
  flexDirection: 'column',
412
497
  // WebkitTouchCallout: "none",
@@ -416,7 +501,7 @@ function SchemaItem({ elem, theme, index }) {
416
501
  // msUserSelect: "none",
417
502
  // userSelect: "none",
418
503
  };
419
- const schemaRowStyle = {
504
+ var schemaRowStyle = {
420
505
  display: 'flex',
421
506
  flexDirection: 'row',
422
507
  alignItems: 'center',
@@ -424,10 +509,10 @@ function SchemaItem({ elem, theme, index }) {
424
509
  justifyContent: 'space-between',
425
510
  cursor: 'pointer',
426
511
  };
427
- const schemaRowHoverStyle = {
512
+ var schemaRowHoverStyle = {
428
513
  background: theme.selectUnderlayColor,
429
514
  };
430
- return ((0, jsx_runtime_1.jsxs)("div", { style: schemaContainerStyle, children: [(0, jsx_runtime_1.jsxs)("div", { style: { ...schemaRowStyle, ...(isOpen && schemaRowHoverStyle) }, onClick: () => setIsOpen(!isOpen), children: [(0, jsx_runtime_1.jsx)("p", { style: {
515
+ return (_jsxs("div", __assign({ style: schemaContainerStyle }, { children: [_jsxs("div", __assign({ style: __assign(__assign({}, schemaRowStyle), (isOpen && schemaRowHoverStyle)), onClick: function () { return setIsOpen(!isOpen); } }, { children: [_jsx("p", __assign({ style: {
431
516
  marginLeft: theme.padding,
432
517
  fontSize: 13,
433
518
  color: '#384151',
@@ -437,8 +522,8 @@ function SchemaItem({ elem, theme, index }) {
437
522
  margin: 0,
438
523
  textOverflow: 'ellipsis',
439
524
  overflow: 'hidden',
440
- fontFamily: theme?.fontFamily,
441
- }, title: elem.displayName, children: elem.displayName }), (0, jsx_runtime_1.jsx)("div", { style: {
525
+ fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
526
+ }, title: elem.displayName }, { children: elem.displayName })), _jsx("div", __assign({ style: {
442
527
  display: 'flex',
443
528
  alignItems: 'center',
444
529
  justifyContent: 'center',
@@ -447,19 +532,19 @@ function SchemaItem({ elem, theme, index }) {
447
532
  paddingBottom: 12,
448
533
  paddingLeft: 0,
449
534
  cursor: 'pointer',
450
- }, children: isOpen ? ((0, jsx_runtime_1.jsx)(solid_1.ChevronDownIcon, { style: { height: 13, width: 13, color: theme.secondaryTextColor }, "aria-hidden": "true" })) : ((0, jsx_runtime_1.jsx)(solid_1.ChevronRightIcon, { style: { height: 13, width: 13, color: theme.secondaryTextColor }, "aria-hidden": "true" })) })] }), isOpen ? ((0, jsx_runtime_1.jsx)("div", { style: {
535
+ } }, { children: isOpen ? (_jsx(ChevronDownIcon, { style: { height: 13, width: 13, color: theme.secondaryTextColor }, "aria-hidden": "true" })) : (_jsx(ChevronRightIcon, { style: { height: 13, width: 13, color: theme.secondaryTextColor }, "aria-hidden": "true" })) }))] })), isOpen ? (_jsx("div", __assign({ style: {
451
536
  paddingBottom: theme.padding,
452
537
  display: 'flex',
453
538
  flexDirection: 'column',
454
539
  paddingLeft: theme.padding,
455
540
  paddingRight: theme.padding,
456
- }, children: elem.columns.map((elem, index) => ((0, jsx_runtime_1.jsxs)("div", { style: {
541
+ } }, { children: elem.columns.map(function (elem, index) { return (_jsxs("div", __assign({ style: {
457
542
  paddingTop: theme.padding,
458
543
  display: 'flex',
459
544
  flexDirection: 'row',
460
545
  alignItems: 'center',
461
546
  justifyContent: 'space-between',
462
- }, children: [(0, jsx_runtime_1.jsx)("div", { title: elem.displayName,
547
+ } }, { children: [_jsx("div", __assign({ title: elem.displayName,
463
548
  // className="text-gray-500"
464
549
  style: {
465
550
  fontSize: 12,
@@ -473,8 +558,8 @@ function SchemaItem({ elem, theme, index }) {
473
558
  overflow: 'hidden',
474
559
  width: 200,
475
560
  maxWidth: 200,
476
- fontFamily: theme?.fontFamily,
477
- }, children: elem.displayName }), (0, jsx_runtime_1.jsx)("div", {
561
+ fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
562
+ } }, { children: elem.displayName })), _jsx("div", __assign({
478
563
  // className="text-gray-500"
479
564
  title: elem.displayName, style: {
480
565
  fontSize: 12,
@@ -482,7 +567,7 @@ function SchemaItem({ elem, theme, index }) {
482
567
  color: theme.secondaryTextColor,
483
568
  padding: 0,
484
569
  margin: 0,
485
- fontFamily: theme?.fontFamily,
486
- }, children: elem.fieldType })] }, elem.displayName + elem.index))) })) : null] }));
570
+ fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
571
+ } }, { children: elem.fieldType }))] }), elem.displayName + elem.index)); }) }))) : null] })));
487
572
  }
488
573
  //# sourceMappingURL=SQLEditor.js.map