feat(ux-27): normalize persian text, add persistent error/retry state and accessible aria empty-state to search
This commit is contained in:
1 parent
21f7768cce
commit
23724df4e4
3 files changed
+132
-65
No files matched your search
@@ -25,3 +25,23 @@ export function isProductOutOfStock(product?: {
|
||||
if (product.packageSize !== undefined && product.packageSize !== null && Number(product.packageSize) <= 0) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
export function normalizePersianText(input: string | undefined | null): string {
|
||||
if (!input) return "";
|
||||
return input
|
||||
.toString()
|
||||
.toLowerCase()
|
||||
.replace(/[\u200B-\u200D\uFEFF]/g, "")
|
||||
.replace(/[\u200C]/g, " ")
|
||||
.replace(/[يیى]/g, "ی")
|
||||
.replace(/[ك]/g, "ک")
|
||||
.replace(/[ة]/g, "ه")
|
||||
.replace(/[أإآ]/g, "ا")
|
||||
.replace(/[ؤ]/g, "و")
|
||||
.replace(/[ء]/g, "")
|
||||
.replace(/[\u064B-\u065F]/g, "")
|
||||
.replace(/[۰-۹]/g, d => "0123456789"["۰۱۲۳۴۵۶۷۸۹".indexOf(d)])
|
||||
.replace(/[٠-٩]/g, d => "0123456789"["٠١٢٣٤٥٦٧٨٩".indexOf(d)])
|
||||
.replace(/\s+/g, " ")
|
||||
.trim();
|
||||
}
|
||||
Reference in new issue
Block a user