jsuites 6.5.2 → 6.6.0
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/dist/jsuites.js +62 -31
- package/package.json +2 -2
package/dist/jsuites.js
CHANGED
|
@@ -991,6 +991,8 @@ var jSuites;
|
|
|
991
991
|
const methodCache = {};
|
|
992
992
|
// Cache for getTokens results
|
|
993
993
|
const tokensCache = {};
|
|
994
|
+
// Cache for the parsed layout of each mask
|
|
995
|
+
const layoutCache = {};
|
|
994
996
|
// Cache for autoCasting results
|
|
995
997
|
const autoCastingCache = {};
|
|
996
998
|
|
|
@@ -1752,32 +1754,33 @@ var jSuites;
|
|
|
1752
1754
|
'#(.{1})##0?(.{1}[0#]+)?( ?;(.*)?)?': function(v) {
|
|
1753
1755
|
// Process first the number
|
|
1754
1756
|
parseMethods['[0#]+([.,]{1}0*#*)?'].call(this, v, true);
|
|
1755
|
-
// Create the separators
|
|
1756
|
-
let separator = this.tokens[this.index].substring(1,2);
|
|
1757
|
-
|
|
1758
1757
|
|
|
1759
1758
|
let currentValue = this.values[this.index];
|
|
1760
|
-
//
|
|
1759
|
+
// The value is already grouped: only a new digit in the integer part changes it
|
|
1760
|
+
if (! (v >= '0' && v <= '9') || currentValue.indexOf(this.decimal) !== -1) {
|
|
1761
|
+
return;
|
|
1762
|
+
}
|
|
1763
|
+
// Create the separators
|
|
1764
|
+
let separator = this.tokens[this.index].substring(1,2);
|
|
1765
|
+
// Remove existing separators
|
|
1761
1766
|
currentValue = currentValue.replaceAll(separator, '');
|
|
1762
1767
|
// Process separators
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
let number = [];
|
|
1768
|
+
if (currentValue.length > 3) {
|
|
1769
|
+
let number = '';
|
|
1766
1770
|
let count = 0;
|
|
1767
|
-
for (
|
|
1768
|
-
let c =
|
|
1769
|
-
if (c >= 0 && c <= 9) {
|
|
1771
|
+
for (let j = currentValue.length - 1; j >= 0 ; j--) {
|
|
1772
|
+
let c = currentValue[j];
|
|
1773
|
+
if (c >= '0' && c <= '9') {
|
|
1770
1774
|
if (count && ! (count % 3)) {
|
|
1771
|
-
number
|
|
1775
|
+
number = separator + number;
|
|
1772
1776
|
}
|
|
1773
1777
|
count++;
|
|
1774
1778
|
}
|
|
1775
|
-
number
|
|
1779
|
+
number = c + number;
|
|
1776
1780
|
}
|
|
1777
|
-
|
|
1781
|
+
currentValue = number;
|
|
1778
1782
|
}
|
|
1779
|
-
|
|
1780
|
-
this.values[this.index] = val.join(this.decimal);
|
|
1783
|
+
this.values[this.index] = currentValue;
|
|
1781
1784
|
},
|
|
1782
1785
|
'[0#]+([.,]{1}0*#*)?E{1}\\+0+': function(v) {
|
|
1783
1786
|
parseMethods['[0#]+([.,]{1}0*#*)?'].call(this, v);
|
|
@@ -2260,6 +2263,26 @@ var jSuites;
|
|
|
2260
2263
|
|
|
2261
2264
|
// TODO, get negative mask automatically based on the input sign?
|
|
2262
2265
|
|
|
2266
|
+
/**
|
|
2267
|
+
* Parse the parts of a mask that do not depend on the value
|
|
2268
|
+
*/
|
|
2269
|
+
const getLayout = function(mask) {
|
|
2270
|
+
const layout = {};
|
|
2271
|
+
// Transform Excel locale patterns (e.g., [$$-409]#,##0.00) - only if pattern exists
|
|
2272
|
+
if (mask.indexOf('[$') !== -1) {
|
|
2273
|
+
mask = transformExcelLocaleMask(mask);
|
|
2274
|
+
}
|
|
2275
|
+
// Cleaning the mask
|
|
2276
|
+
layout.mask = cleanMask(mask, layout);
|
|
2277
|
+
// Get tokens which are the methods for parsing
|
|
2278
|
+
layout.tokens = getTokens(layout.mask);
|
|
2279
|
+
// Get methods from the tokens
|
|
2280
|
+
layout.methods = getMethodsFromTokens(layout.tokens);
|
|
2281
|
+
// Type
|
|
2282
|
+
layout.type = getType(layout);
|
|
2283
|
+
return layout;
|
|
2284
|
+
}
|
|
2285
|
+
|
|
2263
2286
|
const getConfig = function(config, value) {
|
|
2264
2287
|
// Internal default control of the mask system
|
|
2265
2288
|
const control = {
|
|
@@ -2326,21 +2349,28 @@ var jSuites;
|
|
|
2326
2349
|
control.section = mask;
|
|
2327
2350
|
}
|
|
2328
2351
|
|
|
2329
|
-
//
|
|
2330
|
-
|
|
2331
|
-
|
|
2352
|
+
// The layout depends only on the mask: parse it once
|
|
2353
|
+
let layout = layoutCache[mask];
|
|
2354
|
+
if (layout === undefined) {
|
|
2355
|
+
layout = layoutCache[mask] = getLayout(mask);
|
|
2356
|
+
}
|
|
2357
|
+
if (layout.parenthesisForNegativeNumbers) {
|
|
2358
|
+
control.parenthesisForNegativeNumbers = true;
|
|
2332
2359
|
}
|
|
2333
|
-
|
|
2334
|
-
// Cleaning the mask
|
|
2335
|
-
mask = cleanMask(mask, control);
|
|
2336
2360
|
// Get only the first mask for now and remove
|
|
2337
|
-
control.mask = mask;
|
|
2338
|
-
//
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
control.
|
|
2342
|
-
|
|
2343
|
-
|
|
2361
|
+
control.mask = layout.mask;
|
|
2362
|
+
// Tokens and methods are shared and read-only
|
|
2363
|
+
control.tokens = layout.tokens;
|
|
2364
|
+
control.methods = layout.methods;
|
|
2365
|
+
control.type = layout.type;
|
|
2366
|
+
|
|
2367
|
+
// Decimal only for numbers. Without options, it comes from the mask
|
|
2368
|
+
if (isNumeric(control.type) && ! control.decimal && ! control.locale) {
|
|
2369
|
+
if (layout.decimal === undefined) {
|
|
2370
|
+
layout.decimal = getDecimal.call(control);
|
|
2371
|
+
}
|
|
2372
|
+
control.decimal = layout.decimal;
|
|
2373
|
+
}
|
|
2344
2374
|
}
|
|
2345
2375
|
|
|
2346
2376
|
// Decimal only for numbers
|
|
@@ -12595,13 +12625,14 @@ function Path(pathString, value, remove) {
|
|
|
12595
12625
|
return false;
|
|
12596
12626
|
}
|
|
12597
12627
|
|
|
12628
|
+
// Own keys only: a write never walks into what the object inherits
|
|
12598
12629
|
// If the key exists but is null/undefined or a non-object, replace it with an empty object
|
|
12599
12630
|
if (
|
|
12600
|
-
key
|
|
12631
|
+
Object.hasOwn(currentObject, key) &&
|
|
12601
12632
|
(currentObject[key] == null || ! isValidPathObj(currentObject[key]))
|
|
12602
12633
|
) {
|
|
12603
12634
|
currentObject[key] = {};
|
|
12604
|
-
} else if (!(key
|
|
12635
|
+
} else if (! Object.hasOwn(currentObject, key)) {
|
|
12605
12636
|
// If the key doesn't exist, create an empty object
|
|
12606
12637
|
currentObject[key] = {};
|
|
12607
12638
|
}
|
|
@@ -23551,7 +23582,7 @@ var jSuites = {
|
|
|
23551
23582
|
...dictionary,
|
|
23552
23583
|
...helpers,
|
|
23553
23584
|
/** Current version */
|
|
23554
|
-
version: '6.
|
|
23585
|
+
version: '6.6.0',
|
|
23555
23586
|
/** Bind new extensions to Jsuites */
|
|
23556
23587
|
setExtensions: function(o) {
|
|
23557
23588
|
if (typeof(o) == 'object') {
|
package/package.json
CHANGED
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
},
|
|
27
27
|
"main": "dist/jsuites.js",
|
|
28
28
|
"types": "dist/jsuites.d.ts",
|
|
29
|
-
"version": "6.
|
|
29
|
+
"version": "6.6.0",
|
|
30
30
|
"bugs": "https://github.com/jsuites/jsuites/issues",
|
|
31
31
|
"homepage": "https://github.com/jsuites/jsuites",
|
|
32
32
|
"docs": "https://jsuites.net",
|
|
33
33
|
"download": "https://github.com/jsuites/jsuites/archive/master.zip",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@jsuites/utils": "^6.
|
|
35
|
+
"@jsuites/utils": "^6.2.0",
|
|
36
36
|
"@lemonadejs/calendar": "^5.9.3",
|
|
37
37
|
"@lemonadejs/color": "^5.8.0",
|
|
38
38
|
"@lemonadejs/contextmenu": "^5.8.6",
|