@formio/js 5.0.0-dev.5770.0748fdc → 5.0.0-dev.5777.4ccabb1
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 +7 -0
- package/dist/formio.form.js +9 -9
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +10 -10
- package/dist/formio.full.min.js +1 -1
- package/lib/cjs/PDFBuilder.js +2 -1
- package/lib/cjs/components/_classes/multivalue/Multivalue.d.ts +0 -1
- package/lib/cjs/components/_classes/multivalue/Multivalue.js +43 -25
- package/lib/cjs/components/datagrid/DataGrid.js +1 -1
- package/lib/cjs/components/day/Day.d.ts +1 -1
- package/lib/cjs/components/day/Day.js +28 -7
- package/lib/cjs/components/radio/Radio.d.ts +2 -18
- package/lib/cjs/components/radio/Radio.js +22 -21
- package/lib/cjs/components/recaptcha/ReCaptcha.d.ts +6 -0
- package/lib/cjs/components/recaptcha/ReCaptcha.js +6 -0
- package/lib/cjs/components/select/Select.js +2 -2
- package/lib/cjs/components/selectboxes/SelectBoxes.d.ts +0 -22
- package/lib/cjs/components/selectboxes/SelectBoxes.js +12 -9
- package/lib/cjs/components/tags/Tags.js +3 -3
- package/lib/cjs/components/time/Time.js +0 -5
- package/lib/mjs/PDFBuilder.js +1 -1
- package/lib/mjs/components/_classes/multivalue/Multivalue.d.ts +0 -1
- package/lib/mjs/components/_classes/multivalue/Multivalue.js +43 -25
- package/lib/mjs/components/datagrid/DataGrid.js +1 -1
- package/lib/mjs/components/day/Day.d.ts +1 -1
- package/lib/mjs/components/day/Day.js +27 -7
- package/lib/mjs/components/radio/Radio.d.ts +2 -18
- package/lib/mjs/components/radio/Radio.js +25 -24
- package/lib/mjs/components/recaptcha/ReCaptcha.d.ts +6 -0
- package/lib/mjs/components/recaptcha/ReCaptcha.js +9 -0
- package/lib/mjs/components/select/Select.js +2 -2
- package/lib/mjs/components/selectboxes/SelectBoxes.d.ts +0 -22
- package/lib/mjs/components/selectboxes/SelectBoxes.js +16 -9
- package/lib/mjs/components/tags/Tags.js +3 -3
- package/lib/mjs/components/time/Time.js +0 -11
- package/package.json +1 -1
package/lib/cjs/PDFBuilder.js
CHANGED
|
@@ -403,6 +403,7 @@ class PDFBuilder extends WebformBuilder_1.default {
|
|
|
403
403
|
return false;
|
|
404
404
|
}
|
|
405
405
|
onDragEnd(e) {
|
|
406
|
+
var _a;
|
|
406
407
|
// IMPORTANT - must retrieve offsets BEFORE disabling the dropzone - offsets will
|
|
407
408
|
// reflect absolute positioning if accessed after the target element is hidden
|
|
408
409
|
const iframeRect = this.webform.refs.iframeContainer.getBoundingClientRect();
|
|
@@ -435,7 +436,7 @@ class PDFBuilder extends WebformBuilder_1.default {
|
|
|
435
436
|
lodash_1.default.merge(schema, info);
|
|
436
437
|
}
|
|
437
438
|
// Set a unique key for this component.
|
|
438
|
-
builder_1.default.uniquify(
|
|
439
|
+
builder_1.default.uniquify(((_a = this.webform._form) === null || _a === void 0 ? void 0 : _a.components) || [], schema);
|
|
439
440
|
this.webform._form.components.push(schema);
|
|
440
441
|
schema.overlay = {
|
|
441
442
|
top: layerY ? (layerY - this.itemOffsetY + HEIGHT) : (e.clientY - iframeRect.top - (this.itemOffsetY - HEIGHT) * 2),
|
|
@@ -6,12 +6,40 @@ 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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
}
|
|
13
39
|
}
|
|
14
|
-
|
|
40
|
+
}
|
|
41
|
+
get dataValue() {
|
|
42
|
+
return super.dataValue;
|
|
15
43
|
}
|
|
16
44
|
set dataValue(value) {
|
|
17
45
|
super.dataValue = value;
|
|
@@ -31,30 +59,20 @@ class Multivalue extends Field_1.default {
|
|
|
31
59
|
get addAnother() {
|
|
32
60
|
return this.t(this.component.addAnother || 'Add Another');
|
|
33
61
|
}
|
|
34
|
-
useWrapper() {
|
|
35
|
-
return this.component.hasOwnProperty('multiple') && this.component.multiple;
|
|
36
|
-
}
|
|
37
62
|
/**
|
|
38
63
|
* @returns {Field} - The created field.
|
|
39
64
|
*/
|
|
40
65
|
render() {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
}));
|
|
66
|
+
let dataValue = this.normalizeValue(this.dataValue);
|
|
67
|
+
return this.component.hasOwnProperty('multiple') && this.component.multiple
|
|
68
|
+
? super.render(this.renderTemplate('multiValueTable', {
|
|
69
|
+
rows: dataValue.map(this.renderRow.bind(this)).join(''),
|
|
70
|
+
disabled: this.disabled,
|
|
71
|
+
addAnother: this.addAnother,
|
|
72
|
+
}))
|
|
73
|
+
: super.render(`<div ${this._referenceAttributeName}="element">
|
|
74
|
+
${this.renderElement(this.component.type !== 'hidden' ? dataValue : '')}
|
|
75
|
+
</div>`);
|
|
58
76
|
}
|
|
59
77
|
renderElement() {
|
|
60
78
|
return '';
|
|
@@ -436,7 +436,7 @@ class DataGridComponent extends NestedArrayComponent_1.default {
|
|
|
436
436
|
}
|
|
437
437
|
removeRow(index) {
|
|
438
438
|
const makeEmpty = index === 0 && this.rows.length === 1;
|
|
439
|
-
const flags = { isReordered: !makeEmpty, resetValue: makeEmpty };
|
|
439
|
+
const flags = { isReordered: !makeEmpty, resetValue: makeEmpty, modified: true };
|
|
440
440
|
this.splice(index, flags);
|
|
441
441
|
this.emit('dataGridDeleteRow', { index });
|
|
442
442
|
const [row] = this.rows.splice(index, 1);
|
|
@@ -132,6 +132,6 @@ export default class DayComponent extends Field {
|
|
|
132
132
|
getValueAsString(value: any): string | null;
|
|
133
133
|
focus(field: any): void;
|
|
134
134
|
isPartialDay(value: any): boolean;
|
|
135
|
-
getValidationFormat():
|
|
135
|
+
getValidationFormat(): string;
|
|
136
136
|
}
|
|
137
137
|
import Field from '../_classes/field/Field';
|
|
@@ -30,7 +30,8 @@ class DayComponent extends Field_1.default {
|
|
|
30
30
|
required: false
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
|
-
dayFirst: false
|
|
33
|
+
dayFirst: false,
|
|
34
|
+
defaultValue: ''
|
|
34
35
|
}, ...extend);
|
|
35
36
|
}
|
|
36
37
|
static get builderInfo() {
|
|
@@ -343,15 +344,21 @@ class DayComponent extends Field_1.default {
|
|
|
343
344
|
const valueParts = value.split('/');
|
|
344
345
|
const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
|
|
345
346
|
const defaultValue = this.component.defaultValue ? this.component.defaultValue.split('/') : '';
|
|
346
|
-
const getNextPart = (shouldTake, defaultValue) =>
|
|
347
|
+
const getNextPart = (shouldTake, defaultValue) => {
|
|
348
|
+
// Only push the part if it's not an empty string
|
|
349
|
+
const part = shouldTake ? valueParts.shift() : defaultValue;
|
|
350
|
+
if (part !== '') {
|
|
351
|
+
dateParts.push(part);
|
|
352
|
+
}
|
|
353
|
+
};
|
|
347
354
|
if (this.dayFirst) {
|
|
348
|
-
getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : '
|
|
355
|
+
getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : '');
|
|
349
356
|
}
|
|
350
|
-
getNextPart(this.showMonth, defaultValue ? defaultValue[MONTH] : '
|
|
357
|
+
getNextPart(this.showMonth, defaultValue ? defaultValue[MONTH] : '');
|
|
351
358
|
if (!this.dayFirst) {
|
|
352
|
-
getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : '
|
|
359
|
+
getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : '');
|
|
353
360
|
}
|
|
354
|
-
getNextPart(this.showYear, defaultValue ? defaultValue[YEAR] : '
|
|
361
|
+
getNextPart(this.showYear, defaultValue ? defaultValue[YEAR] : '');
|
|
355
362
|
return dateParts.join('/');
|
|
356
363
|
}
|
|
357
364
|
/**
|
|
@@ -558,10 +565,24 @@ class DayComponent extends Field_1.default {
|
|
|
558
565
|
}
|
|
559
566
|
const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
|
|
560
567
|
const values = value.split('/');
|
|
568
|
+
if (values.length < 3) {
|
|
569
|
+
return true;
|
|
570
|
+
}
|
|
561
571
|
return (values[DAY] === '00' || values[MONTH] === '00' || values[YEAR] === '0000');
|
|
562
572
|
}
|
|
563
573
|
getValidationFormat() {
|
|
564
|
-
|
|
574
|
+
var _a, _b, _c, _d, _e, _f;
|
|
575
|
+
let validationFormat = this.dayFirst ? 'DD-MM-YYYY' : 'MM-DD-YYYY';
|
|
576
|
+
if ((_b = (_a = this.fields) === null || _a === void 0 ? void 0 : _a.day) === null || _b === void 0 ? void 0 : _b.hide) {
|
|
577
|
+
validationFormat = validationFormat.replace('DD-', '');
|
|
578
|
+
}
|
|
579
|
+
if ((_d = (_c = this.fields) === null || _c === void 0 ? void 0 : _c.month) === null || _d === void 0 ? void 0 : _d.hide) {
|
|
580
|
+
validationFormat = validationFormat.replace('MM-', '');
|
|
581
|
+
}
|
|
582
|
+
if ((_f = (_e = this.fields) === null || _e === void 0 ? void 0 : _e.year) === null || _f === void 0 ? void 0 : _f.hide) {
|
|
583
|
+
validationFormat = validationFormat.replace('-YYYY', '');
|
|
584
|
+
}
|
|
585
|
+
return validationFormat;
|
|
565
586
|
}
|
|
566
587
|
}
|
|
567
588
|
exports.default = DayComponent;
|
|
@@ -8,26 +8,10 @@ export default class RadioComponent extends ListComponent {
|
|
|
8
8
|
schema: any;
|
|
9
9
|
};
|
|
10
10
|
static get conditionOperatorsSettings(): {
|
|
11
|
-
valueComponent(classComp: any):
|
|
12
|
-
type: string;
|
|
13
|
-
dataSrc: string;
|
|
14
|
-
valueProperty: string;
|
|
15
|
-
dataType: any;
|
|
16
|
-
data: {
|
|
17
|
-
custom(): any;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
11
|
+
valueComponent(classComp: any): any;
|
|
20
12
|
};
|
|
21
13
|
static get serverConditionSettings(): {
|
|
22
|
-
valueComponent(classComp: any):
|
|
23
|
-
type: string;
|
|
24
|
-
dataSrc: string;
|
|
25
|
-
valueProperty: string;
|
|
26
|
-
dataType: any;
|
|
27
|
-
data: {
|
|
28
|
-
custom: string;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
14
|
+
valueComponent(classComp: any): any;
|
|
31
15
|
};
|
|
32
16
|
static savedValueTypes(schema: any): any[];
|
|
33
17
|
constructor(component: any, options: any, data: any);
|
|
@@ -33,31 +33,22 @@ class RadioComponent extends ListComponent_1.default {
|
|
|
33
33
|
}
|
|
34
34
|
static get conditionOperatorsSettings() {
|
|
35
35
|
return Object.assign(Object.assign({}, super.conditionOperatorsSettings), { valueComponent(classComp) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
const isValuesSrc = !classComp.dataSrc || classComp.dataSrc === 'values';
|
|
37
|
+
return isValuesSrc
|
|
38
|
+
? {
|
|
39
|
+
type: 'select',
|
|
40
|
+
dataSrc: 'custom',
|
|
41
|
+
valueProperty: 'value',
|
|
42
|
+
dataType: classComp.dataType || '',
|
|
43
|
+
data: {
|
|
44
|
+
custom: `values = ${classComp && classComp.values ? JSON.stringify(classComp.values) : []}`,
|
|
44
45
|
}
|
|
45
|
-
}
|
|
46
|
-
|
|
46
|
+
}
|
|
47
|
+
: Object.assign(Object.assign({}, classComp), { type: 'select' });
|
|
47
48
|
} });
|
|
48
49
|
}
|
|
49
50
|
static get serverConditionSettings() {
|
|
50
|
-
return
|
|
51
|
-
return {
|
|
52
|
-
type: 'select',
|
|
53
|
-
dataSrc: 'custom',
|
|
54
|
-
valueProperty: 'value',
|
|
55
|
-
dataType: classComp.dataType || '',
|
|
56
|
-
data: {
|
|
57
|
-
custom: `values = ${classComp && classComp.values ? JSON.stringify(classComp.values) : []}`,
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
} });
|
|
51
|
+
return RadioComponent.conditionOperatorsSettings;
|
|
61
52
|
}
|
|
62
53
|
static savedValueTypes(schema) {
|
|
63
54
|
const { boolean, string, number, object, array } = utils_1.componentValueTypes;
|
|
@@ -264,6 +255,16 @@ class RadioComponent extends ListComponent_1.default {
|
|
|
264
255
|
if (method.toUpperCase() === 'GET') {
|
|
265
256
|
body = null;
|
|
266
257
|
}
|
|
258
|
+
const limit = this.component.limit || 100;
|
|
259
|
+
const skip = this.isScrollLoading ? this.selectOptions.length : 0;
|
|
260
|
+
// Allow for url interpolation.
|
|
261
|
+
url = this.sanitize(this.interpolate(url, {
|
|
262
|
+
formioBase: Formio_1.Formio.getBaseUrl(),
|
|
263
|
+
search,
|
|
264
|
+
limit,
|
|
265
|
+
skip,
|
|
266
|
+
page: Math.abs(Math.floor(skip / limit))
|
|
267
|
+
}), this.shouldSanitizeValue);
|
|
267
268
|
// Set ignoreCache if it is
|
|
268
269
|
options.ignoreCache = this.component.ignoreCache;
|
|
269
270
|
// Make the request.
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
export default class ReCaptchaComponent extends Component {
|
|
2
2
|
static get builderInfo(): {};
|
|
3
3
|
static savedValueTypes(): never[];
|
|
4
|
+
static get conditionOperatorsSettings(): {
|
|
5
|
+
operators: string[];
|
|
6
|
+
};
|
|
7
|
+
static get serverConditionSettings(): {
|
|
8
|
+
operators: string[];
|
|
9
|
+
};
|
|
4
10
|
render(): string;
|
|
5
11
|
recaptchaResult: any;
|
|
6
12
|
createInput(): void;
|
|
@@ -31,6 +31,12 @@ class ReCaptchaComponent extends Component_1.default {
|
|
|
31
31
|
static savedValueTypes() {
|
|
32
32
|
return [];
|
|
33
33
|
}
|
|
34
|
+
static get conditionOperatorsSettings() {
|
|
35
|
+
return Object.assign(Object.assign({}, super.conditionOperatorsSettings), { operators: ['isEmpty', 'isNotEmpty'] });
|
|
36
|
+
}
|
|
37
|
+
static get serverConditionSettings() {
|
|
38
|
+
return ReCaptchaComponent.conditionOperatorsSettings;
|
|
39
|
+
}
|
|
34
40
|
render() {
|
|
35
41
|
this.recaptchaResult = null;
|
|
36
42
|
if (this.builderMode) {
|
|
@@ -536,13 +536,13 @@ class SelectComponent extends ListComponent_1.default {
|
|
|
536
536
|
skip,
|
|
537
537
|
};
|
|
538
538
|
// Allow for url interpolation.
|
|
539
|
-
url = this.interpolate(url, {
|
|
539
|
+
url = this.sanitize(this.interpolate(url, {
|
|
540
540
|
formioBase: Formio_1.Formio.getBaseUrl(),
|
|
541
541
|
search,
|
|
542
542
|
limit,
|
|
543
543
|
skip,
|
|
544
544
|
page: Math.abs(Math.floor(skip / limit))
|
|
545
|
-
});
|
|
545
|
+
}), this.shouldSanitizeValue);
|
|
546
546
|
// Add search capability.
|
|
547
547
|
if (this.component.searchField && search) {
|
|
548
548
|
const searchValue = Array.isArray(search)
|
|
@@ -1,26 +1,4 @@
|
|
|
1
1
|
export default class SelectBoxesComponent extends RadioComponent {
|
|
2
|
-
static get serverConditionSettings(): {
|
|
3
|
-
valueComponent(classComp: any): {
|
|
4
|
-
type: string;
|
|
5
|
-
dataSrc: string;
|
|
6
|
-
valueProperty: string;
|
|
7
|
-
dataType: string;
|
|
8
|
-
data: {
|
|
9
|
-
custom: string;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
static get conditionOperatorsSettings(): {
|
|
14
|
-
valueComponent(classComp: any): {
|
|
15
|
-
type: string;
|
|
16
|
-
dataSrc: string;
|
|
17
|
-
valueProperty: string;
|
|
18
|
-
dataType: string;
|
|
19
|
-
data: {
|
|
20
|
-
custom: string;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
2
|
static savedValueTypes(schema: any): string[];
|
|
25
3
|
constructor(...args: any[]);
|
|
26
4
|
get emptyValue(): any;
|
|
@@ -30,15 +30,18 @@ class SelectBoxesComponent extends Radio_1.default {
|
|
|
30
30
|
}
|
|
31
31
|
static get conditionOperatorsSettings() {
|
|
32
32
|
return Object.assign(Object.assign({}, super.conditionOperatorsSettings), { valueComponent(classComp) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
const isValuesSrc = !classComp.dataSrc || classComp.dataSrc === 'values';
|
|
34
|
+
return isValuesSrc
|
|
35
|
+
? {
|
|
36
|
+
type: 'select',
|
|
37
|
+
dataSrc: 'custom',
|
|
38
|
+
valueProperty: 'value',
|
|
39
|
+
dataType: 'string',
|
|
40
|
+
data: {
|
|
41
|
+
custom: `values = ${classComp && classComp.values ? JSON.stringify(classComp.values) : []}`
|
|
42
|
+
},
|
|
43
|
+
}
|
|
44
|
+
: Object.assign(Object.assign({}, classComp), { dataType: 'string', type: 'select' });
|
|
42
45
|
} });
|
|
43
46
|
}
|
|
44
47
|
static savedValueTypes(schema) {
|
|
@@ -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 value.join(this.delimiter);
|
|
121
|
+
return super.normalizeValue(value.join(this.delimiter));
|
|
122
122
|
}
|
|
123
123
|
else if (this.component.storeas === 'array' && typeof value === 'string') {
|
|
124
|
-
return value.split(this.delimiter).filter(result => result);
|
|
124
|
+
return super.normalizeValue(value.split(this.delimiter).filter(result => result));
|
|
125
125
|
}
|
|
126
|
-
return value;
|
|
126
|
+
return super.normalizeValue(value);
|
|
127
127
|
}
|
|
128
128
|
setValue(value, flags = {}) {
|
|
129
129
|
const changed = super.setValue(value, flags);
|
|
@@ -18,11 +18,6 @@ class TimeComponent extends TextField_1.default {
|
|
|
18
18
|
dataFormat: defaultDataFormat,
|
|
19
19
|
}, ...extend);
|
|
20
20
|
}
|
|
21
|
-
static get serverConditionSettings() {
|
|
22
|
-
return Object.assign(Object.assign({}, super.serverConditionSettings), { valueComponent(classComp) {
|
|
23
|
-
return Object.assign(Object.assign({}, classComp), { type: 'time' });
|
|
24
|
-
} });
|
|
25
|
-
}
|
|
26
21
|
constructor(component, options, data) {
|
|
27
22
|
super(component, options, data);
|
|
28
23
|
const { edge: isEdgeBrowser, version: edgeVersion } = (0, utils_1.getBrowserInfo)();
|
package/lib/mjs/PDFBuilder.js
CHANGED
|
@@ -429,7 +429,7 @@ export default class PDFBuilder extends WebformBuilder {
|
|
|
429
429
|
_.merge(schema, info);
|
|
430
430
|
}
|
|
431
431
|
// Set a unique key for this component.
|
|
432
|
-
BuilderUtils.uniquify(
|
|
432
|
+
BuilderUtils.uniquify(this.webform._form?.components || [], schema);
|
|
433
433
|
this.webform._form.components.push(schema);
|
|
434
434
|
schema.overlay = {
|
|
435
435
|
top: layerY ? (layerY - this.itemOffsetY + HEIGHT) : (e.clientY - iframeRect.top - (this.itemOffsetY - HEIGHT) * 2),
|
|
@@ -1,12 +1,40 @@
|
|
|
1
1
|
import Field from '../field/Field';
|
|
2
2
|
import _ from 'lodash';
|
|
3
3
|
export default class Multivalue extends Field {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
}
|
|
8
34
|
}
|
|
9
|
-
|
|
35
|
+
}
|
|
36
|
+
get dataValue() {
|
|
37
|
+
return super.dataValue;
|
|
10
38
|
}
|
|
11
39
|
set dataValue(value) {
|
|
12
40
|
super.dataValue = value;
|
|
@@ -26,30 +54,20 @@ export default class Multivalue extends Field {
|
|
|
26
54
|
get addAnother() {
|
|
27
55
|
return this.t(this.component.addAnother || 'Add Another');
|
|
28
56
|
}
|
|
29
|
-
useWrapper() {
|
|
30
|
-
return this.component.hasOwnProperty('multiple') && this.component.multiple;
|
|
31
|
-
}
|
|
32
57
|
/**
|
|
33
58
|
* @returns {Field} - The created field.
|
|
34
59
|
*/
|
|
35
60
|
render() {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
}));
|
|
61
|
+
let dataValue = this.normalizeValue(this.dataValue);
|
|
62
|
+
return this.component.hasOwnProperty('multiple') && this.component.multiple
|
|
63
|
+
? super.render(this.renderTemplate('multiValueTable', {
|
|
64
|
+
rows: dataValue.map(this.renderRow.bind(this)).join(''),
|
|
65
|
+
disabled: this.disabled,
|
|
66
|
+
addAnother: this.addAnother,
|
|
67
|
+
}))
|
|
68
|
+
: super.render(`<div ${this._referenceAttributeName}="element">
|
|
69
|
+
${this.renderElement(this.component.type !== 'hidden' ? dataValue : '')}
|
|
70
|
+
</div>`);
|
|
53
71
|
}
|
|
54
72
|
renderElement() {
|
|
55
73
|
return '';
|
|
@@ -432,7 +432,7 @@ export default class DataGridComponent extends NestedArrayComponent {
|
|
|
432
432
|
}
|
|
433
433
|
removeRow(index) {
|
|
434
434
|
const makeEmpty = index === 0 && this.rows.length === 1;
|
|
435
|
-
const flags = { isReordered: !makeEmpty, resetValue: makeEmpty };
|
|
435
|
+
const flags = { isReordered: !makeEmpty, resetValue: makeEmpty, modified: true };
|
|
436
436
|
this.splice(index, flags);
|
|
437
437
|
this.emit('dataGridDeleteRow', { index });
|
|
438
438
|
const [row] = this.rows.splice(index, 1);
|
|
@@ -132,6 +132,6 @@ export default class DayComponent extends Field {
|
|
|
132
132
|
getValueAsString(value: any): string | null;
|
|
133
133
|
focus(field: any): void;
|
|
134
134
|
isPartialDay(value: any): boolean;
|
|
135
|
-
getValidationFormat():
|
|
135
|
+
getValidationFormat(): string;
|
|
136
136
|
}
|
|
137
137
|
import Field from '../_classes/field/Field';
|
|
@@ -25,7 +25,8 @@ export default class DayComponent extends Field {
|
|
|
25
25
|
required: false
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
|
-
dayFirst: false
|
|
28
|
+
dayFirst: false,
|
|
29
|
+
defaultValue: ''
|
|
29
30
|
}, ...extend);
|
|
30
31
|
}
|
|
31
32
|
static get builderInfo() {
|
|
@@ -341,15 +342,21 @@ export default class DayComponent extends Field {
|
|
|
341
342
|
const valueParts = value.split('/');
|
|
342
343
|
const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
|
|
343
344
|
const defaultValue = this.component.defaultValue ? this.component.defaultValue.split('/') : '';
|
|
344
|
-
const getNextPart = (shouldTake, defaultValue) =>
|
|
345
|
+
const getNextPart = (shouldTake, defaultValue) => {
|
|
346
|
+
// Only push the part if it's not an empty string
|
|
347
|
+
const part = shouldTake ? valueParts.shift() : defaultValue;
|
|
348
|
+
if (part !== '') {
|
|
349
|
+
dateParts.push(part);
|
|
350
|
+
}
|
|
351
|
+
};
|
|
345
352
|
if (this.dayFirst) {
|
|
346
|
-
getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : '
|
|
353
|
+
getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : '');
|
|
347
354
|
}
|
|
348
|
-
getNextPart(this.showMonth, defaultValue ? defaultValue[MONTH] : '
|
|
355
|
+
getNextPart(this.showMonth, defaultValue ? defaultValue[MONTH] : '');
|
|
349
356
|
if (!this.dayFirst) {
|
|
350
|
-
getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : '
|
|
357
|
+
getNextPart(this.showDay, defaultValue ? defaultValue[DAY] : '');
|
|
351
358
|
}
|
|
352
|
-
getNextPart(this.showYear, defaultValue ? defaultValue[YEAR] : '
|
|
359
|
+
getNextPart(this.showYear, defaultValue ? defaultValue[YEAR] : '');
|
|
353
360
|
return dateParts.join('/');
|
|
354
361
|
}
|
|
355
362
|
/**
|
|
@@ -554,9 +561,22 @@ export default class DayComponent extends Field {
|
|
|
554
561
|
}
|
|
555
562
|
const [DAY, MONTH, YEAR] = this.component.dayFirst ? [0, 1, 2] : [1, 0, 2];
|
|
556
563
|
const values = value.split('/');
|
|
564
|
+
if (values.length < 3) {
|
|
565
|
+
return true;
|
|
566
|
+
}
|
|
557
567
|
return (values[DAY] === '00' || values[MONTH] === '00' || values[YEAR] === '0000');
|
|
558
568
|
}
|
|
559
569
|
getValidationFormat() {
|
|
560
|
-
|
|
570
|
+
let validationFormat = this.dayFirst ? 'DD-MM-YYYY' : 'MM-DD-YYYY';
|
|
571
|
+
if (this.fields?.day?.hide) {
|
|
572
|
+
validationFormat = validationFormat.replace('DD-', '');
|
|
573
|
+
}
|
|
574
|
+
if (this.fields?.month?.hide) {
|
|
575
|
+
validationFormat = validationFormat.replace('MM-', '');
|
|
576
|
+
}
|
|
577
|
+
if (this.fields?.year?.hide) {
|
|
578
|
+
validationFormat = validationFormat.replace('-YYYY', '');
|
|
579
|
+
}
|
|
580
|
+
return validationFormat;
|
|
561
581
|
}
|
|
562
582
|
}
|
|
@@ -8,26 +8,10 @@ export default class RadioComponent extends ListComponent {
|
|
|
8
8
|
schema: any;
|
|
9
9
|
};
|
|
10
10
|
static get conditionOperatorsSettings(): {
|
|
11
|
-
valueComponent(classComp: any):
|
|
12
|
-
type: string;
|
|
13
|
-
dataSrc: string;
|
|
14
|
-
valueProperty: string;
|
|
15
|
-
dataType: any;
|
|
16
|
-
data: {
|
|
17
|
-
custom(): any;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
11
|
+
valueComponent(classComp: any): any;
|
|
20
12
|
};
|
|
21
13
|
static get serverConditionSettings(): {
|
|
22
|
-
valueComponent(classComp: any):
|
|
23
|
-
type: string;
|
|
24
|
-
dataSrc: string;
|
|
25
|
-
valueProperty: string;
|
|
26
|
-
dataType: any;
|
|
27
|
-
data: {
|
|
28
|
-
custom: string;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
14
|
+
valueComponent(classComp: any): any;
|
|
31
15
|
};
|
|
32
16
|
static savedValueTypes(schema: any): any[];
|
|
33
17
|
constructor(component: any, options: any, data: any);
|