UNPKG

@aures/custom-react-table

Version:
71 lines 2.65 kB
export function important(value) { return (value + ' !important'); } export function idsExistInArray(array1, array2) { const array2Ids = array2.map((row) => row.id); return array1.every((row) => array2Ids.includes(row.id)); } export function checkLists(A, B) { // Sort and compare the two lists const sortedA = A.slice().sort(); const sortedB = B.slice().sort(); if (sortedB.length === 0) { return false; } for (let i = 0; i < sortedB.length; i++) { if (A.includes(sortedB[i]) === false) { return false; } } return true; } export function calculateHeight(calculation, th, name) { // Créez un élément div temporaire if (calculation === undefined) { calculation = '600px'; } if (typeof calculation !== 'string' && calculation !== undefined) { calculation = calculation.toString(); } const tempDiv = document.createElement('div'); // Appliquez le calcul comme style au div tempDiv.style.height = calculation; // Ajoutez le div à la fin du corps du document document.body.appendChild(tempDiv); // Obtenez la hauteur calculée const calculatedHeight = parseFloat(getComputedStyle(tempDiv).height); // Supprimez le div temporaire du document document.body.removeChild(tempDiv); const element = document.querySelector('.' + th); // Step 2: Get the height using offsetHeight let heightTh; if (element instanceof HTMLElement) { // Get the height using offsetHeight heightTh = element.offsetHeight; } else { heightTh = 0; } const elementFooter = document.querySelector('.' + name + '_table_footer'); // Step 2: Get the height using offsetHeight let heightFooter; if (elementFooter instanceof HTMLElement) { // Get the height using offsetHeight heightFooter = elementFooter.offsetHeight; } else { heightFooter = 0; } // return 300 // Vérifiez si la hauteur calculée est un nombre valide return isNaN(calculatedHeight) ? null : calculatedHeight - heightTh + 8 - heightFooter * 2; } export function ifOneExists(listecols, filtres) { // Créer un ensemble contenant tous les IDs de la liste de filtres pour une recherche efficace const filterIdsSet = new Set(filtres.map((filter) => filter.id)); // Vérifier si au moins un ID de la liste de colonnes existe dans la liste de filtres return listecols.some((column) => filterIdsSet.has(column.id)); } //# sourceMappingURL=important.js.map