@quillsql/react 2.12.4 → 2.12.5
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.map +1 -1
- package/dist/cjs/Chart.js +192 -74
- package/dist/cjs/ChartBuilder.d.ts +24 -1
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +22 -6
- package/dist/cjs/ChartEditor.d.ts.map +1 -1
- package/dist/cjs/ChartEditor.js +97 -41
- package/dist/cjs/Context.d.ts.map +1 -1
- package/dist/cjs/Context.js +2 -1
- package/dist/cjs/Dashboard.d.ts +22 -1
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +2 -2
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +34 -21
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +1 -1
- package/dist/cjs/Table.d.ts.map +1 -1
- package/dist/cjs/Table.js +1 -3
- package/dist/cjs/components/Dashboard/DataLoader.d.ts +9 -1
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.js +144 -114
- package/dist/cjs/components/Dashboard/TableComponent.d.ts +1 -1
- package/dist/cjs/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/TableComponent.js +29 -11
- package/dist/cjs/components/QuillTable.d.ts +15 -2
- package/dist/cjs/components/QuillTable.d.ts.map +1 -1
- package/dist/cjs/components/QuillTable.js +58 -29
- package/dist/cjs/components/UiComponents.d.ts +11 -1
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +48 -4
- package/dist/cjs/hooks/useExport.d.ts +2 -1
- package/dist/cjs/hooks/useExport.d.ts.map +1 -1
- package/dist/cjs/hooks/useExport.js +44 -9
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/utils/csv.d.ts.map +1 -1
- package/dist/cjs/utils/dashboard.d.ts.map +1 -1
- package/dist/cjs/utils/dashboard.js +2 -0
- package/dist/cjs/utils/pivotProcessing.d.ts +2 -6
- package/dist/cjs/utils/pivotProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/pivotProcessing.js +31 -28
- package/dist/cjs/utils/schema.d.ts.map +1 -1
- package/dist/cjs/utils/schema.js +4 -0
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +192 -74
- package/dist/esm/ChartBuilder.d.ts +24 -1
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +22 -6
- package/dist/esm/ChartEditor.d.ts.map +1 -1
- package/dist/esm/ChartEditor.js +98 -42
- package/dist/esm/Context.d.ts.map +1 -1
- package/dist/esm/Context.js +2 -1
- package/dist/esm/Dashboard.d.ts +22 -1
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +2 -2
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +37 -24
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +2 -2
- package/dist/esm/Table.d.ts.map +1 -1
- package/dist/esm/Table.js +1 -3
- package/dist/esm/components/Dashboard/DataLoader.d.ts +9 -1
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.js +144 -114
- package/dist/esm/components/Dashboard/TableComponent.d.ts +1 -1
- package/dist/esm/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/TableComponent.js +30 -12
- package/dist/esm/components/QuillTable.d.ts +15 -2
- package/dist/esm/components/QuillTable.d.ts.map +1 -1
- package/dist/esm/components/QuillTable.js +58 -26
- package/dist/esm/components/UiComponents.d.ts +11 -1
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +47 -4
- package/dist/esm/hooks/useExport.d.ts +2 -1
- package/dist/esm/hooks/useExport.d.ts.map +1 -1
- package/dist/esm/hooks/useExport.js +44 -9
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/utils/csv.d.ts.map +1 -1
- package/dist/esm/utils/dashboard.d.ts.map +1 -1
- package/dist/esm/utils/dashboard.js +2 -0
- package/dist/esm/utils/pivotProcessing.d.ts +2 -6
- package/dist/esm/utils/pivotProcessing.d.ts.map +1 -1
- package/dist/esm/utils/pivotProcessing.js +31 -28
- package/dist/esm/utils/schema.d.ts.map +1 -1
- package/dist/esm/utils/schema.js +4 -0
- package/package.json +1 -1
package/dist/esm/Table.js
CHANGED
|
@@ -44,7 +44,7 @@ const Table = (props) => {
|
|
|
44
44
|
const { dashboardFilters } = useContext(DashboardFiltersContext);
|
|
45
45
|
const [client, _] = useContext(ClientContext);
|
|
46
46
|
if ('rows' in data && 'columns' in data) {
|
|
47
|
-
return (_jsx(QuillTable, { hideCSVDownloadButton: data.hideCSVDownloadButton,
|
|
47
|
+
return (_jsx(QuillTable, { hideCSVDownloadButton: data.hideCSVDownloadButton, columns: data.columns, rows: data.rows, className: data.className, containerStyle: data.containerStyle, LoadingComponent: data.LoadingComponent, isLoading: data.isLoading, downloadCSV: data.downloadCSV }));
|
|
48
48
|
}
|
|
49
49
|
return (_jsx(ChartUpdater, { hideCSVDownloadButton: data.hideCSVDownloadButton, dispatch: dispatch, dashboard: dashboard, reportId: data.reportId, className: data.className, containerStyle: data.containerStyle, dashboardFilters: dashboardFilters, client: client, csvFilename: data.csvFilename, LoadingComponent: data.LoadingComponent }));
|
|
50
50
|
};
|
|
@@ -99,8 +99,6 @@ const ChartUpdater = ({ reportId, containerStyle, className, dashboard, dispatch
|
|
|
99
99
|
};
|
|
100
100
|
}, [dashboardFilters, client.customerId, reportId]);
|
|
101
101
|
return (_jsx(QuillTable, { hideCSVDownloadButton: hideCSVDownloadButton,
|
|
102
|
-
// @ts-ignore
|
|
103
|
-
downloadFileName: csvFilename || dashboard[reportId]?.name || '',
|
|
104
102
|
// @ts-ignore
|
|
105
103
|
columns: dashboard[reportId]?.columns || [],
|
|
106
104
|
// @ts-ignore
|
|
@@ -4,10 +4,18 @@ import { QuillTheme } from '../../QuillProvider';
|
|
|
4
4
|
export type DataLoaderChildProps = {
|
|
5
5
|
isLoading: boolean;
|
|
6
6
|
error?: string;
|
|
7
|
+
onPageChange: (page: {
|
|
8
|
+
currentPage: number;
|
|
9
|
+
rowsPerPage: number;
|
|
10
|
+
}) => void;
|
|
11
|
+
onSortChange: (sort: {
|
|
12
|
+
field: string;
|
|
13
|
+
direction: string;
|
|
14
|
+
}) => void;
|
|
7
15
|
};
|
|
8
16
|
export default function DataLoader({ id, children, }: {
|
|
9
17
|
id: string;
|
|
10
|
-
children: ({ isLoading, error }: DataLoaderChildProps) => JSX.Element;
|
|
18
|
+
children: ({ isLoading, error, onPageChange, onSortChange, }: DataLoaderChildProps) => JSX.Element;
|
|
11
19
|
}): JSX.Element;
|
|
12
20
|
type ColorMapType = {
|
|
13
21
|
[key: string]: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataLoader.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/DataLoader.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAKjD,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"DataLoader.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/DataLoader.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAKjD,MAAM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
|
const { dashboardFilters } = useContext(DashboardFiltersContext);
|
|
13
13
|
const [customFields] = useContext(CustomFieldContext);
|
|
14
14
|
const [isLoading, setIsLoading] = useState(true);
|
|
15
|
+
const [isPaginationLoading, setIsPaginationLoading] = useState(true);
|
|
15
16
|
const [error, setError] = useState(undefined);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
const [previousPage, setPreviousPage] = useState(0);
|
|
18
|
+
const [additionalProcessing, setAdditionProcessing] = useState({
|
|
19
|
+
page: 0,
|
|
20
|
+
});
|
|
21
|
+
const onPageChange = (page) => {
|
|
22
|
+
if ((previousPage < page.currentPage &&
|
|
23
|
+
(page.currentPage * page.rowsPerPage) % 100 === 0) ||
|
|
24
|
+
(previousPage > page.currentPage &&
|
|
25
|
+
(previousPage * page.rowsPerPage) % 100 === 0)) {
|
|
26
|
+
getChartOptions({ page });
|
|
27
|
+
}
|
|
28
|
+
setPreviousPage(page.currentPage);
|
|
29
|
+
};
|
|
30
|
+
const onSortChange = (sort) => {
|
|
31
|
+
getChartOptions({ sort });
|
|
32
|
+
setPreviousPage(0);
|
|
33
|
+
};
|
|
34
|
+
const getChartOptions = async (processing) => {
|
|
35
|
+
setIsLoading(true);
|
|
36
|
+
if (!didFiltersChange(dashboard[id], dashboardFilters)) {
|
|
37
|
+
setIsLoading(false);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
let updatedProcessing = { ...additionalProcessing, ...processing };
|
|
42
|
+
if (processing && processing.sort) {
|
|
43
|
+
if (!updatedProcessing.page) {
|
|
44
|
+
updatedProcessing.page = {};
|
|
45
|
+
}
|
|
46
|
+
updatedProcessing.page.currentPage = 0;
|
|
22
47
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
delete newFilter['selectedValue'];
|
|
32
|
-
}
|
|
33
|
-
return newFilter;
|
|
34
|
-
})
|
|
35
|
-
: [];
|
|
36
|
-
const hostedBody = {
|
|
37
|
-
metadata: {
|
|
38
|
-
dashboardItemId: id,
|
|
39
|
-
orgId: client.customerId || '*',
|
|
40
|
-
clientId: client.publicKey,
|
|
41
|
-
task: 'item',
|
|
42
|
-
databaseType: client.databaseType,
|
|
43
|
-
filters: minimalFilters,
|
|
44
|
-
customFields,
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
const cloudBody = {
|
|
48
|
-
id: id,
|
|
49
|
-
filters: minimalFilters,
|
|
50
|
-
};
|
|
51
|
-
const resp = await getData(client, 'itempost', 'omit', hostedBody, cloudBody);
|
|
52
|
-
processFilterErrorList(resp);
|
|
53
|
-
if (resp && resp.name !== 'error' && !resp.errorMessage) {
|
|
54
|
-
if (resp.compareRows) {
|
|
55
|
-
mergeComparisonRange(resp);
|
|
48
|
+
// Remove extra fields on each filter so we don't confuse the backend.
|
|
49
|
+
const minimalFilters = Object.values(dashboardFilters).length
|
|
50
|
+
? Object.values(dashboardFilters).map((filter) => {
|
|
51
|
+
const newFilter = { ...filter };
|
|
52
|
+
if (newFilter.filterType === 'date_range') {
|
|
53
|
+
delete newFilter['field'];
|
|
54
|
+
delete newFilter['options'];
|
|
55
|
+
delete newFilter['selectedValue'];
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
57
|
+
return newFilter;
|
|
58
|
+
})
|
|
59
|
+
: [];
|
|
60
|
+
const hostedBody = {
|
|
61
|
+
metadata: {
|
|
62
|
+
dashboardItemId: id,
|
|
63
|
+
orgId: client.customerId || '*',
|
|
64
|
+
clientId: client.publicKey,
|
|
65
|
+
task: 'item',
|
|
66
|
+
databaseType: client.databaseType,
|
|
67
|
+
filters: minimalFilters,
|
|
68
|
+
customFields,
|
|
69
|
+
paginateTable: true,
|
|
70
|
+
additionalProcessing: updatedProcessing,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
const cloudBody = {
|
|
74
|
+
id: id,
|
|
75
|
+
filters: minimalFilters,
|
|
76
|
+
};
|
|
77
|
+
const resp = await getData(client, 'itempost', 'omit', hostedBody, cloudBody);
|
|
78
|
+
processFilterErrorList(resp);
|
|
79
|
+
if (resp && resp.name !== 'error' && !resp.errorMessage) {
|
|
80
|
+
if (resp.compareRows) {
|
|
81
|
+
mergeComparisonRange(resp);
|
|
69
82
|
}
|
|
70
|
-
|
|
83
|
+
dispatch({
|
|
84
|
+
type: 'UPDATE_DASHBOARD_ITEM',
|
|
85
|
+
id: id,
|
|
86
|
+
data: {
|
|
87
|
+
...resp,
|
|
88
|
+
filtersApplied: dashboardFilters,
|
|
89
|
+
id: resp._id,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
71
92
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
setError(e.message);
|
|
93
|
+
else {
|
|
94
|
+
setError(resp?.errorMessage);
|
|
75
95
|
}
|
|
96
|
+
setAdditionProcessing(updatedProcessing);
|
|
97
|
+
setTimeout(() => {
|
|
98
|
+
setIsLoading(false);
|
|
99
|
+
}, 200);
|
|
100
|
+
}
|
|
101
|
+
catch (e) {
|
|
102
|
+
console.log('Error fetching chart: ', e);
|
|
103
|
+
setError(e.message);
|
|
76
104
|
}
|
|
105
|
+
};
|
|
106
|
+
useEffect(() => {
|
|
77
107
|
getChartOptions();
|
|
78
108
|
}, [dashboardFilters, client, id]);
|
|
79
|
-
return _jsx(_Fragment, { children: children({ isLoading, error }) });
|
|
109
|
+
return _jsx(_Fragment, { children: children({ isLoading, error, onPageChange, onSortChange }) });
|
|
80
110
|
}
|
|
81
111
|
// The same data-loader pattern as above, but with special logic for charts
|
|
82
112
|
// At some point these may be able to get merged into one function.
|
|
@@ -90,69 +120,69 @@ export const ChartDataLoader = ({ id, children, hideDateRangeFilter = false, })
|
|
|
90
120
|
const [client, _] = useContext(ClientContext);
|
|
91
121
|
const [customFields] = useContext(CustomFieldContext);
|
|
92
122
|
const theme = useTheme();
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
delete newFilter['selectedValue'];
|
|
112
|
-
}
|
|
113
|
-
return newFilter;
|
|
114
|
-
})
|
|
115
|
-
: [];
|
|
116
|
-
const hostedBody = {
|
|
117
|
-
metadata: {
|
|
118
|
-
dashboardItemId: id,
|
|
119
|
-
orgId: client.customerId || '*',
|
|
120
|
-
clientId: client.publicKey,
|
|
121
|
-
task: 'item',
|
|
122
|
-
databaseType: client.databaseType,
|
|
123
|
-
filters: minimalFilters,
|
|
124
|
-
customFields,
|
|
125
|
-
},
|
|
126
|
-
};
|
|
127
|
-
const cloudBody = {
|
|
128
|
-
id: id,
|
|
129
|
-
filters: minimalFilters,
|
|
130
|
-
};
|
|
131
|
-
setError(undefined);
|
|
132
|
-
const resp = await getData(client, 'itempost', 'omit', hostedBody, cloudBody);
|
|
133
|
-
processFilterErrorList(resp);
|
|
134
|
-
if (resp && resp.name !== 'error' && !resp.errorMessage) {
|
|
135
|
-
setIsComparison(!!resp.compareRows?.length);
|
|
136
|
-
if (resp.compareRows) {
|
|
137
|
-
mergeComparisonRange(resp);
|
|
123
|
+
const getChartOptions = async () => {
|
|
124
|
+
setLoading(true);
|
|
125
|
+
if (!didFiltersChange(dashboard[id], dashboardFilters)) {
|
|
126
|
+
setLoading(false);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
// Remove extra fields on each filter so we don't confuse the backend.
|
|
131
|
+
const allowDateRange = !hideDateRangeFilter;
|
|
132
|
+
const minimalFilters = Object.values(dashboardFilters).length
|
|
133
|
+
? Object.values(dashboardFilters)
|
|
134
|
+
.filter((f) => allowDateRange || f.filterType !== 'date_range')
|
|
135
|
+
.map((filter) => {
|
|
136
|
+
const newFilter = { ...filter };
|
|
137
|
+
if (newFilter.filterType === 'date_range') {
|
|
138
|
+
delete newFilter['field'];
|
|
139
|
+
delete newFilter['options'];
|
|
140
|
+
delete newFilter['selectedValue'];
|
|
138
141
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
142
|
+
return newFilter;
|
|
143
|
+
})
|
|
144
|
+
: [];
|
|
145
|
+
const hostedBody = {
|
|
146
|
+
metadata: {
|
|
147
|
+
dashboardItemId: id,
|
|
148
|
+
orgId: client.customerId || '*',
|
|
149
|
+
clientId: client.publicKey,
|
|
150
|
+
task: 'item',
|
|
151
|
+
databaseType: client.databaseType,
|
|
152
|
+
filters: minimalFilters,
|
|
153
|
+
customFields,
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
const cloudBody = {
|
|
157
|
+
id: id,
|
|
158
|
+
filters: minimalFilters,
|
|
159
|
+
};
|
|
160
|
+
setError(undefined);
|
|
161
|
+
const resp = await getData(client, 'itempost', 'omit', hostedBody, cloudBody);
|
|
162
|
+
processFilterErrorList(resp);
|
|
163
|
+
if (resp && resp.name !== 'error' && !resp.errorMessage) {
|
|
164
|
+
setIsComparison(!!resp.compareRows?.length);
|
|
165
|
+
if (resp.compareRows) {
|
|
166
|
+
mergeComparisonRange(resp);
|
|
148
167
|
}
|
|
149
|
-
|
|
168
|
+
const dashboardItem = { ...resp, filtersApplied: dashboardFilters };
|
|
169
|
+
dispatch({
|
|
170
|
+
type: 'UPDATE_DASHBOARD_ITEM',
|
|
171
|
+
id: id,
|
|
172
|
+
data: dashboardItem,
|
|
173
|
+
});
|
|
150
174
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
setLoading(false);
|
|
175
|
+
else {
|
|
176
|
+
setError(resp?.errorMessage);
|
|
154
177
|
}
|
|
178
|
+
setLoading(false);
|
|
179
|
+
}
|
|
180
|
+
catch (e) {
|
|
181
|
+
console.log('Error fetching chart: ', e);
|
|
182
|
+
setLoading(false);
|
|
155
183
|
}
|
|
184
|
+
};
|
|
185
|
+
useEffect(() => {
|
|
156
186
|
setInitialLoad(false);
|
|
157
187
|
getChartOptions();
|
|
158
188
|
}, [dashboardFilters, client, id]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { QuillReportProps } from '../../Dashboard';
|
|
3
|
-
export default function QuillTableComponent({ report, onClick, isLoading, error, }: QuillReportProps): JSX.Element;
|
|
3
|
+
export default function QuillTableComponent({ report, onClick, isLoading, error, onPageChange, onSortChange, }: QuillReportProps): JSX.Element;
|
|
4
4
|
//# sourceMappingURL=TableComponent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/TableComponent.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"TableComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/TableComponent.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAInD,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAC1C,MAAM,EACN,OAAO,EACP,SAAS,EACT,KAAK,EACL,YAAY,EACZ,YAAY,GACb,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,CAuLhC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useContext, useMemo } from 'react';
|
|
3
|
-
import { downloadCSV } from '../../utils/csv';
|
|
2
|
+
import { useContext, useEffect, useMemo, useState } from 'react';
|
|
4
3
|
import QuillTable from '../QuillTable';
|
|
5
4
|
import { generatePivotTable } from '../../internals/ReportBuilder/PivotModal';
|
|
6
5
|
import { DashboardFiltersContext } from '../../Context';
|
|
@@ -8,9 +7,17 @@ import { quillFormat } from '../../utils/valueFormatter';
|
|
|
8
7
|
import ChartSkeleton from '../Chart/ChartSkeleton';
|
|
9
8
|
import ChartError from '../Chart/ChartError';
|
|
10
9
|
import { useTheme } from '../../hooks';
|
|
11
|
-
|
|
10
|
+
import { useExport } from '../../hooks/useExport';
|
|
11
|
+
export default function QuillTableComponent({ report, onClick, isLoading, error, onPageChange, onSortChange, }) {
|
|
12
12
|
const theme = useTheme();
|
|
13
13
|
const { dashboardFilters } = useContext(DashboardFiltersContext);
|
|
14
|
+
const [initialLoad, setInitialLoad] = useState(true);
|
|
15
|
+
const { downloadCSV } = useExport(report?.id);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (!isLoading) {
|
|
18
|
+
setInitialLoad(false);
|
|
19
|
+
}
|
|
20
|
+
}, [isLoading]);
|
|
14
21
|
const config = report;
|
|
15
22
|
const data = report;
|
|
16
23
|
const dateFilter = Object.values(dashboardFilters).find((filter) => filter.filterType == 'date_range');
|
|
@@ -61,6 +68,17 @@ export default function QuillTableComponent({ report, onClick, isLoading, error,
|
|
|
61
68
|
return formattedRow;
|
|
62
69
|
}, {});
|
|
63
70
|
});
|
|
71
|
+
let numberOfRows = undefined;
|
|
72
|
+
if (data.compareRows &&
|
|
73
|
+
data.compareRows[0] &&
|
|
74
|
+
(data.compareRows[0].count || data.compareRows[0].COUNT)) {
|
|
75
|
+
if (data.compareRows[0].COUNT) {
|
|
76
|
+
numberOfRows = parseInt(data.compareRows[0].COUNT);
|
|
77
|
+
}
|
|
78
|
+
else if (data.compareRows[0].count) {
|
|
79
|
+
numberOfRows = parseInt(data.compareRows[0].count);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
64
82
|
return (_jsxs("div", { style: { cursor: 'pointer' }, onClick: () => onClick && onClick(report), children: [_jsxs("div", { style: {
|
|
65
83
|
display: 'flex',
|
|
66
84
|
flexDirection: 'row',
|
|
@@ -90,20 +108,20 @@ export default function QuillTableComponent({ report, onClick, isLoading, error,
|
|
|
90
108
|
display: 'flex',
|
|
91
109
|
alignItems: 'center',
|
|
92
110
|
justifyContent: 'flex-end',
|
|
93
|
-
}, children: 'view report →' })) : null] }),
|
|
111
|
+
}, children: 'view report →' })) : null] }), initialLoad ? (_jsx(ChartSkeleton, { containerStyle: {
|
|
94
112
|
width: '100%',
|
|
95
113
|
height: '400px',
|
|
96
114
|
} })) : error ? (_jsx(ChartError, { containerStyle: {
|
|
97
115
|
width: '100%',
|
|
98
116
|
height: '400px',
|
|
99
|
-
} })) : (_jsx(QuillTable, { rows: formattedRows ?? [], columns: columns ?? data.yAxisFields, rowsPerPage: 10, containerStyle: {
|
|
117
|
+
} })) : (_jsx(QuillTable, { isLoading: isLoading, rows: formattedRows ?? [], numberOfRows: numberOfRows, columns: columns ?? data.yAxisFields, rowsPerPage: 10, containerStyle: {
|
|
100
118
|
width: '100%',
|
|
101
119
|
height: '400px',
|
|
102
|
-
},
|
|
103
|
-
downloadCSV(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
} }))] }, report?.name));
|
|
120
|
+
}, downloadCSV: () => {
|
|
121
|
+
downloadCSV();
|
|
122
|
+
}, onPageChange: (page) => {
|
|
123
|
+
onPageChange && onPageChange(page);
|
|
124
|
+
}, onSortChange: (sort) => {
|
|
125
|
+
onSortChange && onSortChange(sort);
|
|
126
|
+
}, currentPage: data.page, sort: data.sort }))] }, report?.name));
|
|
109
127
|
}
|
|
@@ -2,20 +2,33 @@ import React from 'react';
|
|
|
2
2
|
import { ButtonComponentProps } from './UiComponents';
|
|
3
3
|
export interface TableComponentProps {
|
|
4
4
|
rows: any[];
|
|
5
|
+
numberOfRows?: number;
|
|
5
6
|
columns: {
|
|
6
7
|
label: string;
|
|
7
8
|
field: string;
|
|
8
9
|
}[];
|
|
10
|
+
currentPage?: number;
|
|
11
|
+
sort?: {
|
|
12
|
+
field: string;
|
|
13
|
+
direction: string;
|
|
14
|
+
};
|
|
9
15
|
className?: string;
|
|
10
16
|
containerStyle?: React.CSSProperties;
|
|
11
17
|
isLoading?: boolean;
|
|
12
18
|
hideCSVDownloadButton?: boolean;
|
|
13
|
-
downloadFileName?: string;
|
|
14
19
|
downloadCSV?: () => void;
|
|
15
20
|
LoadingComponent?: () => JSX.Element;
|
|
16
21
|
DownloadCSVButtonComponent?: (props: ButtonComponentProps) => JSX.Element;
|
|
17
22
|
rowsPerPage?: number;
|
|
18
23
|
emptyStateLabel?: string;
|
|
24
|
+
onPageChange?: (page: {
|
|
25
|
+
currentPage: number;
|
|
26
|
+
rowsPerPage: number;
|
|
27
|
+
}) => void;
|
|
28
|
+
onSortChange?: (sort: {
|
|
29
|
+
field: string;
|
|
30
|
+
direction: string;
|
|
31
|
+
}) => void;
|
|
19
32
|
}
|
|
20
|
-
export default function QuillTable({ rows, columns, isLoading,
|
|
33
|
+
export default function QuillTable({ rows, numberOfRows, columns, isLoading, currentPage, sort, hideCSVDownloadButton, containerStyle, className, LoadingComponent, rowsPerPage, emptyStateLabel, downloadCSV, onPageChange, onSortChange, }: TableComponentProps): import("react/jsx-runtime").JSX.Element;
|
|
21
34
|
//# sourceMappingURL=QuillTable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuillTable.d.ts","sourceRoot":"","sources":["../../../src/components/QuillTable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"QuillTable.d.ts","sourceRoot":"","sources":["../../../src/components/QuillTable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAIxE,OAAO,EAAE,oBA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WAAW,EACX,YAAY,EACZ,YAAY,GACb,EAAE,mBAAmB,2CAicrB"}
|
|
@@ -2,57 +2,87 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useContext, useEffect, useState } from 'react';
|
|
3
3
|
import { compareValues } from '../utils/valueFormatter';
|
|
4
4
|
import { ThemeContext } from '../Context';
|
|
5
|
-
import
|
|
6
|
-
export default function QuillTable({ rows, columns, isLoading, hideCSVDownloadButton = true,
|
|
5
|
+
import { QuillLoadingComponent } from './UiComponents';
|
|
6
|
+
export default function QuillTable({ rows, numberOfRows, columns, isLoading, currentPage, sort, hideCSVDownloadButton = true, containerStyle, className, LoadingComponent = QuillLoadingComponent, rowsPerPage = 10, emptyStateLabel = 'No results', downloadCSV, onPageChange, onSortChange, }) {
|
|
7
7
|
const [activeRows, setActiveRows] = useState([]);
|
|
8
|
-
const [
|
|
8
|
+
const [pageIndex, setPageIndex] = useState(currentPage || 0);
|
|
9
9
|
const [maxPage, setMaxPage] = useState(1);
|
|
10
|
-
const [sortColumn, setSortColumn] = useState('');
|
|
11
|
-
const [sortDirection, setSortDirection] = useState('desc');
|
|
10
|
+
const [sortColumn, setSortColumn] = useState(sort?.field || '');
|
|
11
|
+
const [sortDirection, setSortDirection] = useState(sort?.direction || 'desc');
|
|
12
12
|
const [theme] = useContext(ThemeContext);
|
|
13
13
|
const [isPaginating, setIsPaginating] = useState(true);
|
|
14
|
+
const [initialLoad, setInitialLoad] = useState(isLoading);
|
|
15
|
+
const [currentLoad, setCurrentLoad] = useState(isLoading);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
setSortColumn(sort?.field || '');
|
|
18
|
+
setSortDirection(sort?.direction || 'desc');
|
|
19
|
+
}, [sort]);
|
|
14
20
|
useEffect(() => {
|
|
15
21
|
setIsPaginating(true);
|
|
22
|
+
const curInterval = pageIndex
|
|
23
|
+
? Math.floor(pageIndex / (100 / rowsPerPage)) * (100 / rowsPerPage)
|
|
24
|
+
: 0;
|
|
16
25
|
if (rows?.length === 0 && isLoading) {
|
|
17
26
|
return;
|
|
18
27
|
}
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
28
|
+
const start = (pageIndex - curInterval) * rowsPerPage;
|
|
29
|
+
const end = (pageIndex - curInterval + 1) * rowsPerPage;
|
|
30
|
+
if (numberOfRows) {
|
|
31
|
+
setMaxPage(Math.ceil(numberOfRows / rowsPerPage));
|
|
32
|
+
setActiveRows(rows.slice(start, end));
|
|
25
33
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
34
|
+
else {
|
|
35
|
+
const sortedRows = [...rows];
|
|
36
|
+
if (sortColumn) {
|
|
37
|
+
sortedRows.sort((a, b) => {
|
|
38
|
+
const result = compareValues(a, b, sortColumn);
|
|
39
|
+
return sortDirection === 'asc' ? result : -result;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
29
42
|
setMaxPage(Math.ceil(sortedRows.length / rowsPerPage));
|
|
43
|
+
setActiveRows(sortedRows.slice(start, end));
|
|
30
44
|
}
|
|
31
|
-
setActiveRows(sortedRows.slice(start, end));
|
|
32
45
|
setIsPaginating(false);
|
|
33
|
-
|
|
46
|
+
setInitialLoad(false);
|
|
47
|
+
}, [pageIndex, rows, sortColumn, sortDirection, columns, numberOfRows]);
|
|
34
48
|
const increasePage = () => {
|
|
35
|
-
if (
|
|
49
|
+
if (pageIndex + 1 === maxPage) {
|
|
36
50
|
return;
|
|
37
51
|
}
|
|
38
|
-
|
|
52
|
+
setPageIndex((pageIndex) => pageIndex + 1);
|
|
53
|
+
onPageChange && onPageChange({ currentPage: pageIndex + 1, rowsPerPage });
|
|
39
54
|
};
|
|
40
55
|
const decreasePage = () => {
|
|
41
|
-
if (
|
|
56
|
+
if (pageIndex === 0) {
|
|
42
57
|
return;
|
|
43
58
|
}
|
|
44
|
-
|
|
59
|
+
setPageIndex((pageIndex) => pageIndex - 1);
|
|
60
|
+
onPageChange && onPageChange({ currentPage: pageIndex - 1, rowsPerPage });
|
|
45
61
|
};
|
|
46
62
|
const toggleSort = (column) => {
|
|
47
63
|
if (sortColumn === column.field) {
|
|
48
64
|
setSortDirection(sortDirection === 'asc' ? 'desc' : 'asc');
|
|
65
|
+
setPageIndex(0);
|
|
66
|
+
if (onSortChange) {
|
|
67
|
+
onSortChange({
|
|
68
|
+
field: column.field,
|
|
69
|
+
direction: sortDirection === 'asc' ? 'desc' : 'asc',
|
|
70
|
+
});
|
|
71
|
+
}
|
|
49
72
|
}
|
|
50
73
|
else {
|
|
51
74
|
setSortColumn(column.field);
|
|
52
75
|
setSortDirection('desc');
|
|
76
|
+
setPageIndex(0);
|
|
77
|
+
if (onSortChange) {
|
|
78
|
+
onSortChange({
|
|
79
|
+
field: column.field,
|
|
80
|
+
direction: 'desc',
|
|
81
|
+
});
|
|
82
|
+
}
|
|
53
83
|
}
|
|
54
84
|
};
|
|
55
|
-
if (
|
|
85
|
+
if (initialLoad) {
|
|
56
86
|
return (_jsx("div", { style: {
|
|
57
87
|
height: '100%',
|
|
58
88
|
...containerStyle,
|
|
@@ -87,7 +117,9 @@ export default function QuillTable({ rows, columns, isLoading, hideCSVDownloadBu
|
|
|
87
117
|
minWidth: '100px',
|
|
88
118
|
boxSizing: 'border-box',
|
|
89
119
|
}, children: columns &&
|
|
90
|
-
columns.map((column, index) => (_jsxs("div", { onClick: () =>
|
|
120
|
+
columns.map((column, index) => (_jsxs("div", { onClick: () => {
|
|
121
|
+
toggleSort(column);
|
|
122
|
+
}, style: {
|
|
91
123
|
boxSizing: 'border-box',
|
|
92
124
|
flex: '150 0 auto',
|
|
93
125
|
minWidth: '50px',
|
|
@@ -129,10 +161,10 @@ export default function QuillTable({ rows, columns, isLoading, hideCSVDownloadBu
|
|
|
129
161
|
transform: sortDirection === 'desc'
|
|
130
162
|
? 'rotate(180deg)'
|
|
131
163
|
: undefined,
|
|
132
|
-
}, children: _jsx("path", { fillRule: "evenodd", d: "M10 3a.75.75 0 01.75.75v10.638l3.96-4.158a.75.75 0 111.08 1.04l-5.25 5.5a.75.75 0 01-1.08 0l-5.25-5.5a.75.75 0 111.08-1.04l3.96 4.158V3.75A.75.75 0 0110 3z", clipRule: "evenodd" }) }))] }, 'sqlcol' + index))) }) }), (activeRows && activeRows.length === 0) ||
|
|
164
|
+
}, children: _jsx("path", { fillRule: "evenodd", d: "M10 3a.75.75 0 01.75.75v10.638l3.96-4.158a.75.75 0 111.08 1.04l-5.25 5.5a.75.75 0 01-1.08 0l-5.25-5.5a.75.75 0 111.08-1.04l3.96 4.158V3.75A.75.75 0 0110 3z", clipRule: "evenodd" }) }))] }, 'sqlcol' + index))) }) }), (isPaginating || isLoading) && (_jsx("div", { className: className, children: _jsx(LoadingComponent, {}) })), (activeRows && activeRows.length === 0) ||
|
|
133
165
|
(columns && columns.length === 0) ? (_jsx("div", { style: {
|
|
134
166
|
padding: '30px 0',
|
|
135
|
-
display: 'flex',
|
|
167
|
+
display: isPaginating || isLoading ? 'none' : 'flex',
|
|
136
168
|
flex: '1 0 auto',
|
|
137
169
|
margin: 'auto',
|
|
138
170
|
justifyContent: 'center',
|
|
@@ -141,7 +173,7 @@ export default function QuillTable({ rows, columns, isLoading, hideCSVDownloadBu
|
|
|
141
173
|
color: theme?.secondaryTextColor || 'rgb(55, 65, 81)',
|
|
142
174
|
}, children: emptyStateLabel })) : (_jsx("div", { role: "rowgroup", className: "tbody", children: activeRows &&
|
|
143
175
|
activeRows.map((row, rowIndex) => (_jsx("div", { role: "row", className: "tr", style: {
|
|
144
|
-
display: 'flex',
|
|
176
|
+
display: isPaginating || isLoading ? 'none' : 'flex',
|
|
145
177
|
flex: '1 0 auto',
|
|
146
178
|
minWidth: '100px',
|
|
147
179
|
boxSizing: 'border-box',
|
|
@@ -219,7 +251,7 @@ export default function QuillTable({ rows, columns, isLoading, hideCSVDownloadBu
|
|
|
219
251
|
fontSize: 12,
|
|
220
252
|
fontFamily: theme?.fontFamily,
|
|
221
253
|
color: theme?.primaryTextColor,
|
|
222
|
-
}, children: [
|
|
254
|
+
}, children: [pageIndex + 1, ' of ', maxPage] }), _jsx("div", { style: { width: 8 } }), _jsx("button", { onClick: decreasePage, style: {
|
|
223
255
|
cursor: 'pointer',
|
|
224
256
|
border: 'none',
|
|
225
257
|
background: 'transparent',
|
|
@@ -149,8 +149,18 @@ export interface TableComponentProps {
|
|
|
149
149
|
label: string;
|
|
150
150
|
}[];
|
|
151
151
|
isLoading?: boolean;
|
|
152
|
+
onPageChange?: (page: {
|
|
153
|
+
currentPage: number;
|
|
154
|
+
rowsPerPage: number;
|
|
155
|
+
}) => void;
|
|
156
|
+
onSortChange?: (sort: {
|
|
157
|
+
field: string;
|
|
158
|
+
direction: string;
|
|
159
|
+
}) => void;
|
|
160
|
+
numberOfRows?: number;
|
|
152
161
|
}
|
|
153
|
-
export declare const
|
|
162
|
+
export declare const QuillTableSQLEditorComponent: ({ rows, columns, isLoading, numberOfRows, onPageChange, onSortChange, }: TableComponentProps) => import("react/jsx-runtime").JSX.Element;
|
|
163
|
+
export declare const QuillTableComponent: ({ rows, columns, isLoading, numberOfRows, onPageChange, onSortChange, }: TableComponentProps) => import("react/jsx-runtime").JSX.Element;
|
|
154
164
|
export declare const QuillEmptyDashboardComponent: () => import("react/jsx-runtime").JSX.Element;
|
|
155
165
|
export declare const QuillChartBuilderInputRowContainer: ({ children, }: {
|
|
156
166
|
children: ReactNode;
|