@formio/js 5.0.0-dev.5777.4ccabb1 → 5.0.0-dev.5778.eb7f268
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/formio.form.js +518 -518
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +518 -518
- package/dist/formio.full.min.js +1 -1
- package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +1 -0
- package/lib/cjs/components/_classes/multivalue/Multivalue.js +25 -43
- package/lib/cjs/components/tags/Tags.js +3 -3
- package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +1 -0
- package/lib/mjs/components/_classes/multivalue/Multivalue.js +25 -43
- package/lib/mjs/components/tags/Tags.js +3 -3
- package/package.json +2 -2
|
@@ -6,40 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const Field_1 = __importDefault(require("../field/Field"));
|
|
7
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
8
|
class Multivalue extends Field_1.default {
|
|
9
|
-
/**
|
|
10
|
-
* Normalize values coming into updateValue.
|
|
11
|
-
* @param {*} value - The value to normalize before setting.
|
|
12
|
-
* @returns {*} - The normalized value.
|
|
13
|
-
*/
|
|
14
|
-
normalizeValue(value) {
|
|
15
|
-
if (this.component.multiple) {
|
|
16
|
-
if (Array.isArray(value)) {
|
|
17
|
-
if (value.length === 0) {
|
|
18
|
-
return [this.emptyValue];
|
|
19
|
-
}
|
|
20
|
-
if (this.component.storeas === 'array') {
|
|
21
|
-
return super.normalizeValue([value]);
|
|
22
|
-
}
|
|
23
|
-
return super.normalizeValue(value);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
return super.normalizeValue(value == null ? [this.emptyValue] : [value]);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
if (Array.isArray(value) && this.component.storeas !== 'array') {
|
|
31
|
-
if (this.component.storeas === 'string') {
|
|
32
|
-
return super.normalizeValue(value.join(this.delimiter || ''));
|
|
33
|
-
}
|
|
34
|
-
return super.normalizeValue(value[0] || this.emptyValue);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
return super.normalizeValue(value);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
9
|
get dataValue() {
|
|
42
|
-
|
|
10
|
+
const parent = super.dataValue;
|
|
11
|
+
if (!parent && this.component.multiple) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
return parent;
|
|
43
15
|
}
|
|
44
16
|
set dataValue(value) {
|
|
45
17
|
super.dataValue = value;
|
|
@@ -59,20 +31,30 @@ class Multivalue extends Field_1.default {
|
|
|
59
31
|
get addAnother() {
|
|
60
32
|
return this.t(this.component.addAnother || 'Add Another');
|
|
61
33
|
}
|
|
34
|
+
useWrapper() {
|
|
35
|
+
return this.component.hasOwnProperty('multiple') && this.component.multiple;
|
|
36
|
+
}
|
|
62
37
|
/**
|
|
63
38
|
* @returns {Field} - The created field.
|
|
64
39
|
*/
|
|
65
40
|
render() {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
41
|
+
// If single value field.
|
|
42
|
+
if (!this.useWrapper()) {
|
|
43
|
+
return super.render(`<div ${this._referenceAttributeName}="element">
|
|
44
|
+
${this.renderElement(this.component.type !== 'hidden' ? this.dataValue : '')}
|
|
45
|
+
</div>`);
|
|
46
|
+
}
|
|
47
|
+
// Make sure dataValue is in the correct array format.
|
|
48
|
+
let dataValue = this.dataValue;
|
|
49
|
+
if (!Array.isArray(dataValue)) {
|
|
50
|
+
dataValue = dataValue ? [dataValue] : [];
|
|
51
|
+
}
|
|
52
|
+
// If multiple value field.
|
|
53
|
+
return super.render(this.renderTemplate('multiValueTable', {
|
|
54
|
+
rows: dataValue.map(this.renderRow.bind(this)).join(''),
|
|
55
|
+
disabled: this.disabled,
|
|
56
|
+
addAnother: this.addAnother,
|
|
57
|
+
}));
|
|
76
58
|
}
|
|
77
59
|
renderElement() {
|
|
78
60
|
return '';
|
|
@@ -118,12 +118,12 @@ class TagsComponent extends Input_1.default {
|
|
|
118
118
|
}
|
|
119
119
|
normalizeValue(value) {
|
|
120
120
|
if (this.component.storeas === 'string' && Array.isArray(value)) {
|
|
121
|
-
return
|
|
121
|
+
return value.join(this.delimiter);
|
|
122
122
|
}
|
|
123
123
|
else if (this.component.storeas === 'array' && typeof value === 'string') {
|
|
124
|
-
return
|
|
124
|
+
return value.split(this.delimiter).filter(result => result);
|
|
125
125
|
}
|
|
126
|
-
return
|
|
126
|
+
return value;
|
|
127
127
|
}
|
|
128
128
|
setValue(value, flags = {}) {
|
|
129
129
|
const changed = super.setValue(value, flags);
|
|
@@ -1,40 +1,12 @@
|
|
|
1
1
|
import Field from '../field/Field';
|
|
2
2
|
import _ from 'lodash';
|
|
3
3
|
export default class Multivalue extends Field {
|
|
4
|
-
/**
|
|
5
|
-
* Normalize values coming into updateValue.
|
|
6
|
-
* @param {*} value - The value to normalize before setting.
|
|
7
|
-
* @returns {*} - The normalized value.
|
|
8
|
-
*/
|
|
9
|
-
normalizeValue(value) {
|
|
10
|
-
if (this.component.multiple) {
|
|
11
|
-
if (Array.isArray(value)) {
|
|
12
|
-
if (value.length === 0) {
|
|
13
|
-
return [this.emptyValue];
|
|
14
|
-
}
|
|
15
|
-
if (this.component.storeas === 'array') {
|
|
16
|
-
return super.normalizeValue([value]);
|
|
17
|
-
}
|
|
18
|
-
return super.normalizeValue(value);
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
return super.normalizeValue(value == null ? [this.emptyValue] : [value]);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
if (Array.isArray(value) && this.component.storeas !== 'array') {
|
|
26
|
-
if (this.component.storeas === 'string') {
|
|
27
|
-
return super.normalizeValue(value.join(this.delimiter || ''));
|
|
28
|
-
}
|
|
29
|
-
return super.normalizeValue(value[0] || this.emptyValue);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
return super.normalizeValue(value);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
4
|
get dataValue() {
|
|
37
|
-
|
|
5
|
+
const parent = super.dataValue;
|
|
6
|
+
if (!parent && this.component.multiple) {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
return parent;
|
|
38
10
|
}
|
|
39
11
|
set dataValue(value) {
|
|
40
12
|
super.dataValue = value;
|
|
@@ -54,20 +26,30 @@ export default class Multivalue extends Field {
|
|
|
54
26
|
get addAnother() {
|
|
55
27
|
return this.t(this.component.addAnother || 'Add Another');
|
|
56
28
|
}
|
|
29
|
+
useWrapper() {
|
|
30
|
+
return this.component.hasOwnProperty('multiple') && this.component.multiple;
|
|
31
|
+
}
|
|
57
32
|
/**
|
|
58
33
|
* @returns {Field} - The created field.
|
|
59
34
|
*/
|
|
60
35
|
render() {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
36
|
+
// If single value field.
|
|
37
|
+
if (!this.useWrapper()) {
|
|
38
|
+
return super.render(`<div ${this._referenceAttributeName}="element">
|
|
39
|
+
${this.renderElement(this.component.type !== 'hidden' ? this.dataValue : '')}
|
|
40
|
+
</div>`);
|
|
41
|
+
}
|
|
42
|
+
// Make sure dataValue is in the correct array format.
|
|
43
|
+
let dataValue = this.dataValue;
|
|
44
|
+
if (!Array.isArray(dataValue)) {
|
|
45
|
+
dataValue = dataValue ? [dataValue] : [];
|
|
46
|
+
}
|
|
47
|
+
// If multiple value field.
|
|
48
|
+
return super.render(this.renderTemplate('multiValueTable', {
|
|
49
|
+
rows: dataValue.map(this.renderRow.bind(this)).join(''),
|
|
50
|
+
disabled: this.disabled,
|
|
51
|
+
addAnother: this.addAnother,
|
|
52
|
+
}));
|
|
71
53
|
}
|
|
72
54
|
renderElement() {
|
|
73
55
|
return '';
|
|
@@ -116,12 +116,12 @@ export default class TagsComponent extends Input {
|
|
|
116
116
|
}
|
|
117
117
|
normalizeValue(value) {
|
|
118
118
|
if (this.component.storeas === 'string' && Array.isArray(value)) {
|
|
119
|
-
return
|
|
119
|
+
return value.join(this.delimiter);
|
|
120
120
|
}
|
|
121
121
|
else if (this.component.storeas === 'array' && typeof value === 'string') {
|
|
122
|
-
return
|
|
122
|
+
return value.split(this.delimiter).filter(result => result);
|
|
123
123
|
}
|
|
124
|
-
return
|
|
124
|
+
return value;
|
|
125
125
|
}
|
|
126
126
|
setValue(value, flags = {}) {
|
|
127
127
|
const changed = super.setValue(value, flags);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formio/js",
|
|
3
|
-
"version": "5.0.0-dev.
|
|
3
|
+
"version": "5.0.0-dev.5778.eb7f268",
|
|
4
4
|
"description": "JavaScript powered Forms with JSON Form Builder",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"browser-cookies": "^1.2.0",
|
|
91
91
|
"browser-md5-file": "^1.1.1",
|
|
92
92
|
"compare-versions": "^6.1.1",
|
|
93
|
-
"core-js": "^3.
|
|
93
|
+
"core-js": "^3.38.0",
|
|
94
94
|
"dialog-polyfill": "^0.5.6",
|
|
95
95
|
"dom-autoscroller": "^2.3.4",
|
|
96
96
|
"dompurify": "^3.1.6",
|