|
| 1 | +(function (global, factory) { |
| 2 | + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : |
| 3 | + typeof define === 'function' && define.amd ? define(factory) : |
| 4 | + (global.VueIntlNumberformat = factory()); |
| 5 | +}(this, (function () { 'use strict'; |
| 6 | + |
| 7 | + // |
| 8 | + // |
| 9 | + // |
| 10 | + |
| 11 | + var script = { |
| 12 | + name: 'VueIntlNumberformat', |
| 13 | + props: { |
| 14 | + locale: { |
| 15 | + type: String, |
| 16 | + default: 'en-US', |
| 17 | + required: false |
| 18 | + }, |
| 19 | + formatStyle: { |
| 20 | + type: String, |
| 21 | + default: 'decimal', |
| 22 | + required: false |
| 23 | + }, |
| 24 | + currency: { |
| 25 | + type: String, |
| 26 | + required: false |
| 27 | + }, |
| 28 | + maxDigits: { |
| 29 | + type: Number, |
| 30 | + required: false |
| 31 | + }, |
| 32 | + number: { |
| 33 | + type: Number, |
| 34 | + required: true |
| 35 | + } |
| 36 | + }, |
| 37 | + computed: { |
| 38 | + localeString() { |
| 39 | + const t = this; |
| 40 | + return new Intl.NumberFormat(`${t.locale}`, { |
| 41 | + style: `${t.formatStyle}`, |
| 42 | + currency: `${t.currency}`, |
| 43 | + maximumSignificantDigits: t.maxDigits |
| 44 | + }).format(t.number); |
| 45 | + } |
| 46 | + } |
| 47 | + }; |
| 48 | + |
| 49 | + const __vue_script__ = script; |
| 50 | + |
| 51 | + /* template */ |
| 52 | + var __vue_render__ = function () { |
| 53 | + var _vm = this; |
| 54 | + var _h = _vm.$createElement; |
| 55 | + var _c = _vm._self._c || _h; |
| 56 | + return _c("span", [_vm._v(_vm._s(_vm.localeString))]); |
| 57 | + }; |
| 58 | + var __vue_staticRenderFns__ = []; |
| 59 | + __vue_render__._withStripped = true; |
| 60 | + |
| 61 | + const __vue_template__ = typeof __vue_render__ !== 'undefined' ? { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ } : {}; |
| 62 | + /* style */ |
| 63 | + const __vue_inject_styles__ = undefined; |
| 64 | + /* scoped */ |
| 65 | + const __vue_scope_id__ = undefined; |
| 66 | + /* module identifier */ |
| 67 | + const __vue_module_identifier__ = undefined; |
| 68 | + /* functional template */ |
| 69 | + const __vue_is_functional_template__ = false; |
| 70 | + /* component normalizer */ |
| 71 | + function __vue_normalize__(template, style, script$$1, scope, functional, moduleIdentifier, createInjector, createInjectorSSR) { |
| 72 | + const component = (typeof script$$1 === 'function' ? script$$1.options : script$$1) || {}; |
| 73 | + |
| 74 | + { |
| 75 | + component.__file = "/Users/vinayak/Development/Personal/vue-intl-numberformat/src/VueIntlNumberformat.vue"; |
| 76 | + } |
| 77 | + |
| 78 | + if (!component.render) { |
| 79 | + component.render = template.render; |
| 80 | + component.staticRenderFns = template.staticRenderFns; |
| 81 | + component._compiled = true; |
| 82 | + |
| 83 | + if (functional) component.functional = true; |
| 84 | + } |
| 85 | + |
| 86 | + component._scopeId = scope; |
| 87 | + |
| 88 | + return component; |
| 89 | + } |
| 90 | + /* style inject */ |
| 91 | + function __vue_create_injector__() { |
| 92 | + const head = document.head || document.getElementsByTagName('head')[0]; |
| 93 | + const styles = __vue_create_injector__.styles || (__vue_create_injector__.styles = {}); |
| 94 | + const isOldIE = typeof navigator !== 'undefined' && /msie [6-9]\\b/.test(navigator.userAgent.toLowerCase()); |
| 95 | + |
| 96 | + return function addStyle(id, css) { |
| 97 | + if (document.querySelector('style[data-vue-ssr-id~="' + id + '"]')) return; // SSR styles are present. |
| 98 | + |
| 99 | + const group = isOldIE ? css.media || 'default' : id; |
| 100 | + const style = styles[group] || (styles[group] = { ids: [], parts: [], element: undefined }); |
| 101 | + |
| 102 | + if (!style.ids.includes(id)) { |
| 103 | + let code = css.source; |
| 104 | + let index = style.ids.length; |
| 105 | + |
| 106 | + style.ids.push(id); |
| 107 | + |
| 108 | + if (isOldIE) { |
| 109 | + style.element = style.element || document.querySelector('style[data-group=' + group + ']'); |
| 110 | + } |
| 111 | + |
| 112 | + if (!style.element) { |
| 113 | + const el = style.element = document.createElement('style'); |
| 114 | + el.type = 'text/css'; |
| 115 | + |
| 116 | + if (css.media) el.setAttribute('media', css.media); |
| 117 | + if (isOldIE) { |
| 118 | + el.setAttribute('data-group', group); |
| 119 | + el.setAttribute('data-next-index', '0'); |
| 120 | + } |
| 121 | + |
| 122 | + head.appendChild(el); |
| 123 | + } |
| 124 | + |
| 125 | + if (isOldIE) { |
| 126 | + index = parseInt(style.element.getAttribute('data-next-index')); |
| 127 | + style.element.setAttribute('data-next-index', index + 1); |
| 128 | + } |
| 129 | + |
| 130 | + if (style.element.styleSheet) { |
| 131 | + style.parts.push(code); |
| 132 | + style.element.styleSheet.cssText = style.parts.filter(Boolean).join('\n'); |
| 133 | + } else { |
| 134 | + const textNode = document.createTextNode(code); |
| 135 | + const nodes = style.element.childNodes; |
| 136 | + if (nodes[index]) style.element.removeChild(nodes[index]); |
| 137 | + if (nodes.length) style.element.insertBefore(textNode, nodes[index]);else style.element.appendChild(textNode); |
| 138 | + } |
| 139 | + } |
| 140 | + }; |
| 141 | + } |
| 142 | + /* style inject SSR */ |
| 143 | + |
| 144 | + var VueIntlNumberformat = __vue_normalize__(__vue_template__, __vue_inject_styles__, typeof __vue_script__ === 'undefined' ? {} : __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, typeof __vue_create_injector__ !== 'undefined' ? __vue_create_injector__ : function () {}, typeof __vue_create_injector_ssr__ !== 'undefined' ? __vue_create_injector_ssr__ : function () {}); |
| 145 | + |
| 146 | + return VueIntlNumberformat; |
| 147 | + |
| 148 | +}))); |
0 commit comments