@quillsql/react 1.7.4 → 1.7.6

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 (86) hide show
  1. package/lib/AddToDashboardModal.js +2 -2
  2. package/lib/AddToDashboardModal.js.map +1 -1
  3. package/lib/Chart.js +2 -2
  4. package/lib/Chart.js.map +1 -1
  5. package/lib/Context.d.ts +2 -1
  6. package/lib/Context.js +3 -1
  7. package/lib/Context.js.map +1 -1
  8. package/lib/Dashboard.js +2 -2
  9. package/lib/Dashboard.js.map +1 -1
  10. package/lib/QuillProvider.d.ts +2 -1
  11. package/lib/QuillProvider.js +2 -2
  12. package/lib/QuillProvider.js.map +1 -1
  13. package/lib/ReportBuilder.d.ts +1 -1
  14. package/lib/ReportBuilder.js +3 -2
  15. package/lib/ReportBuilder.js.map +1 -1
  16. package/lib/SQLEditor.js +5 -5
  17. package/lib/SQLEditor.js.map +1 -1
  18. package/lib/Table.js +1 -1
  19. package/lib/Table.js.map +1 -1
  20. package/lib/components/BigModal/BigModal.js +1 -0
  21. package/lib/components/BigModal/BigModal.js.map +1 -1
  22. package/lib/components/Modal/Modal.js +1 -0
  23. package/lib/components/Modal/Modal.js.map +1 -1
  24. package/lib/hooks/useQuill.js +3 -2
  25. package/lib/hooks/useQuill.js.map +1 -1
  26. package/package.json +11 -4
  27. package/.eslintrc.json +0 -19
  28. package/.prettierrc +0 -11
  29. package/.vscode/settings.json +0 -10
  30. package/src/AddToDashboardModal.tsx +0 -1213
  31. package/src/BarList.tsx +0 -580
  32. package/src/Chart.tsx +0 -1336
  33. package/src/Context.tsx +0 -249
  34. package/src/Dashboard.tsx +0 -819
  35. package/src/DateRangePicker/Calendar.tsx +0 -442
  36. package/src/DateRangePicker/DateRangePicker.tsx +0 -261
  37. package/src/DateRangePicker/DateRangePickerButton.tsx +0 -250
  38. package/src/DateRangePicker/dateRangePickerUtils.tsx +0 -480
  39. package/src/DateRangePicker/index.ts +0 -4
  40. package/src/PieChart.tsx +0 -845
  41. package/src/QuillProvider.tsx +0 -78
  42. package/src/ReportBuilder.tsx +0 -2202
  43. package/src/SQLEditor.tsx +0 -1087
  44. package/src/Table.tsx +0 -1074
  45. package/src/TableChart.tsx +0 -428
  46. package/src/assets/ArrowDownHeadIcon.tsx +0 -11
  47. package/src/assets/ArrowDownIcon.tsx +0 -14
  48. package/src/assets/ArrowDownRightIcon.tsx +0 -14
  49. package/src/assets/ArrowLeftHeadIcon.tsx +0 -11
  50. package/src/assets/ArrowRightHeadIcon.tsx +0 -11
  51. package/src/assets/ArrowRightIcon.tsx +0 -14
  52. package/src/assets/ArrowUpHeadIcon.tsx +0 -11
  53. package/src/assets/ArrowUpIcon.tsx +0 -14
  54. package/src/assets/ArrowUpRightIcon.tsx +0 -14
  55. package/src/assets/CalendarIcon.tsx +0 -14
  56. package/src/assets/DoubleArrowLeftHeadIcon.tsx +0 -18
  57. package/src/assets/DoubleArrowRightHeadIcon.tsx +0 -20
  58. package/src/assets/ExclamationFilledIcon.tsx +0 -14
  59. package/src/assets/LoadingSpinner.tsx +0 -11
  60. package/src/assets/SearchIcon.tsx +0 -14
  61. package/src/assets/XCircleIcon.tsx +0 -14
  62. package/src/assets/index.ts +0 -16
  63. package/src/components/BigModal/BigModal.tsx +0 -108
  64. package/src/components/Dropdown/Dropdown.tsx +0 -169
  65. package/src/components/Dropdown/DropdownItem.tsx +0 -68
  66. package/src/components/Dropdown/index.ts +0 -2
  67. package/src/components/Modal/Modal.tsx +0 -132
  68. package/src/components/Modal/index.ts +0 -1
  69. package/src/components/selectUtils.ts +0 -60
  70. package/src/contexts/BaseColorContext.tsx +0 -5
  71. package/src/contexts/HoveredValueContext.tsx +0 -12
  72. package/src/contexts/RootStylesContext.tsx +0 -5
  73. package/src/contexts/SelectedValueContext.tsx +0 -13
  74. package/src/contexts/index.ts +0 -4
  75. package/src/hooks/index.ts +0 -4
  76. package/src/hooks/useInternalState.tsx +0 -18
  77. package/src/hooks/useOnClickOutside.tsx +0 -23
  78. package/src/hooks/useOnWindowResize.tsx +0 -17
  79. package/src/hooks/useQuill.ts +0 -137
  80. package/src/hooks/useSelectOnKeyDown.tsx +0 -80
  81. package/src/index.ts +0 -9
  82. package/src/lib/font.ts +0 -14
  83. package/src/lib/index.ts +0 -3
  84. package/src/lib/inputTypes.ts +0 -81
  85. package/src/lib/utils.tsx +0 -46
  86. package/tsconfig.json +0 -22
package/src/SQLEditor.tsx DELETED
@@ -1,1087 +0,0 @@
1
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
- // @ts-ignore
3
- import React, { useState, useContext, useMemo, useEffect } from 'react';
4
- import MonacoEditor from '@monaco-editor/react';
5
- // import './nightOwlLight.css';
6
- import axios from 'axios';
7
- import { ClientContext, SchemaContext, ThemeContext } from './Context';
8
- import {
9
- ChevronDownIcon,
10
- ChevronRightIcon,
11
- SparklesIcon,
12
- MagnifyingGlassIcon,
13
- } from '@heroicons/react/20/solid';
14
- import { QuillTheme } from './QuillProvider';
15
- import { SpecialTable } from './Table';
16
-
17
- export function convertPostgresColumn(column) {
18
- let format;
19
-
20
- switch (column.dataTypeID) {
21
- case 20: // int8
22
- case 21: // int2
23
- case 23: // int4
24
- format = 'whole_number';
25
- break;
26
- case 700: // float4
27
- case 701: // float8
28
- case 1700: // numeric
29
- format = 'two_decimal_places';
30
- break;
31
- case 1082: // date
32
- case 1083: // time
33
- case 1184: // timestamptz
34
- case 1114: // timestamp
35
- format = 'MMM_dd_yyyy';
36
- break;
37
- case 1043: // varchar
38
- default:
39
- format = 'string';
40
- }
41
-
42
- return {
43
- label: column.name,
44
- field: column.name,
45
- format: format,
46
- };
47
- }
48
-
49
- function defineEditorTheme(monaco, theme) {
50
- monaco.editor.defineTheme('onedark', {
51
- base: theme.darkMode ? 'vs-dark' : 'vs',
52
- inherit: true,
53
- rules: [
54
- {
55
- token: 'comment',
56
- foreground: '#5d7988',
57
- fontStyle: 'italic',
58
- },
59
- { token: 'constant', foreground: '#e06c75' },
60
- ],
61
- colors: {
62
- 'editor.background': '#F9F9F9',
63
- },
64
- });
65
- }
66
- function setEditorTheme(editor, monaco) {
67
- try {
68
- monaco.editor.setTheme('onedark');
69
- } catch (e) {
70
- console.log('ERROR: ', e);
71
- }
72
- }
73
-
74
- interface ButtonComponentProps {
75
- onClick: () => void;
76
- label: string;
77
- }
78
-
79
- interface SQLEditorProps {
80
- containerStyle: React.CSSProperties;
81
- ButtonComponent?: (props: ButtonComponentProps) => JSX.Element;
82
- SecondaryButtonComponent?: (props: ButtonComponentProps) => JSX.Element;
83
- TextInputComponent?: (props: TextInputComponentProps) => JSX.Element;
84
- TableComponent?: (props: TableComponentProps) => JSX.Element;
85
- AddToDashboardButton?: (props: AddToDashboardButtonProps) => JSX.Element;
86
- LoadingComponent?: () => JSX.Element;
87
- }
88
-
89
- interface AddToDashboardButtonProps {
90
- rows: any[];
91
- columns: any[];
92
- query: string;
93
- }
94
-
95
- interface TableComponentProps {
96
- rows: any[];
97
- columns: any[];
98
- height: string;
99
- }
100
-
101
- interface TextInputComponentProps {
102
- onChange: (e: any) => void;
103
- value: string;
104
- id: string;
105
- placeholder?: string;
106
- }
107
-
108
- const QuillButton = ({
109
- onClick,
110
- label,
111
- theme,
112
- secondary,
113
- }: {
114
- onClick: () => void;
115
- label: string;
116
- theme?: any;
117
- secondary?: boolean;
118
- }) => (
119
- <button
120
- style={{
121
- borderRadius: '6px',
122
- backgroundColor: secondary
123
- ? theme?.secondaryButtonColor || '#FFFFFF'
124
- : theme?.primaryButtonColor,
125
- opacity: 1,
126
- paddingLeft: '16px',
127
- paddingRight: '16px',
128
- paddingTop: '10px',
129
- paddingBottom: '10px',
130
- fontSize: '14px',
131
- fontWeight: 600,
132
- color: secondary ? theme?.primaryTextColor : '#FFFFFF',
133
- cursor: 'pointer',
134
- outline: 'none',
135
- border: 'none',
136
- fontFamily: theme?.fontFamily,
137
- }}
138
- onClick={onClick}
139
- >
140
- {label}
141
- </button>
142
- );
143
-
144
- const QuillTextInput = ({
145
- onChange,
146
- value,
147
- id,
148
- placeholder,
149
- theme,
150
- }: {
151
- onChange: (e: any) => void;
152
- value: string;
153
- id: string;
154
- placeholder?: string;
155
- theme?: any;
156
- }) => {
157
- return (
158
- <input
159
- style={{
160
- display: 'flex',
161
- flexDirection: 'row',
162
- alignItems: 'center',
163
- paddingLeft: '12px',
164
- paddingRight: '12px',
165
- fontWeight: 'medium',
166
- height: 36,
167
- boxShadow: 'rgba(0, 0, 0, 0.1) 0px 1px 5px 0px',
168
- width: '445px',
169
- backgroundColor: theme?.backgroundColor || 'white',
170
- color: theme?.primaryTextColor,
171
- borderWidth: '1px',
172
- borderColor: theme?.borderColor || '#E7E7E7',
173
- borderStyle: 'solid',
174
- borderRadius: '6px',
175
- }}
176
- id={id}
177
- onChange={onChange}
178
- value={value}
179
- placeholder={placeholder}
180
- />
181
- );
182
- };
183
-
184
- export default function QueryEditor({
185
- containerStyle = { height: '100vh' },
186
- ButtonComponent,
187
- SecondaryButtonComponent,
188
- TextInputComponent,
189
- TableComponent,
190
- AddToDashboardButton,
191
- LoadingComponent,
192
- }: SQLEditorProps) {
193
- const [sqlPrompt, setSqlPrompt] = useState('');
194
-
195
- const [isOpen, setIsOpen] = useState(false);
196
-
197
- const [client] = useContext(ClientContext);
198
- const [theme] =
199
- useContext<[QuillTheme, (theme: QuillTheme) => void]>(ThemeContext);
200
- const [query, setQuery] = useState('');
201
- const [rows, setRows] = useState([]);
202
- const [columns, setColumns] = useState([]);
203
- const [fields, setFields] = useState([]);
204
- const [schema, setSchema] = useContext(SchemaContext);
205
- const [errorMessage, setErrorMessage] = useState('');
206
- const [sqlResponseLoading, setSqlResponseLoading] = useState(false);
207
- const [sqlQueryLoading, setSqlQueryLoading] = useState(false);
208
- const [schemaLoading, setSchemaLoading] = useState(false);
209
-
210
- useEffect(() => {
211
- let isSubscribed = true;
212
- async function getSchema() {
213
- const { publicKey, environment } = client;
214
- setSchemaLoading(true);
215
- const response3 = await axios.get(
216
- `https://quill-344421.uc.r.appspot.com/schema2/${publicKey}/`,
217
- {
218
- headers: {
219
- Authorization: `Bearer `,
220
- environment: environment || undefined,
221
- },
222
- }
223
- );
224
- if (isSubscribed) {
225
- setSchema(response3.data.tables);
226
- setSchemaLoading(false);
227
- }
228
- }
229
- if (isSubscribed) {
230
- getSchema();
231
- }
232
- return () => {
233
- isSubscribed = false;
234
- };
235
- }, []);
236
-
237
- const handleRunSqlPrompt = async () => {
238
- const { publicKey, environment } = client;
239
- setSqlResponseLoading(true);
240
- const response = await axios.post(
241
- `https://quill-344421.uc.r.appspot.com/quillai`,
242
- {
243
- initialQuestion: sqlPrompt,
244
- publicKey: publicKey,
245
- },
246
- {
247
- headers: {
248
- Authorization: `Bearer `,
249
- environment: environment || undefined,
250
- },
251
- }
252
- );
253
- setQuery(response.data.message);
254
- setSqlResponseLoading(false);
255
- };
256
-
257
- const handleRunQuery = async () => {
258
- const { publicKey, customerId, environment, queryEndpoint, queryHeaders } =
259
- client;
260
- try {
261
- let response;
262
- setSqlQueryLoading(true);
263
- if (queryEndpoint) {
264
- response = await axios.post(
265
- queryEndpoint,
266
- { metadata: { query, task: 'query' } },
267
- { headers: queryHeaders }
268
- );
269
- } else {
270
- response = await axios.post(
271
- `https://quill-344421.uc.r.appspot.com/dashquery`,
272
- {
273
- query,
274
- },
275
- {
276
- params: {
277
- orgId: customerId,
278
- publicKey: publicKey,
279
- },
280
- headers: {
281
- Authorization: `Bearer `,
282
- environment: environment || undefined,
283
- },
284
- }
285
- );
286
- }
287
- if (response && response.data && response.data.errorMessage) {
288
- setSqlQueryLoading(false);
289
- setErrorMessage(
290
- 'Failed to run SQL query: ' + response.data.errorMessage
291
- );
292
- setRows([]);
293
- setColumns([]);
294
- setFields([]);
295
- return;
296
- }
297
- setSqlQueryLoading(false);
298
- setErrorMessage('');
299
- setRows(
300
- response.data.rows && response.data.rows.length
301
- ? response.data.rows
302
- : []
303
- );
304
- setColumns(response.data.fields.map(elem => convertPostgresColumn(elem)));
305
- setFields(response.data.fields);
306
- } catch (e) {
307
- console.log('ERROR: ', e);
308
- return;
309
- }
310
- };
311
-
312
- const handleAddToDashboard = () => {
313
- setIsOpen(true);
314
- };
315
-
316
- /* all your useState and useContext calls and your useEffect hooks */
317
-
318
- const downloadCSV = () => {
319
- // report.rows
320
- if (!rows.length) {
321
- return;
322
- }
323
- const json = rows; // JSON data passed as a prop
324
- const fields = Object.keys(json[0]); // Assumes all objects have same keys
325
- const csvRows = [];
326
-
327
- // Header row
328
- csvRows.push(fields.join(','));
329
-
330
- // Data rows
331
- for (const row of json) {
332
- const values = fields.map(field => JSON.stringify(row[field] || ''));
333
- csvRows.push(values.join(','));
334
- }
335
-
336
- // Create CSV string and create a 'blob' with it
337
- const csvString = csvRows.join('\r\n');
338
- const csvBlob = new Blob([csvString], { type: 'text/csv' });
339
-
340
- // Create a download link and click it
341
- const downloadLink = document.createElement('a');
342
- downloadLink.download = `${query}.csv`;
343
- downloadLink.href = URL.createObjectURL(csvBlob);
344
- downloadLink.style.display = 'none';
345
-
346
- document.body.appendChild(downloadLink);
347
- downloadLink.click();
348
- document.body.removeChild(downloadLink);
349
- };
350
-
351
- /* rest of your methods */
352
-
353
- return (
354
- <div style={containerStyle}>
355
- <div
356
- style={{
357
- height: 'calc(100%)',
358
- display: 'flex',
359
- flexDirection: 'column',
360
- padding: 0,
361
- }}
362
- >
363
- <div
364
- style={{ height: '100%', display: 'flex', flexDirection: 'column' }}
365
- >
366
- <div
367
- style={{
368
- width: '100%',
369
- display: 'flex',
370
- height: '100%',
371
- flexDirection: 'row',
372
- }}
373
- >
374
- <SchemaListComponent
375
- schema={schema}
376
- theme={theme}
377
- LoadingComponent={LoadingComponent}
378
- loading={schemaLoading}
379
- />
380
-
381
- <div
382
- style={{
383
- display: 'flex',
384
- flexDirection: 'column',
385
- width: 'calc(100% - 250px)',
386
- }}
387
- >
388
- <div
389
- style={{
390
- // TODO: change color
391
- height: 80,
392
- background: 'white',
393
- display: 'flex',
394
- flexDirection: 'row',
395
- alignItems: 'center',
396
- }}
397
- >
398
- {/* <div
399
- style={{
400
- display: 'flex',
401
- flexDirection: 'row',
402
- alignItems: 'center',
403
- paddingLeft: '12px',
404
- paddingRight: '12px',
405
- height: 38,
406
- boxShadow: 'rgba(0, 0, 0, 0.1) 0px 1px 5px 0px',
407
- width: '445px',
408
- // TODO: change color
409
- borderColor: theme.borderColor,
410
- color: theme.primaryTextColor,
411
- borderWidth: '1px',
412
- // TODO: change color
413
- backgroundColor: 'white',
414
- borderRadius: 6,
415
- borderStyle: 'solid',
416
- outline: 'none',
417
- fontFamily: theme?.fontFamily,
418
- }}
419
- >
420
- <MagnifyingGlassIcon
421
- style={{
422
- height: 16,
423
- width: 16,
424
- color: theme.secondaryTextColor,
425
- }}
426
- aria-hidden="true"
427
- />
428
- <input
429
- value={sqlPrompt}
430
- onChange={e => setSqlPrompt(e.target.value)}
431
- style={{
432
- outline: 'none',
433
- marginLeft: 8,
434
- width: '100%',
435
- border: 'none',
436
- outline: 'none',
437
- fontFamily: theme?.fontFamily,
438
- }}
439
- />
440
- </div> */}
441
- <div style={{ minWidth: 440, marginRight: 10 }}>
442
- {(TextInputComponent && (
443
- <TextInputComponent
444
- id="ai-search"
445
- value={sqlPrompt}
446
- onChange={e => setSqlPrompt(e.target.value)}
447
- placeholder="Ask a question..."
448
- />
449
- )) || (
450
- <QuillTextInput
451
- id="ai-search"
452
- value={sqlPrompt}
453
- onChange={e => setSqlPrompt(e.target.value)}
454
- placeholder="Ask a question..."
455
- theme={theme}
456
- />
457
- )}
458
- </div>
459
- {(ButtonComponent && (
460
- <ButtonComponent
461
- onClick={handleRunSqlPrompt}
462
- label="Ask AI"
463
- />
464
- )) || (
465
- <QuillButton
466
- theme={theme}
467
- onClick={handleRunSqlPrompt}
468
- label="Ask AI"
469
- />
470
- )}
471
- </div>
472
- <div style={{ height: 'calc(50% - 40px)' }}>
473
- <SQLEditorComponent
474
- query={query}
475
- setQuery={setQuery}
476
- handleRunQuery={handleRunQuery}
477
- theme={theme}
478
- defineEditorTheme={defineEditorTheme}
479
- setEditorTheme={setEditorTheme}
480
- ButtonComponent={ButtonComponent}
481
- loading={sqlResponseLoading}
482
- LoadingComponent={LoadingComponent}
483
- />
484
- </div>
485
- <div
486
- style={{
487
- height: 'calc(50% - 40px)',
488
- display: 'flex',
489
- flexDirection: 'column',
490
- padding: 0,
491
- margin: 0,
492
- border: 'none',
493
- outline: 'none',
494
- }}
495
- >
496
- {errorMessage && (
497
- <div
498
- style={{
499
- fontFamily: theme?.fontFamily,
500
- color: theme?.primaryTextColor,
501
- fontSize: 15,
502
- fontWeight: '400',
503
- }}
504
- >
505
- <div
506
- style={{
507
- padding: 30,
508
- // TODO: change color
509
- background: 'rgba(0,0,0,0.02)',
510
- display: 'inline-block',
511
- flex: 0,
512
- borderRadius: 6,
513
- color: theme?.primaryTextColor,
514
- fontFamily: theme?.fontFamily,
515
- }}
516
- >
517
- {errorMessage}
518
- </div>
519
- </div>
520
- )}
521
- {errorMessage
522
- ? null
523
- : (TableComponent && (
524
- <TableComponent
525
- rows={rows}
526
- columns={columns}
527
- height="calc(100% - 70px)"
528
- />
529
- )) || (
530
- <SpecialTable
531
- rows={rows}
532
- columns={columns}
533
- height="calc(100% - 70px)"
534
- LoadingComponent={LoadingComponent}
535
- loading={sqlQueryLoading}
536
- theme={theme}
537
- />
538
- )}
539
- <div
540
- style={{
541
- height: 70,
542
- // TODO: change color
543
- background: theme?.backgroundColor,
544
- }}
545
- >
546
- {rows.length ? (
547
- <div
548
- style={{
549
- display: 'flex',
550
- flexDirection: 'column',
551
- height: 70,
552
- border: 'none',
553
- }}
554
- >
555
- <div
556
- style={{
557
- height: 1,
558
- width: '100%',
559
- // TODO: change color
560
- // background: theme.borderColor,
561
- }}
562
- />
563
- <div
564
- style={{
565
- marginLeft: 0,
566
- height: 69,
567
- display: 'flex',
568
- alignItems: 'center',
569
- justifyContent: 'flex-end',
570
- paddingRight: 20,
571
- }}
572
- >
573
- {/* <button
574
- type="button"
575
- onClick={downloadCSV}
576
- style={{
577
- borderRadius: 6,
578
- // TODO: change color
579
- backgroundColor: theme.primaryButtonColor,
580
- paddingLeft: '1rem',
581
- paddingRight: '1rem',
582
- paddingTop: '0.5rem',
583
- paddingBottom: '0.5rem',
584
- fontSize: '0.875rem',
585
- fontWeight: '600',
586
- // TODO: change color
587
- color: theme.backgroundColor,
588
- fontFamily: theme.fontFamily,
589
- outline: 'none',
590
- border: 'none',
591
- cursor: 'pointer',
592
- marginTop: 14,
593
- }}
594
- >
595
- Download CSV
596
- </button> */}
597
- {(SecondaryButtonComponent && (
598
- <SecondaryButtonComponent
599
- onClick={downloadCSV}
600
- label="Download CSV"
601
- />
602
- )) || (
603
- <QuillButton
604
- theme={theme}
605
- onClick={downloadCSV}
606
- label="Download CSV"
607
- secondary
608
- />
609
- )}
610
- {AddToDashboardButton && <div style={{ width: 10 }} />}
611
- {AddToDashboardButton && (
612
- <AddToDashboardButton
613
- // @ts-ignore
614
- rows={rows}
615
- columns={columns}
616
- query={query}
617
- />
618
- )}
619
- <div />
620
- </div>
621
- </div>
622
- ) : null}
623
- </div>
624
- </div>
625
- </div>
626
- </div>
627
- </div>
628
- </div>
629
- </div>
630
- );
631
- }
632
-
633
- const SQLEditorComponent = ({
634
- query,
635
- setQuery,
636
- handleRunQuery,
637
- defineEditorTheme,
638
- setEditorTheme,
639
- ButtonComponent,
640
- theme,
641
- loading,
642
- LoadingComponent,
643
- }) => {
644
- return (
645
- <div
646
- style={{
647
- background: theme.backgroundColor,
648
- // maxHeight: 700,
649
- width: '100%',
650
- height: '100%',
651
- // minWidth: 450,
652
- // overflowY: "scroll",
653
- // padding: "20px 30px 20px 20px",
654
- // marginLeft: 20,
655
- borderTopLeftRadius: 6,
656
- borderBottomLeftRadius: 6,
657
- borderTopRightRadius: 0,
658
- borderBottomRightRadius: 0,
659
- overflow: 'hidden',
660
- }}
661
- >
662
- {loading ? (
663
- <div
664
- style={{
665
- height: 'calc(100% - 70px)',
666
- width: '100%',
667
- display: 'flex',
668
- alignItems: 'center',
669
- justifyContent: 'center',
670
- background: '#F9F9F9',
671
- }}
672
- >
673
- {LoadingComponent && <LoadingComponent />}
674
- {!LoadingComponent && (
675
- <svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">
676
- <defs>
677
- <linearGradient
678
- id="circleGradient"
679
- gradientUnits="objectBoundingBox"
680
- >
681
- <stop offset="0%" stop-color="#F9F9FA" />
682
- <stop offset="5%" stop-color="#F9F9FA" />
683
- <stop offset="100%" stop-color="#D1D1D1" />
684
- </linearGradient>
685
- <mask id="mask">
686
- <circle cx="12" cy="12" r="12" fill="white" />
687
- <path
688
- id="sector"
689
- fill="black"
690
- d="M15,15 L15,1.8 A13.2,13.2 0 0,1 15,1.8 Z"
691
- >
692
- <animate
693
- attributeName="d"
694
- from="M15,15 L15,1.8 A13.2,13.2 0 0,0 15,1.8 Z"
695
- to="M15,15 L15,1.8 A13.2,13.2 0 1,1 15,1.8 Z"
696
- dur="2s"
697
- repeatCount="indefinite"
698
- />
699
- </path>
700
- </mask>
701
- </defs>
702
- <g transform="rotate(0 15 15)">
703
- <animateTransform
704
- attributeName="transform"
705
- attributeType="XML"
706
- type="rotate"
707
- from="0 12 12"
708
- to="360 12 12"
709
- dur="2s"
710
- repeatCount="indefinite"
711
- />
712
- <circle
713
- cx="12"
714
- cy="12"
715
- r="12"
716
- fill="none"
717
- stroke="url(#circleGradient)"
718
- stroke-width="8"
719
- mask="url(#mask)"
720
- />
721
- </g>
722
- </svg>
723
- )}
724
- </div>
725
- ) : (
726
- <MonacoEditor
727
- height="calc(100% - 70px)"
728
- width="100%"
729
- defaultLanguage="pgsql"
730
- defaultValue=""
731
- value={query}
732
- loading={<div />}
733
- options={{
734
- wordWrap: 'on',
735
- minimap: {
736
- enabled: false,
737
- },
738
- padding: { top: 16 },
739
- }}
740
- onChange={query => setQuery(query)}
741
- beforeMount={monaco => defineEditorTheme(monaco, theme)}
742
- onMount={setEditorTheme}
743
- />
744
- )}
745
- <div
746
- style={{
747
- display: 'flex',
748
- flexDirection: 'row',
749
- alignItems: 'center',
750
- height: 70,
751
- }}
752
- >
753
- {/* <button
754
- type="button"
755
- onClick={handleRunQuery}
756
- style={{
757
- borderRadius: 8,
758
- width: '100px',
759
- // backgroundColor: "#212121",
760
- height: '32px',
761
- fontSize: 14,
762
- fontWeight: '600',
763
- backgroundColor: 'transparent',
764
- color: '#384151',
765
- border: 'none',
766
- outline: 'none',
767
- cursor: 'pointer',
768
- }}
769
- >
770
- Run query
771
- </button> */}
772
- {/* <button
773
- type="button"
774
- onClick={handleRunQuery}
775
- style={{
776
- borderRadius: 6,
777
- backgroundColor: theme.primaryButtonColor,
778
- height: 32,
779
- width: 100,
780
- marginLeft: 0,
781
- // paddingLeft: '1rem',
782
- // paddingRight: '1rem',
783
- // paddingTop: '0.5rem',
784
- // paddingBottom: '0.5rem',
785
- fontSize: '0.875rem',
786
- fontWeight: '600',
787
- color: theme.backgroundColor,
788
- fontFamily: theme.fontFamily,
789
- outline: 'none',
790
- border: 'none',
791
- cursor: 'pointer',
792
- }}
793
- >
794
- Run query
795
- </button> */}
796
- {(ButtonComponent && (
797
- <ButtonComponent onClick={handleRunQuery} label="Run query" />
798
- )) || (
799
- <QuillButton
800
- onClick={handleRunQuery}
801
- label="Run query"
802
- theme={theme}
803
- />
804
- )}
805
- </div>
806
- </div>
807
- );
808
- };
809
-
810
- const styles = {
811
- columnHeader: {
812
- boxSizing: 'border-box',
813
- flex: '150 0 auto',
814
- minWidth: '50px',
815
- width: '150px',
816
- position: 'relative',
817
- cursor: 'pointer',
818
- background: 'rgb(249, 250, 251)',
819
- borderRight: '1px solid rgb(229, 231, 235)',
820
- whiteSpace: 'nowrap',
821
- display: 'flex',
822
- alignItems: 'center',
823
- overflowX: 'visible',
824
- margin: '0px',
825
- textOverflow: 'ellipsis',
826
- minHeight: '36px',
827
- // 2.25rem * 16px = 36px
828
- },
829
- columnHeaderLabel: {
830
- fontFamily:
831
- 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',
832
- WebkitTapHighlightColor: 'transparent',
833
- color: 'rgb(55, 65, 81)',
834
- textDecoration: 'none',
835
- fontWeight: 500,
836
- fontSize: '14px', // 0.875rem * 16px = 14px
837
- lineHeight: '20px', // 1.25rem * 16px = 20px
838
- textOverflow: 'ellipsis',
839
- whiteSpace: 'nowrap',
840
- overflow: 'hidden',
841
- },
842
- };
843
-
844
- const SchemaListComponent = ({ schema, theme, loading, LoadingComponent }) => {
845
- if (loading) {
846
- return (
847
- <div
848
- style={{
849
- background: theme.backgroundColor,
850
- // maxHeight: 700,
851
- width: 250,
852
- minWidth: 250,
853
- // overflowY: 'scroll',
854
- height: '100%',
855
- // maxHeight: "100%",
856
- paddingLeft: 20,
857
- paddingRight: 30,
858
- paddingTop: 40,
859
- display: 'flex',
860
- // alignItems: 'center',
861
- justifyContent: 'center',
862
- }}
863
- >
864
- <div style={{ height: 100 }} />
865
- {LoadingComponent && <LoadingComponent />}
866
- {!LoadingComponent && (
867
- <svg width="24" height="24" xmlns="http://www.w3.org/2000/svg">
868
- <defs>
869
- <linearGradient
870
- id="circleGradient"
871
- gradientUnits="objectBoundingBox"
872
- >
873
- <stop offset="0%" stop-color="#F9F9FA" />
874
- <stop offset="5%" stop-color="#F9F9FA" />
875
- <stop offset="100%" stop-color="#D1D1D1" />
876
- </linearGradient>
877
- <mask id="mask">
878
- <circle cx="12" cy="12" r="12" fill="white" />
879
- <path
880
- id="sector"
881
- fill="black"
882
- d="M15,15 L15,1.8 A13.2,13.2 0 0,1 15,1.8 Z"
883
- >
884
- <animate
885
- attributeName="d"
886
- from="M15,15 L15,1.8 A13.2,13.2 0 0,0 15,1.8 Z"
887
- to="M15,15 L15,1.8 A13.2,13.2 0 1,1 15,1.8 Z"
888
- dur="2s"
889
- repeatCount="indefinite"
890
- />
891
- </path>
892
- </mask>
893
- </defs>
894
- <g transform="rotate(0 15 15)">
895
- <animateTransform
896
- attributeName="transform"
897
- attributeType="XML"
898
- type="rotate"
899
- from="0 12 12"
900
- to="360 12 12"
901
- dur="2s"
902
- repeatCount="indefinite"
903
- />
904
- <circle
905
- cx="12"
906
- cy="12"
907
- r="12"
908
- fill="none"
909
- stroke="url(#circleGradient)"
910
- stroke-width="8"
911
- mask="url(#mask)"
912
- />
913
- </g>
914
- </svg>
915
- )}
916
- </div>
917
- );
918
- }
919
- return (
920
- <div
921
- style={{
922
- background: theme.backgroundColor,
923
- // maxHeight: 700,
924
- width: 250,
925
- minWidth: 250,
926
- overflowY: 'scroll',
927
- height: '100%',
928
- // maxHeight: "100%",
929
- paddingLeft: 20,
930
- paddingRight: 30,
931
- }}
932
- >
933
- {schema.map((elem, index) => (
934
- <SchemaItem
935
- key={elem.displayName + index}
936
- elem={elem}
937
- theme={theme}
938
- index={index}
939
- />
940
- ))}
941
- </div>
942
- );
943
- };
944
-
945
- function SchemaItem({ elem, theme, index }) {
946
- const [isOpen, setIsOpen] = useState(index === 0);
947
-
948
- const schemaContainerStyle = {
949
- display: 'flex',
950
- flexDirection: 'column',
951
- // WebkitTouchCallout: "none",
952
- // WebkitUserSelect: "none",
953
- // KhtmlUserSelect: "none",
954
- // MozUserSelect: "none",
955
- // msUserSelect: "none",
956
- // userSelect: "none",
957
- };
958
-
959
- const schemaRowStyle = {
960
- display: 'flex',
961
- flexDirection: 'row',
962
- alignItems: 'center',
963
- width: '100%',
964
- justifyContent: 'space-between',
965
- cursor: 'pointer',
966
- };
967
-
968
- const schemaRowHoverStyle = {
969
- background: theme.selectUnderlayColor,
970
- };
971
-
972
- return (
973
- <div style={schemaContainerStyle}>
974
- <div
975
- style={{ ...schemaRowStyle, ...(isOpen && schemaRowHoverStyle) }}
976
- onClick={() => setIsOpen(!isOpen)}
977
- >
978
- <p
979
- style={{
980
- marginLeft: theme.padding,
981
- fontSize: 13,
982
- color: '#384151',
983
- fontWeight: '500',
984
- whiteSpace: 'nowrap',
985
- padding: 0,
986
- margin: 0,
987
- textOverflow: 'ellipsis',
988
- overflow: 'hidden',
989
- fontFamily: theme?.fontFamily,
990
- }}
991
- title={elem.displayName}
992
- >
993
- {elem.displayName}
994
- </p>
995
- <div
996
- style={{
997
- display: 'flex',
998
- alignItems: 'center',
999
- justifyContent: 'center',
1000
- // paddingRight: 25,
1001
- paddingTop: 12,
1002
- paddingBottom: 12,
1003
- paddingLeft: 0,
1004
- cursor: 'pointer',
1005
- }}
1006
- >
1007
- {/* <Arrow
1008
- fill={theme.fontColor}
1009
- style={{
1010
- transform: isOpen ? "scale(0.8) rotate(90deg)" : "scale(0.8)",
1011
- }}
1012
- /> */}
1013
- {isOpen ? (
1014
- <ChevronDownIcon
1015
- style={{ height: 13, width: 13, color: theme.secondaryTextColor }}
1016
- aria-hidden="true"
1017
- />
1018
- ) : (
1019
- <ChevronRightIcon
1020
- style={{ height: 13, width: 13, color: theme.secondaryTextColor }}
1021
- aria-hidden="true"
1022
- />
1023
- )}
1024
- </div>
1025
- </div>
1026
- {isOpen ? (
1027
- <div
1028
- style={{
1029
- paddingBottom: theme.padding,
1030
- display: 'flex',
1031
- flexDirection: 'column',
1032
- paddingLeft: theme.padding,
1033
- paddingRight: theme.padding,
1034
- }}
1035
- >
1036
- {elem.columns.map((elem, index) => (
1037
- <div
1038
- key={elem.displayName + elem.index}
1039
- style={{
1040
- paddingTop: theme.padding,
1041
- display: 'flex',
1042
- flexDirection: 'row',
1043
- alignItems: 'center',
1044
- justifyContent: 'space-between',
1045
- }}
1046
- >
1047
- <div
1048
- title={elem.displayName}
1049
- // className="text-gray-500"
1050
- style={{
1051
- fontSize: 12,
1052
- // color: theme.secondaryFontColor,
1053
- whiteSpace: 'nowrap',
1054
- color: theme.secondaryTextColor,
1055
- // color: "#6C727F",
1056
- padding: 0,
1057
- margin: 0,
1058
- textOverflow: 'ellipsis',
1059
- overflow: 'hidden',
1060
- width: 200,
1061
- maxWidth: 200,
1062
- fontFamily: theme?.fontFamily,
1063
- }}
1064
- >
1065
- {elem.displayName}
1066
- </div>
1067
- <div
1068
- // className="text-gray-500"
1069
- title={elem.displayName}
1070
- style={{
1071
- fontSize: 12,
1072
- // color: '#6C727F',
1073
- color: theme.secondaryTextColor,
1074
- padding: 0,
1075
- margin: 0,
1076
- fontFamily: theme?.fontFamily,
1077
- }}
1078
- >
1079
- {elem.fieldType}
1080
- </div>
1081
- </div>
1082
- ))}
1083
- </div>
1084
- ) : null}
1085
- </div>
1086
- );
1087
- }