UNPKG

mantine-entity

Version:

A library combining Mantine, TanStack Query, and Mantine React Table for efficient entity management

31 lines (30 loc) 1.06 kB
export function capitalizeTxt(txt) { return txt.charAt(0).toUpperCase() + txt.slice(1); //or if you want lowercase the rest txt.slice(1).toLowerCase(); } export function normalizeText(text) { return text .toLowerCase() // Convert to lowercase .trim() // Remove leading and trailing whitespace .replace(/[^a-z0-9\s]/g, " ") // Remove special characters except spaces .replace(/\s+/g, " "); // Normalize whitespace (replace multiple spaces with a single space) } export const toSentenceCase = (str) => { if (!str) return str; return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase(); }; export function analyzeChange(today, yesterday) { if (yesterday === 0) { return { isHigh: today > 0, percentage: today > 0 ? 100 : 0, }; } const difference = today - yesterday; const percentage = (difference / yesterday) * 100; const isHigh = difference > 0; return { isHigh, percentage: parseFloat(percentage.toFixed(2)), }; }