@lion/ui 0.2.1 → 0.2.2
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/components/localize/src/number/parseNumber.js +7 -1
- package/components/localize/test/number/parseNumber.test.js +18 -4
- package/custom-elements.json +6 -6
- package/dist-types/components/localize/src/number/parseNumber.d.ts.map +1 -1
- package/dist-types/tsconfig.tsbuildinfo +1 -1
- package/docs/components/checkbox-group/overview.md +2 -2
- package/docs/components/collapsible/overview.md +1 -1
- package/docs/components/combobox/overview.md +1 -1
- package/docs/components/combobox/use-cases.md +1 -1
- package/docs/components/dialog/overview.md +1 -1
- package/docs/components/fieldset/overview.md +5 -5
- package/docs/components/form/overview.md +3 -3
- package/docs/components/icon/use-cases.md +1 -1
- package/docs/components/input/overview.md +1 -1
- package/docs/components/input-amount/overview.md +3 -3
- package/docs/components/input-date/overview.md +3 -3
- package/docs/components/input-datepicker/overview.md +5 -5
- package/docs/components/input-email/overview.md +2 -2
- package/docs/components/input-iban/overview.md +2 -2
- package/docs/components/input-range/overview.md +2 -2
- package/docs/components/input-stepper/overview.md +1 -1
- package/docs/components/input-tel/overview.md +1 -1
- package/docs/components/input-tel/use-cases.md +6 -6
- package/docs/components/input-tel-dropdown/overview.md +1 -1
- package/docs/components/radio-group/overview.md +3 -3
- package/docs/components/select-rich/use-cases.md +1 -1
- package/docs/components/tabs/examples.md +1 -1
- package/docs/fundamentals/index.md +4 -4
- package/docs/fundamentals/node-tools/providence-analytics/LocalConfiguration.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/QueryResult.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/analyzer.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/dashboard.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/overview.md +3 -3
- package/docs/fundamentals/node-tools/publish-docs/overview.md +3 -3
- package/docs/fundamentals/node-tools/rocket-preset-extend-lion-docs/overview.md +2 -2
- package/docs/fundamentals/systems/core/overview.md +1 -1
- package/docs/fundamentals/systems/form/formatting-and-parsing.md +4 -4
- package/docs/fundamentals/systems/form/model-value.md +1 -1
- package/docs/fundamentals/systems/form/overview.md +28 -28
- package/docs/fundamentals/systems/form/validate.md +1 -1
- package/docs/fundamentals/systems/localize/overview.md +4 -4
- package/docs/fundamentals/systems/overlays/configuration.md +2 -2
- package/docs/fundamentals/systems/overlays/overview.md +5 -5
- package/docs/fundamentals/systems/overlays/use-cases.md +2 -2
- package/docs/fundamentals/tools/helpers/overview.md +1 -1
- package/docs/fundamentals/tools/singleton-manager/overview.md +4 -4
- package/docs/guides/how-to/create-a-custom-field.md +5 -5
- package/docs/guides/how-to/extend-a-native-input.md +2 -2
- package/docs/guides/index.md +8 -8
- package/docs/guides/principles/index.md +5 -5
- package/docs/guides/principles/styling.md +1 -1
- package/package.json +1 -1
|
@@ -23,9 +23,15 @@ import { getDecimalSeparator } from './getDecimalSeparator.js';
|
|
|
23
23
|
function getParseMode(value, { mode = 'auto' } = {}) {
|
|
24
24
|
const separators = value.match(/[., ]/g);
|
|
25
25
|
|
|
26
|
-
if (!separators
|
|
26
|
+
if (!separators) {
|
|
27
27
|
return 'withLocale';
|
|
28
28
|
}
|
|
29
|
+
if (mode === 'auto' && separators.length === 1) {
|
|
30
|
+
const decimalLength = value.split(`${separators}`)[1].length;
|
|
31
|
+
if (decimalLength >= 3) {
|
|
32
|
+
return 'withLocale';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
29
35
|
if (separators.length === 1 || separators[0] !== separators[separators.length - 1]) {
|
|
30
36
|
return 'heuristic';
|
|
31
37
|
}
|
|
@@ -80,18 +80,32 @@ describe('parseNumber()', () => {
|
|
|
80
80
|
expect(parseNumber('1 234 56')).to.equal(123456);
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
-
it('uses
|
|
83
|
+
it('uses heuristic to parse amount if there is only one separator e.g. 12.34 and amount of decimals is 2 or smaller', () => {
|
|
84
84
|
localizeManager.locale = 'en-GB';
|
|
85
|
+
expect(parseNumber('12.3')).to.equal(12.3);
|
|
86
|
+
expect(parseNumber('12,3')).to.equal(12.3);
|
|
85
87
|
expect(parseNumber('12.34')).to.equal(12.34);
|
|
86
|
-
expect(parseNumber('12,34')).to.equal(
|
|
88
|
+
expect(parseNumber('12,34')).to.equal(12.34);
|
|
89
|
+
|
|
90
|
+
localizeManager.locale = 'nl-NL';
|
|
91
|
+
expect(parseNumber('12.3')).to.equal(12.3);
|
|
92
|
+
expect(parseNumber('12,3')).to.equal(12.3);
|
|
93
|
+
expect(parseNumber('12.34')).to.equal(12.34);
|
|
94
|
+
expect(parseNumber('12,34')).to.equal(12.34);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('uses locale to parse amount if there is only one separator e.g. 1.234 and amount of decimals is bigger then 2', () => {
|
|
98
|
+
localizeManager.locale = 'en-GB';
|
|
87
99
|
expect(parseNumber('1.234')).to.equal(1.234);
|
|
88
100
|
expect(parseNumber('1,234')).to.equal(1234);
|
|
101
|
+
expect(parseNumber('1.2345')).to.equal(1.2345);
|
|
102
|
+
expect(parseNumber('1,2345')).to.equal(12345);
|
|
89
103
|
|
|
90
104
|
localizeManager.locale = 'nl-NL';
|
|
91
|
-
expect(parseNumber('12.34')).to.equal(1234);
|
|
92
|
-
expect(parseNumber('12,34')).to.equal(12.34);
|
|
93
105
|
expect(parseNumber('1.234')).to.equal(1234);
|
|
94
106
|
expect(parseNumber('1,234')).to.equal(1.234);
|
|
107
|
+
expect(parseNumber('1.2345')).to.equal(12345);
|
|
108
|
+
expect(parseNumber('1,2345')).to.equal(1.2345);
|
|
95
109
|
});
|
|
96
110
|
|
|
97
111
|
it('returns numbers only if it can not be interpreted e.g. 1.234.567', () => {
|
package/custom-elements.json
CHANGED
|
@@ -62304,12 +62304,6 @@
|
|
|
62304
62304
|
"declarations": [],
|
|
62305
62305
|
"exports": []
|
|
62306
62306
|
},
|
|
62307
|
-
{
|
|
62308
|
-
"kind": "javascript-module",
|
|
62309
|
-
"path": "dist-types/components/input-tel-dropdown/test/LionInputTelDropdown.test.d.ts",
|
|
62310
|
-
"declarations": [],
|
|
62311
|
-
"exports": []
|
|
62312
|
-
},
|
|
62313
62307
|
{
|
|
62314
62308
|
"kind": "javascript-module",
|
|
62315
62309
|
"path": "dist-types/components/input-tel-dropdown/src/LionInputTelDropdown.d.ts",
|
|
@@ -62815,6 +62809,12 @@
|
|
|
62815
62809
|
}
|
|
62816
62810
|
]
|
|
62817
62811
|
},
|
|
62812
|
+
{
|
|
62813
|
+
"kind": "javascript-module",
|
|
62814
|
+
"path": "dist-types/components/input-tel-dropdown/test/LionInputTelDropdown.test.d.ts",
|
|
62815
|
+
"declarations": [],
|
|
62816
|
+
"exports": []
|
|
62817
|
+
},
|
|
62818
62818
|
{
|
|
62819
62819
|
"kind": "javascript-module",
|
|
62820
62820
|
"path": "dist-types/components/input-tel-dropdown/test-suites/LionInputTelDropdown.suite.d.ts",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseNumber.d.ts","sourceRoot":"","sources":["../../../../../components/localize/src/number/parseNumber.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parseNumber.d.ts","sourceRoot":"","sources":["../../../../../components/localize/src/number/parseNumber.js"],"names":[],"mappings":"AAwFA;;;;;;;;;;;;;;;;;;GAkBG;AACH,mCAHW,MAAM,6GA8BhB"}
|