Comparing version 0.9.2 to 0.10.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 i(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=3)}([function(e,t,i){"use strict";function n(e,t){void 0===t&&(t=2),""===(e=e.toString())&&(e="0");for(var i="1",n=0;n<t;n++)i+="0";var r=parseInt(i,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=n,t.fractionToInt=function(e,t){void 0===t&&(t=2);for(var i=e.toString(),n="1",r=0;r<t;r++)n+="0";var s=parseInt(n,10),o=Math.round(parseFloat(i)*s).toString();return parseInt(o,10)},t.displayValue=function(e,t,i,s){return void 0===s&&(s=r()),new Intl.NumberFormat(s,{localeMatcher:"best fit",style:"currency",currency:t.toUpperCase(),currencyDisplay:"symbol",minimumFractionDigits:i,maximumFractionDigits:i}).format(n(e,i))},t.getLocale=r,t.isNegative=function(e){return-1!==e.indexOf("-")}},function(e,t,i){"use strict";t.__esModule=!0;var n=i(0);!function(e){for(var i in e)t.hasOwnProperty(i)||(t[i]=e[i])}(i(0));var r=function(){function e(e){var t;this.isNegative=!1,this.value="",this.display="",this.format="",this.currencies=JSON.parse(JSON.stringify(n.currencies)),this.currency="",this.locale=n.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.isNegative=n.isNegative(e.value.toString()),this.value=n.fractionToInt(e.value,this.currencies[this.currency].fraction).toString()),e.maxValue&&(this.maxValue=n.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.setValue=function(e){this.isNegative=n.isNegative(e.toString()),this.value=n.fractionToInt(e,this.currencies[this.currency].fraction).toString(),this.updateOutput()},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,i="",n=0;n<t;n++)i+="0";this.input.placeholder="0"+(0===t?"":"."+i),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.isNegative?(this.value="-"+this.value.replace("-",""),"-"===this.value&&(this.value="")):this.value=this.value.replace("-",""),this.format=n.intToFraction(this.value,this.currencies[this.currency].fraction).toFixed(this.currencies[this.currency].fraction),this.display=n.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(i,n){e=e.replace(t.substring(0,t.length-n),"")}),e=e.trim(),this.isNegative&&(e="-"+e.replace("-","")),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 i=document.createElement("option");i.value=t,i.text=t.toUpperCase(),this.select.appendChild(i)}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,i=e.shiftKey;8===t||46===t?(e.preventDefault(),this.value=this.value.substring(0,this.value.length-1),"-"===this.value&&(this.value=""),this.updateOutput()):t>=48&&t<=57||t>=96&&t<=105?(e.preventDefault(),this.value+=e.key,this.updateOutput()):9===t||13===t||(107===t||i&&187===t?(e.preventDefault(),this.isNegative=!1,this.updateOutput()):109===t||189===t?(e.preventDefault(),this.isNegative=!0,this.updateOutput()):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,i){"use strict";i.r(t);var n=function(){var e=this.$createElement;return(this._self._c||e)("div",{ref:"fpmoney"})};n._withStripped=!0;var r=i(1),s=i.n(r);var o=function(e,t,i,n,r,s,o,a){var c,u="function"==typeof e?e.options:e;if(t&&(u.render=t,u.staticRenderFns=i,u._compiled=!0),n&&(u.functional=!0),s&&(u._scopeId="data-v-"+s),o?(c=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(o)},u._ssrRegister=c):r&&(c=a?function(){r.call(this,this.$root.$options.shadowRoot)}:r),c)if(u.functional){u._injectStyles=c;var l=u.render;u.render=function(e,t){return c.call(t),l(e,t)}}else{var h=u.beforeCreate;u.beforeCreate=h?[].concat(h,c):[c]}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,values:{value:"",format:"",display:"",currency:"",locale:""}}),mounted(){this.init()},updated(){this.fpmoney&&this.fpmoney.destroy(),this.init()},watch:{value(e,t){this.fpmoney.setValue(e)},currency(e,t){this.fpmoney.setCurrency(e)},locale(e,t){this.fpmoney.setLocale(e)}},methods:{init(){const e={container:this.$refs.fpmoney,onChange:e=>{this.values=e,this.$emit("input",this.values.format),this.$emit("update:value",this.values.value),this.$emit("update:format",this.values.format),this.$emit("update:display",this.values.display),this.$emit("update:currency",this.values.currency),this.$emit("update:locale",this.values.locale),this.onChange&&this.onChange(e)}};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.fpmoney=new s.a(e)}}},n,[],!1,null,null,null);o.options.__file="component.vue";t.default=o.exports}])}); | ||
!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 i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=3)}([function(t,e,i){"use strict";e.__esModule=!0;var n=i(1);!function(t){for(var i in t)e.hasOwnProperty(i)||(e[i]=t[i])}(i(1));var r=function(){function t(t){var e;this.isNegative=!1,this.value="",this.display="",this.format="",this.currencies=JSON.parse(JSON.stringify(n.currencies)),this.currency="",this.locale=n.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.isNegative=n.isNegative(t.value.toString()),this.value=n.fractionToInt(t.value,this.currencies[this.currency].fraction).toString()),t.maxValue&&(this.maxValue=n.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.setValue=function(t){this.isNegative=n.isNegative(t.toString()),this.value=n.fractionToInt(t,this.currencies[this.currency].fraction).toString(),this.updateOutput()},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,i="",n=0;n<e;n++)i+="0";this.input.placeholder="0"+(0===e?"":"."+i),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.isNegative?(this.value="-"+this.value.replace("-",""),"-"===this.value&&(this.value="")):this.value=this.value.replace("-",""),this.format=n.intToFraction(this.value,this.currencies[this.currency].fraction).toFixed(this.currencies[this.currency].fraction),this.display=n.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(i,n){t=t.replace(e.substring(0,e.length-n),"")}),t=t.trim(),this.isNegative&&(t="-"+t.replace("-","")),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 i=document.createElement("option");i.value=e,i.text=e.toUpperCase(),this.select.appendChild(i)}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,i=t.shiftKey;8===e||46===e?(t.preventDefault(),this.value=this.value.substring(0,this.value.length-1),"-"===this.value&&(this.value=""),this.updateOutput()):e>=48&&e<=57||e>=96&&e<=105?(t.preventDefault(),this.value+=t.key,this.updateOutput()):9===e||13===e||(107===e||i&&187===e?(t.preventDefault(),this.isNegative=!1,this.updateOutput()):109===e||189===e?(t.preventDefault(),this.isNegative=!0,this.updateOutput()):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=r},function(t,e,i){"use strict";function n(t,e){void 0===e&&(e=2),""===(t=t.toString())&&(t="0");for(var i="1",n=0;n<e;n++)i+="0";var r=parseInt(i,10);return-1!==t.indexOf(".")&&(t=(parseFloat(t)*r).toString()),0===e?parseInt(t,10):parseFloat((parseInt(t,10)/r).toFixed(e))}function r(){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=n,e.fractionToInt=function(t,e){void 0===e&&(e=2);for(var i=t.toString(),n="1",r=0;r<e;r++)n+="0";var s=parseInt(n,10),o=Math.round(parseFloat(i)*s).toString();return parseInt(o,10)},e.displayValue=function(t,e,i,s){return void 0===s&&(s=r()),new Intl.NumberFormat(s,{localeMatcher:"best fit",style:"currency",currency:e.toUpperCase(),currencyDisplay:"symbol",minimumFractionDigits:i,maximumFractionDigits:i}).format(n(t,i))},e.getLocale=r,e.isNegative=function(t){return-1!==t.indexOf("-")}},,function(t,e,i){"use strict";i.r(e);var n=function(){var t=this.$createElement;return(this._self._c||t)("div",{ref:"fpmoney"})};n._withStripped=!0;var r=i(0),s=i.n(r);var o=function(t,e,i,n,r,s,o,a){var c,u="function"==typeof t?t.options:t;if(e&&(u.render=e,u.staticRenderFns=i,u._compiled=!0),n&&(u.functional=!0),s&&(u._scopeId="data-v-"+s),o?(c=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),r&&r.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(o)},u._ssrRegister=c):r&&(c=a?function(){r.call(this,this.$root.$options.shadowRoot)}:r),c)if(u.functional){u._injectStyles=c;var l=u.render;u.render=function(t,e){return c.call(e),l(t,e)}}else{var h=u.beforeCreate;u.beforeCreate=h?[].concat(h,c):[c]}return{exports:t,options:u}}({name:"fp-money",props:{value:[String,Number],currencies:Object,currency:String,locale:String,maxValue:Number,onChange:Function,valueFormat:{type:String,default:"float",validator:t=>-1!==["float","int"].indexOf(t)},showSelection:{type:Boolean,default:!0}},data:()=>({fpmoney:null,values:{value:"",format:"",display:"",currency:"",locale:""}}),mounted(){this.init()},updated(){this.fpmoney&&this.fpmoney.destroy(),this.init()},watch:{value(t,e){"int"===this.valueFormat?this.fpmoney.setValue(Object(r.intToFraction)(t)):this.fpmoney.setValue(t)},currency(t,e){this.fpmoney.setCurrency(t)},locale(t,e){this.fpmoney.setLocale(t)}},methods:{init(){const t={container:this.$refs.fpmoney,onChange:t=>{this.values=t,this.$emit("input","int"===this.valueFormat?this.values.value:this.values.format),this.$emit("update:value",this.values.value),this.$emit("update:format",this.values.format),this.$emit("update:display",this.values.display),this.$emit("update:currency",this.values.currency),this.$emit("update:locale",this.values.locale),this.onChange&&this.onChange(t)}};this.value&&("int"===this.valueFormat?t.value=Object(r.intToFraction)(this.value):t.value=this.value),this.currencies&&(t.currencies=this.currencies),this.currency&&(t.currency=this.currency),this.locale&&(t.locale=this.locale),this.maxValue&&(t.maxValue=this.maxValue),t.showSelection=this.showSelection,this.fpmoney=new s.a(t)}}},n,[],!1,null,null,null);o.options.__file="component.vue";e.default=o.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 i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=1)}([function(t,e,i){"use strict";function n(t,e){void 0===e&&(e=2),""===(t=t.toString())&&(t="0");for(var i="1",n=0;n<e;n++)i+="0";var r=parseInt(i,10);return-1!==t.indexOf(".")&&(t=(parseFloat(t)*r).toString()),0===e?parseInt(t,10):parseFloat((parseInt(t,10)/r).toFixed(e))}function r(){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=n,e.fractionToInt=function(t,e){void 0===e&&(e=2);for(var i=t.toString(),n="1",r=0;r<e;r++)n+="0";var o=parseInt(n,10),s=Math.round(parseFloat(i)*o).toString();return parseInt(s,10)},e.displayValue=function(t,e,i,o){return void 0===o&&(o=r()),new Intl.NumberFormat(o,{localeMatcher:"best fit",style:"currency",currency:e.toUpperCase(),currencyDisplay:"symbol",minimumFractionDigits:i,maximumFractionDigits:i}).format(n(t,i))},e.getLocale=r,e.isNegative=function(t){return-1!==t.indexOf("-")}},function(t,e,i){"use strict";e.__esModule=!0;var n=i(0);!function(t){for(var i in t)e.hasOwnProperty(i)||(e[i]=t[i])}(i(0));var r=function(){function t(t){var e;this.isNegative=!1,this.value="",this.display="",this.format="",this.currencies=JSON.parse(JSON.stringify(n.currencies)),this.currency="",this.locale=n.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.isNegative=n.isNegative(t.value.toString()),this.value=n.fractionToInt(t.value,this.currencies[this.currency].fraction).toString()),t.maxValue&&(this.maxValue=n.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.setValue=function(t){this.isNegative=n.isNegative(t.toString()),this.value=n.fractionToInt(t,this.currencies[this.currency].fraction).toString(),this.updateOutput()},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,i="",n=0;n<e;n++)i+="0";this.input.placeholder="0"+(0===e?"":"."+i),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.isNegative?(this.value="-"+this.value.replace("-",""),"-"===this.value&&(this.value="")):this.value=this.value.replace("-",""),this.format=n.intToFraction(this.value,this.currencies[this.currency].fraction).toFixed(this.currencies[this.currency].fraction),this.display=n.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(i,n){t=t.replace(e.substring(0,e.length-n),"")}),t=t.trim(),this.isNegative&&(t="-"+t.replace("-","")),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 i=document.createElement("option");i.value=e,i.text=e.toUpperCase(),this.select.appendChild(i)}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,i=t.shiftKey;8===e||46===e?(t.preventDefault(),this.value=this.value.substring(0,this.value.length-1),"-"===this.value&&(this.value=""),this.updateOutput()):e>=48&&e<=57||e>=96&&e<=105?(t.preventDefault(),this.value+=t.key,this.updateOutput()):9===e||13===e||(107===e||i&&187===e?(t.preventDefault(),this.isNegative=!1,this.updateOutput()):109===e||189===e?(t.preventDefault(),this.isNegative=!0,this.updateOutput()):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=r}])}); | ||
!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 i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=0)}([function(t,e,i){"use strict";e.__esModule=!0;var n=i(1);!function(t){for(var i in t)e.hasOwnProperty(i)||(e[i]=t[i])}(i(1));var r=function(){function t(t){var e;this.isNegative=!1,this.value="",this.display="",this.format="",this.currencies=JSON.parse(JSON.stringify(n.currencies)),this.currency="",this.locale=n.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.isNegative=n.isNegative(t.value.toString()),this.value=n.fractionToInt(t.value,this.currencies[this.currency].fraction).toString()),t.maxValue&&(this.maxValue=n.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.setValue=function(t){this.isNegative=n.isNegative(t.toString()),this.value=n.fractionToInt(t,this.currencies[this.currency].fraction).toString(),this.updateOutput()},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,i="",n=0;n<e;n++)i+="0";this.input.placeholder="0"+(0===e?"":"."+i),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.isNegative?(this.value="-"+this.value.replace("-",""),"-"===this.value&&(this.value="")):this.value=this.value.replace("-",""),this.format=n.intToFraction(this.value,this.currencies[this.currency].fraction).toFixed(this.currencies[this.currency].fraction),this.display=n.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(i,n){t=t.replace(e.substring(0,e.length-n),"")}),t=t.trim(),this.isNegative&&(t="-"+t.replace("-","")),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 i=document.createElement("option");i.value=e,i.text=e.toUpperCase(),this.select.appendChild(i)}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,i=t.shiftKey;8===e||46===e?(t.preventDefault(),this.value=this.value.substring(0,this.value.length-1),"-"===this.value&&(this.value=""),this.updateOutput()):e>=48&&e<=57||e>=96&&e<=105?(t.preventDefault(),this.value+=t.key,this.updateOutput()):9===e||13===e||(107===e||i&&187===e?(t.preventDefault(),this.isNegative=!1,this.updateOutput()):109===e||189===e?(t.preventDefault(),this.isNegative=!0,this.updateOutput()):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=r},function(t,e,i){"use strict";function n(t,e){void 0===e&&(e=2),""===(t=t.toString())&&(t="0");for(var i="1",n=0;n<e;n++)i+="0";var r=parseInt(i,10);return-1!==t.indexOf(".")&&(t=(parseFloat(t)*r).toString()),0===e?parseInt(t,10):parseFloat((parseInt(t,10)/r).toFixed(e))}function r(){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=n,e.fractionToInt=function(t,e){void 0===e&&(e=2);for(var i=t.toString(),n="1",r=0;r<e;r++)n+="0";var o=parseInt(n,10),s=Math.round(parseFloat(i)*o).toString();return parseInt(s,10)},e.displayValue=function(t,e,i,o){return void 0===o&&(o=r()),new Intl.NumberFormat(o,{localeMatcher:"best fit",style:"currency",currency:e.toUpperCase(),currencyDisplay:"symbol",minimumFractionDigits:i,maximumFractionDigits:i}).format(n(t,i))},e.getLocale=r,e.isNegative=function(t){return-1!==t.indexOf("-")}}])}); |
@@ -1,2 +0,2 @@ | ||
(function(e){function t(t){for(var a,c,o=t[0],s=t[1],l=t[2],p=0,v=[];p<o.length;p++)c=o[p],i[c]&&v.push(i[c][0]),i[c]=0;for(a in s)Object.prototype.hasOwnProperty.call(s,a)&&(e[a]=s[a]);u&&u(t);while(v.length)v.shift()();return r.push.apply(r,l||[]),n()}function n(){for(var e,t=0;t<r.length;t++){for(var n=r[t],a=!0,o=1;o<n.length;o++){var s=n[o];0!==i[s]&&(a=!1)}a&&(r.splice(t--,1),e=c(c.s=n[0]))}return e}var a={},i={app:0},r=[];function c(t){if(a[t])return a[t].exports;var n=a[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,c),n.l=!0,n.exports}c.m=e,c.c=a,c.d=function(e,t,n){c.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},c.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.t=function(e,t){if(1&t&&(e=c(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(c.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)c.d(n,a,function(t){return e[t]}.bind(null,a));return n},c.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return c.d(t,"a",t),t},c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},c.p="/";var o=window["webpackJsonp"]=window["webpackJsonp"]||[],s=o.push.bind(o);o.push=t,o=o.slice();for(var l=0;l<o.length;l++)t(o[l]);var u=s;r.push([0,"chunk-vendors"]),n()})({0:function(e,t,n){e.exports=n("cd49")},"078e":function(e,t,n){"use strict";var a=n("b13f"),i=n.n(a);i.a},"0df1":function(e,t,n){"use strict";var a=n("e637"),i=n.n(a);i.a},"3b63":function(e,t,n){},4286:function(e,t,n){},8325:function(e,t){e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpFNTE3OEEyQTk5QTAxMUUyOUExNUJDMTA0NkE4OTA0RCIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpFNTE3OEEyQjk5QTAxMUUyOUExNUJDMTA0NkE4OTA0RCI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkU1MTc4QTI4OTlBMDExRTI5QTE1QkMxMDQ2QTg5MDREIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkU1MTc4QTI5OTlBMDExRTI5QTE1QkMxMDQ2QTg5MDREIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+m4QGuQAAAyRJREFUeNrEl21ojWEYx895TDPbMNlBK46IUiNmPvHBSUjaqc0H8pF5+aDUKPEBqU2NhRQpX5Rv5jWlDIWlMCv7MMSWsWwmb3tpXub4XXWdPHvc9/Gc41nu+nedc7/8r/99PffLdYdDPsvkwsgkTBwsA/PADJCnzX2gHTwBt8Hl7p537/3whn04XoDZDcpBlk+9P8AFcAghzRkJwPF4zGGw0Y9QS0mAM2AnQj77FqCzrtcwB1Hk81SYojHK4DyGuQ6mhIIrBWB9Xm7ug/6B/nZrBHBegrkFxoVGpnwBMSLR9EcEcC4qb8pP14BWcBcUgewMnF3T34VqhWMFkThLJAalwnENOAKiHpJq1FZgI2AT6HZtuxZwR9GidSHtI30jOrbawxlVX78/AbNfhHlomEUJJI89O2MqeE79T8/nk8nMBm/dK576hZgmA3cp/R4l9/UeSxiHLVIlNm4nFfT0bxyuIj7LHRTKai+zdJobwMKzcZSJb0ePV5PKN+BqAAKE47UlMnERELMM3EdYP/yrd+XYb2mOiYBiQ8OQnoRBlXrl9JZix7D1pHTazu4MoyBcnYamqAjIMTR8G4FT8LuhLsexXYYjICBiqhQBvYb6fLZIJCjPypVvaOoVAW2WcasCnL2Nq82xHJNSqlCeFcDshaPK0twkAhosjZL31QYw+1rlMpWGMArl23SBsZZO58F2tlJXmjOXS+s4WGvpMiBJT/I2PInZ6lIs9/hBsNS1hS6BG0DSqmYEDRlCXQrmy50P1oDRKTSegmNbUsA0zDMwRhPJXeCE3vWLPQMvan6X8AgIa1vcR4AkGZkDR4ejJ1UHpsaVI0g2LInpOsNFUud1rhxSV+fzC9Woz2EZkWQuja7/B+jUrgtIMpy9YCW4n4K41YfzRneW5E1KJTe4B2Zq1Q5EHEtj4U3AfEzR5SVY4l7QYQPJdN2as7RKBF0BPZqqH4VgMAMBL8Byxr7y8zCZiDlnOcEKIPmUpgB5Z2ww5RdOiiRiNajUmWda5IG6WbhsyY2fx6m8gLcoJDJFkH219M3We1+cnda93pfycZpIJEL/s/wSYADmOAwAQgdpBAAAAABJRU5ErkJggg=="},"94b9":function(e,t,n){"use strict";var a=n("3b63"),i=n.n(a);i.a},b13f:function(e,t,n){},bc8c:function(e,t,n){},c30d:function(e,t,n){"use strict";var a=n("4286"),i=n.n(a);i.a},cd49:function(e,t,n){"use strict";n.r(t);n("cadf"),n("551c"),n("097d"),n("dc22");var a=n("2b0e"),i=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"container"},[n("div",{staticClass:"bluebar"}),n("div",{staticClass:"greenbar"}),n("div",{staticClass:"orangebar"}),n("div",{staticClass:"app"},[n("Header"),n("transition",{attrs:{mode:"out-in",name:"slide-left"}},[n("router-view")],1)],1)])},r=[],c=function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{staticClass:"header"},[a("div",{staticClass:"title"},[e._v("FluidPay Money Formatter")]),a("div",{staticClass:"menu"},[a("router-link",{attrs:{to:"/"}},[e._v("Home")]),a("router-link",{attrs:{to:"/functions"}},[e._v("Functions")]),a("router-link",{attrs:{to:"/vue"}},[e._v("Vue")]),a("a",{attrs:{target:"_blank",href:"http://github.com/fluidpay/fp-money"}},[a("img",{attrs:{height:"20",alt:"Github Logomark",src:n("8325")}})])],1)])},o=[],s=a["a"].extend({}),l=s,u=(n("0df1"),n("2877")),p=Object(u["a"])(l,c,o,!1,null,null,null);p.options.__file="header.vue";var v=p.exports,f=a["a"].extend({name:"app",components:{Header:v}}),h=f,d=(n("c30d"),Object(u["a"])(h,i,r,!1,null,null,null));d.options.__file="App.vue";var m=d.exports,y=n("8c4f"),g=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"basic"},[n("div",{attrs:{id:"example"}}),n("div",{staticClass:"outputs"},[e._v("\n Value: "+e._s(e.value)),n("br"),e._v("\n Format: "+e._s(e.format)),n("br"),e._v("\n Display: "+e._s(e.display)),n("br"),e._v("\n Currency: "+e._s(e.currency)+"\n ")]),e._m(0),e._m(1),e._m(2)])},b=[function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("pre",[e._v(" "),n("code",{staticClass:"language-bash"},[e._v("\n npm install fp-money\n ")]),e._v("\n ")])},function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("pre",[e._v(" "),n("code",{staticClass:"language-html"},[e._v('\n <div id="example"></div>\n ')]),e._v("\n ")])},function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("pre",[e._v(" "),n("code",{staticClass:"language-javascript"},[e._v("\n import FPMoney from 'fp-money'\n import 'fp-money/dist/fp-money.css'\n\n new FPMoney({\n container: document.querySelector('#example'),\n // value: 86753.09, // optional - default ''\n // currencies: Object // optional - {USD: {symbol: '$', fraction:2}}\n // currency: 'USD', // optional - default 'USD'\n // locale: 'en-us', // optional - default navigator.language\n // maxValue: 999, // optional - default no limit\n // showSelection: true, // optional - default true\n\n onChange: (values) => {\n console.log(values)\n // {\n // value: \"8675309\",\n // format: \"86753.09\",\n // display: \"$86,753.09\",\n // currency: \"USD\",\n // locale: \"en-US\"\n // }\n }\n })\n ")]),e._v("\n ")])}],_=(n("28a5"),n("a481"),n("6b54"),n("ac6a"),n("456d"),n("c665")),A=n("aa9a"),S={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}};function C(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;e=e.toString(),""===e&&(e="0");for(var n="1",a=0;a<t;a++)n+="0";var i=parseInt(n,10);return-1!==e.indexOf(".")&&(e=(parseFloat(e)*i).toString()),0===t?parseInt(e,10):parseFloat((parseInt(e,10)/i).toFixed(t))}function E(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=e.toString(),a="1",i=0;i<t;i++)a+="0";var r=parseInt(a,10),c=Math.round(parseFloat(n)*r).toString();return parseInt(c,10)}function w(e,t,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:x(),i=new Intl.NumberFormat(a,{localeMatcher:"best fit",style:"currency",currency:t.toUpperCase(),currencyDisplay:"symbol",minimumFractionDigits:n,maximumFractionDigits:n});return i.format(C(e,n))}function x(){return void 0!==navigator.languages?navigator.languages[0]:navigator.language?navigator.language:"en-US"}function I(e){return-1!==e.indexOf("-")}var D=function(){function e(t){var n;Object(_["a"])(this,e),this.isNegative=!1,this.value="",this.display="",this.format="",this.currencies=JSON.parse(JSON.stringify(S)),this.currency="",this.locale=x(),this.maxValue=0,this.showSelection=!0,this.validate(t),n="string"===typeof t.container?document.querySelector(t.container):t.container,this.container=n,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.isNegative=I(t.value.toString()),this.value=E(t.value,this.currencies[this.currency].fraction).toString()),t.maxValue&&(this.maxValue=E(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 Object(A["a"])(e,[{key:"setValue",value:function(e){this.isNegative=I(e.toString()),this.value=E(e,this.currencies[this.currency].fraction).toString(),this.updateOutput()}},{key:"setCurrency",value:function(e){e=e.toUpperCase(),this.currency=e,this.currencyDiv.innerHTML=this.currencies[e].symbol;for(var t=this.currencies[e].fraction,n="",a=0;a<t;a++)n+="0";this.input.placeholder="0"+(0===t?"":"."+n),this.select.value=e,this.updateOutput()}},{key:"setLocale",value:function(e){this.locale=e,this.updateOutput()}},{key:"destroy",value:function(){this.container.innerHTML=""}},{key:"validate",value:function(e){var t;if(t="string"===typeof e.container?document.querySelector(e.container):e.container,!t)throw new Error("Could not find container")}},{key:"updateOutput",value:function(){if(""!==this.value){var e=parseInt(this.value,10);0!==this.maxValue&&e>this.maxValue&&(e=this.maxValue),this.value=e.toString()}this.isNegative?(this.value="-"+this.value.replace("-",""),"-"===this.value&&(this.value="")):this.value=this.value.replace("-",""),this.format=C(this.value,this.currencies[this.currency].fraction).toFixed(this.currencies[this.currency].fraction),this.display=w(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})}},{key:"updateInputDisplay",value: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,a){e=e.replace(t.substring(0,t.length-a),"")}),e=e.trim(),this.isNegative&&(e="-"+e.replace("-","")),this.input.value=e}else this.input.value=""}},{key:"render",value: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)}},{key:"inputKeydown",value:function(e){var t=e.keyCode||e.which,n=e.shiftKey;8===t||46===t?(e.preventDefault(),this.value=this.value.substring(0,this.value.length-1),"-"===this.value&&(this.value=""),this.updateOutput()):t>=48&&t<=57||t>=96&&t<=105?(e.preventDefault(),this.value+=e.key,this.updateOutput()):9===t||13===t||(107===t||n&&187===t?(e.preventDefault(),this.isNegative=!1,this.updateOutput()):109===t||189===t?(e.preventDefault(),this.isNegative=!0,this.updateOutput()):e.preventDefault())}},{key:"moveCursorToEnd",value:function(e){if("number"===typeof e.selectionStart)e.selectionStart=e.selectionEnd=e.value.length;else if("undefined"!==typeof e.createTextRange){e.focus();var t=e.createTextRange();t.collapse(!1),t.select()}}}]),e}(),O=a["a"].extend({data:function(){return{value:"",format:"",display:"",currency:""}},mounted:function(){var e=this;new D({container:document.querySelector("#example"),value:86753.09,onChange:function(t){console.log(t),e.value=t.value,e.format=t.format,e.display=t.display,e.currency=t.currency}})}}),M=O,T=(n("078e"),Object(u["a"])(M,g,b,!1,null,null,null));T.options.__file="home.vue";var j=T.exports,k=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"main functions"},[e._m(0),n("div",{staticClass:"section"},[n("div",{staticClass:"item"},[e._v("fractionToInt(value, fraction): 86753.09 - "+e._s(e.fractionToInt(86753.09,2)))]),n("div",{staticClass:"item"},[e._v("intToFraction(value, fraction): 8675309 - "+e._s(e.intToFraction(8675309,2)))]),n("div",{staticClass:"item"},[e._v("displayValue(value, currency, fraction, locale): 86753.09 - "+e._s(e.displayValue(86753.09,"usd",2,"en-us")))]),n("div",{staticClass:"item"},[e._v("getLocale(): "+e._s(e.getLocale()))])])])},N=[function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("pre",[e._v(" "),n("code",{staticClass:"language-javascript"},[e._v("\n import {\n currencies, // Array of object currencies\n fractionToInt, \n intToFraction, \n displayValue, \n getLocale // Will output a string based upon your local language\n } from 'fp-money'\n ")]),e._v("\n ")])}],R=a["a"].extend({data:function(){return{}},methods:{fractionToInt:function(e,t){return E(e,t)},intToFraction:function(e,t){return C(e,t)},displayValue:function(e,t,n,a){return w(e,t,n,a)},getLocale:function(){return x()}}}),B=R,U=(n("94b9"),Object(u["a"])(B,k,N,!1,null,null,null));U.options.__file="functions.vue";var J=U.exports,Z=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"vue"},[n("fpmoney",{attrs:{id:"example",value:e.int,format:e.format,display:e.display,currency:e.currency,locale:e.locale,onChange:e.change},on:{"update:value":function(t){e.int=t},"update:format":function(t){e.format=t},"update:display":function(t){e.display=t},"update:currency":function(t){e.currency=t},"update:locale":function(t){e.locale=t}},model:{value:e.value,callback:function(t){e.value=t},expression:"value"}}),n("div",{staticClass:"outputs"},[e._v("\n Value: "+e._s(e.int)),n("br"),e._v("\n Format: "+e._s(e.format)),n("br"),e._v("\n Display: "+e._s(e.display)),n("br"),e._v("\n Currency: "+e._s(e.currency)+"\n ")]),e._m(0),e._m(1)],1)},F=[function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("pre",[e._v(" "),n("code",{staticClass:"language-javascript"},[e._v("\n import fpmoney from 'fp-money/dist/fp-money-vue.js'\n\n export default {\n components: { fpmoney },\n data() {\n return {\n value: 86753.09,\n int: '',\n format: '',\n display: '',\n currency: '',\n locale: 'en-us'\n }\n },\n methods: {\n change(values) {\n console.log(values)\n }\n }\n }\n ")]),e._v("\n ")])},function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("pre",[e._v(" "),n("code",{staticClass:"language-html"},[e._v('\n <fpmoney id="example" \n v-model="value" \n :value.sync="int" <-- Optional\n :format.sync="format" <-- Optional\n :display.sync="display" <-- Optional\n :currency.sync="currency" <-- Optional\n :locale="locale" <-- Optional\n :onChange="change" <-- Optional \n :showSelection="true" <-- Optional />\n ')]),e._v("\n ")])}],L=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{ref:"fpmoney"})},P=[],V=(n("c5f6"),{name:"fp-money",props:{value:[String,Number],currencies:Object,currency:String,locale:String,maxValue:Number,onChange:Function,showSelection:{type:Boolean,default:!0}},data:function(){return{fpmoney:null,values:{value:"",format:"",display:"",currency:"",locale:""}}},mounted:function(){this.init()},updated:function(){this.fpmoney&&this.fpmoney.destroy(),this.init()},watch:{value:function(e,t){this.fpmoney.setValue(e)},currency:function(e,t){this.fpmoney.setCurrency(e)},locale:function(e,t){this.fpmoney.setLocale(e)}},methods:{init:function(){var e=this,t={container:this.$refs.fpmoney,onChange:function(t){e.values=t,e.$emit("input",e.values.format),e.$emit("update:value",e.values.value),e.$emit("update:format",e.values.format),e.$emit("update:display",e.values.display),e.$emit("update:currency",e.values.currency),e.$emit("update:locale",e.values.locale),e.onChange&&e.onChange(t)}};this.value&&(t.value=this.value),this.currencies&&(t.currencies=this.currencies),this.currency&&(t.currency=this.currency),this.locale&&(t.locale=this.locale),this.maxValue&&(t.maxValue=this.maxValue),t.showSelection=this.showSelection,this.fpmoney=new D(t)}}}),G=V,W=Object(u["a"])(G,L,P,!1,null,null,null);W.options.__file="component.vue";var Y=W.exports,H=a["a"].extend({components:{fpmoney:Y},data:function(){return{value:86753.09,int:"",format:"",display:"",currency:"",locale:"en-US"}},methods:{change:function(e){console.log(e)}}}),Q=H,X=(n("d57a"),Object(u["a"])(Q,Z,F,!1,null,null,null));X.options.__file="vue.vue";var z=X.exports;a["a"].use(y["a"]);var $=new y["a"]({mode:"history",routes:[{path:"/",component:j},{path:"/functions",component:J},{path:"/vue",component:z}]}),K=n("c197"),q=n.n(K),ee=n("6f35"),te=n.n(ee);n("e391"),n("7362");new te.a({"remove-trailing":!0,"remove-indent":!0,"left-trim":!0,"right-trim":!0}),a["a"].mixin({updated:function(){q.a.highlightAll()}}),a["a"].config.productionTip=!1,new a["a"]({router:$,render:function(e){return e(m)}}).$mount("#app")},d57a:function(e,t,n){"use strict";var a=n("bc8c"),i=n.n(a);i.a},dc22:function(e,t,n){},e637:function(e,t,n){}}); | ||
(function(e){function t(t){for(var a,o,c=t[0],s=t[1],l=t[2],p=0,v=[];p<c.length;p++)o=c[p],i[o]&&v.push(i[o][0]),i[o]=0;for(a in s)Object.prototype.hasOwnProperty.call(s,a)&&(e[a]=s[a]);u&&u(t);while(v.length)v.shift()();return r.push.apply(r,l||[]),n()}function n(){for(var e,t=0;t<r.length;t++){for(var n=r[t],a=!0,c=1;c<n.length;c++){var s=n[c];0!==i[s]&&(a=!1)}a&&(r.splice(t--,1),e=o(o.s=n[0]))}return e}var a={},i={app:0},r=[];function o(t){if(a[t])return a[t].exports;var n=a[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,o),n.l=!0,n.exports}o.m=e,o.c=a,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)o.d(n,a,function(t){return e[t]}.bind(null,a));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="/";var c=window["webpackJsonp"]=window["webpackJsonp"]||[],s=c.push.bind(c);c.push=t,c=c.slice();for(var l=0;l<c.length;l++)t(c[l]);var u=s;r.push([0,"chunk-vendors"]),n()})({0:function(e,t,n){e.exports=n("cd49")},"078e":function(e,t,n){"use strict";var a=n("250c"),i=n.n(a);i.a},"0df1":function(e,t,n){"use strict";var a=n("f6a3"),i=n.n(a);i.a},"250c":function(e,t,n){},"3eba":function(e,t,n){},7721:function(e,t,n){},"7ddf":function(e,t,n){},8325:function(e,t){e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpFNTE3OEEyQTk5QTAxMUUyOUExNUJDMTA0NkE4OTA0RCIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpFNTE3OEEyQjk5QTAxMUUyOUExNUJDMTA0NkE4OTA0RCI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkU1MTc4QTI4OTlBMDExRTI5QTE1QkMxMDQ2QTg5MDREIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkU1MTc4QTI5OTlBMDExRTI5QTE1QkMxMDQ2QTg5MDREIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+m4QGuQAAAyRJREFUeNrEl21ojWEYx895TDPbMNlBK46IUiNmPvHBSUjaqc0H8pF5+aDUKPEBqU2NhRQpX5Rv5jWlDIWlMCv7MMSWsWwmb3tpXub4XXWdPHvc9/Gc41nu+nedc7/8r/99PffLdYdDPsvkwsgkTBwsA/PADJCnzX2gHTwBt8Hl7p537/3whn04XoDZDcpBlk+9P8AFcAghzRkJwPF4zGGw0Y9QS0mAM2AnQj77FqCzrtcwB1Hk81SYojHK4DyGuQ6mhIIrBWB9Xm7ug/6B/nZrBHBegrkFxoVGpnwBMSLR9EcEcC4qb8pP14BWcBcUgewMnF3T34VqhWMFkThLJAalwnENOAKiHpJq1FZgI2AT6HZtuxZwR9GidSHtI30jOrbawxlVX78/AbNfhHlomEUJJI89O2MqeE79T8/nk8nMBm/dK576hZgmA3cp/R4l9/UeSxiHLVIlNm4nFfT0bxyuIj7LHRTKai+zdJobwMKzcZSJb0ePV5PKN+BqAAKE47UlMnERELMM3EdYP/yrd+XYb2mOiYBiQ8OQnoRBlXrl9JZix7D1pHTazu4MoyBcnYamqAjIMTR8G4FT8LuhLsexXYYjICBiqhQBvYb6fLZIJCjPypVvaOoVAW2WcasCnL2Nq82xHJNSqlCeFcDshaPK0twkAhosjZL31QYw+1rlMpWGMArl23SBsZZO58F2tlJXmjOXS+s4WGvpMiBJT/I2PInZ6lIs9/hBsNS1hS6BG0DSqmYEDRlCXQrmy50P1oDRKTSegmNbUsA0zDMwRhPJXeCE3vWLPQMvan6X8AgIa1vcR4AkGZkDR4ejJ1UHpsaVI0g2LInpOsNFUud1rhxSV+fzC9Woz2EZkWQuja7/B+jUrgtIMpy9YCW4n4K41YfzRneW5E1KJTe4B2Zq1Q5EHEtj4U3AfEzR5SVY4l7QYQPJdN2as7RKBF0BPZqqH4VgMAMBL8Byxr7y8zCZiDlnOcEKIPmUpgB5Z2ww5RdOiiRiNajUmWda5IG6WbhsyY2fx6m8gLcoJDJFkH219M3We1+cnda93pfycZpIJEL/s/wSYADmOAwAQgdpBAAAAABJRU5ErkJggg=="},"94b9":function(e,t,n){"use strict";var a=n("7ddf"),i=n.n(a);i.a},c30d:function(e,t,n){"use strict";var a=n("3eba"),i=n.n(a);i.a},cd49:function(e,t,n){"use strict";n.r(t);n("cadf"),n("551c"),n("097d"),n("dc22");var a=n("2b0e"),i=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"container"},[n("div",{staticClass:"bluebar"}),n("div",{staticClass:"greenbar"}),n("div",{staticClass:"orangebar"}),n("div",{staticClass:"app"},[n("Header"),n("transition",{attrs:{mode:"out-in",name:"slide-left"}},[n("router-view")],1)],1)])},r=[],o=function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{staticClass:"header"},[a("div",{staticClass:"title"},[e._v("FluidPay Money Formatter")]),a("div",{staticClass:"menu"},[a("router-link",{attrs:{to:"/"}},[e._v("Home")]),a("router-link",{attrs:{to:"/functions"}},[e._v("Functions")]),a("router-link",{attrs:{to:"/vue"}},[e._v("Vue")]),a("a",{attrs:{target:"_blank",href:"http://github.com/fluidpay/fp-money"}},[a("img",{attrs:{height:"20",alt:"Github Logomark",src:n("8325")}})])],1)])},c=[],s=a["a"].extend({}),l=s,u=(n("0df1"),n("2877")),p=Object(u["a"])(l,o,c,!1,null,null,null);p.options.__file="header.vue";var v=p.exports,f=a["a"].extend({name:"app",components:{Header:v}}),h=f,d=(n("c30d"),Object(u["a"])(h,i,r,!1,null,null,null));d.options.__file="App.vue";var m=d.exports,y=n("8c4f"),g=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"basic"},[n("div",{attrs:{id:"example"}}),n("div",{staticClass:"outputs"},[e._v("\n Value: "+e._s(e.value)),n("br"),e._v("\n Format: "+e._s(e.format)),n("br"),e._v("\n Display: "+e._s(e.display)),n("br"),e._v("\n Currency: "+e._s(e.currency)+"\n ")]),e._m(0),e._m(1),e._m(2)])},b=[function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("pre",[e._v(" "),n("code",{staticClass:"language-bash"},[e._v("\n npm install fp-money\n ")]),e._v("\n ")])},function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("pre",[e._v(" "),n("code",{staticClass:"language-html"},[e._v('\n <div id="example"></div>\n ')]),e._v("\n ")])},function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("pre",[e._v(" "),n("code",{staticClass:"language-javascript"},[e._v("\n import FPMoney from 'fp-money'\n import 'fp-money/dist/fp-money.css'\n\n new FPMoney({\n container: document.querySelector('#example'),\n // value: 86753.09, // optional - default ''\n // currencies: Object // optional - {USD: {symbol: '$', fraction:2}}\n // currency: 'USD', // optional - default 'USD'\n // locale: 'en-us', // optional - default navigator.language\n // maxValue: 999, // optional - default no limit\n // showSelection: true, // optional - default true\n\n onChange: (values) => {\n console.log(values)\n // {\n // value: \"8675309\",\n // format: \"86753.09\",\n // display: \"$86,753.09\",\n // currency: \"USD\",\n // locale: \"en-US\"\n // }\n }\n })\n ")]),e._v("\n ")])}],_=(n("28a5"),n("a481"),n("6b54"),n("ac6a"),n("456d"),n("d4ec")),A=n("bee2"),S={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}};function C(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;e=e.toString(),""===e&&(e="0");for(var n="1",a=0;a<t;a++)n+="0";var i=parseInt(n,10);return-1!==e.indexOf(".")&&(e=(parseFloat(e)*i).toString()),0===t?parseInt(e,10):parseFloat((parseInt(e,10)/i).toFixed(t))}function E(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=e.toString(),a="1",i=0;i<t;i++)a+="0";var r=parseInt(a,10),o=Math.round(parseFloat(n)*r).toString();return parseInt(o,10)}function w(e,t,n){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:x(),i=new Intl.NumberFormat(a,{localeMatcher:"best fit",style:"currency",currency:t.toUpperCase(),currencyDisplay:"symbol",minimumFractionDigits:n,maximumFractionDigits:n});return i.format(C(e,n))}function x(){return void 0!==navigator.languages?navigator.languages[0]:navigator.language?navigator.language:"en-US"}function O(e){return-1!==e.indexOf("-")}var I=function(){function e(t){var n;Object(_["a"])(this,e),this.isNegative=!1,this.value="",this.display="",this.format="",this.currencies=JSON.parse(JSON.stringify(S)),this.currency="",this.locale=x(),this.maxValue=0,this.showSelection=!0,this.validate(t),n="string"===typeof t.container?document.querySelector(t.container):t.container,this.container=n,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.isNegative=O(t.value.toString()),this.value=E(t.value,this.currencies[this.currency].fraction).toString()),t.maxValue&&(this.maxValue=E(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 Object(A["a"])(e,[{key:"setValue",value:function(e){this.isNegative=O(e.toString()),this.value=E(e,this.currencies[this.currency].fraction).toString(),this.updateOutput()}},{key:"setCurrency",value:function(e){e=e.toUpperCase(),this.currency=e,this.currencyDiv.innerHTML=this.currencies[e].symbol;for(var t=this.currencies[e].fraction,n="",a=0;a<t;a++)n+="0";this.input.placeholder="0"+(0===t?"":"."+n),this.select.value=e,this.updateOutput()}},{key:"setLocale",value:function(e){this.locale=e,this.updateOutput()}},{key:"destroy",value:function(){this.container.innerHTML=""}},{key:"validate",value:function(e){var t;if(t="string"===typeof e.container?document.querySelector(e.container):e.container,!t)throw new Error("Could not find container")}},{key:"updateOutput",value:function(){if(""!==this.value){var e=parseInt(this.value,10);0!==this.maxValue&&e>this.maxValue&&(e=this.maxValue),this.value=e.toString()}this.isNegative?(this.value="-"+this.value.replace("-",""),"-"===this.value&&(this.value="")):this.value=this.value.replace("-",""),this.format=C(this.value,this.currencies[this.currency].fraction).toFixed(this.currencies[this.currency].fraction),this.display=w(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})}},{key:"updateInputDisplay",value: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,a){e=e.replace(t.substring(0,t.length-a),"")}),e=e.trim(),this.isNegative&&(e="-"+e.replace("-","")),this.input.value=e}else this.input.value=""}},{key:"render",value: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)}},{key:"inputKeydown",value:function(e){var t=e.keyCode||e.which,n=e.shiftKey;8===t||46===t?(e.preventDefault(),this.value=this.value.substring(0,this.value.length-1),"-"===this.value&&(this.value=""),this.updateOutput()):t>=48&&t<=57||t>=96&&t<=105?(e.preventDefault(),this.value+=e.key,this.updateOutput()):9===t||13===t||(107===t||n&&187===t?(e.preventDefault(),this.isNegative=!1,this.updateOutput()):109===t||189===t?(e.preventDefault(),this.isNegative=!0,this.updateOutput()):e.preventDefault())}},{key:"moveCursorToEnd",value:function(e){if("number"===typeof e.selectionStart)e.selectionStart=e.selectionEnd=e.value.length;else if("undefined"!==typeof e.createTextRange){e.focus();var t=e.createTextRange();t.collapse(!1),t.select()}}}]),e}(),D=a["a"].extend({data:function(){return{value:"",format:"",display:"",currency:""}},mounted:function(){var e=this;new I({container:document.querySelector("#example"),value:86753.09,onChange:function(t){console.log(t),e.value=t.value,e.format=t.format,e.display=t.display,e.currency=t.currency}})}}),M=D,T=(n("078e"),Object(u["a"])(M,g,b,!1,null,null,null));T.options.__file="home.vue";var j=T.exports,k=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"main functions"},[e._m(0),n("div",{staticClass:"section"},[n("div",{staticClass:"item"},[e._v("fractionToInt(value, fraction): 86753.09 - "+e._s(e.fractionToInt(86753.09,2)))]),n("div",{staticClass:"item"},[e._v("intToFraction(value, fraction): 8675309 - "+e._s(e.intToFraction(8675309,2)))]),n("div",{staticClass:"item"},[e._v("displayValue(value, currency, fraction, locale): 86753.09 - "+e._s(e.displayValue(86753.09,"usd",2,"en-us")))]),n("div",{staticClass:"item"},[e._v("getLocale(): "+e._s(e.getLocale()))])])])},N=[function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("pre",[e._v(" "),n("code",{staticClass:"language-javascript"},[e._v("\n import {\n currencies, // Array of object currencies\n fractionToInt, \n intToFraction, \n displayValue, \n getLocale // Will output a string based upon your local language\n } from 'fp-money'\n ")]),e._v("\n ")])}],R=a["a"].extend({data:function(){return{}},methods:{fractionToInt:function(e,t){return E(e,t)},intToFraction:function(e,t){return C(e,t)},displayValue:function(e,t,n,a){return w(e,t,n,a)},getLocale:function(){return x()}}}),B=R,F=(n("94b9"),Object(u["a"])(B,k,N,!1,null,null,null));F.options.__file="functions.vue";var U=F.exports,J=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"vue"},[n("fpmoney",{attrs:{id:"example",value:e.int,format:e.format,display:e.display,currency:e.currency,locale:e.locale,onChange:e.change},on:{"update:value":function(t){e.int=t},"update:format":function(t){e.format=t},"update:display":function(t){e.display=t},"update:currency":function(t){e.currency=t},"update:locale":function(t){e.locale=t}},model:{value:e.value,callback:function(t){e.value=t},expression:"value"}}),n("div",{staticClass:"outputs"},[e._v("\n Value: "+e._s(e.int)),n("br"),e._v("\n Format: "+e._s(e.format)),n("br"),e._v("\n Display: "+e._s(e.display)),n("br"),e._v("\n Currency: "+e._s(e.currency)+"\n ")]),e._m(0),e._m(1)],1)},Z=[function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("pre",[e._v(" "),n("code",{staticClass:"language-javascript"},[e._v("\n import fpmoney from 'fp-money/dist/fp-money-vue.js'\n\n export default {\n components: { fpmoney },\n data() {\n return {\n value: 86753.09,\n int: '',\n format: '',\n display: '',\n currency: '',\n locale: 'en-us'\n }\n },\n methods: {\n change(values) {\n console.log(values)\n }\n }\n }\n ")]),e._v("\n ")])},function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("pre",[e._v(" "),n("code",{staticClass:"language-html"},[e._v('\n <fpmoney id="example" \n v-model="value" \n :value.sync="int" <-- Optional\n :format.sync="format" <-- Optional\n :display.sync="display" <-- Optional\n :currency.sync="currency" <-- Optional\n :locale="locale" <-- Optional\n valueFormat="float | int" <-- Optional - default float\n :onChange="change" <-- Optional \n :showSelection="true" <-- Optional />\n ')]),e._v("\n ")])}],L=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{ref:"fpmoney"})},P=[],V=(n("c5f6"),{name:"fp-money",props:{value:[String,Number],currencies:Object,currency:String,locale:String,maxValue:Number,onChange:Function,valueFormat:{type:String,default:"float",validator:function(e){return-1!==["float","int"].indexOf(e)}},showSelection:{type:Boolean,default:!0}},data:function(){return{fpmoney:null,values:{value:"",format:"",display:"",currency:"",locale:""}}},mounted:function(){this.init()},updated:function(){this.fpmoney&&this.fpmoney.destroy(),this.init()},watch:{value:function(e,t){"int"===this.valueFormat?this.fpmoney.setValue(C(e)):this.fpmoney.setValue(e)},currency:function(e,t){this.fpmoney.setCurrency(e)},locale:function(e,t){this.fpmoney.setLocale(e)}},methods:{init:function(){var e=this,t={container:this.$refs.fpmoney,onChange:function(t){e.values=t,e.$emit("input","int"===e.valueFormat?e.values.value:e.values.format),e.$emit("update:value",e.values.value),e.$emit("update:format",e.values.format),e.$emit("update:display",e.values.display),e.$emit("update:currency",e.values.currency),e.$emit("update:locale",e.values.locale),e.onChange&&e.onChange(t)}};this.value&&("int"===this.valueFormat?t.value=C(this.value):t.value=this.value),this.currencies&&(t.currencies=this.currencies),this.currency&&(t.currency=this.currency),this.locale&&(t.locale=this.locale),this.maxValue&&(t.maxValue=this.maxValue),t.showSelection=this.showSelection,this.fpmoney=new I(t)}}}),G=V,W=Object(u["a"])(G,L,P,!1,null,null,null);W.options.__file="component.vue";var Y=W.exports,H=a["a"].extend({components:{fpmoney:Y},data:function(){return{value:86753.09,int:"",format:"",display:"",currency:"",locale:"en-US"}},methods:{change:function(e){console.log(e)}}}),Q=H,X=(n("d57a"),Object(u["a"])(Q,J,Z,!1,null,null,null));X.options.__file="vue.vue";var z=X.exports;a["a"].use(y["a"]);var $=new y["a"]({mode:"history",routes:[{path:"/",component:j},{path:"/functions",component:U},{path:"/vue",component:z}]}),K=n("c197"),q=n.n(K),ee=n("6f35"),te=n.n(ee);n("e391"),n("7362");new te.a({"remove-trailing":!0,"remove-indent":!0,"left-trim":!0,"right-trim":!0}),a["a"].mixin({updated:function(){q.a.highlightAll()}}),a["a"].config.productionTip=!1,new a["a"]({router:$,render:function(e){return e(m)}}).$mount("#app")},d57a:function(e,t,n){"use strict";var a=n("7721"),i=n.n(a);i.a},dc22:function(e,t,n){},f6a3:function(e,t,n){}}); | ||
//# sourceMappingURL=app.js.map |
{ | ||
"name": "fp-money", | ||
"version": "0.9.2", | ||
"version": "0.10.0", | ||
"private": false, | ||
@@ -24,5 +24,5 @@ "description": "FluidPay input formatter and currency selector", | ||
"@types/prismjs": "^1.9.0", | ||
"@vue/cli-plugin-babel": "^3.0.5", | ||
"@vue/cli-plugin-typescript": "^3.0.5", | ||
"@vue/cli-service": "^3.0.5", | ||
"@vue/cli-plugin-babel": "^3.1.0", | ||
"@vue/cli-plugin-typescript": "^3.1.0", | ||
"@vue/cli-service": "^3.1.0", | ||
"ajv": "^6.5.4", | ||
@@ -29,0 +29,0 @@ "node-sass": "^4.9.4", |
{ | ||
"compilerOptions": { | ||
"declaration": true, // Generates corresponding '.d.ts' file. | ||
"strict": true | ||
"strict": true, | ||
"outDir": "../../dist" // Output to dist folder | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
5403119
3240