diff --git a/package.json b/package.json index 9e7a1b0..76d706f 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "clipboard": "^2.0.11", "esri-leaflet": "^3.0.12", "esri-leaflet-geocoder": "^3.1.5", + "imask": "^7.6.1", "jquery": "^3.7.1", "mini-svg-data-uri": "^1.4.4", "notie": "^4.3.1", diff --git a/resources/js/app.js b/resources/js/app.js index 12ff1b4..3a46f53 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -6,6 +6,7 @@ import Swal from "sweetalert2"; import TomSelect from "tom-select"; import toast from "toastr"; import "toastr/build/toastr.css"; +import IMask from "imask"; window.jQuery = $; window.$ = $; @@ -13,6 +14,8 @@ window.$ = $; window.Swal = Swal; window.swal = Swal; +window.IMask = IMask; + document.querySelectorAll(".tomselect").forEach((el) => { let settings = { plugins: ["dropdown_input"], @@ -75,3 +78,19 @@ window.formatRupiah = function (angka) { }); return formatter.format(angka); }; + +document.querySelectorAll(".currency").forEach((el) => { + IMask(el, { + mask: Number, // enable number mask + + // other options are optional with defaults below + scale: 2, // 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, + }); +});