2024-03-22 16:06:56 +00:00
|
|
|
/**
|
|
|
|
* A shortcut for executing directly in the component: stopPropagation
|
|
|
|
*/
|
|
|
|
export function stopPropagation(e: Event) {
|
|
|
|
e.stopPropagation();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A shortcut for executing directly in the component: preventDefault
|
|
|
|
*/
|
|
|
|
export function preventDefault(e: Event) {
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
2024-05-06 14:18:19 +00:00
|
|
|
|
|
|
|
export const rootEl = document.getElementById('root');
|
2024-05-05 06:10:12 +00:00
|
|
|
|
|
|
|
export function downloadCSV(csv: string, filename: string): void {
|
|
|
|
const fakeLink = document.createElement('a');
|
|
|
|
fakeLink.style.display = 'none';
|
|
|
|
document.body.appendChild(fakeLink);
|
|
|
|
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8' });
|
|
|
|
// @ts-ignore
|
|
|
|
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
|
|
|
|
// Manage IE11+ & Edge
|
|
|
|
// @ts-ignore
|
|
|
|
window.navigator.msSaveOrOpenBlob(blob, `${filename}.csv`);
|
|
|
|
} else {
|
|
|
|
fakeLink.setAttribute('href', URL.createObjectURL(blob));
|
|
|
|
fakeLink.setAttribute('download', `${filename}.csv`);
|
|
|
|
fakeLink.click();
|
|
|
|
}
|
|
|
|
}
|