@aures/custom-react-table
Version:
dynamic table based on react table v7
79 lines • 3.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ifOneExists = exports.calculateHeight = exports.checkLists = exports.idsExistInArray = exports.important = void 0;
function important(value) {
return (value + ' !important');
}
exports.important = important;
function idsExistInArray(array1, array2) {
const array2Ids = array2.map((row) => row.id);
return array1.every((row) => array2Ids.includes(row.id));
}
exports.idsExistInArray = idsExistInArray;
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;
}
exports.checkLists = checkLists;
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;
}
exports.calculateHeight = calculateHeight;
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));
}
exports.ifOneExists = ifOneExists;
//# sourceMappingURL=important.js.map