@quillsql/react 1.7.5 → 1.7.7

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