@quillsql/react 2.11.30 → 2.12.1
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/dist/cjs/Chart.d.ts +25 -18
- package/dist/cjs/Chart.d.ts.map +1 -1
- package/dist/cjs/Chart.js +25 -17
- package/dist/cjs/ChartBuilder.d.ts +9 -5
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +34 -38
- package/dist/cjs/ChartEditor.d.ts +10 -6
- package/dist/cjs/ChartEditor.d.ts.map +1 -1
- package/dist/cjs/ChartEditor.js +11 -9
- package/dist/cjs/Dashboard.d.ts +53 -38
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +36 -17
- package/dist/cjs/ReportBuilder.d.ts +3 -3
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +20 -22
- package/dist/cjs/SQLEditor.d.ts +5 -5
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +2 -2
- package/dist/cjs/Table.d.ts +6 -6
- package/dist/cjs/Table.d.ts.map +1 -1
- package/dist/cjs/Table.js +14 -12
- package/dist/cjs/components/Chart/BarChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/BarChart.js +8 -1
- package/dist/cjs/components/Chart/ChartSkeleton.d.ts +2 -1
- package/dist/cjs/components/Chart/ChartSkeleton.d.ts.map +1 -1
- package/dist/cjs/components/Chart/ChartSkeleton.js +5 -1
- package/dist/cjs/components/Dashboard/ChartComponent.d.ts +2 -2
- package/dist/cjs/components/Dashboard/ChartComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/ChartComponent.js +4 -4
- package/dist/cjs/components/Dashboard/DashboardFilter.d.ts +12 -1
- package/dist/cjs/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DashboardFilter.js +26 -2
- package/dist/cjs/components/Dashboard/DataLoader.d.ts +2 -2
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.js +3 -0
- package/dist/cjs/components/Dashboard/MetricComponent.d.ts +2 -2
- package/dist/cjs/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/MetricComponent.js +6 -6
- package/dist/cjs/components/Dashboard/TableComponent.d.ts +2 -2
- package/dist/cjs/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/TableComponent.js +6 -6
- package/dist/cjs/components/QuillMultiSelect.d.ts +11 -0
- package/dist/cjs/components/QuillMultiSelect.d.ts.map +1 -0
- package/dist/cjs/components/QuillMultiSelect.js +183 -0
- package/dist/cjs/components/QuillSelect.d.ts.map +1 -1
- package/dist/cjs/components/QuillSelect.js +0 -1
- package/dist/cjs/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/ui.js +1 -0
- package/dist/cjs/components/UiComponents.d.ts +10 -0
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +15 -17
- package/dist/cjs/hooks/useExport.d.ts +1 -1
- package/dist/cjs/hooks/useExport.d.ts.map +1 -1
- package/dist/cjs/hooks/useExport.js +2 -2
- package/dist/cjs/hooks/useFormat.d.ts +1 -1
- package/dist/cjs/hooks/useFormat.d.ts.map +1 -1
- package/dist/cjs/hooks/useFormat.js +2 -2
- package/dist/cjs/hooks/useQuill.d.ts +2 -2
- package/dist/cjs/hooks/useQuill.d.ts.map +1 -1
- package/dist/cjs/hooks/useQuill.js +12 -11
- package/dist/cjs/index.d.ts +1 -3
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -3
- package/dist/cjs/models/Filter.d.ts +7 -0
- package/dist/cjs/models/Filter.d.ts.map +1 -0
- package/dist/cjs/models/Filter.js +2 -0
- package/dist/cjs/utils/dashboard.d.ts +2 -2
- package/dist/cjs/utils/dashboard.d.ts.map +1 -1
- package/dist/cjs/utils/dashboard.js +2 -14
- package/dist/cjs/utils/errorProcessing.d.ts +2 -0
- package/dist/cjs/utils/errorProcessing.d.ts.map +1 -0
- package/dist/cjs/utils/errorProcessing.js +12 -0
- package/dist/cjs/utils/valueFormatter.js +1 -1
- package/dist/esm/Chart.d.ts +25 -18
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +25 -17
- package/dist/esm/ChartBuilder.d.ts +9 -5
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +35 -39
- package/dist/esm/ChartEditor.d.ts +10 -6
- package/dist/esm/ChartEditor.d.ts.map +1 -1
- package/dist/esm/ChartEditor.js +12 -10
- package/dist/esm/Dashboard.d.ts +53 -38
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +36 -17
- package/dist/esm/ReportBuilder.d.ts +3 -3
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +20 -22
- package/dist/esm/SQLEditor.d.ts +5 -5
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +2 -2
- package/dist/esm/Table.d.ts +6 -6
- package/dist/esm/Table.d.ts.map +1 -1
- package/dist/esm/Table.js +14 -12
- package/dist/esm/components/Chart/BarChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/BarChart.js +8 -1
- package/dist/esm/components/Chart/ChartSkeleton.d.ts +2 -1
- package/dist/esm/components/Chart/ChartSkeleton.d.ts.map +1 -1
- package/dist/esm/components/Chart/ChartSkeleton.js +3 -1
- package/dist/esm/components/Dashboard/ChartComponent.d.ts +2 -2
- package/dist/esm/components/Dashboard/ChartComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/ChartComponent.js +4 -4
- package/dist/esm/components/Dashboard/DashboardFilter.d.ts +12 -1
- package/dist/esm/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DashboardFilter.js +26 -2
- package/dist/esm/components/Dashboard/DataLoader.d.ts +2 -2
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.js +3 -0
- package/dist/esm/components/Dashboard/MetricComponent.d.ts +2 -2
- package/dist/esm/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/MetricComponent.js +6 -6
- package/dist/esm/components/Dashboard/TableComponent.d.ts +2 -2
- package/dist/esm/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/TableComponent.js +6 -6
- package/dist/esm/components/QuillMultiSelect.d.ts +11 -0
- package/dist/esm/components/QuillMultiSelect.d.ts.map +1 -0
- package/dist/esm/components/QuillMultiSelect.js +178 -0
- package/dist/esm/components/QuillSelect.d.ts.map +1 -1
- package/dist/esm/components/QuillSelect.js +0 -1
- package/dist/esm/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/ui.js +1 -0
- package/dist/esm/components/UiComponents.d.ts +10 -0
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +15 -17
- package/dist/esm/hooks/useExport.d.ts +1 -1
- package/dist/esm/hooks/useExport.d.ts.map +1 -1
- package/dist/esm/hooks/useExport.js +2 -2
- package/dist/esm/hooks/useFormat.d.ts +1 -1
- package/dist/esm/hooks/useFormat.d.ts.map +1 -1
- package/dist/esm/hooks/useFormat.js +2 -2
- package/dist/esm/hooks/useQuill.d.ts +2 -2
- package/dist/esm/hooks/useQuill.d.ts.map +1 -1
- package/dist/esm/hooks/useQuill.js +12 -11
- package/dist/esm/index.d.ts +1 -3
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/models/Filter.d.ts +7 -0
- package/dist/esm/models/Filter.d.ts.map +1 -0
- package/dist/esm/models/Filter.js +1 -0
- package/dist/esm/utils/dashboard.d.ts +2 -2
- package/dist/esm/utils/dashboard.d.ts.map +1 -1
- package/dist/esm/utils/dashboard.js +2 -14
- package/dist/esm/utils/errorProcessing.d.ts +2 -0
- package/dist/esm/utils/errorProcessing.d.ts.map +1 -0
- package/dist/esm/utils/errorProcessing.js +8 -0
- package/dist/esm/utils/valueFormatter.js +1 -1
- package/package.json +1 -1
package/dist/esm/ChartBuilder.js
CHANGED
|
@@ -6,7 +6,7 @@ import { getData, getDataFromCloud } from './utils/dataFetcher';
|
|
|
6
6
|
import { PivotModal, generatePivotTable, isDateField, } from './internals/ReportBuilder/PivotModal';
|
|
7
7
|
import { PivotCard } from './internals/ReportBuilder/PivotList';
|
|
8
8
|
import Chart from './Chart';
|
|
9
|
-
import { MemoizedModal, QuillTextInput, MemoizedButton, MemoizedSecondaryButton, MemoizedHeader, MemoizedLabel, MemoizedDeleteButton, MemoizedText, MemoizedPopover, QuillTableComponent, QuillChartBuilderInputRowContainer, QuillChartBuilderInputColumnContainer, MemoizedSubHeader, QuillErrorMessageComponent, QuillPivotRowContainer, QuillPivotColumnContainer, QuillChartBuilderFormContainer, } from './components/UiComponents';
|
|
9
|
+
import { MemoizedModal, QuillTextInput, MemoizedButton, MemoizedSecondaryButton, MemoizedHeader, MemoizedLabel, MemoizedDeleteButton, MemoizedText, MemoizedPopover, QuillTableComponent, QuillChartBuilderInputRowContainer, QuillChartBuilderInputColumnContainer, MemoizedSubHeader, QuillErrorMessageComponent, QuillPivotRowContainer, QuillPivotColumnContainer, QuillChartBuilderFormContainer, QuillLoadingComponent, } from './components/UiComponents';
|
|
10
10
|
import { mergeComparisonRange } from './utils/merge';
|
|
11
11
|
import { removeDoubleQuotes, snakeCaseToTitleCase, } from './utils/textProcessing';
|
|
12
12
|
import { QuillSelectComponent } from './components/QuillSelect';
|
|
@@ -231,7 +231,7 @@ export function ChartBuilderWithModal(props) {
|
|
|
231
231
|
* ### Chart Builder API
|
|
232
232
|
* @see https://docs.quillsql.com/components/chart-builder
|
|
233
233
|
*/
|
|
234
|
-
export default function ChartBuilder({ TextInputComponent = QuillTextInput, SelectComponent = QuillSelectComponent, ButtonComponent = MemoizedButton, SecondaryButtonComponent = MemoizedSecondaryButton, HeaderComponent = MemoizedHeader, SubHeaderComponent = MemoizedSubHeader, LabelComponent = MemoizedLabel, DeleteButtonComponent = MemoizedDeleteButton, TextComponent = MemoizedText, PopoverComponent = MemoizedPopover, CardComponent = QuillCard, TableComponent = QuillTableComponent, ModalComponent, ErrorMessageComponent = QuillErrorMessageComponent, ChartBuilderInputRowContainer = QuillChartBuilderInputRowContainer, ChartBuilderInputColumnContainer = QuillChartBuilderInputColumnContainer, PivotRowContainer = QuillPivotRowContainer, PivotColumnContainer = QuillPivotColumnContainer, FormContainer = QuillChartBuilderFormContainer, isOpen, isHorizontalView = true, pivot, setIsOpen, rows, columns, query, queryNoDateColumn, dateRange: dr, showTableFormatOptions = false, showDateFieldOptions = false, showAccessControlOptions = false, showDashboardDropdown = true, onAddToDashboardComplete, onDelete,
|
|
234
|
+
export default function ChartBuilder({ TextInputComponent = QuillTextInput, SelectComponent = QuillSelectComponent, ButtonComponent = MemoizedButton, SecondaryButtonComponent = MemoizedSecondaryButton, HeaderComponent = MemoizedHeader, SubHeaderComponent = MemoizedSubHeader, LabelComponent = MemoizedLabel, DeleteButtonComponent = MemoizedDeleteButton, TextComponent = MemoizedText, PopoverComponent = MemoizedPopover, CardComponent = QuillCard, TableComponent = QuillTableComponent, ModalComponent, LoadingComponent = QuillLoadingComponent, ErrorMessageComponent = QuillErrorMessageComponent, ChartBuilderInputRowContainer = QuillChartBuilderInputRowContainer, ChartBuilderInputColumnContainer = QuillChartBuilderInputColumnContainer, PivotRowContainer = QuillPivotRowContainer, PivotColumnContainer = QuillPivotColumnContainer, FormContainer = QuillChartBuilderFormContainer, isOpen, isHorizontalView = true, pivot, setIsOpen, rows, columns, query, queryNoDateColumn, dateRange: dr, showTableFormatOptions = false, showDateFieldOptions = false, showAccessControlOptions = false, showDashboardDropdown = true, onAddToDashboardComplete, onDelete, report = undefined, recommendedPivots: rp = [], createdPivots: cp = [], destinationDashboard, dateColumn, buttonLabel, organizationName, pivotData, hideDeleteButton = false, hideSubmitButton = false, hideDateRangeFilter = false, initialUniqueValues, pivotRecommendationsEnabled = true, }) {
|
|
235
235
|
const dateRange = dr;
|
|
236
236
|
const [client] = useContext(ClientContext);
|
|
237
237
|
const [theme] = useContext(ThemeContext);
|
|
@@ -303,7 +303,7 @@ export default function ChartBuilder({ TextInputComponent = QuillTextInput, Sele
|
|
|
303
303
|
}, []);
|
|
304
304
|
// get dashboards
|
|
305
305
|
const [dashboardOptions, setDashboardOptions] = useState([]);
|
|
306
|
-
const [defaultDashboardName, setDefaultDashboardName] = useState(destinationDashboard ||
|
|
306
|
+
const [defaultDashboardName, setDefaultDashboardName] = useState(destinationDashboard || report?.dashboardName || '');
|
|
307
307
|
const { dashboardFilters } = useContext(DashboardFiltersContext);
|
|
308
308
|
const [dashboardFilters2, setDashboardFilters] = useState([]);
|
|
309
309
|
const [dashboardHasDateFilter, setDashboardHasDateFilter] = useState(false);
|
|
@@ -317,7 +317,7 @@ export default function ChartBuilder({ TextInputComponent = QuillTextInput, Sele
|
|
|
317
317
|
const [tableName, setTableName] = useState(undefined);
|
|
318
318
|
const selectedTable = schema?.find((t) => t.displayName === tableName);
|
|
319
319
|
const [pivotPopUpTitle, setPivotPopUpTitle] = useState('Add pivot');
|
|
320
|
-
const [createdPivots, setCreatedPivots] = useState(pivot ? [pivot] :
|
|
320
|
+
const [createdPivots, setCreatedPivots] = useState(pivot ? [pivot] : report?.pivot ? [report.pivot] : cp);
|
|
321
321
|
const [recommendedPivots, setRecommendedPivots] = useState(rp);
|
|
322
322
|
const [pivotRowField, setPivotRowField] = useState(pivot?.rowField);
|
|
323
323
|
const [pivotColumnField, setPivotColumnField] = useState(pivot?.columnField);
|
|
@@ -382,15 +382,15 @@ export default function ChartBuilder({ TextInputComponent = QuillTextInput, Sele
|
|
|
382
382
|
};
|
|
383
383
|
const pivotFormData = (pivot) => {
|
|
384
384
|
const yAxisField = pivot.columnField || pivot.valueField;
|
|
385
|
-
const yAxisLabel =
|
|
386
|
-
?
|
|
385
|
+
const yAxisLabel = report?.yAxisFields?.length > 0
|
|
386
|
+
? report.yAxisFields[0].label
|
|
387
387
|
: pivot.valueField;
|
|
388
388
|
// date labels for pivots should be treated like strings since they are
|
|
389
389
|
// formatted in generatePivotTable
|
|
390
390
|
const yAxisIsDate = pivot.columnField
|
|
391
391
|
? isDateField(pivot.columnFieldType || '')
|
|
392
392
|
: false;
|
|
393
|
-
const chartType =
|
|
393
|
+
const chartType = report?.chartType ?? (pivot.rowField ? 'column' : 'metric');
|
|
394
394
|
return {
|
|
395
395
|
pivot,
|
|
396
396
|
chartType: chartType,
|
|
@@ -399,15 +399,15 @@ export default function ChartBuilder({ TextInputComponent = QuillTextInput, Sele
|
|
|
399
399
|
? 'string'
|
|
400
400
|
: columns.find((col) => col.field === pivot.rowField)?.format ||
|
|
401
401
|
'whole_number',
|
|
402
|
-
xAxisLabel:
|
|
402
|
+
xAxisLabel: report?.xAxisLabel || pivot.rowField,
|
|
403
403
|
yAxisFields: [
|
|
404
404
|
{
|
|
405
405
|
field: yAxisField,
|
|
406
406
|
label: yAxisLabel,
|
|
407
407
|
format: yAxisIsDate
|
|
408
408
|
? 'string'
|
|
409
|
-
:
|
|
410
|
-
?
|
|
409
|
+
: report?.yAxisFields?.length > 0
|
|
410
|
+
? report?.yAxisFields[0].format
|
|
411
411
|
: columns.find((col) => col.field === pivot.valueField)?.format ||
|
|
412
412
|
'whole_number',
|
|
413
413
|
},
|
|
@@ -417,11 +417,11 @@ export default function ChartBuilder({ TextInputComponent = QuillTextInput, Sele
|
|
|
417
417
|
const [formData, setFormData] = useState(pivot
|
|
418
418
|
? {
|
|
419
419
|
...formEmptyState,
|
|
420
|
-
...
|
|
420
|
+
...report,
|
|
421
421
|
...pivotFormData(pivot),
|
|
422
422
|
...(destinationDashboard && { dashboardName: destinationDashboard }),
|
|
423
423
|
}
|
|
424
|
-
:
|
|
424
|
+
: report || formEmptyState);
|
|
425
425
|
useEffect(() => {
|
|
426
426
|
async function getFormData() {
|
|
427
427
|
const curFormData = formData;
|
|
@@ -430,19 +430,13 @@ export default function ChartBuilder({ TextInputComponent = QuillTextInput, Sele
|
|
|
430
430
|
.filter((elem) => elem !== null)
|
|
431
431
|
.map((key) => ({ label: key, value: key }));
|
|
432
432
|
await updateDashboardFilters(destinationDashboard ??
|
|
433
|
-
(
|
|
434
|
-
? dashboardItem?.dashboardName
|
|
435
|
-
: dashboardOptions[0]?.label));
|
|
433
|
+
(report ? report?.dashboardName : dashboardOptions[0]?.label));
|
|
436
434
|
setDashboardOptions(dashboardOptions);
|
|
437
435
|
const dashboardName = destinationDashboard ??
|
|
438
|
-
(
|
|
439
|
-
? dashboardItem?.dashboardName
|
|
440
|
-
: dashboardOptions[0]?.label);
|
|
436
|
+
(report ? report?.dashboardName : dashboardOptions[0]?.label);
|
|
441
437
|
curFormData.dashboardName = dashboardName;
|
|
442
438
|
setDefaultDashboardName(destinationDashboard ??
|
|
443
|
-
(
|
|
444
|
-
? dashboardItem?.dashboardName
|
|
445
|
-
: dashboardOptions[0]?.label));
|
|
439
|
+
(report ? report?.dashboardName : dashboardOptions[0]?.label));
|
|
446
440
|
const { queryEndpoint, queryHeaders, publicKey } = client;
|
|
447
441
|
const response = await fetch(`${queryEndpoint}`, {
|
|
448
442
|
method: 'POST',
|
|
@@ -495,8 +489,8 @@ export default function ChartBuilder({ TextInputComponent = QuillTextInput, Sele
|
|
|
495
489
|
curFormData.dateField = dateField;
|
|
496
490
|
setFormData({
|
|
497
491
|
...curFormData,
|
|
498
|
-
dashboardName:
|
|
499
|
-
?
|
|
492
|
+
dashboardName: report
|
|
493
|
+
? report?.dashboardName
|
|
500
494
|
: dashboardOptions[0]?.label,
|
|
501
495
|
});
|
|
502
496
|
}
|
|
@@ -713,12 +707,12 @@ export default function ChartBuilder({ TextInputComponent = QuillTextInput, Sele
|
|
|
713
707
|
event.preventDefault();
|
|
714
708
|
};
|
|
715
709
|
const deleteChart = async () => {
|
|
716
|
-
if (!
|
|
710
|
+
if (!report._id || !client) {
|
|
717
711
|
return;
|
|
718
712
|
}
|
|
719
713
|
const { publicKey, customerId } = client;
|
|
720
714
|
const cloudBody = {
|
|
721
|
-
dashboardItemId:
|
|
715
|
+
dashboardItemId: report._id,
|
|
722
716
|
};
|
|
723
717
|
const searchParams = new URLSearchParams(customerId
|
|
724
718
|
? {
|
|
@@ -767,11 +761,10 @@ export default function ChartBuilder({ TextInputComponent = QuillTextInput, Sele
|
|
|
767
761
|
return;
|
|
768
762
|
}
|
|
769
763
|
// If the dashbaordItem is a template but the editor isn't an admin, create a new dashboardItem and set the template to false
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
: undefined;
|
|
764
|
+
let dashboardItemId = report ? report._id : undefined;
|
|
765
|
+
if (report && !showDateFieldOptions && report.template) {
|
|
766
|
+
dashboardItemId = undefined;
|
|
767
|
+
}
|
|
775
768
|
const cloudBody = {
|
|
776
769
|
...formData,
|
|
777
770
|
...(formData.dateField?.table
|
|
@@ -786,7 +779,9 @@ export default function ChartBuilder({ TextInputComponent = QuillTextInput, Sele
|
|
|
786
779
|
pivot: formData.pivot,
|
|
787
780
|
referencedTables: allTables,
|
|
788
781
|
referencedColumns,
|
|
789
|
-
template: !showDateFieldOptions &&
|
|
782
|
+
template: report && !showDateFieldOptions && report.template
|
|
783
|
+
? false
|
|
784
|
+
: formData.template,
|
|
790
785
|
customerId: customerId || '*',
|
|
791
786
|
};
|
|
792
787
|
// @ts-ignore
|
|
@@ -876,12 +871,15 @@ export default function ChartBuilder({ TextInputComponent = QuillTextInput, Sele
|
|
|
876
871
|
height: formData.chartType === 'metric'
|
|
877
872
|
? 100
|
|
878
873
|
: isHorizontalView || !isOpen
|
|
879
|
-
?
|
|
874
|
+
? showTableFormatOptions
|
|
875
|
+
? 'calc(50% - 10px)'
|
|
876
|
+
: 'calc(100% - 10px)'
|
|
880
877
|
: 400,
|
|
881
878
|
...(isHorizontalView && { flexGrow: 1 }),
|
|
882
879
|
} })),
|
|
883
880
|
// Make sure to display non-pivoted table when using pivot chart
|
|
884
|
-
|
|
881
|
+
showTableFormatOptions &&
|
|
882
|
+
(isHorizontalView || (!isOpen && windowWidth < 1200)) && (_jsx("div", { style: {
|
|
885
883
|
width: '100%',
|
|
886
884
|
height: isHorizontalView || !isOpen ? 'calc(50% - 10px)' : 400,
|
|
887
885
|
flexGrow: 1,
|
|
@@ -920,7 +918,7 @@ export default function ChartBuilder({ TextInputComponent = QuillTextInput, Sele
|
|
|
920
918
|
// marginTop: 6,
|
|
921
919
|
display: 'flex',
|
|
922
920
|
flexDirection: 'column',
|
|
923
|
-
}, children: _jsx(PivotModal, { pivotRowField: pivotRowField, setPivotRowField: setPivotRowField, pivotColumnField: pivotColumnField, setPivotColumnField: setPivotColumnField, pivotValueField: pivotValueField, setPivotValueField: setPivotValueField, pivotAggregation: pivotAggregation, setPivotAggregation: setPivotAggregation, createdPivots: createdPivots, setCreatedPivots: setCreatedPivots, recommendedPivots: recommendedPivots, setRecommendedPivots: setRecommendedPivots, popUpTitle: pivotPopUpTitle, setPopUpTitle: setPivotPopUpTitle, selectedTable: selectedTable, SelectComponent: SelectComponent, ButtonComponent: ButtonComponent, CardComponent: CardComponent, SecondaryButtonComponent: SecondaryButtonComponent, PopoverComponent: PopoverComponent, LabelComponent: LabelComponent, TextComponent: TextComponent, HeaderComponent: HeaderComponent, ErrorMessageComponent: ErrorMessageComponent, PivotRowContainer: PivotRowContainer, PivotColumnContainer: PivotColumnContainer, theme: theme, isOpen: showPivotPopover, setIsOpen: setShowPivotPopover, showUpdatePivot: isEdittingPivot, setShowUpdatePivot: setIsEdittingPivot, parentRef: parentRef, data: rows, columns: columns, triggerButtonText: 'Add pivot +', selectedPivotIndex: selectedPivotIndex, setSelectedPivotIndex: setSelectedPivotIndex, removePivot: handleDeletePivot, selectPivot: handleAddPivot, dateRange: dateRange, selectPivotOnEdit: true, showTrigger: !formData.pivot, query: query, pivotCountRequest: 4, initialUniqueValues: initialUniqueValues, initialSelectedPivotTable: selectedPivotTable, pivotRecommendationsEnabled: pivotRecommendationsEnabled }) }), formData.pivot && (_jsx("div", { children: _jsx("div", { style: { width: pivotCardWidth }, children: _jsx(PivotCard, { pivotTable: {
|
|
921
|
+
}, children: _jsx(PivotModal, { pivotRowField: pivotRowField, setPivotRowField: setPivotRowField, pivotColumnField: pivotColumnField, setPivotColumnField: setPivotColumnField, pivotValueField: pivotValueField, setPivotValueField: setPivotValueField, pivotAggregation: pivotAggregation, setPivotAggregation: setPivotAggregation, createdPivots: createdPivots, setCreatedPivots: setCreatedPivots, recommendedPivots: recommendedPivots, setRecommendedPivots: setRecommendedPivots, popUpTitle: pivotPopUpTitle, setPopUpTitle: setPivotPopUpTitle, selectedTable: selectedTable, SelectComponent: SelectComponent, ButtonComponent: ButtonComponent, CardComponent: CardComponent, SecondaryButtonComponent: SecondaryButtonComponent, PopoverComponent: PopoverComponent, LabelComponent: LabelComponent, TextComponent: TextComponent, HeaderComponent: HeaderComponent, ErrorMessageComponent: ErrorMessageComponent, PivotRowContainer: PivotRowContainer, PivotColumnContainer: PivotColumnContainer, LoadingComponent: LoadingComponent, theme: theme, isOpen: showPivotPopover, setIsOpen: setShowPivotPopover, showUpdatePivot: isEdittingPivot, setShowUpdatePivot: setIsEdittingPivot, parentRef: parentRef, data: rows, columns: columns, triggerButtonText: 'Add pivot +', selectedPivotIndex: selectedPivotIndex, setSelectedPivotIndex: setSelectedPivotIndex, removePivot: handleDeletePivot, selectPivot: handleAddPivot, dateRange: dateRange, selectPivotOnEdit: true, showTrigger: !formData.pivot, query: query, pivotCountRequest: 4, initialUniqueValues: initialUniqueValues, initialSelectedPivotTable: selectedPivotTable, pivotRecommendationsEnabled: pivotRecommendationsEnabled }) }), formData.pivot && (_jsx("div", { children: _jsx("div", { style: { width: pivotCardWidth }, children: _jsx(PivotCard, { pivotTable: {
|
|
924
922
|
pivot: formData.pivot,
|
|
925
923
|
rows: selectedPivotTable?.rows,
|
|
926
924
|
columns: selectedPivotTable?.columns,
|
|
@@ -972,9 +970,7 @@ export default function ChartBuilder({ TextInputComponent = QuillTextInput, Sele
|
|
|
972
970
|
: ''
|
|
973
971
|
: yAxisField.format, onChange: (e) => handleChange(e.target.value, 'yAxisFields.format', index), options: formData.pivot
|
|
974
972
|
? NUMBER_OPTIONS
|
|
975
|
-
: formatOptions, width: 200 }), formData.pivot === null && (_jsx("div", { ref: deleteRef, style: { marginLeft: deleteButtonMargin }, children: _jsx(DeleteButtonComponent, { onClick: () => handleRemoveField('yAxisFields', index) }) }))] }, 'yAxisField' + index))), formData.pivot === null && (_jsx("div", { children: _jsx(SecondaryButtonComponent, { onClick: () => handleAddField('yAxisFields'), label: "Add field +" }) }))] })] }))] })),
|
|
976
|
-
// Make sure to display non-pivoted table when using pivot chart
|
|
977
|
-
windowWidth < 1200 && (_jsx("div", { style: {
|
|
973
|
+
: formatOptions, width: 200 }), formData.pivot === null && (_jsx("div", { ref: deleteRef, style: { marginLeft: deleteButtonMargin }, children: _jsx(DeleteButtonComponent, { onClick: () => handleRemoveField('yAxisFields', index) }) }))] }, 'yAxisField' + index))), formData.pivot === null && (_jsx("div", { children: _jsx(SecondaryButtonComponent, { onClick: () => handleAddField('yAxisFields'), label: "Add field +" }) }))] })] }))] })), showTableFormatOptions && windowWidth < 1200 && (_jsx("div", { style: {
|
|
978
974
|
width: '100%',
|
|
979
975
|
height: isHorizontalView || !isOpen ? 'calc(50% - 10px)' : 400,
|
|
980
976
|
flexGrow: 1,
|
|
@@ -1035,9 +1031,9 @@ export default function ChartBuilder({ TextInputComponent = QuillTextInput, Sele
|
|
|
1035
1031
|
justifyContent: 'flex-end',
|
|
1036
1032
|
marginTop: 'auto',
|
|
1037
1033
|
gap: 10,
|
|
1038
|
-
}, children: [!hideDeleteButton && !isHorizontalView &&
|
|
1034
|
+
}, children: [!hideDeleteButton && !isHorizontalView && report && (_jsx(SecondaryButtonComponent, { onClick: deleteChart, label: 'Delete' })), !hideSubmitButton && (_jsx(ButtonComponent, { onClick: () => editChart(), label: buttonLabel
|
|
1039
1035
|
? buttonLabel
|
|
1040
|
-
:
|
|
1036
|
+
: report
|
|
1041
1037
|
? 'Save changes'
|
|
1042
1038
|
: 'Add to dashboard' }))] })] }))] }), _jsx(DashboardFilterModal, { isOpen: showFilterModal, setIsOpen: setShowFilterModal, issues: filterIssues, ButtonComponent: ButtonComponent })] }));
|
|
1043
1039
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { QuillReport } from './Dashboard';
|
|
3
3
|
/**
|
|
4
4
|
* Props for the Quill ChartEditor component.
|
|
5
5
|
*/
|
|
@@ -9,7 +9,7 @@ export interface ChartEditorProps {
|
|
|
9
9
|
/** A callback that sets the isOpen state. */
|
|
10
10
|
setIsOpen: (isOpen: boolean) => void;
|
|
11
11
|
/** The id of the chart that is being edited. */
|
|
12
|
-
|
|
12
|
+
reportId: string;
|
|
13
13
|
/** Whether the editor has administrative priveleges. */
|
|
14
14
|
isAdmin?: boolean;
|
|
15
15
|
/** The title of the chart builder form. */
|
|
@@ -19,7 +19,7 @@ export interface ChartEditorProps {
|
|
|
19
19
|
/**
|
|
20
20
|
* A callback that is fired when the add to dashboard flow has been completed.
|
|
21
21
|
*/
|
|
22
|
-
onAddToDashboardComplete?: (
|
|
22
|
+
onAddToDashboardComplete?: (report: QuillReport) => void;
|
|
23
23
|
/** A callback that is fired when the item is deleted. */
|
|
24
24
|
onDelete?: () => void;
|
|
25
25
|
/** A select component. */
|
|
@@ -114,6 +114,10 @@ export interface ChartEditorProps {
|
|
|
114
114
|
}[];
|
|
115
115
|
isLoading?: boolean;
|
|
116
116
|
}) => JSX.Element;
|
|
117
|
+
/**
|
|
118
|
+
* A loading component to show in the pivot modal while suggestions load.
|
|
119
|
+
*/
|
|
120
|
+
LoadingComponent?: () => JSX.Element;
|
|
117
121
|
/**
|
|
118
122
|
* A container for each row of inputs for the ChartBuilder form.
|
|
119
123
|
*/
|
|
@@ -169,7 +173,7 @@ export interface ChartEditorProps {
|
|
|
169
173
|
* @example
|
|
170
174
|
* ```js
|
|
171
175
|
* // Usage without custom components
|
|
172
|
-
* <ChartEditor isOpen={true}
|
|
176
|
+
* <ChartEditor isOpen={true} reportId="1234" />
|
|
173
177
|
* ```
|
|
174
178
|
*
|
|
175
179
|
* @example
|
|
@@ -178,7 +182,7 @@ export interface ChartEditorProps {
|
|
|
178
182
|
* <ChartEditor
|
|
179
183
|
* isOpen={isOpen}
|
|
180
184
|
* setIsOpen={setIsOpen}
|
|
181
|
-
*
|
|
185
|
+
* reportId="1234"
|
|
182
186
|
* Button={MyButton}
|
|
183
187
|
* Modal={MyModal}
|
|
184
188
|
* />
|
|
@@ -187,5 +191,5 @@ export interface ChartEditorProps {
|
|
|
187
191
|
* ### Chart Editor API
|
|
188
192
|
* @see https://docs.quillsql.com/components/chart-editor
|
|
189
193
|
*/
|
|
190
|
-
export default function ChartEditor({ isOpen,
|
|
194
|
+
export default function ChartEditor({ isOpen, reportId, isAdmin, destinationDashboard, chartBuilderTitle, chartBuilderButtonLabel, onAddToDashboardComplete, organizationName, isHorizontalView, onDelete, setIsOpen, SelectComponent, TextInputComponent, ButtonComponent, SecondaryButtonComponent, HeaderComponent, SubHeaderComponent, LabelComponent, TextComponent, DeleteButtonComponent, ModalComponent, CardComponent, PopoverComponent, LoadingComponent, TableComponent, ChartBuilderInputRowContainer, ChartBuilderInputColumnContainer, PivotRowContainer, PivotColumnContainer, ErrorMessageComponent, ChartBuilderFormContainer, hideDeleteButton, hideSubmitButton, }: ChartEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
191
195
|
//# sourceMappingURL=ChartEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartEditor.d.ts","sourceRoot":"","sources":["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MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,MAAM,EACN,QAAQ,EACR,OAAe,EACf,oBAAoB,EACpB,iBAAgC,EAChC,uBAAuB,EACvB,wBAAwB,EACxB,gBAAgB,EAChB,gBAAuB,EACvB,QAAQ,EACR,SAAS,EACT,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,wBAAwB,EACxB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,qBAAqB,EACrB,cAA8B,EAC9B,aAAyB,EACzB,gBAAgB,EAChB,gBAAwC,EACxC,cAAoC,EACpC,6BAAkE,EAClE,gCAAwE,EACxE,iBAA0C,EAC1C,oBAAgD,EAChD,qBAAkD,EAClD,yBAA0D,EAC1D,gBAAwB,EACxB,gBAAwB,GACzB,EAAE,gBAAgB,2CAgKlB"}
|
package/dist/esm/ChartEditor.js
CHANGED
|
@@ -3,10 +3,11 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { useContext, useEffect, useRef, useState, } from 'react';
|
|
4
4
|
import ChartBuilder from './ChartBuilder';
|
|
5
5
|
import { DashboardContext, DashboardFiltersContext, ClientContext, } from './Context';
|
|
6
|
-
import { MemoizedModal, QuillChartBuilderFormContainer, QuillChartBuilderInputColumnContainer, QuillChartBuilderInputRowContainer, QuillErrorMessageComponent, QuillPivotColumnContainer, QuillPivotRowContainer, QuillTableComponent, } from './components/UiComponents';
|
|
6
|
+
import { MemoizedModal, QuillChartBuilderFormContainer, QuillChartBuilderInputColumnContainer, QuillChartBuilderInputRowContainer, QuillErrorMessageComponent, QuillLoadingComponent, QuillPivotColumnContainer, QuillPivotRowContainer, QuillTableComponent, } from './components/UiComponents';
|
|
7
7
|
import { getData } from './utils/dataFetcher';
|
|
8
8
|
import { mergeComparisonRange } from './utils/merge';
|
|
9
9
|
import { QuillCard } from './components/QuillCard';
|
|
10
|
+
import { processFilterErrorList } from './utils/errorProcessing';
|
|
10
11
|
/**
|
|
11
12
|
* ### Quill Chart Editor
|
|
12
13
|
*
|
|
@@ -15,7 +16,7 @@ import { QuillCard } from './components/QuillCard';
|
|
|
15
16
|
* @example
|
|
16
17
|
* ```js
|
|
17
18
|
* // Usage without custom components
|
|
18
|
-
* <ChartEditor isOpen={true}
|
|
19
|
+
* <ChartEditor isOpen={true} reportId="1234" />
|
|
19
20
|
* ```
|
|
20
21
|
*
|
|
21
22
|
* @example
|
|
@@ -24,7 +25,7 @@ import { QuillCard } from './components/QuillCard';
|
|
|
24
25
|
* <ChartEditor
|
|
25
26
|
* isOpen={isOpen}
|
|
26
27
|
* setIsOpen={setIsOpen}
|
|
27
|
-
*
|
|
28
|
+
* reportId="1234"
|
|
28
29
|
* Button={MyButton}
|
|
29
30
|
* Modal={MyModal}
|
|
30
31
|
* />
|
|
@@ -33,14 +34,14 @@ import { QuillCard } from './components/QuillCard';
|
|
|
33
34
|
* ### Chart Editor API
|
|
34
35
|
* @see https://docs.quillsql.com/components/chart-editor
|
|
35
36
|
*/
|
|
36
|
-
export default function ChartEditor({ isOpen,
|
|
37
|
+
export default function ChartEditor({ isOpen, reportId, isAdmin = false, destinationDashboard, chartBuilderTitle = 'Edit chart', chartBuilderButtonLabel, onAddToDashboardComplete, organizationName, isHorizontalView = true, onDelete, setIsOpen, SelectComponent, TextInputComponent, ButtonComponent, SecondaryButtonComponent, HeaderComponent, SubHeaderComponent, LabelComponent, TextComponent, DeleteButtonComponent, ModalComponent = MemoizedModal, CardComponent = QuillCard, PopoverComponent, LoadingComponent = QuillLoadingComponent, TableComponent = QuillTableComponent, ChartBuilderInputRowContainer = QuillChartBuilderInputRowContainer, ChartBuilderInputColumnContainer = QuillChartBuilderInputColumnContainer, PivotRowContainer = QuillPivotRowContainer, PivotColumnContainer = QuillPivotColumnContainer, ErrorMessageComponent = QuillErrorMessageComponent, ChartBuilderFormContainer = QuillChartBuilderFormContainer, hideDeleteButton = false, hideSubmitButton = false, }) {
|
|
37
38
|
const parentRef = useRef(null);
|
|
38
39
|
const [modalWidth, setModalWidth] = useState(200);
|
|
39
40
|
const [modalHeight, setModalHeight] = useState(200);
|
|
40
41
|
const { dispatch, dashboard } = useContext(DashboardContext);
|
|
41
42
|
const { dashboardFilters } = useContext(DashboardFiltersContext);
|
|
42
43
|
const [client, _] = useContext(ClientContext);
|
|
43
|
-
const [dashboardItem, setDashboardItem] = useState(dashboard?.[
|
|
44
|
+
const [dashboardItem, setDashboardItem] = useState(dashboard?.[reportId]);
|
|
44
45
|
const [isLoading, setIsLoading] = useState(false);
|
|
45
46
|
const dateFilter = Object.values(dashboardFilters).find((filter) => filter.filterType == 'date_range');
|
|
46
47
|
const dateRange = dateFilter?.startDate
|
|
@@ -71,7 +72,7 @@ export default function ChartEditor({ isOpen, chartId, isAdmin = false, destinat
|
|
|
71
72
|
try {
|
|
72
73
|
const hostedBody = {
|
|
73
74
|
metadata: {
|
|
74
|
-
dashboardItemId:
|
|
75
|
+
dashboardItemId: reportId,
|
|
75
76
|
orgId: client?.customerId || '*',
|
|
76
77
|
task: 'item',
|
|
77
78
|
filters: [],
|
|
@@ -80,10 +81,11 @@ export default function ChartEditor({ isOpen, chartId, isAdmin = false, destinat
|
|
|
80
81
|
},
|
|
81
82
|
};
|
|
82
83
|
const cloudBody = {
|
|
83
|
-
id:
|
|
84
|
+
id: reportId,
|
|
84
85
|
filters: [],
|
|
85
86
|
};
|
|
86
87
|
const resp = await getData(client, 'itempost', 'omit', hostedBody, cloudBody);
|
|
88
|
+
processFilterErrorList(resp);
|
|
87
89
|
if (resp && resp.name !== 'error') {
|
|
88
90
|
if (resp.compareRows) {
|
|
89
91
|
mergeComparisonRange(resp);
|
|
@@ -94,7 +96,7 @@ export default function ChartEditor({ isOpen, chartId, isAdmin = false, destinat
|
|
|
94
96
|
});
|
|
95
97
|
dispatch({
|
|
96
98
|
type: 'UPDATE_DASHBOARD_ITEM',
|
|
97
|
-
id:
|
|
99
|
+
id: reportId,
|
|
98
100
|
data: {
|
|
99
101
|
...resp,
|
|
100
102
|
filtersApplied: dashboardFilters,
|
|
@@ -115,12 +117,12 @@ export default function ChartEditor({ isOpen, chartId, isAdmin = false, destinat
|
|
|
115
117
|
return () => {
|
|
116
118
|
isSubscribed = false;
|
|
117
119
|
};
|
|
118
|
-
}, [client,
|
|
120
|
+
}, [client, reportId]);
|
|
119
121
|
if (!dashboardItem) {
|
|
120
122
|
return _jsx("div", {});
|
|
121
123
|
}
|
|
122
124
|
return (_jsx("div", { ref: parentRef, style: { height: '100%' }, children: _jsx(ModalComponent, { isOpen: isOpen, setIsOpen: setIsOpen, title: chartBuilderTitle || 'Add to dashboard',
|
|
123
125
|
// For isHorizontalView, use full viewport size minus 80px for padding,
|
|
124
126
|
// otherwise use the default layout method of the modal (contents).
|
|
125
|
-
width: isHorizontalView ? modalWidth : undefined, height: isHorizontalView ? modalHeight : undefined, children: _jsx(ChartBuilder, {
|
|
127
|
+
width: isHorizontalView ? modalWidth : undefined, height: isHorizontalView ? modalHeight : undefined, children: _jsx(ChartBuilder, { report: dashboardItem, rows: dashboardItem.rows, columns: dashboardItem.columns, query: dashboardItem.queryString, pivot: dashboardItem.pivot, isOpen: isOpen, setIsOpen: setIsOpen, showTableFormatOptions: isAdmin, showDateFieldOptions: isAdmin, showAccessControlOptions: isAdmin, showDashboardDropdown: isAdmin, destinationDashboard: destinationDashboard, onAddToDashboardComplete: onAddToDashboardComplete, dateRange: dateRange, SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, HeaderComponent: HeaderComponent, SubHeaderComponent: SubHeaderComponent, LabelComponent: LabelComponent, TextComponent: TextComponent, DeleteButtonComponent: DeleteButtonComponent, CardComponent: CardComponent, ModalComponent: ModalComponent, isHorizontalView: isHorizontalView, PopoverComponent: PopoverComponent, TableComponent: TableComponent, ChartBuilderInputRowContainer: ChartBuilderInputRowContainer, ChartBuilderInputColumnContainer: ChartBuilderInputColumnContainer, PivotRowContainer: PivotRowContainer, PivotColumnContainer: PivotColumnContainer, ErrorMessageComponent: ErrorMessageComponent, LoadingComponent: LoadingComponent, onDelete: onDelete, title: chartBuilderTitle, buttonLabel: chartBuilderButtonLabel, organizationName: organizationName, hideSubmitButton: hideSubmitButton, hideDeleteButton: hideDeleteButton, FormContainer: ChartBuilderFormContainer }) }) }));
|
|
126
128
|
}
|
package/dist/esm/Dashboard.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React, { ReactNode, ChangeEvent } from 'react';
|
|
2
2
|
import { Column } from './models/Columns';
|
|
3
|
+
import { Filter } from './models/Filter';
|
|
3
4
|
/**
|
|
4
5
|
* The props passed into the ChartComponent, TableComponent, and MetricComponent
|
|
5
6
|
* functions in the dashboard.
|
|
6
7
|
*/
|
|
7
|
-
export interface
|
|
8
|
-
|
|
9
|
-
onClick?: (
|
|
8
|
+
export interface QuillReportProps {
|
|
9
|
+
report: QuillReport;
|
|
10
|
+
onClick?: (report: QuillReport) => void;
|
|
10
11
|
isLoading?: boolean;
|
|
11
12
|
error?: string;
|
|
12
13
|
children?: ReactNode;
|
|
@@ -16,31 +17,31 @@ export interface DashboardItemProps {
|
|
|
16
17
|
*/
|
|
17
18
|
export type AxisFormat = 'percent' | 'dollar_amount' | 'dollar_cents' | 'whole_number' | 'one_decimal_place' | 'two_decimal_places' | 'string' | 'yyyy' | 'MMM_yyyy' | 'MMM_dd_yyyy' | 'hh_ap_pm' | 'MMM_dd-MMM_dd' | 'MMM_dd_hh:mm_ap_pm' | 'wo, yyyy';
|
|
18
19
|
/**
|
|
19
|
-
* ##
|
|
20
|
-
*
|
|
20
|
+
* ## QuillReport
|
|
21
|
+
* Represents an individual item on a dashboard.
|
|
21
22
|
*
|
|
22
23
|
* Dashboard items can be charts, metric tiles, tables, etc. and can be styled
|
|
23
24
|
* however you'd like.
|
|
24
25
|
*
|
|
25
26
|
* ### API Reference
|
|
26
|
-
* @see https://docs.quillsql.com/components/quill-provider#
|
|
27
|
+
* @see https://docs.quillsql.com/components/quill-provider#quill-report
|
|
27
28
|
*/
|
|
28
|
-
export interface
|
|
29
|
-
/** The
|
|
29
|
+
export interface QuillReport {
|
|
30
|
+
/** The report's unique id. */
|
|
30
31
|
id: string;
|
|
31
|
-
/** The name of the
|
|
32
|
+
/** The name of the report. */
|
|
32
33
|
name: string;
|
|
33
|
-
/** The name of the dashboard this
|
|
34
|
+
/** The name of the dashboard this report belongs to. */
|
|
34
35
|
dashboardName: string;
|
|
35
|
-
/** The rows of data returned from this
|
|
36
|
+
/** The rows of data returned from this report's query. */
|
|
36
37
|
rows: {
|
|
37
38
|
[key: string]: string;
|
|
38
39
|
}[];
|
|
39
|
-
/** The columns data returned from this
|
|
40
|
+
/** The columns data returned from this report's query. */
|
|
40
41
|
columns: Column[];
|
|
41
42
|
/** The type of this chart. */
|
|
42
43
|
chartType: string;
|
|
43
|
-
/** The table and field this
|
|
44
|
+
/** The table and field this report uses for date filtering, if any. */
|
|
44
45
|
dateField: {
|
|
45
46
|
table: string;
|
|
46
47
|
field: string;
|
|
@@ -61,15 +62,15 @@ export interface DashboardItem {
|
|
|
61
62
|
/** The formatted comparison range aggregation value, if any. */
|
|
62
63
|
comparisonAggregation?: string;
|
|
63
64
|
/** The percent change in the aggragations, if any. */
|
|
64
|
-
aggregationPercentChange?:
|
|
65
|
+
aggregationPercentChange?: number;
|
|
65
66
|
/** The label of the xAxis. */
|
|
66
67
|
xAxisLabel: string;
|
|
67
|
-
/** The field to use for this
|
|
68
|
+
/** The field to use for this report's xAxis. */
|
|
68
69
|
xAxisField: string;
|
|
69
|
-
/** The format for this
|
|
70
|
+
/** The format for this report's xAxis. */
|
|
70
71
|
xAxisFormat: AxisFormat;
|
|
71
72
|
/**
|
|
72
|
-
* A list of metadata about the yAxes of this
|
|
73
|
+
* A list of metadata about the yAxes of this report.
|
|
73
74
|
*/
|
|
74
75
|
yAxisFields: {
|
|
75
76
|
/** The field for this yAxis. */
|
|
@@ -80,17 +81,17 @@ export interface DashboardItem {
|
|
|
80
81
|
format: AxisFormat;
|
|
81
82
|
}[];
|
|
82
83
|
/**
|
|
83
|
-
* The relative ordering of this
|
|
84
|
-
*
|
|
84
|
+
* The relative ordering of this report in relation to its siblings. Ordering
|
|
85
|
+
* starts at 1 and counts up (eg. 1, 2, 3, etc.).
|
|
85
86
|
*
|
|
86
|
-
* Also note that
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* the
|
|
87
|
+
* Also note that reports in the same section are first grouped by `chartType`
|
|
88
|
+
* and then each group is sorted by `order`. Currently, the first group is the
|
|
89
|
+
* `metric` reports and the last group is the `table` reports with the rest of
|
|
90
|
+
* the reports in between.
|
|
90
91
|
*/
|
|
91
92
|
order: number;
|
|
92
93
|
/**
|
|
93
|
-
* The rows of data returned from this
|
|
94
|
+
* The rows of data returned from this report's query over the comparison date
|
|
94
95
|
* range as opposed to the primary date range.
|
|
95
96
|
*/
|
|
96
97
|
compareRows: {
|
|
@@ -110,24 +111,24 @@ export interface DashboardProps {
|
|
|
110
111
|
*/
|
|
111
112
|
name?: string;
|
|
112
113
|
/** A component that wraps a dashboard item for 'metric' chart types. */
|
|
113
|
-
MetricComponent?: ({
|
|
114
|
-
|
|
115
|
-
onClick?: (
|
|
114
|
+
MetricComponent?: ({ report, onClick, isLoading, error, }: {
|
|
115
|
+
report: QuillReport;
|
|
116
|
+
onClick?: (report: QuillReport) => void;
|
|
116
117
|
isLoading?: boolean;
|
|
117
118
|
error?: string;
|
|
118
119
|
}) => JSX.Element;
|
|
119
120
|
/** A component that wraps a dashboard item for non-table, non-metric chart types. */
|
|
120
|
-
ChartComponent?: ({
|
|
121
|
-
|
|
122
|
-
onClick?: (
|
|
121
|
+
ChartComponent?: ({ report, onClick, isLoading, error, children, }: {
|
|
122
|
+
report: QuillReport;
|
|
123
|
+
onClick?: (report: QuillReport) => void;
|
|
123
124
|
isLoading?: boolean;
|
|
124
125
|
error?: string;
|
|
125
126
|
children?: ReactNode;
|
|
126
127
|
}) => JSX.Element;
|
|
127
128
|
/** A component that wraps a dashboard item for 'table' chart types. */
|
|
128
|
-
TableComponent?: ({
|
|
129
|
-
|
|
130
|
-
onClick?: (
|
|
129
|
+
TableComponent?: ({ report, onClick, isLoading, error, }: {
|
|
130
|
+
report: QuillReport;
|
|
131
|
+
onClick?: (report: QuillReport) => void;
|
|
131
132
|
isLoading?: boolean;
|
|
132
133
|
error?: string;
|
|
133
134
|
}) => JSX.Element;
|
|
@@ -142,10 +143,22 @@ export interface DashboardProps {
|
|
|
142
143
|
}[];
|
|
143
144
|
onChange: (event: React.ChangeEvent<HTMLSelectElement>) => void;
|
|
144
145
|
}) => JSX.Element;
|
|
146
|
+
/** A multiselect component. */
|
|
147
|
+
MultiSelectComponent?: ({ label, value, options, onChange, width, }: {
|
|
148
|
+
value: string[];
|
|
149
|
+
width: number;
|
|
150
|
+
label?: string;
|
|
151
|
+
options: {
|
|
152
|
+
value: string;
|
|
153
|
+
label: string;
|
|
154
|
+
}[];
|
|
155
|
+
onChange: (event: React.ChangeEvent<HTMLSelectElement>) => void;
|
|
156
|
+
}) => JSX.Element;
|
|
145
157
|
/** A date range picker component. */
|
|
146
|
-
DateRangePickerComponent?: ({ dateRange, label, presetOptions, preset, onChangeDateRange, onChangePreset, }: {
|
|
158
|
+
DateRangePickerComponent?: ({ dateRange, label, presetOptions, preset, selectWidth, onChangeDateRange, onChangePreset, }: {
|
|
147
159
|
preset: string;
|
|
148
160
|
label?: string;
|
|
161
|
+
selectWidth?: number;
|
|
149
162
|
dateRange: {
|
|
150
163
|
startDate: Date;
|
|
151
164
|
endDate: Date;
|
|
@@ -177,8 +190,8 @@ export interface DashboardProps {
|
|
|
177
190
|
}) => JSX.Element;
|
|
178
191
|
/** A fallback component displayed when an active dashboard has no items. */
|
|
179
192
|
EmptyDashboardComponent?: () => JSX.Element;
|
|
180
|
-
/** A callback fired when a
|
|
181
|
-
|
|
193
|
+
/** A callback fired when a report is clicked. */
|
|
194
|
+
onClickReport?: (report: QuillReport) => void;
|
|
182
195
|
/** A callback that is fired when the loading status of the dashboard changes. */
|
|
183
196
|
onChangeLoading?: (isLoading: boolean) => void;
|
|
184
197
|
/** Whether to hide the dashboard filters (default: `false`). */
|
|
@@ -210,6 +223,8 @@ export interface DashboardProps {
|
|
|
210
223
|
containerStyle?: React.CSSProperties;
|
|
211
224
|
/** The styles for the chart container. */
|
|
212
225
|
chartContainerStyle?: React.CSSProperties;
|
|
226
|
+
/** An array of dashboard filters that are indicated by the frontend dev. */
|
|
227
|
+
filters?: Filter[];
|
|
213
228
|
}
|
|
214
229
|
/**
|
|
215
230
|
* ### Quill Dashboard
|
|
@@ -231,7 +246,7 @@ export interface DashboardProps {
|
|
|
231
246
|
* <Dashboard
|
|
232
247
|
* name="saved_reports"
|
|
233
248
|
* SelectComponent={MySelect}
|
|
234
|
-
*
|
|
249
|
+
* onClickReport={(report) => navigate(`/detail/${report.id}`)}
|
|
235
250
|
* MetricComponent={MyMetric}
|
|
236
251
|
* ChartComponent={MyChart}
|
|
237
252
|
* TableComponent={MyTable}
|
|
@@ -242,5 +257,5 @@ export interface DashboardProps {
|
|
|
242
257
|
* ### API Reference
|
|
243
258
|
* @see https://docs.quillsql.com/components/dashboard
|
|
244
259
|
*/
|
|
245
|
-
export default function Dashboard({ name, SelectComponent, EmptyDashboardComponent, DateRangePickerComponent, MetricComponent, ChartComponent, TableComponent, DashboardSectionComponent, DashboardSectionContainerComponent, FilterContainerComponent,
|
|
260
|
+
export default function Dashboard({ name, SelectComponent, MultiSelectComponent, EmptyDashboardComponent, DateRangePickerComponent, MetricComponent, ChartComponent, TableComponent, DashboardSectionComponent, DashboardSectionContainerComponent, FilterContainerComponent, onClickReport, onChangeLoading, hideFilters, hideDateRangeFilter, hideXAxis, hideYAxis, hideCartesianGrid, comparisonLineStyle, containerStyle, className, chartContainerStyle, filters, }: DashboardProps): import("react/jsx-runtime").JSX.Element | null;
|
|
246
261
|
//# sourceMappingURL=Dashboard.d.ts.map
|