feat(lpj-form-penilai): gunakan IMask untuk formatting currency dinamis

- Ganti formatter manual formatCurrency dengan library IMask pada input class currency
- Terapkan thousand separator titik (.) dan radix koma (,) sesuai format lokal
- Gunakan mask Number tanpa desimal (scale 0) untuk nilai harga
- Pindahkan trigger event dari input ke change untuk efisiensi performa
- IMask otomatis menolak karakter non-numerik dan menormalkan nilai
- Thousand separator muncul otomatis saat input nilai besar
- Format angka menjadi konsisten dan standar di seluruh form penilaian
- Kurangi potensi error input akibat formatting manual
This commit is contained in:
Daeng Deni Mardaeni
2025-12-15 11:08:42 +07:00
parent 6378ba0f98
commit 1c5b48ff1b

View File

@@ -302,9 +302,20 @@
});
// Tambahkan event listener untuk currency format
newNPWRow.querySelectorAll('.currency-format').forEach(input => {
input.addEventListener('input', function() {
formatCurrency(this);
newNPWRow.querySelectorAll('.currency').forEach(input => {
input.addEventListener('change', function() {
window.IMask(this, {
mask: Number, // enable number mask
// other options are optional with defaults below
scale: 0, // digits after point, 0 for integers
thousandsSeparator: ".", // any single char
padFractionalZeros: false, // if true, then pads zeros at end to the length of scale
normalizeZeros: true, // appends or removes zeros at ends
radix: ",", // fractional delimiter
mapToRadix: ["."], // symbols to process as radix
autofix: true,
});
});
});