@quillsql/react 1.6.0 → 1.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/lib/AddToDashboardButton.d.ts +1 -0
  2. package/lib/AddToDashboardButton.js +2 -0
  3. package/lib/AddToDashboardButton.js.map +1 -0
  4. package/lib/AddToDashboardModal.d.ts +22 -0
  5. package/lib/AddToDashboardModal.js +638 -0
  6. package/lib/AddToDashboardModal.js.map +1 -0
  7. package/lib/BarList.js +28 -28
  8. package/lib/BarList.js.map +1 -1
  9. package/lib/Chart.js +30 -114
  10. package/lib/Chart.js.map +1 -1
  11. package/lib/Context.d.ts +3 -3
  12. package/lib/Context.js +3 -3
  13. package/lib/Context.js.map +1 -1
  14. package/lib/Dashboard.js +31 -16
  15. package/lib/Dashboard.js.map +1 -1
  16. package/lib/Dialog.d.ts +68 -0
  17. package/lib/Dialog.js +407 -0
  18. package/lib/Dialog.js.map +1 -0
  19. package/lib/Portal.d.ts +32 -0
  20. package/lib/Portal.js +171 -0
  21. package/lib/Portal.js.map +1 -0
  22. package/lib/Props.d.ts +0 -0
  23. package/lib/Props.js +2 -0
  24. package/lib/Props.js.map +1 -0
  25. package/lib/QuillProvider.d.ts +32 -14
  26. package/lib/QuillProvider.js +15 -2
  27. package/lib/QuillProvider.js.map +1 -1
  28. package/lib/ReportBuilder.d.ts +26 -2
  29. package/lib/ReportBuilder.js +220 -492
  30. package/lib/ReportBuilder.js.map +1 -1
  31. package/lib/SQLEditor.d.ts +35 -1
  32. package/lib/SQLEditor.js +264 -211
  33. package/lib/SQLEditor.js.map +1 -1
  34. package/lib/Table.js +2 -10
  35. package/lib/Table.js.map +1 -1
  36. package/lib/components/BigModal/BigModal.d.ts +14 -0
  37. package/lib/components/BigModal/BigModal.js +85 -0
  38. package/lib/components/BigModal/BigModal.js.map +1 -0
  39. package/lib/components/BigModal/Modal.d.ts +14 -0
  40. package/lib/components/BigModal/Modal.js +109 -0
  41. package/lib/components/BigModal/Modal.js.map +1 -0
  42. package/lib/components/Modal/Modal.d.ts +1 -1
  43. package/lib/hooks/useQuill.js +14 -24
  44. package/lib/hooks/useQuill.js.map +1 -1
  45. package/lib/hooks/useSyncRefs.d.ts +5 -0
  46. package/lib/hooks/useSyncRefs.js +38 -0
  47. package/lib/hooks/useSyncRefs.js.map +1 -0
  48. package/lib/index.d.ts +1 -0
  49. package/lib/index.js +1 -0
  50. package/lib/index.js.map +1 -1
  51. package/lib/types/Props.d.ts +0 -0
  52. package/lib/types/Props.js +2 -0
  53. package/lib/types/Props.js.map +1 -0
  54. package/lib/types.d.ts +27 -0
  55. package/lib/types.js +6 -0
  56. package/lib/types.js.map +1 -0
  57. package/package.json +2 -1
  58. package/src/AddToDashboardModal.tsx +1213 -0
  59. package/src/BarList.tsx +28 -28
  60. package/src/Chart.tsx +31 -107
  61. package/src/Context.tsx +8 -5
  62. package/src/Dashboard.tsx +29 -2
  63. package/src/QuillProvider.tsx +52 -10
  64. package/src/ReportBuilder.tsx +433 -652
  65. package/src/SQLEditor.tsx +578 -235
  66. package/src/Table.tsx +9 -21
  67. package/src/components/BigModal/BigModal.tsx +108 -0
  68. package/src/components/Modal/Modal.tsx +1 -1
  69. package/src/continue_logs.txt +75 -0
  70. package/src/hooks/useQuill.ts +2 -16
  71. package/src/index.ts +1 -0
package/src/BarList.tsx CHANGED
@@ -142,7 +142,7 @@ const BarList = React.forwardRef<HTMLDivElement, BarListProps>((props, ref) => {
142
142
  style={{
143
143
  // width: '100%',
144
144
  height: '100%',
145
- marginLeft: 25,
145
+ // marginLeft: 25,
146
146
  // background: 'red',
147
147
  marginTop: 20,
148
148
  // paddingRight: 25,
@@ -150,8 +150,8 @@ const BarList = React.forwardRef<HTMLDivElement, BarListProps>((props, ref) => {
150
150
  boxSizing: 'content-box',
151
151
  display: 'flex',
152
152
  justifyContent: 'space-between',
153
- marginLeft: '1.5rem',
154
- width: 'calc(100% - 1.5rem)',
153
+ // marginLeft: '24px',
154
+ width: 'calc(100% - 24px)',
155
155
  }}
156
156
  // className={twMerge(
157
157
  // // makeBarListClassName('root'),
@@ -206,7 +206,7 @@ const BarList = React.forwardRef<HTMLDivElement, BarListProps>((props, ref) => {
206
206
  textOverflow: 'ellipsis',
207
207
  fontFamily:
208
208
  theme?.chartLabelFontFamily || theme?.fontFamily,
209
- fontSize: theme?.fontSizeSmall || '0.875rem',
209
+ fontSize: theme?.fontSizeSmall || '14px',
210
210
  }}
211
211
  // className={twMerge(
212
212
  // makeBarListClassName('barText'),
@@ -237,9 +237,9 @@ const BarList = React.forwardRef<HTMLDivElement, BarListProps>((props, ref) => {
237
237
  style={{
238
238
  display: 'flex',
239
239
  alignItems: 'center',
240
- height: '2.25rem',
241
- borderRadius: '0.25rem',
242
- marginBottom: '0.5rem',
240
+ height: '36px',
241
+ borderRadius: '4px',
242
+ marginBottom: '8px',
243
243
  width: `${widths[idx]}%`,
244
244
  transition: showAnimation ? 'all 2s' : '',
245
245
  backgroundColor: hexToRgbaWith10PercentAlpha(colors[0]),
@@ -252,7 +252,7 @@ const BarList = React.forwardRef<HTMLDivElement, BarListProps>((props, ref) => {
252
252
  display: 'flex',
253
253
  maxWidth: '100%',
254
254
  boxSizing: 'content-box',
255
- marginLeft: '0.5rem',
255
+ marginLeft: '8px',
256
256
  }}
257
257
  // className={twMerge(
258
258
  // 'qq-absolute qq-max-w-full qq-flex',
@@ -268,7 +268,7 @@ const BarList = React.forwardRef<HTMLDivElement, BarListProps>((props, ref) => {
268
268
  whiteSpace: 'nowrap',
269
269
  overflow: 'hidden',
270
270
  textOverflow: 'ellipsis',
271
- fontSize: theme?.fontSizeSmall || '0.875rem',
271
+ fontSize: theme?.fontSizeSmall || '14px',
272
272
  }}
273
273
  // className={twMerge(
274
274
  // makeBarListClassName('barText'),
@@ -285,9 +285,9 @@ const BarList = React.forwardRef<HTMLDivElement, BarListProps>((props, ref) => {
285
285
  style={{
286
286
  display: 'flex',
287
287
  alignItems: 'center',
288
- height: '2.25rem',
289
- borderRadius: '0.25rem',
290
- marginBottom: '0.5rem',
288
+ height: '36px',
289
+ borderRadius: '4px',
290
+ marginBottom: '8px',
291
291
  width: `${widths2[idx]}%`,
292
292
  transition: showAnimation ? 'all 2s' : '',
293
293
  backgroundColor: hexToRgbaWith10PercentAlpha(colors[1]),
@@ -300,7 +300,7 @@ const BarList = React.forwardRef<HTMLDivElement, BarListProps>((props, ref) => {
300
300
  position: 'absolute',
301
301
  maxWidth: '100%',
302
302
  display: 'flex',
303
- marginLeft: '0.5rem',
303
+ marginLeft: '8px',
304
304
  }}
305
305
  // className={twMerge(
306
306
  // 'qq-absolute qq-max-w-full qq-flex',
@@ -316,7 +316,7 @@ const BarList = React.forwardRef<HTMLDivElement, BarListProps>((props, ref) => {
316
316
  textOverflow: 'ellipsis',
317
317
  fontFamily:
318
318
  theme?.chartLabelFontFamily || theme?.fontFamily,
319
- fontSize: theme?.fontSizeSmall || '0.875rem',
319
+ fontSize: theme?.fontSizeSmall || '14px',
320
320
  }}
321
321
  // className={twMerge(
322
322
  // makeBarListClassName('barText'),
@@ -339,7 +339,7 @@ const BarList = React.forwardRef<HTMLDivElement, BarListProps>((props, ref) => {
339
339
  color: theme?.chartLabelColor,
340
340
  boxSizing: 'content-box',
341
341
  fontFamily: theme?.chartLabelFontFamily || theme?.fontFamily,
342
- fontSize: theme?.fontSizeSmall || '0.875rem',
342
+ fontSize: theme?.fontSizeSmall || '14px',
343
343
  }}
344
344
  // className="qq-text-sm"
345
345
  >
@@ -367,8 +367,8 @@ const BarList = React.forwardRef<HTMLDivElement, BarListProps>((props, ref) => {
367
367
  display: 'flex',
368
368
  justifyContent: 'flex-end',
369
369
  alignItems: 'center',
370
- marginBottom: idx === data.length - 1 ? 0 : '0.5rem',
371
- height: '2.25rem',
370
+ marginBottom: idx === data.length - 1 ? 0 : '8px',
371
+ height: '36px',
372
372
  }}
373
373
  // className={twMerge(
374
374
  // makeBarListClassName('labelWrapper'),
@@ -385,7 +385,7 @@ const BarList = React.forwardRef<HTMLDivElement, BarListProps>((props, ref) => {
385
385
  whiteSpace: 'nowrap',
386
386
  overflow: 'hidden',
387
387
  textOverflow: 'ellipsis',
388
- fontSize: theme?.fontSizeSmall || '0.875rem',
388
+ fontSize: theme?.fontSizeSmall || '14px',
389
389
  }}
390
390
  // className={twMerge(
391
391
  // makeBarListClassName('labelText'),
@@ -420,7 +420,7 @@ const BarList = React.forwardRef<HTMLDivElement, BarListProps>((props, ref) => {
420
420
  // paddingRight: 25,
421
421
  overflow: 'hidden',
422
422
  display: 'flex',
423
- marginLeft: '1.5rem',
423
+ marginLeft: 25,
424
424
  justifyContent: 'space-between',
425
425
  }}
426
426
  // className={twMerge(
@@ -457,9 +457,9 @@ const BarList = React.forwardRef<HTMLDivElement, BarListProps>((props, ref) => {
457
457
  backgroundColor: hexToRgbaWith10PercentAlpha(colors[0]),
458
458
  display: 'flex',
459
459
  alignItems: 'center',
460
- height: '2.25rem',
461
- marginBottom: '0.5rem',
462
- borderRadius: '0.25rem',
460
+ height: '36px',
461
+ marginBottom: '8px',
462
+ borderRadius: '4px',
463
463
  }}
464
464
  >
465
465
  <div
@@ -468,7 +468,7 @@ const BarList = React.forwardRef<HTMLDivElement, BarListProps>((props, ref) => {
468
468
  position: 'absolute',
469
469
  maxWidth: '100%',
470
470
  display: 'flex',
471
- marginLeft: '0.5rem',
471
+ marginLeft: '8px',
472
472
  }}
473
473
  // className={twMerge(
474
474
  // 'qq-absolute qq-max-w-full qq-flex',
@@ -484,7 +484,7 @@ const BarList = React.forwardRef<HTMLDivElement, BarListProps>((props, ref) => {
484
484
  textOverflow: 'ellipsis',
485
485
  fontFamily:
486
486
  theme?.chartLabelFontFamily || theme?.fontFamily,
487
- fontSize: theme?.fontSizeSmall || '0.875rem',
487
+ fontSize: theme?.fontSizeSmall || '14px',
488
488
  }}
489
489
  // className={twMerge(
490
490
  // makeBarListClassName('barText'),
@@ -509,7 +509,7 @@ const BarList = React.forwardRef<HTMLDivElement, BarListProps>((props, ref) => {
509
509
  color: theme?.chartLabelColor,
510
510
  boxSizing: 'content-box',
511
511
  fontFamily: theme?.chartLabelFontFamily || theme?.fontFamily,
512
- fontSize: theme?.fontSizeSmall || '0.875rem',
512
+ fontSize: theme?.fontSizeSmall || '14px',
513
513
  }}
514
514
  // className="qq-text-sm"
515
515
  >
@@ -537,8 +537,8 @@ const BarList = React.forwardRef<HTMLDivElement, BarListProps>((props, ref) => {
537
537
  display: 'flex',
538
538
  alignItems: 'center',
539
539
  justifyContent: 'flex-end',
540
- marginBottom: idx === data.length - 1 ? 0 : '0.5rem',
541
- height: '2.25rem',
540
+ marginBottom: idx === data.length - 1 ? 0 : '8px',
541
+ height: '36px',
542
542
  }}
543
543
  // className={twMerge(
544
544
  // makeBarListClassName('labelWrapper'),
@@ -555,7 +555,7 @@ const BarList = React.forwardRef<HTMLDivElement, BarListProps>((props, ref) => {
555
555
  whiteSpace: 'nowrap',
556
556
  overflow: 'hidden',
557
557
  textOverflow: 'ellipsis',
558
- fontSize: theme?.fontSizeSmall || '0.875rem',
558
+ fontSize: theme?.fontSizeSmall || '14px',
559
559
  }}
560
560
  // className={twMerge(
561
561
  // makeBarListClassName('labelText'),
package/src/Chart.tsx CHANGED
@@ -4,7 +4,6 @@ import React, { useState, useEffect, useContext, useMemo } from 'react';
4
4
  import {
5
5
  Area,
6
6
  CartesianGrid,
7
- Legend,
8
7
  ComposedChart as ReChartsAreaChart,
9
8
  ResponsiveContainer,
10
9
  Tooltip,
@@ -13,7 +12,7 @@ import {
13
12
  Bar,
14
13
  BarChart as ReChartsBarChart,
15
14
  } from 'recharts';
16
- import { endOfWeek, format, isValid, parseISO, startOfWeek } from 'date-fns';
15
+ import { endOfWeek, format, isValid, startOfWeek } from 'date-fns';
17
16
  import { utcToZonedTime } from 'date-fns-tz';
18
17
  import BarList from './BarList';
19
18
  import PieChart, { findComplementaryAndAnalogousColors } from './PieChart';
@@ -28,6 +27,7 @@ import {
28
27
  import Skeleton from 'react-loading-skeleton';
29
28
  import 'react-loading-skeleton/dist/skeleton.css';
30
29
  import TableChart from './TableChart';
30
+ import { QuillTheme } from './QuillProvider';
31
31
 
32
32
  const colorValues = [
33
33
  'slate',
@@ -95,69 +95,6 @@ interface ButtonProps {
95
95
  // },
96
96
  // ];
97
97
 
98
- const data = [
99
- {
100
- date_trunc: '2022-04-01T00:00:00.000Z',
101
- avg_days: 17.8471360852448,
102
- median_days: 7.36806134259259,
103
- },
104
- {
105
- date_trunc: '2022-05-01T00:00:00.000Z',
106
- avg_days: 17.4874354062884,
107
- median_days: 7.9372337962963,
108
- },
109
- {
110
- date_trunc: '2022-06-01T00:00:00.000Z',
111
- avg_days: 18.240144813895,
112
- median_days: 7.89506365740741,
113
- },
114
- {
115
- date_trunc: '2022-07-01T00:00:00.000Z',
116
- avg_days: 16.2354793525833,
117
- median_days: 7.548125,
118
- },
119
- {
120
- date_trunc: '2022-08-01T00:00:00.000Z',
121
- avg_days: 13.2098485657861,
122
- median_days: 5.95611111111111,
123
- },
124
- {
125
- date_trunc: '2022-09-01T00:00:00.000Z',
126
- avg_days: 19.5792522310747,
127
- median_days: 7.37486111111111,
128
- },
129
- {
130
- date_trunc: '2022-10-01T00:00:00.000Z',
131
- avg_days: 27.538275364544,
132
- median_days: 13.9421527777778,
133
- },
134
- {
135
- date_trunc: '2022-11-01T00:00:00.000Z',
136
- avg_days: 21.6456397342308,
137
- median_days: 10.1523958333333,
138
- },
139
- {
140
- date_trunc: '2022-12-01T00:00:00.000Z',
141
- avg_days: 15.5662888454861,
142
- median_days: 8.40572916666667,
143
- },
144
- {
145
- date_trunc: '2023-01-01T00:00:00.000Z',
146
- avg_days: 11.2846224012116,
147
- median_days: 5.96854166666667,
148
- },
149
- {
150
- date_trunc: '2023-02-01T00:00:00.000Z',
151
- avg_days: 9.69899060044893,
152
- median_days: 5.82388310185185,
153
- },
154
- {
155
- date_trunc: '2023-03-01T00:00:00.000Z',
156
- avg_days: 7.18273680555556,
157
- median_days: 4.78365162037037,
158
- },
159
- ];
160
-
161
98
  export const valueFormatter = ({ value, field, fields }) => {
162
99
  if (
163
100
  value === undefined ||
@@ -284,7 +221,7 @@ export const ChartTooltipFrame = ({
284
221
  overflow: 'hidden',
285
222
  borderWidth: 1,
286
223
  background: theme?.backgroundColor || '#ffffff',
287
- borderRadius: '0.375rem',
224
+ borderRadius: '6px',
288
225
  boxShadow:
289
226
  '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)',
290
227
  }}
@@ -317,7 +254,7 @@ export const ChartTooltipRow = ({
317
254
  }: ChartTooltipRowProps) => (
318
255
  <div
319
256
  style={{
320
- marginRight: '1.5rem',
257
+ marginRight: '24px',
321
258
  display: 'flex',
322
259
  alignItems: 'center',
323
260
  justifyContent: 'space-between',
@@ -343,8 +280,8 @@ export const ChartTooltipRow = ({
343
280
  borderStyle: 'solid',
344
281
  borderColor: 'white',
345
282
  boxShadow: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
346
- height: '0.5rem',
347
- width: '0.5rem',
283
+ height: '8px',
284
+ width: '8px',
348
285
  borderRadius: 100,
349
286
  marginRight: 4,
350
287
  }}
@@ -373,7 +310,7 @@ export const ChartTooltipRow = ({
373
310
  marginBottom: 0,
374
311
  fontFamily: theme?.fontFamily,
375
312
  color: theme?.primaryTextColor,
376
- fontSize: theme?.fontSizeSmall || '0.875rem',
313
+ fontSize: theme?.fontSizeSmall || '14px',
377
314
  fontWeight: theme?.fontWeightMedium || '500',
378
315
  }}
379
316
  // className="qq-font-medium qq-tabular-nums qq-text-right qq-whitespace-nowrap qq-text-black"
@@ -391,7 +328,7 @@ export const ChartTooltipRow = ({
391
328
  whiteSpace: 'nowrap',
392
329
  overflow: 'hidden',
393
330
  textOverflow: 'ellipsis',
394
- fontSize: theme?.fontSizeSmall || '0.875rem',
331
+ fontSize: theme?.fontSizeSmall || '14px',
395
332
  fontWeight: theme?.fontWeightNormal || '400',
396
333
  }}
397
334
  // className={twMerge(
@@ -438,10 +375,10 @@ const ChartTooltip = ({
438
375
  borderBottomWidth: 1,
439
376
  display: 'flex',
440
377
  flexDirection: 'column',
441
- paddingLeft: '1rem',
442
- paddingRight: '1rem',
443
- paddingTop: '0.5rem',
444
- paddingBottom: '0.5rem',
378
+ paddingLeft: '16px',
379
+ paddingRight: '16px',
380
+ paddingTop: '8px',
381
+ paddingBottom: '8px',
445
382
  }}
446
383
  // className="qq-flex qq-flex-col qq-py-2 qq-px-4 qq-gray-200"
447
384
  // className={
@@ -460,7 +397,7 @@ const ChartTooltip = ({
460
397
  marginBottom: 0,
461
398
  fontFamily: theme?.fontFamily,
462
399
  color: theme?.primaryTextColor,
463
- fontSize: theme?.fontSizeSmall || '0.875rem',
400
+ fontSize: theme?.fontSizeSmall || '14px',
464
401
  fontWeight: theme?.boldFontWeight || '500',
465
402
  paddingTop: 2,
466
403
  paddingBottom: 2,
@@ -487,10 +424,10 @@ const ChartTooltip = ({
487
424
  <div
488
425
  // className="qq-px-4 qq-space-y-1 qq-py-2 qq-px-4"
489
426
  style={{
490
- paddingRight: '1rem',
491
- paddingLeft: '1rem',
492
- paddingTop: '0.5rem',
493
- paddingBottom: '0.5rem',
427
+ paddingRight: '16px',
428
+ paddingLeft: '16px',
429
+ paddingTop: '8px',
430
+ paddingBottom: '8px',
494
431
  // marginTop: '0.25rem',
495
432
  }}
496
433
  // className={
@@ -561,7 +498,8 @@ const Chart = ({
561
498
  const { dateFilterObj } = useContext(DateFilterContext);
562
499
  const { dashboardFilters } = useContext(DashboardFiltersContext);
563
500
  const [client, _] = useContext(ClientContext);
564
- const [theme] = useContext(ThemeContext);
501
+ const [theme] =
502
+ useContext<[QuillTheme, (theme: QuillTheme) => void]>(ThemeContext);
565
503
  const chartColors = useMemo(() => {
566
504
  return colors?.length ? colors : ['#6269E9', '#E14F62'];
567
505
  }, [colors]);
@@ -717,35 +655,23 @@ const ChartUpdater: React.FC<ChartProps> = ({
717
655
  try {
718
656
  // if self-hosting option, only get metadata and query
719
657
  if (queryEndpoint) {
720
- const resp = await axios.get(
721
- 'https://quill-344421.uc.r.appspot.com/selfhostitem',
722
- {
723
- params: {
724
- id: chartId,
725
- orgId: customerId,
726
- publicKey: publicKey,
727
- },
728
- environment: environment || undefined,
729
- }
730
- );
731
- const resp1 = await axios.post(
732
- queryEndpoint,
733
- { query: resp.data.queryString },
734
- { headers: queryHeaders }
735
- );
736
-
737
- // const [resp1, resp] = await Promise.all([
738
- // axios.post(queryEndpoint, { query }, { headers: queryHeaders }),
739
- // axios.get('https://quill-344421.uc.r.appspot.com/selfhostitem', {
658
+ // const resp = await axios.get(
659
+ // 'https://quill-344421.uc.r.appspot.com/selfhostitem',
660
+ // {
740
661
  // params: {
741
662
  // id: chartId,
742
663
  // orgId: customerId,
743
664
  // publicKey: publicKey,
744
665
  // },
745
666
  // environment: environment || undefined,
746
- // }),
747
- // ]);
748
- // console.log('RESP: ', resp.data);
667
+ // }
668
+ // );
669
+ const resp = await axios.post(
670
+ queryEndpoint,
671
+ { metadata: { id: chartId, task: 'item' } },
672
+ { headers: queryHeaders }
673
+ );
674
+
749
675
  if (resp.data) {
750
676
  const {
751
677
  xAxisField,
@@ -762,7 +688,7 @@ const ChartUpdater: React.FC<ChartProps> = ({
762
688
  yAxisLabel,
763
689
  xAxisFormat,
764
690
  chartType,
765
- rows: resp1.data.rows,
691
+ rows: resp.data.rows,
766
692
  filters: dashboardFilters,
767
693
  });
768
694
  setLoading(false);
@@ -771,8 +697,6 @@ const ChartUpdater: React.FC<ChartProps> = ({
771
697
  id,
772
698
  data: {
773
699
  ...resp.data,
774
- rows: resp1.data.rows,
775
- fields: resp1.data.fields,
776
700
  filters: dashboardFilters,
777
701
  },
778
702
  });
package/src/Context.tsx CHANGED
@@ -1,5 +1,6 @@
1
1
  // @ts-nocheck
2
2
  import React, { useState, createContext, useEffect, useReducer } from 'react';
3
+ import { QuillTheme } from './QuillProvider';
3
4
 
4
5
  // eslint-disable-next-line @typescript-eslint/no-empty-function
5
6
  const dummySetter = () => {};
@@ -15,7 +16,9 @@ export const SaveQueryModalStatusContext = createContext([
15
16
  dummySetter,
16
17
  ]);
17
18
  export const EditorQueryContext = createContext(['', dummySetter]);
18
- export const ThemeContext = createContext([null, dummySetter]);
19
+ export const ThemeContext = createContext<
20
+ [QuillTheme, (theme: QuillTheme) => void]
21
+ >([null, dummySetter]);
19
22
  export const ClientContext = createContext([null, dummySetter]);
20
23
  export const CreateVisualizationModalVisibleContext = createContext([
21
24
  false,
@@ -91,7 +94,6 @@ const dashboardFiltersReducer = (state, action) => {
91
94
 
92
95
  export const ContextProvider = ({
93
96
  children,
94
- containerStyle,
95
97
  initialTheme,
96
98
  publicKey,
97
99
  environment,
@@ -102,7 +104,8 @@ export const ContextProvider = ({
102
104
  queryHeaders,
103
105
  }) => {
104
106
  const [client, setClient] = useState(null);
105
- const [theme, setTheme] = useState(null);
107
+ const [theme, setTheme] =
108
+ useState<[QuillTheme, (theme: QuillTheme) => void]>(null);
106
109
  const [columns, setColumns] = useState(null);
107
110
  const [rows, setRows] = useState(null);
108
111
  const [schema, setSchema] = useState([]);
@@ -130,9 +133,9 @@ export const ContextProvider = ({
130
133
  // SETS INITIAL THEME
131
134
  useEffect(() => {
132
135
  if (!theme) {
133
- setTheme({ ...initialTheme, containerStyle });
136
+ setTheme({ ...initialTheme });
134
137
  }
135
- }, [initialTheme, containerStyle]);
138
+ }, [initialTheme]);
136
139
 
137
140
  // SETS INITIAL CLIENT
138
141
  useEffect(() => {
package/src/Dashboard.tsx CHANGED
@@ -46,7 +46,8 @@ export default function Dashboard({
46
46
  const [dashboardSections, setDashboardSections] = useState<any>(null);
47
47
  const { dashboard } = useContext(DashboardContext);
48
48
  const [client, _] = useContext(ClientContext);
49
- const [theme, _] = useContext(ThemeContext);
49
+ const [theme, _] =
50
+ useContext<[QuillTheme, (theme: QuillTheme) => void]>(ThemeContext);
50
51
  const { dateFilter, dateFilterDispatch } = useContext(DateFilterContext);
51
52
  const { dashboardFiltersDispatch } = useContext(DashboardFiltersContext);
52
53
  const [configFilters, setConfigFilters] = useState([]);
@@ -60,12 +61,37 @@ export default function Dashboard({
60
61
 
61
62
  React.useEffect(() => {
62
63
  async function getDashboards() {
63
- const { publicKey, customerId, environment } = client;
64
+ const {
65
+ publicKey,
66
+ customerId,
67
+ environment,
68
+ queryEndpoint,
69
+ queryHeaders,
70
+ } = client;
64
71
  try {
65
72
  // const response = await fetch(
66
73
  // `https://quill-344421.uc.r.appspot.com/dashsections/${publicKey}/${customerId}/${name}`
67
74
  // );
68
75
 
76
+ if (queryEndpoint && queryHeaders) {
77
+ const response = await axios.post(
78
+ queryEndpoint,
79
+ {
80
+ metadata: { name, task: 'config' },
81
+ },
82
+ {
83
+ headers: queryHeaders,
84
+ }
85
+ );
86
+ if (response.status !== 200) {
87
+ throw new Error(`HTTP error! Status: ${response.status}`);
88
+ }
89
+
90
+ setDashboardSections(response.data.sections);
91
+ setConfigFilters(response.data.filters || []);
92
+ return;
93
+ }
94
+
69
95
  const response = await axios.get(
70
96
  'https://quill-344421.uc.r.appspot.com/dashconfig',
71
97
  {
@@ -73,6 +99,7 @@ export default function Dashboard({
73
99
  publicKey: publicKey,
74
100
  orgId: customerId,
75
101
  name: name,
102
+ task: 'dashconfig',
76
103
  },
77
104
  headers: {
78
105
  environment: environment || undefined,
@@ -2,25 +2,67 @@
2
2
  import React, { useContext, useEffect } from 'react';
3
3
  import { ContextProvider } from './Context';
4
4
 
5
+ interface BaseQuillProviderProps {
6
+ publicKey: string;
7
+ environment?: string;
8
+ theme?: QuillTheme;
9
+ children?: React.ReactNode;
10
+ }
11
+
12
+ interface WithOrganizationId extends BaseQuillProviderProps {
13
+ organizationId: string;
14
+ queryEndpoint?: never;
15
+ queryHeaders?: never;
16
+ }
17
+
18
+ interface WithQueryEndpoint extends BaseQuillProviderProps {
19
+ organizationId?: never;
20
+ queryEndpoint: string;
21
+ queryHeaders: object;
22
+ }
23
+
24
+ type QuillProviderProps = WithOrganizationId | WithQueryEndpoint;
25
+
26
+ export interface QuillTheme {
27
+ fontFamily: string;
28
+ backgroundColor: string;
29
+ primaryTextColor: string;
30
+ secondaryTextColor: string;
31
+ chartLabelFontFamily: string;
32
+ chartLabelColor: string;
33
+ chartTickColor: string;
34
+ chartColors: string[];
35
+ borderColor: string;
36
+ primaryButtonColor: string;
37
+ borderWidth: number;
38
+ }
39
+
40
+ const defaultTheme = {
41
+ fontFamily: 'Inter; Helvetica',
42
+ backgroundColor: '#FFFFFF',
43
+ primaryTextColor: '#364153',
44
+ secondaryTextColor: '#6C727F',
45
+ chartLabelFontFamily: 'Inter; Helvetica',
46
+ chartLabelColor: '#666666',
47
+ chartTickColor: '#CCCCCC',
48
+ chartColors: ['#6269E9', '#E14F62'],
49
+ borderColor: '#CCCCCC',
50
+ primaryButtonColor: '#364153',
51
+ borderWidth: 1,
52
+ };
53
+
5
54
  const QuillProvider = ({
6
55
  organizationId,
7
- authToken,
8
56
  publicKey,
9
- environment,
10
- theme,
11
- containerStyle,
12
- runQueryButton,
13
- saveQueryButton,
14
- exportQueryButton,
15
57
  queryEndpoint,
16
58
  queryHeaders,
59
+ environment,
17
60
  children,
18
- }) => {
61
+ theme = defaultTheme,
62
+ }: QuillProviderProps) => {
19
63
  return (
20
64
  <ContextProvider
21
- containerStyle={containerStyle}
22
65
  initialTheme={theme}
23
- authToken={authToken}
24
66
  publicKey={publicKey}
25
67
  environment={environment}
26
68
  customerId={organizationId}