@quillsql/react 1.6.6 → 1.6.8

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.
package/src/Table.tsx CHANGED
@@ -10,8 +10,9 @@ import {
10
10
  } from './Context';
11
11
  import Skeleton from 'react-loading-skeleton';
12
12
  import { valueFormatter } from './Chart';
13
- import { SpecialTable } from './SQLEditor';
13
+ // import { SpecialTable } from './SQLEditor';
14
14
  import { QuillTheme } from './QuillProvider';
15
+ import { TailSpin } from 'react-loader-spinner';
15
16
 
16
17
  interface TableColumn {
17
18
  label: string;
@@ -103,6 +104,602 @@ const Table = ({
103
104
  );
104
105
  };
105
106
 
107
+ interface TableButtonComponentProps {
108
+ onClick: () => void;
109
+ }
110
+
111
+ export function SpecialTable({
112
+ columns,
113
+ rows,
114
+ height,
115
+ containerStyle,
116
+ loading,
117
+ LoadingComponent,
118
+ theme,
119
+ showDownloadCsvButton,
120
+ csvFilename,
121
+ DownloadCSVButtonComponent,
122
+ AddToDashboardButtonComponent,
123
+ }: {
124
+ columns: any[];
125
+ rows: any[];
126
+ height: string;
127
+ containerStyle?: React.CSSProperties;
128
+ loading?: boolean;
129
+ LoadingComponent?: () => JSX.Element;
130
+ theme?: any;
131
+ showDownloadCsvButton?: boolean;
132
+ csvFilename?: string;
133
+ DownloadCSVButtonComponent?: (
134
+ props: TableButtonComponentProps
135
+ ) => JSX.Element;
136
+ AddToDashboardButtonComponent?: (
137
+ props: TableButtonComponentProps
138
+ ) => JSX.Element;
139
+ }) {
140
+ const downloadCSV = () => {
141
+ // report.rows
142
+ if (!rows.length) {
143
+ return;
144
+ }
145
+ const json = rows; // JSON data passed as a prop
146
+ const fields = Object.keys(json[0]); // Assumes all objects have same keys
147
+ const csvRows = [];
148
+
149
+ // Header row
150
+ csvRows.push(fields.join(','));
151
+
152
+ // Data rows
153
+ for (const row of json) {
154
+ const values = fields.map(field => JSON.stringify(row[field] || ''));
155
+ csvRows.push(values.join(','));
156
+ }
157
+
158
+ // Create CSV string and create a 'blob' with it
159
+ const csvString = csvRows.join('\r\n');
160
+ const csvBlob = new Blob([csvString], { type: 'text/csv' });
161
+
162
+ // Create a download link and click it
163
+ const downloadLink = document.createElement('a');
164
+ downloadLink.download = `${csvFilename}.csv`;
165
+ downloadLink.href = URL.createObjectURL(csvBlob);
166
+ downloadLink.style.display = 'none';
167
+
168
+ document.body.appendChild(downloadLink);
169
+ downloadLink.click();
170
+ document.body.removeChild(downloadLink);
171
+ };
172
+ if (loading) {
173
+ return (
174
+ <div
175
+ style={{
176
+ ...containerStyle,
177
+ // paddingLeft: 25,
178
+ // paddingRight: 25,
179
+ // borderRadius: 8,
180
+ // marginTop: 25,
181
+ // overflow: 'visible',
182
+ width: '100%',
183
+ height: height,
184
+ // overflow: 'hidden',
185
+ // @ts-ignore
186
+ // boxShadow: 'rgba(231, 231, 231, 0.5) 0px 1px 2px 0px',
187
+ }}
188
+ >
189
+ <div
190
+ style={{
191
+ height: '100%',
192
+ overflow: 'scroll',
193
+ borderRadius: 6,
194
+ border: '1px solid rgb(229, 231, 235)',
195
+ padding: 0,
196
+ margin: 0,
197
+ // border: 'none',
198
+ boxSizing: 'border-box',
199
+ outline: 'none',
200
+ display: 'flex',
201
+ flexDirection: 'column',
202
+ justifyContent: 'center',
203
+ alignItems: 'center',
204
+ // maxHeight: 600,
205
+ }}
206
+ >
207
+ {LoadingComponent && <LoadingComponent />}
208
+ {!LoadingComponent && (
209
+ <TailSpin height={36} width={36} color="#364153" />
210
+ )}
211
+ </div>
212
+ </div>
213
+ );
214
+ }
215
+ if (!columns || !columns.length || !rows) {
216
+ return null;
217
+ }
218
+
219
+ if (showDownloadCsvButton) {
220
+ return (
221
+ <div
222
+ style={{
223
+ ...containerStyle,
224
+ // paddingLeft: 25,
225
+ // paddingRight: 25,
226
+ // borderRadius: 8,
227
+ // marginTop: 25,
228
+ overflow: 'visible',
229
+ height: height,
230
+ // overflow: 'hidden',
231
+ // @ts-ignore
232
+ // boxShadow: 'rgba(231, 231, 231, 0.5) 0px 1px 2px 0px',
233
+ }}
234
+ >
235
+ <div style={{ height: 50, background: 'white' }} className="thead">
236
+ <div
237
+ role="row"
238
+ className="tr"
239
+ style={{
240
+ display: 'flex',
241
+ flex: '1 0 auto',
242
+ minWidth: '100px',
243
+ boxSizing: 'border-box',
244
+ alignItems: 'center',
245
+ height: 50,
246
+ // position: 'absolute',
247
+ // bottom: 0,
248
+ }}
249
+ >
250
+ {DownloadCSVButtonComponent && (
251
+ <DownloadCSVButtonComponent onClick={downloadCSV} />
252
+ )}
253
+ {!DownloadCSVButtonComponent && (
254
+ <div
255
+ onClick={downloadCSV}
256
+ style={{
257
+ height: 40,
258
+ minHeight: 40,
259
+ color: theme?.primaryTextColor,
260
+ boxSizing: 'content-box',
261
+ fontFamily: theme?.chartLabelFontFamily || theme?.fontFamily,
262
+ fontSize: theme?.fontSizeSmall || '14px',
263
+ fontWeight: theme?.fontWeightMedium || '500',
264
+ // marginTop: 8,
265
+ marginLeft: 20,
266
+ alignItems: 'center',
267
+ display: 'flex',
268
+ cursor: 'pointer',
269
+ }}
270
+ >
271
+ Download CSV
272
+ </div>
273
+ )}
274
+ </div>
275
+ </div>
276
+ <div
277
+ style={{
278
+ height: 'calc(100% - 50px)',
279
+ overflow: 'scroll',
280
+ borderRadius: 6,
281
+ border: '1px solid rgb(229, 231, 235)',
282
+ padding: 0,
283
+ margin: 0,
284
+ // border: 'none',
285
+ boxSizing: 'border-box',
286
+ outline: 'none',
287
+ // maxHeight: 600,
288
+ }}
289
+ >
290
+ <div role="table" className="table" style={{ minWidth: '0px' }}>
291
+ <div className="thead">
292
+ <div
293
+ role="row"
294
+ className="tr"
295
+ style={{
296
+ display: 'flex',
297
+ flex: '1 0 auto',
298
+ minWidth: '100px',
299
+ boxSizing: 'border-box',
300
+ }}
301
+ >
302
+ {/* @ts-ignore */}
303
+ {columns.map((column, index) => (
304
+ <div
305
+ key={'sqlcol' + index}
306
+ // @ts-ignore
307
+ style={{
308
+ boxSizing: 'border-box',
309
+ flex: '150 0 auto',
310
+ minWidth: '50px',
311
+ width: '150px',
312
+ position: 'relative',
313
+ cursor: 'pointer',
314
+ background: 'rgb(249, 250, 251)',
315
+ borderRight: '1px solid rgb(229, 231, 235)',
316
+ whiteSpace: 'nowrap',
317
+ display: 'flex',
318
+ alignItems: 'center',
319
+ overflowX: 'visible',
320
+ margin: '0px',
321
+ textOverflow: 'ellipsis',
322
+ minHeight: '36px',
323
+ }}
324
+ >
325
+ <div style={{ width: 16 }} />
326
+ <div
327
+ aria-haspopup="dialog"
328
+ aria-expanded="false"
329
+ aria-controls="mantine-r6-dropdown"
330
+ // @ts-ignore
331
+ style={{
332
+ // fontFamily:
333
+ // 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',
334
+ WebkitTapHighlightColor: 'transparent',
335
+ fontFamily: theme?.fontFamily,
336
+ // color: 'rgb(55, 65, 81)',
337
+ color: theme?.primaryTextColor,
338
+ textDecoration: 'none',
339
+ fontSize: theme?.fontSizeSmall || '14px',
340
+ fontWeight: theme?.fontWeightMedium || '500',
341
+ lineHeight: '20px', // 1.25rem * 16px = 20px
342
+ textOverflow: 'ellipsis',
343
+ whiteSpace: 'nowrap',
344
+ overflow: 'hidden',
345
+ }}
346
+ >
347
+ {column.label}
348
+ </div>
349
+ </div>
350
+ ))}
351
+ </div>
352
+ </div>
353
+ <div role="rowgroup" className="tbody">
354
+ {/* @ts-ignore */}
355
+ {!rows.length ? (
356
+ <div
357
+ key={'sqlrow0'}
358
+ role="row"
359
+ className="tr"
360
+ style={{
361
+ display: 'flex',
362
+ flex: '1 0 auto',
363
+ minWidth: '100px',
364
+ boxSizing: 'border-box',
365
+ }}
366
+ >
367
+ <div
368
+ key={'sqlcell0'}
369
+ role="cell"
370
+ className="td airplane-1h7muk6"
371
+ style={{
372
+ boxSizing: 'border-box',
373
+ flex: '150 0 auto',
374
+ minWidth: '50px',
375
+ width: '150px',
376
+ display: 'flex',
377
+ margin: '0px',
378
+ textOverflow: 'ellipsis',
379
+ minHeight: '36px',
380
+ borderRight: '1px solid rgb(229, 231, 235)',
381
+ overflow: 'hidden',
382
+ borderTop: '1px solid rgb(229, 231, 235)',
383
+ }}
384
+ >
385
+ <div
386
+ style={{
387
+ lineHeight: '24px',
388
+ width: '100%',
389
+ display: 'flex',
390
+ cursor: 'default',
391
+ position: 'relative',
392
+ }}
393
+ className="airplane-gowkln"
394
+ data-testid="static-cell"
395
+ >
396
+ <div
397
+ className="airplane-Text-root airplane-mzqt6k"
398
+ aria-haspopup="dialog"
399
+ aria-expanded="false"
400
+ aria-controls="mantine-r8-dropdown"
401
+ id="mantine-r8-target"
402
+ style={{
403
+ fontFamily:
404
+ theme?.fontFamily ||
405
+ 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',
406
+ WebkitTapHighlightColor: 'transparent',
407
+ // color: 'rgb(55, 65, 81)',
408
+ color: theme?.secondaryTextColor || 'rgb(55, 65, 81)',
409
+ textDecoration: 'none',
410
+ fontWeight: 400,
411
+ fontSize: theme?.fontSizeSmall || '14px',
412
+ lineHeight: '20px',
413
+ textOverflow: 'ellipsis',
414
+ whiteSpace: 'nowrap',
415
+ overflow: 'hidden',
416
+ padding: '8px 16px',
417
+ }}
418
+ >
419
+ No rows returned
420
+ </div>
421
+ </div>
422
+ </div>
423
+ </div>
424
+ ) : (
425
+ rows.map((row, rowIndex) => (
426
+ <div
427
+ key={'sqlrow' + rowIndex}
428
+ role="row"
429
+ className="tr"
430
+ style={{
431
+ display: 'flex',
432
+ flex: '1 0 auto',
433
+ minWidth: '100px',
434
+ boxSizing: 'border-box',
435
+ }}
436
+ >
437
+ {/* @ts-ignore */}
438
+ {columns.map((column, columnIndex) => (
439
+ <div
440
+ key={'sqlcell' + columnIndex}
441
+ role="cell"
442
+ className="td airplane-1h7muk6"
443
+ style={{
444
+ boxSizing: 'border-box',
445
+ flex: '150 0 auto',
446
+ minWidth: '50px',
447
+ width: '150px',
448
+ display: 'flex',
449
+ margin: '0px',
450
+ textOverflow: 'ellipsis',
451
+ minHeight: '36px',
452
+ borderRight: '1px solid rgb(229, 231, 235)',
453
+ overflow: 'hidden',
454
+ borderTop: '1px solid rgb(229, 231, 235)',
455
+ borderBottom:
456
+ rowIndex === rows.length - 1
457
+ ? '1px solid rgb(229, 231, 235)'
458
+ : undefined,
459
+ }}
460
+ >
461
+ <div
462
+ style={{
463
+ lineHeight: '24px',
464
+ width: '100%',
465
+ display: 'flex',
466
+ cursor: 'default',
467
+ position: 'relative',
468
+ }}
469
+ className="airplane-gowkln"
470
+ data-testid="static-cell"
471
+ >
472
+ <div
473
+ className="airplane-Text-root airplane-mzqt6k"
474
+ aria-haspopup="dialog"
475
+ aria-expanded="false"
476
+ aria-controls="mantine-r8-dropdown"
477
+ id="mantine-r8-target"
478
+ style={{
479
+ fontFamily:
480
+ theme?.fontFamily ||
481
+ 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',
482
+ WebkitTapHighlightColor: 'transparent',
483
+ // color: 'rgb(55, 65, 81)',
484
+ color:
485
+ theme?.secondaryTextColor || 'rgb(55, 65, 81)',
486
+ textDecoration: 'none',
487
+ fontWeight: 400,
488
+ fontSize: theme?.fontSizeSmall || '14px',
489
+ lineHeight: '20px',
490
+ textOverflow: 'ellipsis',
491
+ whiteSpace: 'nowrap',
492
+ overflow: 'hidden',
493
+ padding: '8px 16px',
494
+ }}
495
+ >
496
+ {typeof row[column.field] === 'object'
497
+ ? JSON.stringify(row[column.field]).length > 55
498
+ ? JSON.stringify(row[column.field]).substring(
499
+ 0,
500
+ 52
501
+ ) + '...'
502
+ : JSON.stringify(row[column.field])
503
+ : row[column.field].length > 55
504
+ ? row[column.field].substring(0, 52) + '...'
505
+ : row[column.field]}
506
+ </div>
507
+ </div>
508
+ </div>
509
+ ))}
510
+ </div>
511
+ ))
512
+ )}
513
+ </div>
514
+ </div>
515
+ </div>
516
+ </div>
517
+ );
518
+ }
519
+
520
+ return (
521
+ <div
522
+ style={{
523
+ ...containerStyle,
524
+ // paddingLeft: 25,
525
+ // paddingRight: 25,
526
+ // borderRadius: 8,
527
+ // marginTop: 25,
528
+ overflow: 'visible',
529
+ height: height,
530
+ // overflow: 'hidden',
531
+ // @ts-ignore
532
+ // boxShadow: 'rgba(231, 231, 231, 0.5) 0px 1px 2px 0px',
533
+ }}
534
+ >
535
+ <div
536
+ style={{
537
+ height: '100%',
538
+ overflow: 'scroll',
539
+ borderRadius: 6,
540
+ border: '1px solid rgb(229, 231, 235)',
541
+ padding: 0,
542
+ margin: 0,
543
+ // border: 'none',
544
+ boxSizing: 'border-box',
545
+ outline: 'none',
546
+ // maxHeight: 600,
547
+ }}
548
+ >
549
+ <div role="table" className="table" style={{ minWidth: '0px' }}>
550
+ <div className="thead">
551
+ <div
552
+ role="row"
553
+ className="tr"
554
+ style={{
555
+ display: 'flex',
556
+ flex: '1 0 auto',
557
+ minWidth: '100px',
558
+ boxSizing: 'border-box',
559
+ }}
560
+ >
561
+ {/* @ts-ignore */}
562
+ {columns.map((column, index) => (
563
+ <div
564
+ key={'sqlcol' + index}
565
+ // @ts-ignore
566
+ style={{
567
+ boxSizing: 'border-box',
568
+ flex: '150 0 auto',
569
+ minWidth: '50px',
570
+ width: '150px',
571
+ position: 'relative',
572
+ cursor: 'pointer',
573
+ background: 'rgb(249, 250, 251)',
574
+ borderRight: '1px solid rgb(229, 231, 235)',
575
+ whiteSpace: 'nowrap',
576
+ display: 'flex',
577
+ alignItems: 'center',
578
+ overflowX: 'visible',
579
+ margin: '0px',
580
+ textOverflow: 'ellipsis',
581
+ minHeight: '36px',
582
+ }}
583
+ >
584
+ <div style={{ width: 16 }} />
585
+ <div
586
+ aria-haspopup="dialog"
587
+ aria-expanded="false"
588
+ aria-controls="mantine-r6-dropdown"
589
+ // @ts-ignore
590
+ style={{
591
+ // fontFamily:
592
+ // 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',
593
+ WebkitTapHighlightColor: 'transparent',
594
+ fontFamily: theme?.fontFamily,
595
+ // color: 'rgb(55, 65, 81)',
596
+ color: theme?.primaryTextColor,
597
+ textDecoration: 'none',
598
+ fontSize: theme?.fontSizeSmall || '14px',
599
+ fontWeight: theme?.fontWeightMedium || '500',
600
+ lineHeight: '20px', // 1.25rem * 16px = 20px
601
+ textOverflow: 'ellipsis',
602
+ whiteSpace: 'nowrap',
603
+ overflow: 'hidden',
604
+ }}
605
+ >
606
+ {column.label}
607
+ </div>
608
+ </div>
609
+ ))}
610
+ </div>
611
+ </div>
612
+ <div role="rowgroup" className="tbody">
613
+ {/* @ts-ignore */}
614
+ {rows.map((row, rowIndex) => (
615
+ <div
616
+ key={'sqlrow' + rowIndex}
617
+ role="row"
618
+ className="tr"
619
+ style={{
620
+ display: 'flex',
621
+ flex: '1 0 auto',
622
+ minWidth: '100px',
623
+ boxSizing: 'border-box',
624
+ }}
625
+ >
626
+ {/* @ts-ignore */}
627
+ {columns.map((column, columnIndex) => (
628
+ <div
629
+ key={'sqlcell' + columnIndex}
630
+ role="cell"
631
+ className="td airplane-1h7muk6"
632
+ style={{
633
+ boxSizing: 'border-box',
634
+ flex: '150 0 auto',
635
+ minWidth: '50px',
636
+ width: '150px',
637
+ display: 'flex',
638
+ margin: '0px',
639
+ textOverflow: 'ellipsis',
640
+ minHeight: '36px',
641
+ borderRight: '1px solid rgb(229, 231, 235)',
642
+ overflow: 'hidden',
643
+ borderTop: '1px solid rgb(229, 231, 235)',
644
+ }}
645
+ >
646
+ <div
647
+ style={{
648
+ lineHeight: '24px',
649
+ width: '100%',
650
+ display: 'flex',
651
+ cursor: 'default',
652
+ position: 'relative',
653
+ }}
654
+ className="airplane-gowkln"
655
+ data-testid="static-cell"
656
+ >
657
+ <div
658
+ className="airplane-Text-root airplane-mzqt6k"
659
+ aria-haspopup="dialog"
660
+ aria-expanded="false"
661
+ aria-controls="mantine-r8-dropdown"
662
+ id="mantine-r8-target"
663
+ style={{
664
+ fontFamily:
665
+ theme?.fontFamily ||
666
+ 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',
667
+ WebkitTapHighlightColor: 'transparent',
668
+ // color: 'rgb(55, 65, 81)',
669
+ color: theme?.secondaryTextColor || 'rgb(55, 65, 81)',
670
+ textDecoration: 'none',
671
+ fontWeight: 400,
672
+ fontSize: theme?.fontSizeSmall || '14px',
673
+ lineHeight: '20px',
674
+ textOverflow: 'ellipsis',
675
+ whiteSpace: 'nowrap',
676
+ overflow: 'hidden',
677
+ padding: '8px 16px',
678
+ }}
679
+ >
680
+ {typeof row[column.field] === 'object'
681
+ ? JSON.stringify(row[column.field]).length > 55
682
+ ? JSON.stringify(row[column.field]).substring(
683
+ 0,
684
+ 52
685
+ ) + '...'
686
+ : JSON.stringify(row[column.field])
687
+ : row[column.field].length > 55
688
+ ? row[column.field].substring(0, 52) + '...'
689
+ : row[column.field]}
690
+ </div>
691
+ </div>
692
+ </div>
693
+ ))}
694
+ </div>
695
+ ))}
696
+ </div>
697
+ </div>
698
+ </div>
699
+ </div>
700
+ );
701
+ }
702
+
106
703
  const ChartUpdater = ({
107
704
  chartId,
108
705
  containerStyle,
@@ -1,50 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const { glob } = require('glob');
4
-
5
- const rootDir = path.resolve(__dirname);
6
- const classNameRegex = /className=["']([\w\s-]+)["']/g;
7
-
8
- console.log('Root directory:', rootDir);
9
-
10
- try {
11
- const files = glob.sync('**/*.{js,jsx,tsx}', {
12
- cwd: rootDir,
13
- ignore: '**/node_modules/**',
14
- });
15
-
16
- console.log('Files found:', files);
17
-
18
- files.forEach(file => {
19
- console.log('Processing file:', file);
20
- const filePath = path.join(rootDir, file);
21
- fs.readFile(filePath, 'utf-8', (err, data) => {
22
- if (err) {
23
- console.error('Error reading file:', err);
24
- return;
25
- }
26
-
27
- const result = data.replace(classNameRegex, (match, p1) => {
28
- const classNames = p1.split(' ');
29
- const prefixedClassNames = classNames.map(className => {
30
- if (className.startsWith('qq-')) {
31
- return className;
32
- } else {
33
- return `qq-${className}`;
34
- }
35
- });
36
- return `className="${prefixedClassNames.join(' ')}"`;
37
- });
38
-
39
- fs.writeFile(filePath, result, 'utf-8', err => {
40
- if (err) {
41
- console.error('Error writing file:', err);
42
- return;
43
- }
44
- console.log('File updated successfully:', filePath);
45
- });
46
- });
47
- });
48
- } catch (error) {
49
- console.error('Error in glob.sync():', error);
50
- }