AURORA-865
This commit is contained in:
parent
569138530d
commit
580d9db311
@ -37,7 +37,7 @@ const highlightText = (text, searchQueries) => {
|
|||||||
if (cleanSearchQueries.length == 0) return text;
|
if (cleanSearchQueries.length == 0) return text;
|
||||||
|
|
||||||
const escapedQueries = cleanSearchQueries.map(query => query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
|
const escapedQueries = cleanSearchQueries.map(query => query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
|
||||||
const regex = new RegExp(`(${ escapedQueries.join('|')})`, 'gi');
|
const regex = new RegExp(`(${escapedQueries.join('|')})`, 'gi');
|
||||||
const parts = text.split(regex);
|
const parts = text.split(regex);
|
||||||
|
|
||||||
return parts.map((part, index) =>
|
return parts.map((part, index) =>
|
||||||
@ -60,6 +60,35 @@ const highlightText = (text, searchQueries) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const highlightWithFormatting = (originalValue, formattedValue, searchQueries) => {
|
||||||
|
if (!originalValue && originalValue !== 0) return formattedValue;
|
||||||
|
|
||||||
|
const cleanSearchQueries = searchQueries.filter(q => (q !== undefined && q !== ''));
|
||||||
|
if (cleanSearchQueries.length == 0) return formattedValue;
|
||||||
|
|
||||||
|
const originalString = String(originalValue);
|
||||||
|
const escapedQueries = cleanSearchQueries.map(query => query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
|
||||||
|
const regex = new RegExp(`(${escapedQueries.join('|')})`, 'gi');
|
||||||
|
|
||||||
|
if (!regex.test(originalString)) {
|
||||||
|
return formattedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<mark
|
||||||
|
style={{
|
||||||
|
backgroundColor: '#ffeb3b',
|
||||||
|
color: '#000',
|
||||||
|
fontWeight: 'bold',
|
||||||
|
padding: '0 2px',
|
||||||
|
borderRadius: '2px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{formattedValue}
|
||||||
|
</mark>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const INTEGER_COLUMN_IDS = new Set([
|
const INTEGER_COLUMN_IDS = new Set([
|
||||||
'data.header.num_group',
|
'data.header.num_group',
|
||||||
'data.nomenclature_group_id',
|
'data.nomenclature_group_id',
|
||||||
@ -97,18 +126,21 @@ const Cell = React.memo(({ cell, row, column, onClick, globalFilter, columnFilte
|
|||||||
const isLocked = lockedCells.includes(cellKey);
|
const isLocked = lockedCells.includes(cellKey);
|
||||||
|
|
||||||
const cellValue = cell.getValue();
|
const cellValue = cell.getValue();
|
||||||
let textValue = String(cellValue || '');
|
let originalValue = cellValue;
|
||||||
|
let displayValue = String(cellValue || '');
|
||||||
|
|
||||||
const isNumeric = !isNaN(Number(cellValue)) && cellValue !== null && cellValue !== undefined && cellValue !== '';
|
const isNumeric = !isNaN(Number(cellValue)) && cellValue !== null && cellValue !== undefined && cellValue !== '';
|
||||||
if (isNumeric) {
|
if (isNumeric) {
|
||||||
const asInteger = INTEGER_COLUMN_IDS.has(column.id);
|
const asInteger = INTEGER_COLUMN_IDS.has(column.id);
|
||||||
textValue = formatNumber(cellValue, asInteger);
|
displayValue = formatNumber(cellValue, asInteger);
|
||||||
}
|
}
|
||||||
|
|
||||||
const highlightedContent = useMemo(() => {
|
const highlightedContent = useMemo(() => {
|
||||||
return highlightText(textValue, [globalFilter, columnFilter]);
|
if (!isNumeric) {
|
||||||
}, [textValue, globalFilter]);
|
return highlightText(displayValue, [globalFilter, columnFilter]);
|
||||||
|
}
|
||||||
|
return highlightWithFormatting(originalValue, displayValue, [globalFilter, columnFilter]);
|
||||||
|
}, [originalValue, displayValue, globalFilter, columnFilter, isNumeric]);
|
||||||
|
|
||||||
// Базовые стили для заблокированной ячейки
|
// Базовые стили для заблокированной ячейки
|
||||||
const lockedStyles = isLocked ? {
|
const lockedStyles = isLocked ? {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user