@formio/js 5.0.0-dev.5705.fda3511 → 5.0.0-dev.5707.d029d4d
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/Changelog.md +10 -0
- package/dist/formio.form.js +3 -3
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +3 -3
- package/dist/formio.full.min.js +1 -1
- package/lib/cjs/components/currency/Currency.d.ts +1 -0
- package/lib/cjs/components/datagrid/DataGrid.js +2 -2
- package/lib/cjs/components/datamap/DataMap.js +2 -2
- package/lib/cjs/components/number/Number.d.ts +10 -1
- package/lib/cjs/components/number/Number.js +15 -6
- package/lib/cjs/components/number/fixtures/comp9.d.ts +18 -0
- package/lib/cjs/components/number/fixtures/comp9.js +21 -0
- package/lib/cjs/components/number/fixtures/index.d.ts +2 -1
- package/lib/cjs/components/number/fixtures/index.js +3 -1
- package/lib/mjs/components/currency/Currency.d.ts +1 -0
- package/lib/mjs/components/datagrid/DataGrid.js +1 -1
- package/lib/mjs/components/datamap/DataMap.js +1 -1
- package/lib/mjs/components/number/Number.d.ts +10 -1
- package/lib/mjs/components/number/Number.js +14 -5
- package/lib/mjs/components/number/fixtures/comp9.d.ts +18 -0
- package/lib/mjs/components/number/fixtures/comp9.js +19 -0
- package/lib/mjs/components/number/fixtures/index.d.ts +2 -1
- package/lib/mjs/components/number/fixtures/index.js +2 -1
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ export default class CurrencyComponent extends NumberComponent {
|
|
|
2
2
|
constructor(component: any, options: any, data: any);
|
|
3
3
|
currencyPrefix: any;
|
|
4
4
|
currencySuffix: any;
|
|
5
|
+
parseValue(value: any): string | null;
|
|
5
6
|
addZerosAndFormatValue(value: any): any;
|
|
6
7
|
stripPrefixSuffix(value: any): any;
|
|
7
8
|
}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const lodash_1 = __importDefault(require("lodash"));
|
|
7
7
|
const NestedArrayComponent_1 = __importDefault(require("../_classes/nestedarray/NestedArrayComponent"));
|
|
8
8
|
const utils_1 = require("../../utils/utils");
|
|
9
|
-
const Components_1 =
|
|
9
|
+
const Components_1 = require("../Components");
|
|
10
10
|
const dragula_1 = __importDefault(require("dragula"));
|
|
11
11
|
class DataGridComponent extends NestedArrayComponent_1.default {
|
|
12
12
|
static schema(...extend) {
|
|
@@ -422,7 +422,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
422
422
|
}
|
|
423
423
|
component.rowIndex = rowIndex;
|
|
424
424
|
component.row = `${rowIndex}-${colIndex}`;
|
|
425
|
-
component.path = Components_1.
|
|
425
|
+
component.path = Components_1.Components.getComponentPath(component);
|
|
426
426
|
});
|
|
427
427
|
}
|
|
428
428
|
updateRowsComponents(rowIndex) {
|
|
@@ -8,7 +8,7 @@ const DataGrid_1 = __importDefault(require("../datagrid/DataGrid"));
|
|
|
8
8
|
const lodash_1 = __importDefault(require("lodash"));
|
|
9
9
|
const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
10
10
|
const utils_1 = require("../../utils/utils");
|
|
11
|
-
const Components_1 =
|
|
11
|
+
const Components_1 = require("../Components");
|
|
12
12
|
class DataMapComponent extends DataGrid_1.default {
|
|
13
13
|
static schema(...extend) {
|
|
14
14
|
return Component_1.default.schema({
|
|
@@ -241,7 +241,7 @@ class DataMapComponent extends DataGrid_1.default {
|
|
|
241
241
|
delete dataValue[key];
|
|
242
242
|
const comp = components[this.valueKey];
|
|
243
243
|
comp.component.key = newKey;
|
|
244
|
-
comp.path = Components_1.
|
|
244
|
+
comp.path = Components_1.Components.calculateComponentPath(comp);
|
|
245
245
|
key = newKey;
|
|
246
246
|
});
|
|
247
247
|
const valueComponent = lodash_1.default.clone(this.component.valueComponent);
|
|
@@ -31,7 +31,16 @@ export default class NumberComponent extends Input {
|
|
|
31
31
|
setInputMask(input: any): void;
|
|
32
32
|
getValueAt(index: any): number | null;
|
|
33
33
|
setValueAt(index: any, value: any, flags?: {}): void;
|
|
34
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Converts a string to a floating point number, formats the number based on the parsed float function
|
|
36
|
+
* (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat) and then returns the
|
|
37
|
+
* formatted number back as a string
|
|
38
|
+
* Example Input: "123.456,22"
|
|
39
|
+
* Example Output: "123456,22"
|
|
40
|
+
* @param {string | number} input the numeric string to parse
|
|
41
|
+
* @returns {string | null} a parsed string
|
|
42
|
+
*/
|
|
43
|
+
parseValue(input: string | number): string | null;
|
|
35
44
|
focus(): void;
|
|
36
45
|
getMaskedValue(value: any): any;
|
|
37
46
|
getValueAsString(value: any, options: any): any;
|
|
@@ -45,19 +45,19 @@ class NumberComponent extends Input_1.default {
|
|
|
45
45
|
return (0, utils_1.getComponentSavedTypes)(schema) || [utils_1.componentValueTypes.number];
|
|
46
46
|
}
|
|
47
47
|
constructor(...args) {
|
|
48
|
-
var _a, _b;
|
|
48
|
+
var _a, _b, _c;
|
|
49
49
|
super(...args);
|
|
50
50
|
const separators = (0, utils_1.getNumberSeparators)(this.options.language || navigator.language);
|
|
51
51
|
this.decimalSeparator = this.options.decimalSeparator = this.component.decimalSymbol || this.options.decimalSeparator
|
|
52
52
|
|| ((_a = this.options.properties) === null || _a === void 0 ? void 0 : _a.decimalSeparator)
|
|
53
53
|
|| separators.decimalSeparator;
|
|
54
54
|
if (this.component.delimiter) {
|
|
55
|
-
|
|
56
|
-
console.warn("Property 'thousandsSeparator' is deprecated. Please use i18n to specify delimiter.");
|
|
57
|
-
}
|
|
58
|
-
this.delimiter = ((_b = this.options.properties) === null || _b === void 0 ? void 0 : _b.thousandsSeparator) || this.options.thousandsSeparator || separators.delimiter;
|
|
55
|
+
this.delimiter = this.component.thousandsSeparator || ((_b = this.options.properties) === null || _b === void 0 ? void 0 : _b.thousandsSeparator) || this.options.thousandsSeparator || separators.delimiter;
|
|
59
56
|
}
|
|
60
57
|
else {
|
|
58
|
+
if (this.component.thousandsSeparator || ((_c = this.options.properties) === null || _c === void 0 ? void 0 : _c.thousandsSeparator) || this.options.thousandsSeparator) {
|
|
59
|
+
console.warn('In order for thousands separator to work properly, you must set the delimiter to true in the component json');
|
|
60
|
+
}
|
|
61
61
|
this.delimiter = '';
|
|
62
62
|
}
|
|
63
63
|
const requireDecimal = lodash_1.default.get(this.component, 'requireDecimal', false);
|
|
@@ -79,7 +79,7 @@ class NumberComponent extends Input_1.default {
|
|
|
79
79
|
prefix: '',
|
|
80
80
|
suffix: '',
|
|
81
81
|
requireDecimal: lodash_1.default.get(this.component, 'requireDecimal', false),
|
|
82
|
-
thousandsSeparatorSymbol:
|
|
82
|
+
thousandsSeparatorSymbol: this.delimiter || '',
|
|
83
83
|
decimalSymbol: lodash_1.default.get(this.component, 'decimalSymbol', this.decimalSeparator),
|
|
84
84
|
decimalLimit: lodash_1.default.get(this.component, 'decimalLimit', this.decimalLimit),
|
|
85
85
|
allowNegative: lodash_1.default.get(this.component, 'allowNegative', true),
|
|
@@ -146,6 +146,15 @@ class NumberComponent extends Input_1.default {
|
|
|
146
146
|
setValueAt(index, value, flags = {}) {
|
|
147
147
|
return super.setValueAt(index, this.formatValue(this.parseValue(value)), flags);
|
|
148
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Converts a string to a floating point number, formats the number based on the parsed float function
|
|
151
|
+
* (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat) and then returns the
|
|
152
|
+
* formatted number back as a string
|
|
153
|
+
* Example Input: "123.456,22"
|
|
154
|
+
* Example Output: "123456,22"
|
|
155
|
+
* @param {string | number} input the numeric string to parse
|
|
156
|
+
* @returns {string | null} a parsed string
|
|
157
|
+
*/
|
|
149
158
|
parseValue(input) {
|
|
150
159
|
if (typeof input === 'string') {
|
|
151
160
|
input = input.split(this.delimiter).join('').replace(this.decimalSeparator, '.');
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare namespace _default {
|
|
2
|
+
let components: {
|
|
3
|
+
label: string;
|
|
4
|
+
applyMaskOn: string;
|
|
5
|
+
mask: boolean;
|
|
6
|
+
tableView: boolean;
|
|
7
|
+
delimiter: boolean;
|
|
8
|
+
requireDecimal: boolean;
|
|
9
|
+
inputFormat: string;
|
|
10
|
+
truncateMultipleSpaces: boolean;
|
|
11
|
+
key: string;
|
|
12
|
+
type: string;
|
|
13
|
+
input: boolean;
|
|
14
|
+
decimalSymbol: string;
|
|
15
|
+
thousandsSeparator: string;
|
|
16
|
+
}[];
|
|
17
|
+
}
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
components: [
|
|
5
|
+
{
|
|
6
|
+
"label": "Number",
|
|
7
|
+
"applyMaskOn": "change",
|
|
8
|
+
"mask": false,
|
|
9
|
+
"tableView": false,
|
|
10
|
+
"delimiter": true,
|
|
11
|
+
"requireDecimal": false,
|
|
12
|
+
"inputFormat": "plain",
|
|
13
|
+
"truncateMultipleSpaces": false,
|
|
14
|
+
"key": "number",
|
|
15
|
+
"type": "number",
|
|
16
|
+
"input": true,
|
|
17
|
+
"decimalSymbol": ",",
|
|
18
|
+
"thousandsSeparator": "."
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
};
|
|
@@ -6,4 +6,5 @@ import comp5 from './comp5';
|
|
|
6
6
|
import comp6 from './comp6';
|
|
7
7
|
import comp7 from './comp7';
|
|
8
8
|
import comp8 from './comp8';
|
|
9
|
-
|
|
9
|
+
import comp9 from './comp9';
|
|
10
|
+
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9 };
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
|
|
6
|
+
exports.comp9 = exports.comp8 = exports.comp7 = exports.comp6 = exports.comp5 = exports.comp4 = exports.comp3 = exports.comp2 = exports.comp1 = void 0;
|
|
7
7
|
const comp1_1 = __importDefault(require("./comp1"));
|
|
8
8
|
exports.comp1 = comp1_1.default;
|
|
9
9
|
const comp2_1 = __importDefault(require("./comp2"));
|
|
@@ -20,3 +20,5 @@ const comp7_1 = __importDefault(require("./comp7"));
|
|
|
20
20
|
exports.comp7 = comp7_1.default;
|
|
21
21
|
const comp8_1 = __importDefault(require("./comp8"));
|
|
22
22
|
exports.comp8 = comp8_1.default;
|
|
23
|
+
const comp9_1 = __importDefault(require("./comp9"));
|
|
24
|
+
exports.comp9 = comp9_1.default;
|
|
@@ -2,6 +2,7 @@ export default class CurrencyComponent extends NumberComponent {
|
|
|
2
2
|
constructor(component: any, options: any, data: any);
|
|
3
3
|
currencyPrefix: any;
|
|
4
4
|
currencySuffix: any;
|
|
5
|
+
parseValue(value: any): string | null;
|
|
5
6
|
addZerosAndFormatValue(value: any): any;
|
|
6
7
|
stripPrefixSuffix(value: any): any;
|
|
7
8
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import NestedArrayComponent from '../_classes/nestedarray/NestedArrayComponent';
|
|
3
3
|
import { fastCloneDeep, getFocusableElements } from '../../utils/utils';
|
|
4
|
-
import Components from '../Components';
|
|
4
|
+
import { Components } from '../Components';
|
|
5
5
|
import dragula from 'dragula';
|
|
6
6
|
export default class DataGridComponent extends NestedArrayComponent {
|
|
7
7
|
static schema(...extend) {
|
|
@@ -3,7 +3,7 @@ import DataGridComponent from '../datagrid/DataGrid';
|
|
|
3
3
|
import _ from 'lodash';
|
|
4
4
|
import EventEmitter from 'eventemitter3';
|
|
5
5
|
import { componentValueTypes, getComponentSavedTypes, uniqueKey } from '../../utils/utils';
|
|
6
|
-
import Components from '../Components';
|
|
6
|
+
import { Components } from '../Components';
|
|
7
7
|
export default class DataMapComponent extends DataGridComponent {
|
|
8
8
|
static schema(...extend) {
|
|
9
9
|
return Component.schema({
|
|
@@ -31,7 +31,16 @@ export default class NumberComponent extends Input {
|
|
|
31
31
|
setInputMask(input: any): void;
|
|
32
32
|
getValueAt(index: any): number | null;
|
|
33
33
|
setValueAt(index: any, value: any, flags?: {}): void;
|
|
34
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Converts a string to a floating point number, formats the number based on the parsed float function
|
|
36
|
+
* (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat) and then returns the
|
|
37
|
+
* formatted number back as a string
|
|
38
|
+
* Example Input: "123.456,22"
|
|
39
|
+
* Example Output: "123456,22"
|
|
40
|
+
* @param {string | number} input the numeric string to parse
|
|
41
|
+
* @returns {string | null} a parsed string
|
|
42
|
+
*/
|
|
43
|
+
parseValue(input: string | number): string | null;
|
|
35
44
|
focus(): void;
|
|
36
45
|
getMaskedValue(value: any): any;
|
|
37
46
|
getValueAsString(value: any, options: any): any;
|
|
@@ -50,12 +50,12 @@ export default class NumberComponent extends Input {
|
|
|
50
50
|
|| this.options.properties?.decimalSeparator
|
|
51
51
|
|| separators.decimalSeparator;
|
|
52
52
|
if (this.component.delimiter) {
|
|
53
|
-
|
|
54
|
-
console.warn("Property 'thousandsSeparator' is deprecated. Please use i18n to specify delimiter.");
|
|
55
|
-
}
|
|
56
|
-
this.delimiter = this.options.properties?.thousandsSeparator || this.options.thousandsSeparator || separators.delimiter;
|
|
53
|
+
this.delimiter = this.component.thousandsSeparator || this.options.properties?.thousandsSeparator || this.options.thousandsSeparator || separators.delimiter;
|
|
57
54
|
}
|
|
58
55
|
else {
|
|
56
|
+
if (this.component.thousandsSeparator || this.options.properties?.thousandsSeparator || this.options.thousandsSeparator) {
|
|
57
|
+
console.warn('In order for thousands separator to work properly, you must set the delimiter to true in the component json');
|
|
58
|
+
}
|
|
59
59
|
this.delimiter = '';
|
|
60
60
|
}
|
|
61
61
|
const requireDecimal = _.get(this.component, 'requireDecimal', false);
|
|
@@ -77,7 +77,7 @@ export default class NumberComponent extends Input {
|
|
|
77
77
|
prefix: '',
|
|
78
78
|
suffix: '',
|
|
79
79
|
requireDecimal: _.get(this.component, 'requireDecimal', false),
|
|
80
|
-
thousandsSeparatorSymbol:
|
|
80
|
+
thousandsSeparatorSymbol: this.delimiter || '',
|
|
81
81
|
decimalSymbol: _.get(this.component, 'decimalSymbol', this.decimalSeparator),
|
|
82
82
|
decimalLimit: _.get(this.component, 'decimalLimit', this.decimalLimit),
|
|
83
83
|
allowNegative: _.get(this.component, 'allowNegative', true),
|
|
@@ -144,6 +144,15 @@ export default class NumberComponent extends Input {
|
|
|
144
144
|
setValueAt(index, value, flags = {}) {
|
|
145
145
|
return super.setValueAt(index, this.formatValue(this.parseValue(value)), flags);
|
|
146
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Converts a string to a floating point number, formats the number based on the parsed float function
|
|
149
|
+
* (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat) and then returns the
|
|
150
|
+
* formatted number back as a string
|
|
151
|
+
* Example Input: "123.456,22"
|
|
152
|
+
* Example Output: "123456,22"
|
|
153
|
+
* @param {string | number} input the numeric string to parse
|
|
154
|
+
* @returns {string | null} a parsed string
|
|
155
|
+
*/
|
|
147
156
|
parseValue(input) {
|
|
148
157
|
if (typeof input === 'string') {
|
|
149
158
|
input = input.split(this.delimiter).join('').replace(this.decimalSeparator, '.');
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare namespace _default {
|
|
2
|
+
let components: {
|
|
3
|
+
label: string;
|
|
4
|
+
applyMaskOn: string;
|
|
5
|
+
mask: boolean;
|
|
6
|
+
tableView: boolean;
|
|
7
|
+
delimiter: boolean;
|
|
8
|
+
requireDecimal: boolean;
|
|
9
|
+
inputFormat: string;
|
|
10
|
+
truncateMultipleSpaces: boolean;
|
|
11
|
+
key: string;
|
|
12
|
+
type: string;
|
|
13
|
+
input: boolean;
|
|
14
|
+
decimalSymbol: string;
|
|
15
|
+
thousandsSeparator: string;
|
|
16
|
+
}[];
|
|
17
|
+
}
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
components: [
|
|
3
|
+
{
|
|
4
|
+
"label": "Number",
|
|
5
|
+
"applyMaskOn": "change",
|
|
6
|
+
"mask": false,
|
|
7
|
+
"tableView": false,
|
|
8
|
+
"delimiter": true,
|
|
9
|
+
"requireDecimal": false,
|
|
10
|
+
"inputFormat": "plain",
|
|
11
|
+
"truncateMultipleSpaces": false,
|
|
12
|
+
"key": "number",
|
|
13
|
+
"type": "number",
|
|
14
|
+
"input": true,
|
|
15
|
+
"decimalSymbol": ",",
|
|
16
|
+
"thousandsSeparator": "."
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
};
|
|
@@ -6,4 +6,5 @@ import comp5 from './comp5';
|
|
|
6
6
|
import comp6 from './comp6';
|
|
7
7
|
import comp7 from './comp7';
|
|
8
8
|
import comp8 from './comp8';
|
|
9
|
-
|
|
9
|
+
import comp9 from './comp9';
|
|
10
|
+
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9 };
|
|
@@ -6,4 +6,5 @@ import comp5 from './comp5';
|
|
|
6
6
|
import comp6 from './comp6';
|
|
7
7
|
import comp7 from './comp7';
|
|
8
8
|
import comp8 from './comp8';
|
|
9
|
-
|
|
9
|
+
import comp9 from './comp9';
|
|
10
|
+
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9 };
|