@factoringplus/pl-components-pack-v3 0.1.1 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.browserslistrc +3 -0
- package/.editorconfig +7 -0
- package/.storybook/main.js +30 -0
- package/.storybook/preview.js +15 -0
- package/build/rollup.config.js +37 -0
- package/entry.js +32 -34
- package/package.json +11 -11
- package/dist/@factoringplus/pl-components-pack-v3.common.js +0 -996
- package/dist/@factoringplus/pl-components-pack-v3.common.js.map +0 -1
- package/dist/@factoringplus/pl-components-pack-v3.css +0 -1
- package/dist/@factoringplus/pl-components-pack-v3.umd.js +0 -1006
- package/dist/@factoringplus/pl-components-pack-v3.umd.js.map +0 -1
- package/dist/@factoringplus/pl-components-pack-v3.umd.min.js +0 -8
- package/dist/@factoringplus/pl-components-pack-v3.umd.min.js.map +0 -1
- package/dist/demo.html +0 -10
- package/package-lock.json +0 -20696
|
@@ -1,1006 +0,0 @@
|
|
|
1
|
-
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
|
-
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
-
module.exports = factory(require("vue"));
|
|
4
|
-
else if(typeof define === 'function' && define.amd)
|
|
5
|
-
define([], factory);
|
|
6
|
-
else if(typeof exports === 'object')
|
|
7
|
-
exports["@factoringplus/pl-components-pack-v3"] = factory(require("vue"));
|
|
8
|
-
else
|
|
9
|
-
root["@factoringplus/pl-components-pack-v3"] = factory(root["Vue"]);
|
|
10
|
-
})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__8bbf__) {
|
|
11
|
-
return /******/ (function(modules) { // webpackBootstrap
|
|
12
|
-
/******/ // The module cache
|
|
13
|
-
/******/ var installedModules = {};
|
|
14
|
-
/******/
|
|
15
|
-
/******/ // The require function
|
|
16
|
-
/******/ function __webpack_require__(moduleId) {
|
|
17
|
-
/******/
|
|
18
|
-
/******/ // Check if module is in cache
|
|
19
|
-
/******/ if(installedModules[moduleId]) {
|
|
20
|
-
/******/ return installedModules[moduleId].exports;
|
|
21
|
-
/******/ }
|
|
22
|
-
/******/ // Create a new module (and put it into the cache)
|
|
23
|
-
/******/ var module = installedModules[moduleId] = {
|
|
24
|
-
/******/ i: moduleId,
|
|
25
|
-
/******/ l: false,
|
|
26
|
-
/******/ exports: {}
|
|
27
|
-
/******/ };
|
|
28
|
-
/******/
|
|
29
|
-
/******/ // Execute the module function
|
|
30
|
-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
31
|
-
/******/
|
|
32
|
-
/******/ // Flag the module as loaded
|
|
33
|
-
/******/ module.l = true;
|
|
34
|
-
/******/
|
|
35
|
-
/******/ // Return the exports of the module
|
|
36
|
-
/******/ return module.exports;
|
|
37
|
-
/******/ }
|
|
38
|
-
/******/
|
|
39
|
-
/******/
|
|
40
|
-
/******/ // expose the modules object (__webpack_modules__)
|
|
41
|
-
/******/ __webpack_require__.m = modules;
|
|
42
|
-
/******/
|
|
43
|
-
/******/ // expose the module cache
|
|
44
|
-
/******/ __webpack_require__.c = installedModules;
|
|
45
|
-
/******/
|
|
46
|
-
/******/ // define getter function for harmony exports
|
|
47
|
-
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
48
|
-
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
49
|
-
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
50
|
-
/******/ }
|
|
51
|
-
/******/ };
|
|
52
|
-
/******/
|
|
53
|
-
/******/ // define __esModule on exports
|
|
54
|
-
/******/ __webpack_require__.r = function(exports) {
|
|
55
|
-
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
56
|
-
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
57
|
-
/******/ }
|
|
58
|
-
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
59
|
-
/******/ };
|
|
60
|
-
/******/
|
|
61
|
-
/******/ // create a fake namespace object
|
|
62
|
-
/******/ // mode & 1: value is a module id, require it
|
|
63
|
-
/******/ // mode & 2: merge all properties of value into the ns
|
|
64
|
-
/******/ // mode & 4: return value when already ns object
|
|
65
|
-
/******/ // mode & 8|1: behave like require
|
|
66
|
-
/******/ __webpack_require__.t = function(value, mode) {
|
|
67
|
-
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
68
|
-
/******/ if(mode & 8) return value;
|
|
69
|
-
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
70
|
-
/******/ var ns = Object.create(null);
|
|
71
|
-
/******/ __webpack_require__.r(ns);
|
|
72
|
-
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
73
|
-
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
74
|
-
/******/ return ns;
|
|
75
|
-
/******/ };
|
|
76
|
-
/******/
|
|
77
|
-
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
78
|
-
/******/ __webpack_require__.n = function(module) {
|
|
79
|
-
/******/ var getter = module && module.__esModule ?
|
|
80
|
-
/******/ function getDefault() { return module['default']; } :
|
|
81
|
-
/******/ function getModuleExports() { return module; };
|
|
82
|
-
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
83
|
-
/******/ return getter;
|
|
84
|
-
/******/ };
|
|
85
|
-
/******/
|
|
86
|
-
/******/ // Object.prototype.hasOwnProperty.call
|
|
87
|
-
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
88
|
-
/******/
|
|
89
|
-
/******/ // __webpack_public_path__
|
|
90
|
-
/******/ __webpack_require__.p = "";
|
|
91
|
-
/******/
|
|
92
|
-
/******/
|
|
93
|
-
/******/ // Load entry module and return exports
|
|
94
|
-
/******/ return __webpack_require__(__webpack_require__.s = "fb15");
|
|
95
|
-
/******/ })
|
|
96
|
-
/************************************************************************/
|
|
97
|
-
/******/ ({
|
|
98
|
-
|
|
99
|
-
/***/ "023e":
|
|
100
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
101
|
-
|
|
102
|
-
// extracted by mini-css-extract-plugin
|
|
103
|
-
|
|
104
|
-
/***/ }),
|
|
105
|
-
|
|
106
|
-
/***/ "3df6":
|
|
107
|
-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
108
|
-
|
|
109
|
-
"use strict";
|
|
110
|
-
/* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_9_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_9_oneOf_1_1_node_modules_vue_loader_v16_dist_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_9_oneOf_1_2_node_modules_sass_loader_dist_cjs_js_ref_9_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_1_0_node_modules_vue_loader_v16_dist_index_js_ref_1_1_pl_currency_vue_vue_type_style_index_0_id_0538fbc8_lang_scss__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("023e");
|
|
111
|
-
/* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_9_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_9_oneOf_1_1_node_modules_vue_loader_v16_dist_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_9_oneOf_1_2_node_modules_sass_loader_dist_cjs_js_ref_9_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_1_0_node_modules_vue_loader_v16_dist_index_js_ref_1_1_pl_currency_vue_vue_type_style_index_0_id_0538fbc8_lang_scss__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_mini_css_extract_plugin_dist_loader_js_ref_9_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_9_oneOf_1_1_node_modules_vue_loader_v16_dist_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_9_oneOf_1_2_node_modules_sass_loader_dist_cjs_js_ref_9_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_1_0_node_modules_vue_loader_v16_dist_index_js_ref_1_1_pl_currency_vue_vue_type_style_index_0_id_0538fbc8_lang_scss__WEBPACK_IMPORTED_MODULE_0__);
|
|
112
|
-
/* unused harmony reexport * */
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
/***/ }),
|
|
116
|
-
|
|
117
|
-
/***/ "8875":
|
|
118
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
119
|
-
|
|
120
|
-
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// addapted from the document.currentScript polyfill by Adam Miller
|
|
121
|
-
// MIT license
|
|
122
|
-
// source: https://github.com/amiller-gh/currentScript-polyfill
|
|
123
|
-
|
|
124
|
-
// added support for Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1620505
|
|
125
|
-
|
|
126
|
-
(function (root, factory) {
|
|
127
|
-
if (true) {
|
|
128
|
-
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
|
|
129
|
-
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
|
|
130
|
-
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
|
|
131
|
-
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
|
132
|
-
} else {}
|
|
133
|
-
}(typeof self !== 'undefined' ? self : this, function () {
|
|
134
|
-
function getCurrentScript () {
|
|
135
|
-
var descriptor = Object.getOwnPropertyDescriptor(document, 'currentScript')
|
|
136
|
-
// for chrome
|
|
137
|
-
if (!descriptor && 'currentScript' in document && document.currentScript) {
|
|
138
|
-
return document.currentScript
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// for other browsers with native support for currentScript
|
|
142
|
-
if (descriptor && descriptor.get !== getCurrentScript && document.currentScript) {
|
|
143
|
-
return document.currentScript
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// IE 8-10 support script readyState
|
|
147
|
-
// IE 11+ & Firefox support stack trace
|
|
148
|
-
try {
|
|
149
|
-
throw new Error();
|
|
150
|
-
}
|
|
151
|
-
catch (err) {
|
|
152
|
-
// Find the second match for the "at" string to get file src url from stack.
|
|
153
|
-
var ieStackRegExp = /.*at [^(]*\((.*):(.+):(.+)\)$/ig,
|
|
154
|
-
ffStackRegExp = /@([^@]*):(\d+):(\d+)\s*$/ig,
|
|
155
|
-
stackDetails = ieStackRegExp.exec(err.stack) || ffStackRegExp.exec(err.stack),
|
|
156
|
-
scriptLocation = (stackDetails && stackDetails[1]) || false,
|
|
157
|
-
line = (stackDetails && stackDetails[2]) || false,
|
|
158
|
-
currentLocation = document.location.href.replace(document.location.hash, ''),
|
|
159
|
-
pageSource,
|
|
160
|
-
inlineScriptSourceRegExp,
|
|
161
|
-
inlineScriptSource,
|
|
162
|
-
scripts = document.getElementsByTagName('script'); // Live NodeList collection
|
|
163
|
-
|
|
164
|
-
if (scriptLocation === currentLocation) {
|
|
165
|
-
pageSource = document.documentElement.outerHTML;
|
|
166
|
-
inlineScriptSourceRegExp = new RegExp('(?:[^\\n]+?\\n){0,' + (line - 2) + '}[^<]*<script>([\\d\\D]*?)<\\/script>[\\d\\D]*', 'i');
|
|
167
|
-
inlineScriptSource = pageSource.replace(inlineScriptSourceRegExp, '$1').trim();
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
for (var i = 0; i < scripts.length; i++) {
|
|
171
|
-
// If ready state is interactive, return the script tag
|
|
172
|
-
if (scripts[i].readyState === 'interactive') {
|
|
173
|
-
return scripts[i];
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// If src matches, return the script tag
|
|
177
|
-
if (scripts[i].src === scriptLocation) {
|
|
178
|
-
return scripts[i];
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// If inline source matches, return the script tag
|
|
182
|
-
if (
|
|
183
|
-
scriptLocation === currentLocation &&
|
|
184
|
-
scripts[i].innerHTML &&
|
|
185
|
-
scripts[i].innerHTML.trim() === inlineScriptSource
|
|
186
|
-
) {
|
|
187
|
-
return scripts[i];
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// If no match, return null
|
|
192
|
-
return null;
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
return getCurrentScript
|
|
197
|
-
}));
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
/***/ }),
|
|
201
|
-
|
|
202
|
-
/***/ "8afd":
|
|
203
|
-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
204
|
-
|
|
205
|
-
"use strict";
|
|
206
|
-
/* unused harmony export set */
|
|
207
|
-
/* unused harmony export del */
|
|
208
|
-
/* unused harmony export Vue2 */
|
|
209
|
-
/* unused harmony export isVue2 */
|
|
210
|
-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isVue3", function() { return isVue3; });
|
|
211
|
-
/* unused harmony export install */
|
|
212
|
-
/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("8bbf");
|
|
213
|
-
/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(vue__WEBPACK_IMPORTED_MODULE_0__);
|
|
214
|
-
/* harmony reexport (checked) */ if(__webpack_require__.o(vue__WEBPACK_IMPORTED_MODULE_0__, "computed")) __webpack_require__.d(__webpack_exports__, "computed", function() { return vue__WEBPACK_IMPORTED_MODULE_0__["computed"]; });
|
|
215
|
-
|
|
216
|
-
/* harmony reexport (checked) */ if(__webpack_require__.o(vue__WEBPACK_IMPORTED_MODULE_0__, "getCurrentInstance")) __webpack_require__.d(__webpack_exports__, "getCurrentInstance", function() { return vue__WEBPACK_IMPORTED_MODULE_0__["getCurrentInstance"]; });
|
|
217
|
-
|
|
218
|
-
/* harmony reexport (checked) */ if(__webpack_require__.o(vue__WEBPACK_IMPORTED_MODULE_0__, "onUnmounted")) __webpack_require__.d(__webpack_exports__, "onUnmounted", function() { return vue__WEBPACK_IMPORTED_MODULE_0__["onUnmounted"]; });
|
|
219
|
-
|
|
220
|
-
/* harmony reexport (checked) */ if(__webpack_require__.o(vue__WEBPACK_IMPORTED_MODULE_0__, "ref")) __webpack_require__.d(__webpack_exports__, "ref", function() { return vue__WEBPACK_IMPORTED_MODULE_0__["ref"]; });
|
|
221
|
-
|
|
222
|
-
/* harmony reexport (checked) */ if(__webpack_require__.o(vue__WEBPACK_IMPORTED_MODULE_0__, "watch")) __webpack_require__.d(__webpack_exports__, "watch", function() { return vue__WEBPACK_IMPORTED_MODULE_0__["watch"]; });
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
var isVue2 = false
|
|
227
|
-
var isVue3 = true
|
|
228
|
-
var Vue2 = undefined
|
|
229
|
-
|
|
230
|
-
function install() {}
|
|
231
|
-
|
|
232
|
-
function set(target, key, val) {
|
|
233
|
-
if (Array.isArray(target)) {
|
|
234
|
-
target.length = Math.max(target.length, key)
|
|
235
|
-
target.splice(key, 1, val)
|
|
236
|
-
return val
|
|
237
|
-
}
|
|
238
|
-
target[key] = val
|
|
239
|
-
return val
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
function del(target, key) {
|
|
243
|
-
if (Array.isArray(target)) {
|
|
244
|
-
target.splice(key, 1)
|
|
245
|
-
return
|
|
246
|
-
}
|
|
247
|
-
delete target[key]
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
/***/ }),
|
|
255
|
-
|
|
256
|
-
/***/ "8bbf":
|
|
257
|
-
/***/ (function(module, exports) {
|
|
258
|
-
|
|
259
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE__8bbf__;
|
|
260
|
-
|
|
261
|
-
/***/ }),
|
|
262
|
-
|
|
263
|
-
/***/ "fb15":
|
|
264
|
-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
265
|
-
|
|
266
|
-
"use strict";
|
|
267
|
-
// ESM COMPAT FLAG
|
|
268
|
-
__webpack_require__.r(__webpack_exports__);
|
|
269
|
-
|
|
270
|
-
// CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/setPublicPath.js
|
|
271
|
-
// This file is imported into lib/wc client bundles.
|
|
272
|
-
|
|
273
|
-
if (typeof window !== 'undefined') {
|
|
274
|
-
var currentScript = window.document.currentScript
|
|
275
|
-
if (true) {
|
|
276
|
-
var getCurrentScript = __webpack_require__("8875")
|
|
277
|
-
currentScript = getCurrentScript()
|
|
278
|
-
|
|
279
|
-
// for backward compatibility, because previously we directly included the polyfill
|
|
280
|
-
if (!('currentScript' in document)) {
|
|
281
|
-
Object.defineProperty(document, 'currentScript', { get: getCurrentScript })
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
var src = currentScript && currentScript.src.match(/(.+\/)[^/]+\.js(\?.*)?$/)
|
|
286
|
-
if (src) {
|
|
287
|
-
__webpack_require__.p = src[1] // eslint-disable-line
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
// Indicate to webpack that this file can be concatenated
|
|
292
|
-
/* harmony default export */ var setPublicPath = (null);
|
|
293
|
-
|
|
294
|
-
// EXTERNAL MODULE: external {"commonjs":"vue","commonjs2":"vue","root":"Vue"}
|
|
295
|
-
var external_commonjs_vue_commonjs2_vue_root_Vue_ = __webpack_require__("8bbf");
|
|
296
|
-
|
|
297
|
-
// EXTERNAL MODULE: ./node_modules/vue-demi/lib/index.mjs
|
|
298
|
-
var lib = __webpack_require__("8afd");
|
|
299
|
-
|
|
300
|
-
// CONCATENATED MODULE: ./node_modules/vue-currency-input/dist/index.esm.js
|
|
301
|
-
/**
|
|
302
|
-
* Vue Currency Input 2.4.0
|
|
303
|
-
* (c) 2018-2022 Matthias Stiller
|
|
304
|
-
* @license MIT
|
|
305
|
-
*/
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
const escapeRegExp = (str) => {
|
|
309
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
310
|
-
};
|
|
311
|
-
const removeLeadingZeros = (str) => {
|
|
312
|
-
return str.replace(/^0+(0$|[^0])/, '$1');
|
|
313
|
-
};
|
|
314
|
-
const count = (str, search) => {
|
|
315
|
-
return (str.match(new RegExp(escapeRegExp(search), 'g')) || []).length;
|
|
316
|
-
};
|
|
317
|
-
const substringBefore = (str, search) => {
|
|
318
|
-
return str.substring(0, str.indexOf(search));
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
var CurrencyDisplay;
|
|
322
|
-
(function (CurrencyDisplay) {
|
|
323
|
-
CurrencyDisplay["symbol"] = "symbol";
|
|
324
|
-
CurrencyDisplay["narrowSymbol"] = "narrowSymbol";
|
|
325
|
-
CurrencyDisplay["code"] = "code";
|
|
326
|
-
CurrencyDisplay["name"] = "name";
|
|
327
|
-
CurrencyDisplay["hidden"] = "hidden";
|
|
328
|
-
})(CurrencyDisplay || (CurrencyDisplay = {}));
|
|
329
|
-
var ValueScaling;
|
|
330
|
-
(function (ValueScaling) {
|
|
331
|
-
ValueScaling["precision"] = "precision";
|
|
332
|
-
ValueScaling["thousands"] = "thousands";
|
|
333
|
-
ValueScaling["millions"] = "millions";
|
|
334
|
-
ValueScaling["billions"] = "billions";
|
|
335
|
-
})(ValueScaling || (ValueScaling = {}));
|
|
336
|
-
const parse = (formattedValue, options) => {
|
|
337
|
-
return new CurrencyFormat(options).parse(formattedValue);
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
const DECIMAL_SEPARATORS = [',', '.', '٫'];
|
|
341
|
-
const INTEGER_PATTERN = '(0|[1-9]\\d*)';
|
|
342
|
-
class CurrencyFormat {
|
|
343
|
-
constructor(options) {
|
|
344
|
-
var _a, _b, _c, _d, _e, _f;
|
|
345
|
-
const { currency, currencyDisplay, locale, precision, accountingSign } = options;
|
|
346
|
-
this.locale = locale;
|
|
347
|
-
this.options = {
|
|
348
|
-
style: 'currency',
|
|
349
|
-
currency,
|
|
350
|
-
currencySign: accountingSign ? 'accounting' : undefined,
|
|
351
|
-
currencyDisplay: currencyDisplay !== CurrencyDisplay.hidden ? currencyDisplay : undefined
|
|
352
|
-
};
|
|
353
|
-
const numberFormat = new Intl.NumberFormat(locale, this.options);
|
|
354
|
-
const formatParts = numberFormat.formatToParts(123456);
|
|
355
|
-
this.currency = (_a = formatParts.find(({ type }) => type === 'currency')) === null || _a === void 0 ? void 0 : _a.value;
|
|
356
|
-
this.digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map((i) => i.toLocaleString(locale));
|
|
357
|
-
this.decimalSymbol = (_b = formatParts.find(({ type }) => type === 'decimal')) === null || _b === void 0 ? void 0 : _b.value;
|
|
358
|
-
this.groupingSymbol = (_c = formatParts.find(({ type }) => type === 'group')) === null || _c === void 0 ? void 0 : _c.value;
|
|
359
|
-
this.minusSign = (_d = numberFormat.formatToParts(-1).find(({ type }) => type === 'minusSign')) === null || _d === void 0 ? void 0 : _d.value;
|
|
360
|
-
if (this.decimalSymbol === undefined) {
|
|
361
|
-
this.minimumFractionDigits = this.maximumFractionDigits = 0;
|
|
362
|
-
}
|
|
363
|
-
else if (typeof precision === 'number') {
|
|
364
|
-
this.minimumFractionDigits = this.maximumFractionDigits = precision;
|
|
365
|
-
}
|
|
366
|
-
else {
|
|
367
|
-
this.minimumFractionDigits = (_e = precision === null || precision === void 0 ? void 0 : precision.min) !== null && _e !== void 0 ? _e : numberFormat.resolvedOptions().minimumFractionDigits;
|
|
368
|
-
this.maximumFractionDigits = (_f = precision === null || precision === void 0 ? void 0 : precision.max) !== null && _f !== void 0 ? _f : numberFormat.resolvedOptions().maximumFractionDigits;
|
|
369
|
-
}
|
|
370
|
-
const getPrefix = (str) => {
|
|
371
|
-
return substringBefore(str, this.digits[1]);
|
|
372
|
-
};
|
|
373
|
-
const getSuffix = (str) => {
|
|
374
|
-
return str.substring(str.lastIndexOf(this.decimalSymbol ? this.digits[0] : this.digits[1]) + 1);
|
|
375
|
-
};
|
|
376
|
-
this.prefix = getPrefix(numberFormat.format(1));
|
|
377
|
-
this.suffix = getSuffix(numberFormat.format(1));
|
|
378
|
-
this.negativePrefix = getPrefix(numberFormat.format(-1));
|
|
379
|
-
this.negativeSuffix = getSuffix(numberFormat.format(-1));
|
|
380
|
-
}
|
|
381
|
-
parse(str) {
|
|
382
|
-
if (str) {
|
|
383
|
-
const negative = this.isNegative(str);
|
|
384
|
-
str = this.normalizeDigits(str);
|
|
385
|
-
str = this.stripCurrency(str, negative);
|
|
386
|
-
str = this.stripSignLiterals(str);
|
|
387
|
-
const fraction = this.decimalSymbol ? `(?:${escapeRegExp(this.decimalSymbol)}(\\d*))?` : '';
|
|
388
|
-
const match = this.stripGroupingSeparator(str).match(new RegExp(`^${INTEGER_PATTERN}${fraction}$`));
|
|
389
|
-
if (match && this.isValidIntegerFormat(this.decimalSymbol ? str.split(this.decimalSymbol)[0] : str, Number(match[1]))) {
|
|
390
|
-
return Number(`${negative ? '-' : ''}${this.onlyDigits(match[1])}.${this.onlyDigits(match[2] || '')}`);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
return null;
|
|
394
|
-
}
|
|
395
|
-
isValidIntegerFormat(formattedNumber, integerNumber) {
|
|
396
|
-
const options = { ...this.options, minimumFractionDigits: 0 };
|
|
397
|
-
return [
|
|
398
|
-
this.stripCurrency(this.normalizeDigits(integerNumber.toLocaleString(this.locale, {
|
|
399
|
-
...options,
|
|
400
|
-
useGrouping: true
|
|
401
|
-
})), false),
|
|
402
|
-
this.stripCurrency(this.normalizeDigits(integerNumber.toLocaleString(this.locale, {
|
|
403
|
-
...options,
|
|
404
|
-
useGrouping: false
|
|
405
|
-
})), false)
|
|
406
|
-
].includes(formattedNumber);
|
|
407
|
-
}
|
|
408
|
-
format(value, options = {
|
|
409
|
-
minimumFractionDigits: this.minimumFractionDigits,
|
|
410
|
-
maximumFractionDigits: this.maximumFractionDigits
|
|
411
|
-
}) {
|
|
412
|
-
return value != null ? value.toLocaleString(this.locale, { ...this.options, ...options }) : '';
|
|
413
|
-
}
|
|
414
|
-
toFraction(str) {
|
|
415
|
-
return `${this.digits[0]}${this.decimalSymbol}${this.onlyLocaleDigits(str.substr(1)).substr(0, this.maximumFractionDigits)}`;
|
|
416
|
-
}
|
|
417
|
-
isFractionIncomplete(str) {
|
|
418
|
-
return !!this.normalizeDigits(this.stripGroupingSeparator(str)).match(new RegExp(`^${INTEGER_PATTERN}${escapeRegExp(this.decimalSymbol)}$`));
|
|
419
|
-
}
|
|
420
|
-
isNegative(str) {
|
|
421
|
-
return (str.startsWith(this.negativePrefix) ||
|
|
422
|
-
(this.minusSign === undefined && (str.startsWith('(') || str.startsWith('-'))) ||
|
|
423
|
-
(this.minusSign !== undefined && str.replace('-', this.minusSign).startsWith(this.minusSign)));
|
|
424
|
-
}
|
|
425
|
-
insertCurrency(str, negative) {
|
|
426
|
-
return `${negative ? this.negativePrefix : this.prefix}${str}${negative ? this.negativeSuffix : this.suffix}`;
|
|
427
|
-
}
|
|
428
|
-
stripGroupingSeparator(str) {
|
|
429
|
-
return this.groupingSymbol !== undefined ? str.replace(new RegExp(escapeRegExp(this.groupingSymbol), 'g'), '') : str;
|
|
430
|
-
}
|
|
431
|
-
stripSignLiterals(str) {
|
|
432
|
-
if (this.minusSign !== undefined) {
|
|
433
|
-
return str.replace('-', this.minusSign).replace(this.minusSign, '');
|
|
434
|
-
}
|
|
435
|
-
else {
|
|
436
|
-
return str.replace(/[-()]/g, '');
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
stripCurrency(str, negative) {
|
|
440
|
-
return str.replace(negative ? this.negativePrefix : this.prefix, '').replace(negative ? this.negativeSuffix : this.suffix, '');
|
|
441
|
-
}
|
|
442
|
-
normalizeDecimalSeparator(str, from) {
|
|
443
|
-
DECIMAL_SEPARATORS.forEach((s) => {
|
|
444
|
-
str = str.substr(0, from) + str.substr(from).replace(s, this.decimalSymbol);
|
|
445
|
-
});
|
|
446
|
-
return str;
|
|
447
|
-
}
|
|
448
|
-
normalizeDigits(str) {
|
|
449
|
-
if (this.digits[0] !== '0') {
|
|
450
|
-
this.digits.forEach((digit, index) => {
|
|
451
|
-
str = str.replace(new RegExp(digit, 'g'), String(index));
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
|
-
return str;
|
|
455
|
-
}
|
|
456
|
-
onlyDigits(str) {
|
|
457
|
-
return this.normalizeDigits(str).replace(/\D+/g, '');
|
|
458
|
-
}
|
|
459
|
-
onlyLocaleDigits(str) {
|
|
460
|
-
return str.replace(new RegExp(`[^${this.digits.join('')}]*`, 'g'), '');
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
class AbstractInputMask {
|
|
465
|
-
constructor(currencyFormat) {
|
|
466
|
-
this.currencyFormat = currencyFormat;
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
class DefaultInputMask extends AbstractInputMask {
|
|
470
|
-
conformToMask(str, previousConformedValue = '') {
|
|
471
|
-
const negative = this.currencyFormat.isNegative(str);
|
|
472
|
-
const isEmptyNegativeValue = (str) => str === '' &&
|
|
473
|
-
negative &&
|
|
474
|
-
!(this.currencyFormat.minusSign === undefined
|
|
475
|
-
? previousConformedValue === this.currencyFormat.negativePrefix + this.currencyFormat.negativeSuffix
|
|
476
|
-
: previousConformedValue === this.currencyFormat.negativePrefix);
|
|
477
|
-
const checkIncompleteValue = (str) => {
|
|
478
|
-
if (isEmptyNegativeValue(str)) {
|
|
479
|
-
return '';
|
|
480
|
-
}
|
|
481
|
-
else if (this.currencyFormat.maximumFractionDigits > 0) {
|
|
482
|
-
if (this.currencyFormat.isFractionIncomplete(str)) {
|
|
483
|
-
return str;
|
|
484
|
-
}
|
|
485
|
-
else if (str.startsWith(this.currencyFormat.decimalSymbol)) {
|
|
486
|
-
return this.currencyFormat.toFraction(str);
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
return null;
|
|
490
|
-
};
|
|
491
|
-
let value = str;
|
|
492
|
-
value = this.currencyFormat.stripCurrency(value, negative);
|
|
493
|
-
value = this.currencyFormat.stripSignLiterals(value);
|
|
494
|
-
const incompleteValue = checkIncompleteValue(value);
|
|
495
|
-
if (incompleteValue != null) {
|
|
496
|
-
return this.currencyFormat.insertCurrency(incompleteValue, negative);
|
|
497
|
-
}
|
|
498
|
-
const [integer, ...fraction] = value.split(this.currencyFormat.decimalSymbol);
|
|
499
|
-
const integerDigits = removeLeadingZeros(this.currencyFormat.onlyDigits(integer));
|
|
500
|
-
const fractionDigits = this.currencyFormat.onlyDigits(fraction.join('')).substr(0, this.currencyFormat.maximumFractionDigits);
|
|
501
|
-
const invalidFraction = fraction.length > 0 && fractionDigits.length === 0;
|
|
502
|
-
const invalidNegativeValue = integerDigits === '' &&
|
|
503
|
-
negative &&
|
|
504
|
-
(this.currencyFormat.minusSign === undefined
|
|
505
|
-
? previousConformedValue === str.slice(0, -2) + this.currencyFormat.negativeSuffix
|
|
506
|
-
: previousConformedValue === str.slice(0, -1));
|
|
507
|
-
if (invalidFraction || invalidNegativeValue || isEmptyNegativeValue(integerDigits)) {
|
|
508
|
-
return previousConformedValue;
|
|
509
|
-
}
|
|
510
|
-
else if (integerDigits.match(/\d+/)) {
|
|
511
|
-
return {
|
|
512
|
-
numberValue: Number(`${negative ? '-' : ''}${integerDigits}.${fractionDigits}`),
|
|
513
|
-
fractionDigits
|
|
514
|
-
};
|
|
515
|
-
}
|
|
516
|
-
else {
|
|
517
|
-
return '';
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
class AutoDecimalDigitsInputMask extends AbstractInputMask {
|
|
522
|
-
conformToMask(str, previousConformedValue = '') {
|
|
523
|
-
if (str === '' ||
|
|
524
|
-
(this.currencyFormat.parse(previousConformedValue) === 0 &&
|
|
525
|
-
this.currencyFormat.stripCurrency(previousConformedValue, true).slice(0, -1) === this.currencyFormat.stripCurrency(str, true))) {
|
|
526
|
-
return '';
|
|
527
|
-
}
|
|
528
|
-
const negative = this.currencyFormat.isNegative(str);
|
|
529
|
-
const numberValue = this.currencyFormat.stripSignLiterals(str) === ''
|
|
530
|
-
? -0
|
|
531
|
-
: Number(`${negative ? '-' : ''}${removeLeadingZeros(this.currencyFormat.onlyDigits(str))}`) / Math.pow(10, this.currencyFormat.maximumFractionDigits);
|
|
532
|
-
return {
|
|
533
|
-
numberValue,
|
|
534
|
-
fractionDigits: numberValue.toFixed(this.currencyFormat.maximumFractionDigits).slice(-this.currencyFormat.maximumFractionDigits)
|
|
535
|
-
};
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
const DEFAULT_OPTIONS = {
|
|
540
|
-
locale: undefined,
|
|
541
|
-
currency: undefined,
|
|
542
|
-
currencyDisplay: undefined,
|
|
543
|
-
exportValueAsInteger: false,
|
|
544
|
-
hideGroupingSeparatorOnFocus: true,
|
|
545
|
-
hideCurrencySymbolOnFocus: true,
|
|
546
|
-
hideNegligibleDecimalDigitsOnFocus: true,
|
|
547
|
-
precision: undefined,
|
|
548
|
-
autoDecimalDigits: false,
|
|
549
|
-
valueRange: undefined,
|
|
550
|
-
autoSign: true,
|
|
551
|
-
useGrouping: true,
|
|
552
|
-
valueScaling: undefined
|
|
553
|
-
};
|
|
554
|
-
class CurrencyInput {
|
|
555
|
-
constructor(el, options) {
|
|
556
|
-
this.el = el;
|
|
557
|
-
this.numberValue = null;
|
|
558
|
-
this.addEventListener();
|
|
559
|
-
this.init(options);
|
|
560
|
-
this.setValue(this.currencyFormat.parse(this.el.value));
|
|
561
|
-
}
|
|
562
|
-
setOptions(options) {
|
|
563
|
-
this.init(options);
|
|
564
|
-
this.applyFixedFractionFormat(this.numberValue, true);
|
|
565
|
-
}
|
|
566
|
-
getValue() {
|
|
567
|
-
const numberValue = this.valueScaling && this.numberValue != null ? this.toInteger(this.numberValue, this.valueScaling) : this.numberValue;
|
|
568
|
-
return { number: numberValue, formatted: this.formattedValue };
|
|
569
|
-
}
|
|
570
|
-
setValue(value) {
|
|
571
|
-
const newValue = this.valueScaling !== undefined && value != null ? this.toFloat(value, this.valueScaling) : value;
|
|
572
|
-
if (newValue !== this.numberValue) {
|
|
573
|
-
this.applyFixedFractionFormat(newValue);
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
dispatchEvent(eventName) {
|
|
577
|
-
this.el.dispatchEvent(new CustomEvent(eventName, { detail: this.getValue() }));
|
|
578
|
-
}
|
|
579
|
-
init(options) {
|
|
580
|
-
this.options = {
|
|
581
|
-
...DEFAULT_OPTIONS,
|
|
582
|
-
...options
|
|
583
|
-
};
|
|
584
|
-
if (this.options.autoDecimalDigits) {
|
|
585
|
-
this.options.hideNegligibleDecimalDigitsOnFocus = false;
|
|
586
|
-
this.el.setAttribute('inputmode', 'numeric');
|
|
587
|
-
}
|
|
588
|
-
else {
|
|
589
|
-
this.el.setAttribute('inputmode', 'decimal');
|
|
590
|
-
}
|
|
591
|
-
this.currencyFormat = new CurrencyFormat(this.options);
|
|
592
|
-
this.numberMask = this.options.autoDecimalDigits ? new AutoDecimalDigitsInputMask(this.currencyFormat) : new DefaultInputMask(this.currencyFormat);
|
|
593
|
-
const valueScalingOptions = {
|
|
594
|
-
[ValueScaling.precision]: this.currencyFormat.maximumFractionDigits,
|
|
595
|
-
[ValueScaling.thousands]: 3,
|
|
596
|
-
[ValueScaling.millions]: 6,
|
|
597
|
-
[ValueScaling.billions]: 9
|
|
598
|
-
};
|
|
599
|
-
if (this.options.exportValueAsInteger) {
|
|
600
|
-
this.valueScaling = valueScalingOptions[ValueScaling.precision];
|
|
601
|
-
}
|
|
602
|
-
else {
|
|
603
|
-
this.valueScaling = this.options.valueScaling ? valueScalingOptions[this.options.valueScaling] : undefined;
|
|
604
|
-
}
|
|
605
|
-
this.valueScalingFractionDigits =
|
|
606
|
-
this.valueScaling !== undefined && this.options.valueScaling !== ValueScaling.precision
|
|
607
|
-
? this.valueScaling + this.currencyFormat.maximumFractionDigits
|
|
608
|
-
: this.currencyFormat.maximumFractionDigits;
|
|
609
|
-
this.minValue = this.getMinValue();
|
|
610
|
-
this.maxValue = this.getMaxValue();
|
|
611
|
-
}
|
|
612
|
-
getMinValue() {
|
|
613
|
-
var _a, _b;
|
|
614
|
-
let min = this.toFloat(-Number.MAX_SAFE_INTEGER);
|
|
615
|
-
if (((_a = this.options.valueRange) === null || _a === void 0 ? void 0 : _a.min) !== undefined) {
|
|
616
|
-
min = Math.max((_b = this.options.valueRange) === null || _b === void 0 ? void 0 : _b.min, this.toFloat(-Number.MAX_SAFE_INTEGER));
|
|
617
|
-
}
|
|
618
|
-
if (!this.options.autoSign && min < 0) {
|
|
619
|
-
min = 0;
|
|
620
|
-
}
|
|
621
|
-
return min;
|
|
622
|
-
}
|
|
623
|
-
getMaxValue() {
|
|
624
|
-
var _a, _b;
|
|
625
|
-
let max = this.toFloat(Number.MAX_SAFE_INTEGER);
|
|
626
|
-
if (((_a = this.options.valueRange) === null || _a === void 0 ? void 0 : _a.max) !== undefined) {
|
|
627
|
-
max = Math.min((_b = this.options.valueRange) === null || _b === void 0 ? void 0 : _b.max, this.toFloat(Number.MAX_SAFE_INTEGER));
|
|
628
|
-
}
|
|
629
|
-
if (!this.options.autoSign && max < 0) {
|
|
630
|
-
max = this.toFloat(Number.MAX_SAFE_INTEGER);
|
|
631
|
-
}
|
|
632
|
-
return max;
|
|
633
|
-
}
|
|
634
|
-
toFloat(value, maxFractionDigits) {
|
|
635
|
-
return value / Math.pow(10, maxFractionDigits !== null && maxFractionDigits !== void 0 ? maxFractionDigits : this.valueScalingFractionDigits);
|
|
636
|
-
}
|
|
637
|
-
toInteger(value, maxFractionDigits) {
|
|
638
|
-
return Number(value
|
|
639
|
-
.toFixed(maxFractionDigits !== null && maxFractionDigits !== void 0 ? maxFractionDigits : this.valueScalingFractionDigits)
|
|
640
|
-
.split('.')
|
|
641
|
-
.join(''));
|
|
642
|
-
}
|
|
643
|
-
validateValueRange(value) {
|
|
644
|
-
return value != null ? Math.min(Math.max(value, this.minValue), this.maxValue) : value;
|
|
645
|
-
}
|
|
646
|
-
applyFixedFractionFormat(number, forcedChange = false) {
|
|
647
|
-
this.format(this.currencyFormat.format(this.validateValueRange(number)));
|
|
648
|
-
if (number !== this.numberValue || forcedChange) {
|
|
649
|
-
this.dispatchEvent('change');
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
format(value, hideNegligibleDecimalDigits = false) {
|
|
653
|
-
if (value != null) {
|
|
654
|
-
if (this.decimalSymbolInsertedAt !== undefined) {
|
|
655
|
-
value = this.currencyFormat.normalizeDecimalSeparator(value, this.decimalSymbolInsertedAt);
|
|
656
|
-
this.decimalSymbolInsertedAt = undefined;
|
|
657
|
-
}
|
|
658
|
-
const conformedValue = this.numberMask.conformToMask(value, this.formattedValue);
|
|
659
|
-
let formattedValue;
|
|
660
|
-
if (typeof conformedValue === 'object') {
|
|
661
|
-
const { numberValue, fractionDigits } = conformedValue;
|
|
662
|
-
let { maximumFractionDigits, minimumFractionDigits } = this.currencyFormat;
|
|
663
|
-
if (this.focus) {
|
|
664
|
-
minimumFractionDigits = hideNegligibleDecimalDigits
|
|
665
|
-
? fractionDigits.replace(/0+$/, '').length
|
|
666
|
-
: Math.min(maximumFractionDigits, fractionDigits.length);
|
|
667
|
-
}
|
|
668
|
-
else if (Number.isInteger(numberValue) && !this.options.autoDecimalDigits && (this.options.precision === undefined || minimumFractionDigits === 0)) {
|
|
669
|
-
minimumFractionDigits = maximumFractionDigits = 0;
|
|
670
|
-
}
|
|
671
|
-
formattedValue =
|
|
672
|
-
this.toInteger(Math.abs(numberValue)) > Number.MAX_SAFE_INTEGER
|
|
673
|
-
? this.formattedValue
|
|
674
|
-
: this.currencyFormat.format(numberValue, {
|
|
675
|
-
useGrouping: this.options.useGrouping && !(this.focus && this.options.hideGroupingSeparatorOnFocus),
|
|
676
|
-
minimumFractionDigits,
|
|
677
|
-
maximumFractionDigits
|
|
678
|
-
});
|
|
679
|
-
}
|
|
680
|
-
else {
|
|
681
|
-
formattedValue = conformedValue;
|
|
682
|
-
}
|
|
683
|
-
if (this.options.autoSign) {
|
|
684
|
-
if (this.maxValue <= 0 && !this.currencyFormat.isNegative(formattedValue) && this.currencyFormat.parse(formattedValue) !== 0) {
|
|
685
|
-
formattedValue = formattedValue.replace(this.currencyFormat.prefix, this.currencyFormat.negativePrefix);
|
|
686
|
-
}
|
|
687
|
-
if (this.minValue >= 0) {
|
|
688
|
-
formattedValue = formattedValue.replace(this.currencyFormat.negativePrefix, this.currencyFormat.prefix);
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
if (this.options.currencyDisplay === CurrencyDisplay.hidden || (this.focus && this.options.hideCurrencySymbolOnFocus)) {
|
|
692
|
-
formattedValue = formattedValue
|
|
693
|
-
.replace(this.currencyFormat.negativePrefix, this.currencyFormat.minusSign !== undefined ? this.currencyFormat.minusSign : '(')
|
|
694
|
-
.replace(this.currencyFormat.negativeSuffix, this.currencyFormat.minusSign !== undefined ? '' : ')')
|
|
695
|
-
.replace(this.currencyFormat.prefix, '')
|
|
696
|
-
.replace(this.currencyFormat.suffix, '');
|
|
697
|
-
}
|
|
698
|
-
this.el.value = formattedValue;
|
|
699
|
-
this.numberValue = this.currencyFormat.parse(formattedValue);
|
|
700
|
-
}
|
|
701
|
-
else {
|
|
702
|
-
this.el.value = '';
|
|
703
|
-
this.numberValue = null;
|
|
704
|
-
}
|
|
705
|
-
this.formattedValue = this.el.value;
|
|
706
|
-
this.dispatchEvent('input');
|
|
707
|
-
}
|
|
708
|
-
addEventListener() {
|
|
709
|
-
this.el.addEventListener('input', (e) => {
|
|
710
|
-
if (!e.detail) {
|
|
711
|
-
const { value, selectionStart } = this.el;
|
|
712
|
-
const inputEvent = e;
|
|
713
|
-
if (selectionStart && inputEvent.data && DECIMAL_SEPARATORS.includes(inputEvent.data)) {
|
|
714
|
-
this.decimalSymbolInsertedAt = selectionStart - 1;
|
|
715
|
-
}
|
|
716
|
-
this.format(value);
|
|
717
|
-
if (this.focus && selectionStart != null) {
|
|
718
|
-
const getCaretPositionAfterFormat = () => {
|
|
719
|
-
const { prefix, suffix, decimalSymbol, maximumFractionDigits, groupingSymbol } = this.currencyFormat;
|
|
720
|
-
let caretPositionFromLeft = value.length - selectionStart;
|
|
721
|
-
const newValueLength = this.formattedValue.length;
|
|
722
|
-
if (this.currencyFormat.minusSign === undefined && (value.startsWith('(') || value.startsWith('-')) && !value.endsWith(')')) {
|
|
723
|
-
return newValueLength - this.currencyFormat.negativeSuffix.length > 1 ? this.formattedValue.substring(selectionStart).length : 1;
|
|
724
|
-
}
|
|
725
|
-
if (this.formattedValue.substr(selectionStart, 1) === groupingSymbol &&
|
|
726
|
-
count(this.formattedValue, groupingSymbol) === count(value, groupingSymbol) + 1) {
|
|
727
|
-
return newValueLength - caretPositionFromLeft - 1;
|
|
728
|
-
}
|
|
729
|
-
if (newValueLength < caretPositionFromLeft) {
|
|
730
|
-
return selectionStart;
|
|
731
|
-
}
|
|
732
|
-
if (decimalSymbol !== undefined && value.indexOf(decimalSymbol) !== -1) {
|
|
733
|
-
const decimalSymbolPosition = value.indexOf(decimalSymbol) + 1;
|
|
734
|
-
if (Math.abs(newValueLength - value.length) > 1 && selectionStart <= decimalSymbolPosition) {
|
|
735
|
-
return this.formattedValue.indexOf(decimalSymbol) + 1;
|
|
736
|
-
}
|
|
737
|
-
else {
|
|
738
|
-
if (!this.options.autoDecimalDigits && selectionStart > decimalSymbolPosition) {
|
|
739
|
-
if (this.currencyFormat.onlyDigits(value.substr(decimalSymbolPosition)).length - 1 === maximumFractionDigits) {
|
|
740
|
-
caretPositionFromLeft -= 1;
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
return this.options.hideCurrencySymbolOnFocus || this.options.currencyDisplay === CurrencyDisplay.hidden
|
|
746
|
-
? newValueLength - caretPositionFromLeft
|
|
747
|
-
: Math.max(newValueLength - Math.max(caretPositionFromLeft, suffix.length), prefix.length);
|
|
748
|
-
};
|
|
749
|
-
this.setCaretPosition(getCaretPositionAfterFormat());
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
}, { capture: true });
|
|
753
|
-
this.el.addEventListener('focus', () => {
|
|
754
|
-
this.focus = true;
|
|
755
|
-
setTimeout(() => {
|
|
756
|
-
const { value, selectionStart, selectionEnd } = this.el;
|
|
757
|
-
this.format(value, this.options.hideNegligibleDecimalDigitsOnFocus);
|
|
758
|
-
if (selectionStart != null && selectionEnd != null && Math.abs(selectionStart - selectionEnd) > 0) {
|
|
759
|
-
this.setCaretPosition(0, this.el.value.length);
|
|
760
|
-
}
|
|
761
|
-
else if (selectionStart != null) {
|
|
762
|
-
const caretPositionOnFocus = this.getCaretPositionOnFocus(value, selectionStart);
|
|
763
|
-
this.setCaretPosition(caretPositionOnFocus);
|
|
764
|
-
}
|
|
765
|
-
});
|
|
766
|
-
});
|
|
767
|
-
this.el.addEventListener('blur', () => {
|
|
768
|
-
this.focus = false;
|
|
769
|
-
this.applyFixedFractionFormat(this.numberValue);
|
|
770
|
-
});
|
|
771
|
-
this.el.addEventListener('change', (e) => {
|
|
772
|
-
if (!e.detail) {
|
|
773
|
-
this.dispatchEvent('change');
|
|
774
|
-
}
|
|
775
|
-
}, { capture: true });
|
|
776
|
-
}
|
|
777
|
-
getCaretPositionOnFocus(value, selectionStart) {
|
|
778
|
-
if (this.numberValue == null) {
|
|
779
|
-
return selectionStart;
|
|
780
|
-
}
|
|
781
|
-
const { prefix, negativePrefix, suffix, negativeSuffix, groupingSymbol, currency } = this.currencyFormat;
|
|
782
|
-
const isNegative = this.numberValue < 0;
|
|
783
|
-
const currentPrefix = isNegative ? negativePrefix : prefix;
|
|
784
|
-
const prefixLength = currentPrefix.length;
|
|
785
|
-
if (this.options.hideCurrencySymbolOnFocus || this.options.currencyDisplay === CurrencyDisplay.hidden) {
|
|
786
|
-
if (isNegative) {
|
|
787
|
-
if (selectionStart <= 1) {
|
|
788
|
-
return 1;
|
|
789
|
-
}
|
|
790
|
-
else if (value.endsWith(')') && selectionStart > value.indexOf(')')) {
|
|
791
|
-
return this.formattedValue.length - 1;
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
else {
|
|
796
|
-
const suffixLength = isNegative ? negativeSuffix.length : suffix.length;
|
|
797
|
-
if (selectionStart >= value.length - suffixLength) {
|
|
798
|
-
return this.formattedValue.length - suffixLength;
|
|
799
|
-
}
|
|
800
|
-
else if (selectionStart < prefixLength) {
|
|
801
|
-
return prefixLength;
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
let result = selectionStart;
|
|
805
|
-
if (this.options.hideCurrencySymbolOnFocus &&
|
|
806
|
-
this.options.currencyDisplay !== CurrencyDisplay.hidden &&
|
|
807
|
-
selectionStart >= prefixLength &&
|
|
808
|
-
currency !== undefined &&
|
|
809
|
-
currentPrefix.includes(currency)) {
|
|
810
|
-
result -= prefixLength;
|
|
811
|
-
if (isNegative) {
|
|
812
|
-
result += 1;
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
if (this.options.hideGroupingSeparatorOnFocus && groupingSymbol !== undefined) {
|
|
816
|
-
result -= count(value.substring(0, selectionStart), groupingSymbol);
|
|
817
|
-
}
|
|
818
|
-
return result;
|
|
819
|
-
}
|
|
820
|
-
setCaretPosition(start, end = start) {
|
|
821
|
-
this.el.setSelectionRange(start, end);
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
const findInput = (el) => ((el === null || el === void 0 ? void 0 : el.matches('input')) ? el : el === null || el === void 0 ? void 0 : el.querySelector('input'));
|
|
826
|
-
var useCurrencyInput = (options) => {
|
|
827
|
-
var _a;
|
|
828
|
-
let numberInput;
|
|
829
|
-
let input;
|
|
830
|
-
const inputRef = Object(lib["ref"])(null);
|
|
831
|
-
const formattedValue = Object(lib["ref"])(null);
|
|
832
|
-
const instance = Object(lib["getCurrentInstance"])();
|
|
833
|
-
const emit = (event, value) => instance === null || instance === void 0 ? void 0 : instance.emit(event, value);
|
|
834
|
-
const lazyModel = lib["isVue3"] && ((_a = instance === null || instance === void 0 ? void 0 : instance.attrs.modelModifiers) === null || _a === void 0 ? void 0 : _a.lazy);
|
|
835
|
-
const numberValue = Object(lib["computed"])(() => instance === null || instance === void 0 ? void 0 : instance.props[lib["isVue3"] ? 'modelValue' : 'value']);
|
|
836
|
-
const inputEvent = lib["isVue3"] ? 'update:modelValue' : 'input';
|
|
837
|
-
const changeEvent = lazyModel ? 'update:modelValue' : 'change';
|
|
838
|
-
const hasInputEventListener = !lib["isVue3"] || !lazyModel;
|
|
839
|
-
const hasChangeEventListener = !lib["isVue3"] || lazyModel || !(instance === null || instance === void 0 ? void 0 : instance.attrs.onChange);
|
|
840
|
-
const onInput = (e) => {
|
|
841
|
-
if (e.detail) {
|
|
842
|
-
if (numberValue.value !== e.detail.number) {
|
|
843
|
-
emit(inputEvent, e.detail.number);
|
|
844
|
-
}
|
|
845
|
-
formattedValue.value = e.detail.formatted;
|
|
846
|
-
}
|
|
847
|
-
};
|
|
848
|
-
const onChange = (e) => {
|
|
849
|
-
if (e.detail) {
|
|
850
|
-
emit(changeEvent, e.detail.number);
|
|
851
|
-
formattedValue.value = e.detail.formatted;
|
|
852
|
-
}
|
|
853
|
-
};
|
|
854
|
-
Object(lib["watch"])(inputRef, (value) => {
|
|
855
|
-
var _a, _b;
|
|
856
|
-
if (value) {
|
|
857
|
-
input = findInput((_b = (_a = value) === null || _a === void 0 ? void 0 : _a.$el) !== null && _b !== void 0 ? _b : value);
|
|
858
|
-
if (input) {
|
|
859
|
-
numberInput = new CurrencyInput(input, options);
|
|
860
|
-
if (hasInputEventListener) {
|
|
861
|
-
input.addEventListener('input', onInput);
|
|
862
|
-
}
|
|
863
|
-
if (hasChangeEventListener) {
|
|
864
|
-
input.addEventListener('change', onChange);
|
|
865
|
-
}
|
|
866
|
-
numberInput.setValue(numberValue.value);
|
|
867
|
-
}
|
|
868
|
-
else {
|
|
869
|
-
console.error('No input element found. Please make sure that the "inputRef" template ref is properly assigned.');
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
else {
|
|
873
|
-
numberInput = null;
|
|
874
|
-
}
|
|
875
|
-
});
|
|
876
|
-
Object(lib["onUnmounted"])(() => {
|
|
877
|
-
if (hasInputEventListener) {
|
|
878
|
-
input === null || input === void 0 ? void 0 : input.removeEventListener('input', onInput);
|
|
879
|
-
}
|
|
880
|
-
if (hasChangeEventListener) {
|
|
881
|
-
input === null || input === void 0 ? void 0 : input.removeEventListener('change', onChange);
|
|
882
|
-
}
|
|
883
|
-
});
|
|
884
|
-
return {
|
|
885
|
-
inputRef,
|
|
886
|
-
formattedValue,
|
|
887
|
-
setValue: (value) => numberInput === null || numberInput === void 0 ? void 0 : numberInput.setValue(value),
|
|
888
|
-
setOptions: (options) => numberInput === null || numberInput === void 0 ? void 0 : numberInput.setOptions(options)
|
|
889
|
-
};
|
|
890
|
-
};
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader-v16/dist??ref--1-1!./src/components/pl-currency/src/pl-currency.vue?vue&type=script&setup=true&lang=js
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
var _hoisted_1 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", {
|
|
898
|
-
class: "pl-currency__rub-icon"
|
|
899
|
-
}, "₽", -1);
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
// eslint-disable-next-line no-unused-vars,no-undef
|
|
903
|
-
|
|
904
|
-
/* harmony default export */ var pl_currencyvue_type_script_setup_true_lang_js = ({
|
|
905
|
-
props: {
|
|
906
|
-
modelValue: String
|
|
907
|
-
},
|
|
908
|
-
emits: ['update:modelValue'],
|
|
909
|
-
setup: function setup(__props, _ref) {
|
|
910
|
-
var emit = _ref.emit;
|
|
911
|
-
var props = __props; // eslint-disable-next-line no-undef
|
|
912
|
-
|
|
913
|
-
var innerValue = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["ref"])(null);
|
|
914
|
-
var options = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["reactive"])({
|
|
915
|
-
currency: 'EUR',
|
|
916
|
-
currencyDisplay: 'hidden',
|
|
917
|
-
precision: 2
|
|
918
|
-
});
|
|
919
|
-
|
|
920
|
-
var _useCurrencyInput = useCurrencyInput(options),
|
|
921
|
-
inputRef = _useCurrencyInput.inputRef;
|
|
922
|
-
|
|
923
|
-
Object(external_commonjs_vue_commonjs2_vue_root_Vue_["watch"])(innerValue, function (newValue) {
|
|
924
|
-
emit('update:modelValue', newValue);
|
|
925
|
-
});
|
|
926
|
-
return function (_ctx, _cache) {
|
|
927
|
-
var _component_el_input = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("el-input");
|
|
928
|
-
|
|
929
|
-
return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])(_component_el_input, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["mergeProps"])(_ctx.$attrs, {
|
|
930
|
-
ref_key: "inputRef",
|
|
931
|
-
ref: inputRef,
|
|
932
|
-
modelValue: innerValue.value,
|
|
933
|
-
"onUpdate:modelValue": _cache[0] || (_cache[0] = function ($event) {
|
|
934
|
-
return innerValue.value = $event;
|
|
935
|
-
}),
|
|
936
|
-
class: "pl-currency"
|
|
937
|
-
}), {
|
|
938
|
-
append: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withCtx"])(function () {
|
|
939
|
-
return [_hoisted_1];
|
|
940
|
-
}),
|
|
941
|
-
_: 1
|
|
942
|
-
}, 16, ["modelValue"]);
|
|
943
|
-
};
|
|
944
|
-
}
|
|
945
|
-
});
|
|
946
|
-
// CONCATENATED MODULE: ./src/components/pl-currency/src/pl-currency.vue?vue&type=script&setup=true&lang=js
|
|
947
|
-
|
|
948
|
-
// EXTERNAL MODULE: ./src/components/pl-currency/src/pl-currency.vue?vue&type=style&index=0&id=0538fbc8&lang=scss
|
|
949
|
-
var pl_currencyvue_type_style_index_0_id_0538fbc8_lang_scss = __webpack_require__("3df6");
|
|
950
|
-
|
|
951
|
-
// CONCATENATED MODULE: ./src/components/pl-currency/src/pl-currency.vue
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
const __exports__ = pl_currencyvue_type_script_setup_true_lang_js;
|
|
958
|
-
|
|
959
|
-
/* harmony default export */ var pl_currency = (__exports__);
|
|
960
|
-
// CONCATENATED MODULE: ./entry.js
|
|
961
|
-
|
|
962
|
-
/* harmony default export */ var entry = (pl_currency); // // Объявление функции установки, выполняемой Vue.use()
|
|
963
|
-
// export function install(Vue) {
|
|
964
|
-
// if (install.installed) {
|
|
965
|
-
// return;
|
|
966
|
-
// }
|
|
967
|
-
// install.installed = true;
|
|
968
|
-
// Vue.component('PlCurrency', PlCurrency);
|
|
969
|
-
// }
|
|
970
|
-
//
|
|
971
|
-
// // Создание значения модуля для Vue.use()
|
|
972
|
-
// const plugin = {
|
|
973
|
-
// install,
|
|
974
|
-
// };
|
|
975
|
-
//
|
|
976
|
-
// // Автоматическая установка, когда vue найден (например в браузере с помощью тега <script>)
|
|
977
|
-
// let GlobalVue = null;
|
|
978
|
-
// if (typeof window !== 'undefined') {
|
|
979
|
-
// GlobalVue = window.Vue;
|
|
980
|
-
// } else if (typeof global !== 'undefined') {
|
|
981
|
-
// GlobalVue = global.Vue;
|
|
982
|
-
// }
|
|
983
|
-
// if (GlobalVue) {
|
|
984
|
-
// GlobalVue.use(plugin);
|
|
985
|
-
// }
|
|
986
|
-
//
|
|
987
|
-
// PlCurrency.install = install;
|
|
988
|
-
//
|
|
989
|
-
// // Экспорт компонента, для использования в качестве модуля (npm/webpack/etc.)
|
|
990
|
-
// export default {
|
|
991
|
-
// version: '0.1.0',
|
|
992
|
-
// install,
|
|
993
|
-
// PlCurrency,
|
|
994
|
-
// };
|
|
995
|
-
// CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/entry-lib.js
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
/* harmony default export */ var entry_lib = __webpack_exports__["default"] = (entry);
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
/***/ })
|
|
1003
|
-
|
|
1004
|
-
/******/ });
|
|
1005
|
-
});
|
|
1006
|
-
//# sourceMappingURL=pl-components-pack-v3.umd.js.map
|