Comparing version 0.5.0 to 0.6.0
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FPMoney=t():e.FPMoney=t()}(window,function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=4)}([function(e,t,n){"use strict";function i(e,t){void 0===t&&(t=2),""===(e=e.toString())&&(e="0");for(var n="1",i=0;i<t;i++)n+="0";var r=parseInt(n,10);return-1!==e.indexOf(".")&&(e=(parseFloat(e)*r).toString()),0===t?parseInt(e,10):parseFloat((parseInt(e,10)/r).toFixed(t))}function r(){return void 0!==navigator.languages?navigator.languages[0]:navigator.language?navigator.language:"en-US"}t.__esModule=!0,t.currencies={USD:{symbol:"$",fraction:2},EUR:{symbol:"€",fraction:2},GBP:{symbol:"£",fraction:2},INR:{symbol:"₹",fraction:2},CRC:{symbol:"₡",fraction:2},VND:{symbol:"₫",fraction:0},HUF:{symbol:"Ft",fraction:2},ILS:{symbol:"₪",fraction:2},CNY:{symbol:"¥",fraction:2},KRW:{symbol:"₩",fraction:0},NGN:{symbol:"₦",fraction:2},PYG:{symbol:"₲",fraction:0},PHP:{symbol:"₱",fraction:2},PLN:{symbol:"zł",fraction:2},THB:{symbol:"฿",fraction:2},UAH:{symbol:"₴",fraction:2},JPY:{symbol:"¥",fraction:0}},t.intToFraction=i,t.fractionToInt=function(e,t){void 0===t&&(t=2);for(var n=e.toString(),i="1",r=0;r<t;r++)i+="0";var o=parseInt(i,10),s=Math.round(parseFloat(n)*o).toString();return parseInt(s,10)},t.displayValue=function(e,t,n,o){return void 0===o&&(o=r()),new Intl.NumberFormat(o,{localeMatcher:"best fit",style:"currency",currency:t.toUpperCase(),currencyDisplay:"symbol",minimumFractionDigits:n,maximumFractionDigits:n}).format(i(e,n))},t.getLocale=r},function(e,t,n){"use strict";t.__esModule=!0;var i=n(0);!function(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}(n(0));var r=function(){function e(e){var t;this.value="",this.display="",this.format="",this.currencies=JSON.parse(JSON.stringify(i.currencies)),this.currency="",this.locale=i.getLocale(),this.maxValue=0,this.showSelection=!0,this.validate(e),t="string"==typeof e.container?document.querySelector(e.container):e.container,this.container=t,e.currencies&&(this.currencies=e.currencies),e.currency?this.currency=e.currency.toUpperCase():this.currency=Object.keys(this.currencies)[0],e.locale&&(this.locale=e.locale),e.value&&(this.value=i.fractionToInt(e.value,this.currencies[this.currency].fraction).toString()),e.maxValue&&(this.maxValue=i.fractionToInt(e.maxValue,this.currencies[this.currency].fraction)),void 0!==e.showSelection&&(this.showSelection=e.showSelection),this.onChange=e.onChange?this.onChange=e.onChange:function(){},this.currencyDiv=document.createElement("div"),this.input=document.createElement("input"),this.select=document.createElement("select"),this.render(),this.setCurrency(this.currency)}return e.prototype.setCurrency=function(e){e=e.toUpperCase(),this.currency=e,this.currencyDiv.innerHTML=this.currencies[e].symbol;for(var t=this.currencies[e].fraction,n="",i=0;i<t;i++)n+="0";this.input.placeholder="0"+(0===t?"":"."+n),this.select.value=e,this.updateOutput()},e.prototype.setLocale=function(e){this.locale=e,this.updateOutput()},e.prototype.destroy=function(){this.container.innerHTML=""},e.prototype.validate=function(e){if(!("string"==typeof e.container?document.querySelector(e.container):e.container))throw new Error("Could not find container")},e.prototype.updateOutput=function(){if(""!==this.value){var e=parseInt(this.value,10);0!==this.maxValue&&e>this.maxValue&&(e=this.maxValue),this.value=e.toString()}this.format=i.intToFraction(this.value,this.currencies[this.currency].fraction).toFixed(this.currencies[this.currency].fraction),this.display=i.displayValue(this.value,this.currency,this.currencies[this.currency].fraction,this.locale),this.updateInputDisplay(),this.onChange({value:this.value,display:this.display,format:this.format,currency:this.currency,locale:this.locale})},e.prototype.updateInputDisplay=function(){if(""!==this.value){var e=this.display.replace(this.currencies[this.currency.toUpperCase()].symbol,""),t=this.currency;e=e.replace(t,""),t.split("").forEach(function(n,i){e=e.replace(t.substring(0,t.length-i),"")}),e=e.trim(),this.input.value=e}else this.input.value=""},e.prototype.render=function(){var e=this;for(var t in this.container.classList.add("fpm"),this.currencyDiv.classList.add("fpm-currency"),this.input.classList.add("fpm-value"),this.select.classList.add("fpm-select"),this.input.addEventListener("keydown",function(t){e.inputKeydown(t)},!1),this.input.addEventListener("click",function(t){e.input.focus(),e.moveCursorToEnd(e.input)},!1),this.currencies)if(this.currencies.hasOwnProperty(t)){var n=document.createElement("option");n.value=t,n.text=t.toUpperCase(),this.select.appendChild(n)}this.select.addEventListener("change",function(){e.setCurrency(e.select.value)}),this.container.appendChild(this.currencyDiv),this.container.appendChild(this.input),this.showSelection&&this.container.appendChild(this.select)},e.prototype.inputKeydown=function(e){var t=e.keyCode||e.which;8===t||46===t?(e.preventDefault(),this.value=this.value.substring(0,this.value.length-1),this.updateOutput()):t>=48&&t<=57||t>=96&&t<=105?(e.preventDefault(),this.value+=e.key,this.updateOutput()):9===t||13===t||e.preventDefault()},e.prototype.moveCursorToEnd=function(e){if("number"==typeof e.selectionStart)e.selectionStart=e.selectionEnd=e.value.length;else if(void 0!==e.createTextRange){e.focus();var t=e.createTextRange();t.collapse(!1),t.select()}},e}();t.default=r},,,function(e,t,n){"use strict";n.r(t);var i=function(){var e=this.$createElement;return(this._self._c||e)("div",{ref:"fpmoney"})};i._withStripped=!0;var r=n(1),o=n.n(r);var s=function(e,t,n,i,r,o,s,c){var a,u="function"==typeof e?e.options:e;if(t&&(u.render=t,u.staticRenderFns=n,u._compiled=!0),i&&(u.functional=!0),o&&(u._scopeId="data-v-"+o),s?(a=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),r&&r.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(s)},u._ssrRegister=a):r&&(a=c?function(){r.call(this,this.$root.$options.shadowRoot)}:r),a)if(u.functional){u._injectStyles=a;var l=u.render;u.render=function(e,t){return a.call(t),l(e,t)}}else{var h=u.beforeCreate;u.beforeCreate=h?[].concat(h,a):[a]}return{exports:e,options:u}}({name:"fp-money",props:{value:[String,Number],currencies:Object,currency:String,locale:String,maxValue:Number,onChange:Function,showSelection:{type:Boolean,default:!0}},data:()=>({fpmoney:null}),mounted(){this.init()},updated(){this.fpmoney&&this.fpmoney.destroy(),this.init()},methods:{init(){const e={container:this.$refs.fpmoney};this.value&&(e.value=this.value),this.currencies&&(e.currencies=this.currencies),this.currency&&(e.currency=this.currency),this.locale&&(e.locale=this.locale),this.maxValue&&(e.maxValue=this.maxValue),e.showSelection=this.showSelection,this.onChange&&(e.onChange=this.onChange),this.fpmoney=new o.a(e)}}},i,[],!1,null,null,null);s.options.__file="component.vue";t.default=s.exports}]).default}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FPMoney=t():e.FPMoney=t()}(window,function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=4)}([function(e,t,n){"use strict";function i(e,t){void 0===t&&(t=2),""===(e=e.toString())&&(e="0");for(var n="1",i=0;i<t;i++)n+="0";var r=parseInt(n,10);return-1!==e.indexOf(".")&&(e=(parseFloat(e)*r).toString()),0===t?parseInt(e,10):parseFloat((parseInt(e,10)/r).toFixed(t))}function r(){return void 0!==navigator.languages?navigator.languages[0]:navigator.language?navigator.language:"en-US"}t.__esModule=!0,t.currencies={USD:{symbol:"$",fraction:2},EUR:{symbol:"€",fraction:2},GBP:{symbol:"£",fraction:2},INR:{symbol:"₹",fraction:2},CRC:{symbol:"₡",fraction:2},VND:{symbol:"₫",fraction:0},HUF:{symbol:"Ft",fraction:2},ILS:{symbol:"₪",fraction:2},CNY:{symbol:"¥",fraction:2},KRW:{symbol:"₩",fraction:0},NGN:{symbol:"₦",fraction:2},PYG:{symbol:"₲",fraction:0},PHP:{symbol:"₱",fraction:2},PLN:{symbol:"zł",fraction:2},THB:{symbol:"฿",fraction:2},UAH:{symbol:"₴",fraction:2},JPY:{symbol:"¥",fraction:0}},t.intToFraction=i,t.fractionToInt=function(e,t){void 0===t&&(t=2);for(var n=e.toString(),i="1",r=0;r<t;r++)i+="0";var o=parseInt(i,10),s=Math.round(parseFloat(n)*o).toString();return parseInt(s,10)},t.displayValue=function(e,t,n,o){return void 0===o&&(o=r()),new Intl.NumberFormat(o,{localeMatcher:"best fit",style:"currency",currency:t.toUpperCase(),currencyDisplay:"symbol",minimumFractionDigits:n,maximumFractionDigits:n}).format(i(e,n))},t.getLocale=r},function(e,t,n){"use strict";t.__esModule=!0;var i=n(0);!function(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}(n(0));var r=function(){function e(e){var t;this.value="",this.display="",this.format="",this.currencies=JSON.parse(JSON.stringify(i.currencies)),this.currency="",this.locale=i.getLocale(),this.maxValue=0,this.showSelection=!0,this.validate(e),t="string"==typeof e.container?document.querySelector(e.container):e.container,this.container=t,e.currencies&&(this.currencies=e.currencies),e.currency?this.currency=e.currency.toUpperCase():this.currency=Object.keys(this.currencies)[0],e.locale&&(this.locale=e.locale),e.value&&(this.value=i.fractionToInt(e.value,this.currencies[this.currency].fraction).toString()),e.maxValue&&(this.maxValue=i.fractionToInt(e.maxValue,this.currencies[this.currency].fraction)),void 0!==e.showSelection&&(this.showSelection=e.showSelection),this.onChange=e.onChange?this.onChange=e.onChange:function(){},this.currencyDiv=document.createElement("div"),this.input=document.createElement("input"),this.select=document.createElement("select"),this.render(),this.setCurrency(this.currency)}return e.prototype.setCurrency=function(e){e=e.toUpperCase(),this.currency=e,this.currencyDiv.innerHTML=this.currencies[e].symbol;for(var t=this.currencies[e].fraction,n="",i=0;i<t;i++)n+="0";this.input.placeholder="0"+(0===t?"":"."+n),this.select.value=e,this.updateOutput()},e.prototype.setLocale=function(e){this.locale=e,this.updateOutput()},e.prototype.destroy=function(){this.container.innerHTML=""},e.prototype.validate=function(e){if(!("string"==typeof e.container?document.querySelector(e.container):e.container))throw new Error("Could not find container")},e.prototype.updateOutput=function(){if(""!==this.value){var e=parseInt(this.value,10);0!==this.maxValue&&e>this.maxValue&&(e=this.maxValue),this.value=e.toString()}this.format=i.intToFraction(this.value,this.currencies[this.currency].fraction).toFixed(this.currencies[this.currency].fraction),this.display=i.displayValue(this.value,this.currency,this.currencies[this.currency].fraction,this.locale),this.updateInputDisplay(),this.onChange({value:this.value,display:this.display,format:this.format,currency:this.currency,locale:this.locale})},e.prototype.updateInputDisplay=function(){if(""!==this.value){var e=this.display.replace(this.currencies[this.currency.toUpperCase()].symbol,""),t=this.currency;e=e.replace(t,""),t.split("").forEach(function(n,i){e=e.replace(t.substring(0,t.length-i),"")}),e=e.trim(),this.input.value=e}else this.input.value=""},e.prototype.render=function(){var e=this;for(var t in this.container.classList.add("fpm"),this.currencyDiv.classList.add("fpm-currency"),this.input.classList.add("fpm-value"),this.select.classList.add("fpm-select"),this.input.addEventListener("keydown",function(t){e.inputKeydown(t)},!1),this.input.addEventListener("click",function(t){e.input.focus(),e.moveCursorToEnd(e.input)},!1),this.currencies)if(this.currencies.hasOwnProperty(t)){var n=document.createElement("option");n.value=t,n.text=t.toUpperCase(),this.select.appendChild(n)}this.select.addEventListener("change",function(){e.setCurrency(e.select.value)}),this.container.appendChild(this.currencyDiv),this.container.appendChild(this.input),this.showSelection&&this.container.appendChild(this.select)},e.prototype.inputKeydown=function(e){var t=e.keyCode||e.which;8===t||46===t?(e.preventDefault(),this.value=this.value.substring(0,this.value.length-1),this.updateOutput()):t>=48&&t<=57||t>=96&&t<=105?(e.preventDefault(),this.value+=e.key,this.updateOutput()):9===t||13===t||e.preventDefault()},e.prototype.moveCursorToEnd=function(e){if("number"==typeof e.selectionStart)e.selectionStart=e.selectionEnd=e.value.length;else if(void 0!==e.createTextRange){e.focus();var t=e.createTextRange();t.collapse(!1),t.select()}},e}();t.default=r},,,function(e,t,n){"use strict";n.r(t);var i=function(){var e=this.$createElement;return(this._self._c||e)("div",{ref:"fpmoney"})};i._withStripped=!0;var r=n(1),o=n.n(r);var s=function(e,t,n,i,r,o,s,c){var a,u="function"==typeof e?e.options:e;if(t&&(u.render=t,u.staticRenderFns=n,u._compiled=!0),i&&(u.functional=!0),o&&(u._scopeId="data-v-"+o),s?(a=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),r&&r.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(s)},u._ssrRegister=a):r&&(a=c?function(){r.call(this,this.$root.$options.shadowRoot)}:r),a)if(u.functional){u._injectStyles=a;var l=u.render;u.render=function(e,t){return a.call(t),l(e,t)}}else{var h=u.beforeCreate;u.beforeCreate=h?[].concat(h,a):[a]}return{exports:e,options:u}}({name:"fp-money",props:{value:[String,Number],currencies:Object,currency:String,locale:String,maxValue:Number,onChange:Function,showSelection:{type:Boolean,default:!0}},data:()=>({fpmoney:null}),mounted(){this.init()},updated(){this.fpmoney&&this.fpmoney.destroy(),this.init()},methods:{init(){const e={container:this.$refs.fpmoney};this.value&&(e.value=this.value),this.currencies&&(e.currencies=this.currencies),this.currency&&(e.currency=this.currency),this.locale&&(e.locale=this.locale),this.maxValue&&(e.maxValue=this.maxValue),e.showSelection=this.showSelection,this.onChange&&(e.onChange=this.onChange),this.fpmoney=new o.a(e)}}},i,[],!1,null,null,null);s.options.__file="component.vue";t.default=s.exports}])}); |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.FPMoney=e():t.FPMoney=e()}(window,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(t,e,n){"use strict";function r(t,e){void 0===e&&(e=2),""===(t=t.toString())&&(t="0");for(var n="1",r=0;r<e;r++)n+="0";var i=parseInt(n,10);return-1!==t.indexOf(".")&&(t=(parseFloat(t)*i).toString()),0===e?parseInt(t,10):parseFloat((parseInt(t,10)/i).toFixed(e))}function i(){return void 0!==navigator.languages?navigator.languages[0]:navigator.language?navigator.language:"en-US"}e.__esModule=!0,e.currencies={USD:{symbol:"$",fraction:2},EUR:{symbol:"€",fraction:2},GBP:{symbol:"£",fraction:2},INR:{symbol:"₹",fraction:2},CRC:{symbol:"₡",fraction:2},VND:{symbol:"₫",fraction:0},HUF:{symbol:"Ft",fraction:2},ILS:{symbol:"₪",fraction:2},CNY:{symbol:"¥",fraction:2},KRW:{symbol:"₩",fraction:0},NGN:{symbol:"₦",fraction:2},PYG:{symbol:"₲",fraction:0},PHP:{symbol:"₱",fraction:2},PLN:{symbol:"zł",fraction:2},THB:{symbol:"฿",fraction:2},UAH:{symbol:"₴",fraction:2},JPY:{symbol:"¥",fraction:0}},e.intToFraction=r,e.fractionToInt=function(t,e){void 0===e&&(e=2);for(var n=t.toString(),r="1",i=0;i<e;i++)r+="0";var o=parseInt(r,10),c=Math.round(parseFloat(n)*o).toString();return parseInt(c,10)},e.displayValue=function(t,e,n,o){return void 0===o&&(o=i()),new Intl.NumberFormat(o,{localeMatcher:"best fit",style:"currency",currency:e.toUpperCase(),currencyDisplay:"symbol",minimumFractionDigits:n,maximumFractionDigits:n}).format(r(t,n))},e.getLocale=i},function(t,e,n){"use strict";e.__esModule=!0;var r=n(0);!function(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}(n(0));var i=function(){function t(t){var e;this.value="",this.display="",this.format="",this.currencies=JSON.parse(JSON.stringify(r.currencies)),this.currency="",this.locale=r.getLocale(),this.maxValue=0,this.showSelection=!0,this.validate(t),e="string"==typeof t.container?document.querySelector(t.container):t.container,this.container=e,t.currencies&&(this.currencies=t.currencies),t.currency?this.currency=t.currency.toUpperCase():this.currency=Object.keys(this.currencies)[0],t.locale&&(this.locale=t.locale),t.value&&(this.value=r.fractionToInt(t.value,this.currencies[this.currency].fraction).toString()),t.maxValue&&(this.maxValue=r.fractionToInt(t.maxValue,this.currencies[this.currency].fraction)),void 0!==t.showSelection&&(this.showSelection=t.showSelection),this.onChange=t.onChange?this.onChange=t.onChange:function(){},this.currencyDiv=document.createElement("div"),this.input=document.createElement("input"),this.select=document.createElement("select"),this.render(),this.setCurrency(this.currency)}return t.prototype.setCurrency=function(t){t=t.toUpperCase(),this.currency=t,this.currencyDiv.innerHTML=this.currencies[t].symbol;for(var e=this.currencies[t].fraction,n="",r=0;r<e;r++)n+="0";this.input.placeholder="0"+(0===e?"":"."+n),this.select.value=t,this.updateOutput()},t.prototype.setLocale=function(t){this.locale=t,this.updateOutput()},t.prototype.destroy=function(){this.container.innerHTML=""},t.prototype.validate=function(t){if(!("string"==typeof t.container?document.querySelector(t.container):t.container))throw new Error("Could not find container")},t.prototype.updateOutput=function(){if(""!==this.value){var t=parseInt(this.value,10);0!==this.maxValue&&t>this.maxValue&&(t=this.maxValue),this.value=t.toString()}this.format=r.intToFraction(this.value,this.currencies[this.currency].fraction).toFixed(this.currencies[this.currency].fraction),this.display=r.displayValue(this.value,this.currency,this.currencies[this.currency].fraction,this.locale),this.updateInputDisplay(),this.onChange({value:this.value,display:this.display,format:this.format,currency:this.currency,locale:this.locale})},t.prototype.updateInputDisplay=function(){if(""!==this.value){var t=this.display.replace(this.currencies[this.currency.toUpperCase()].symbol,""),e=this.currency;t=t.replace(e,""),e.split("").forEach(function(n,r){t=t.replace(e.substring(0,e.length-r),"")}),t=t.trim(),this.input.value=t}else this.input.value=""},t.prototype.render=function(){var t=this;for(var e in this.container.classList.add("fpm"),this.currencyDiv.classList.add("fpm-currency"),this.input.classList.add("fpm-value"),this.select.classList.add("fpm-select"),this.input.addEventListener("keydown",function(e){t.inputKeydown(e)},!1),this.input.addEventListener("click",function(e){t.input.focus(),t.moveCursorToEnd(t.input)},!1),this.currencies)if(this.currencies.hasOwnProperty(e)){var n=document.createElement("option");n.value=e,n.text=e.toUpperCase(),this.select.appendChild(n)}this.select.addEventListener("change",function(){t.setCurrency(t.select.value)}),this.container.appendChild(this.currencyDiv),this.container.appendChild(this.input),this.showSelection&&this.container.appendChild(this.select)},t.prototype.inputKeydown=function(t){var e=t.keyCode||t.which;8===e||46===e?(t.preventDefault(),this.value=this.value.substring(0,this.value.length-1),this.updateOutput()):e>=48&&e<=57||e>=96&&e<=105?(t.preventDefault(),this.value+=t.key,this.updateOutput()):9===e||13===e||t.preventDefault()},t.prototype.moveCursorToEnd=function(t){if("number"==typeof t.selectionStart)t.selectionStart=t.selectionEnd=t.value.length;else if(void 0!==t.createTextRange){t.focus();var e=t.createTextRange();e.collapse(!1),e.select()}},t}();e.default=i}]).default}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.FPMoney=e():t.FPMoney=e()}(window,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(t,e,n){"use strict";function r(t,e){void 0===e&&(e=2),""===(t=t.toString())&&(t="0");for(var n="1",r=0;r<e;r++)n+="0";var i=parseInt(n,10);return-1!==t.indexOf(".")&&(t=(parseFloat(t)*i).toString()),0===e?parseInt(t,10):parseFloat((parseInt(t,10)/i).toFixed(e))}function i(){return void 0!==navigator.languages?navigator.languages[0]:navigator.language?navigator.language:"en-US"}e.__esModule=!0,e.currencies={USD:{symbol:"$",fraction:2},EUR:{symbol:"€",fraction:2},GBP:{symbol:"£",fraction:2},INR:{symbol:"₹",fraction:2},CRC:{symbol:"₡",fraction:2},VND:{symbol:"₫",fraction:0},HUF:{symbol:"Ft",fraction:2},ILS:{symbol:"₪",fraction:2},CNY:{symbol:"¥",fraction:2},KRW:{symbol:"₩",fraction:0},NGN:{symbol:"₦",fraction:2},PYG:{symbol:"₲",fraction:0},PHP:{symbol:"₱",fraction:2},PLN:{symbol:"zł",fraction:2},THB:{symbol:"฿",fraction:2},UAH:{symbol:"₴",fraction:2},JPY:{symbol:"¥",fraction:0}},e.intToFraction=r,e.fractionToInt=function(t,e){void 0===e&&(e=2);for(var n=t.toString(),r="1",i=0;i<e;i++)r+="0";var o=parseInt(r,10),c=Math.round(parseFloat(n)*o).toString();return parseInt(c,10)},e.displayValue=function(t,e,n,o){return void 0===o&&(o=i()),new Intl.NumberFormat(o,{localeMatcher:"best fit",style:"currency",currency:e.toUpperCase(),currencyDisplay:"symbol",minimumFractionDigits:n,maximumFractionDigits:n}).format(r(t,n))},e.getLocale=i},function(t,e,n){"use strict";e.__esModule=!0;var r=n(0);!function(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}(n(0));var i=function(){function t(t){var e;this.value="",this.display="",this.format="",this.currencies=JSON.parse(JSON.stringify(r.currencies)),this.currency="",this.locale=r.getLocale(),this.maxValue=0,this.showSelection=!0,this.validate(t),e="string"==typeof t.container?document.querySelector(t.container):t.container,this.container=e,t.currencies&&(this.currencies=t.currencies),t.currency?this.currency=t.currency.toUpperCase():this.currency=Object.keys(this.currencies)[0],t.locale&&(this.locale=t.locale),t.value&&(this.value=r.fractionToInt(t.value,this.currencies[this.currency].fraction).toString()),t.maxValue&&(this.maxValue=r.fractionToInt(t.maxValue,this.currencies[this.currency].fraction)),void 0!==t.showSelection&&(this.showSelection=t.showSelection),this.onChange=t.onChange?this.onChange=t.onChange:function(){},this.currencyDiv=document.createElement("div"),this.input=document.createElement("input"),this.select=document.createElement("select"),this.render(),this.setCurrency(this.currency)}return t.prototype.setCurrency=function(t){t=t.toUpperCase(),this.currency=t,this.currencyDiv.innerHTML=this.currencies[t].symbol;for(var e=this.currencies[t].fraction,n="",r=0;r<e;r++)n+="0";this.input.placeholder="0"+(0===e?"":"."+n),this.select.value=t,this.updateOutput()},t.prototype.setLocale=function(t){this.locale=t,this.updateOutput()},t.prototype.destroy=function(){this.container.innerHTML=""},t.prototype.validate=function(t){if(!("string"==typeof t.container?document.querySelector(t.container):t.container))throw new Error("Could not find container")},t.prototype.updateOutput=function(){if(""!==this.value){var t=parseInt(this.value,10);0!==this.maxValue&&t>this.maxValue&&(t=this.maxValue),this.value=t.toString()}this.format=r.intToFraction(this.value,this.currencies[this.currency].fraction).toFixed(this.currencies[this.currency].fraction),this.display=r.displayValue(this.value,this.currency,this.currencies[this.currency].fraction,this.locale),this.updateInputDisplay(),this.onChange({value:this.value,display:this.display,format:this.format,currency:this.currency,locale:this.locale})},t.prototype.updateInputDisplay=function(){if(""!==this.value){var t=this.display.replace(this.currencies[this.currency.toUpperCase()].symbol,""),e=this.currency;t=t.replace(e,""),e.split("").forEach(function(n,r){t=t.replace(e.substring(0,e.length-r),"")}),t=t.trim(),this.input.value=t}else this.input.value=""},t.prototype.render=function(){var t=this;for(var e in this.container.classList.add("fpm"),this.currencyDiv.classList.add("fpm-currency"),this.input.classList.add("fpm-value"),this.select.classList.add("fpm-select"),this.input.addEventListener("keydown",function(e){t.inputKeydown(e)},!1),this.input.addEventListener("click",function(e){t.input.focus(),t.moveCursorToEnd(t.input)},!1),this.currencies)if(this.currencies.hasOwnProperty(e)){var n=document.createElement("option");n.value=e,n.text=e.toUpperCase(),this.select.appendChild(n)}this.select.addEventListener("change",function(){t.setCurrency(t.select.value)}),this.container.appendChild(this.currencyDiv),this.container.appendChild(this.input),this.showSelection&&this.container.appendChild(this.select)},t.prototype.inputKeydown=function(t){var e=t.keyCode||t.which;8===e||46===e?(t.preventDefault(),this.value=this.value.substring(0,this.value.length-1),this.updateOutput()):e>=48&&e<=57||e>=96&&e<=105?(t.preventDefault(),this.value+=t.key,this.updateOutput()):9===e||13===e||t.preventDefault()},t.prototype.moveCursorToEnd=function(t){if("number"==typeof t.selectionStart)t.selectionStart=t.selectionEnd=t.value.length;else if(void 0!==t.createTextRange){t.focus();var e=t.createTextRange();e.collapse(!1),e.select()}},t}();e.default=i}])}); |
{ | ||
"name": "fp-money", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "FluidPay input formatter and currency selector", |
@@ -67,3 +67,3 @@ const path = require('path') | ||
libraryTarget: 'umd', | ||
libraryExport: 'default', | ||
// libraryExport: 'default', | ||
filename: '[name].js', | ||
@@ -70,0 +70,0 @@ path: path.resolve(__dirname, '../../dist') |
Sorry, the diff of this file is not supported yet
1126333