@formio/js 5.0.0-dev.5936.905c79f → 5.0.0-dev.5937.6595453
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 +302 -10
- package/dist/formio.form.js +586 -596
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.form.min.js.LICENSE.txt +2 -4
- package/dist/formio.full.js +587 -597
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.full.min.js.LICENSE.txt +2 -4
- package/dist/formio.js +3006 -287
- package/dist/formio.min.js +1 -1
- package/dist/formio.min.js.LICENSE.txt +13 -1
- package/dist/formio.utils.js +41 -51
- package/dist/formio.utils.min.js +1 -1
- package/dist/formio.utils.min.js.LICENSE.txt +2 -4
- package/lib/cjs/Webform.d.ts +1 -1
- package/lib/cjs/Webform.js +27 -28
- package/lib/cjs/WebformBuilder.js +6 -13
- package/lib/cjs/Wizard.js +4 -11
- package/lib/cjs/components/Components.d.ts +0 -7
- package/lib/cjs/components/Components.js +1 -33
- package/lib/cjs/components/_classes/component/Component.d.ts +39 -7
- package/lib/cjs/components/_classes/component/Component.js +97 -29
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +2 -2
- package/lib/cjs/components/_classes/componentModal/ComponentModal.d.ts +1 -0
- package/lib/cjs/components/_classes/componentModal/ComponentModal.js +1 -0
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +4 -19
- package/lib/cjs/components/_classes/nested/NestedComponent.js +54 -60
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -1
- package/lib/cjs/components/_classes/nestedarray/NestedArrayComponent.js +9 -46
- package/lib/cjs/components/datagrid/DataGrid.d.ts +0 -1
- package/lib/cjs/components/datagrid/DataGrid.js +1 -45
- package/lib/cjs/components/datamap/DataMap.js +2 -3
- package/lib/cjs/components/editgrid/EditGrid.d.ts +1 -1
- package/lib/cjs/components/editgrid/EditGrid.js +20 -15
- package/lib/cjs/components/form/Form.d.ts +1 -3
- package/lib/cjs/components/form/Form.js +21 -28
- package/lib/cjs/components/html/HTML.js +15 -3
- package/lib/cjs/components/number/Number.js +11 -4
- package/lib/cjs/components/radio/Radio.d.ts +0 -4
- package/lib/cjs/components/radio/Radio.js +23 -66
- package/lib/cjs/components/selectboxes/SelectBoxes.js +0 -1
- package/lib/cjs/formio.form.js +1 -0
- package/lib/cjs/utils/conditionOperators/DateGreaterThan.js +2 -2
- package/lib/cjs/utils/conditionOperators/IsEmptyValue.d.ts +2 -2
- package/lib/cjs/utils/conditionOperators/IsEmptyValue.js +2 -2
- package/lib/cjs/utils/conditionOperators/IsEqualTo.d.ts +2 -2
- package/lib/cjs/utils/conditionOperators/IsEqualTo.js +2 -2
- package/lib/cjs/utils/formUtils.d.ts +25 -14
- package/lib/cjs/utils/formUtils.js +11 -16
- package/lib/cjs/utils/utils.d.ts +1 -2
- package/lib/cjs/utils/utils.js +15 -31
- package/lib/mjs/Webform.d.ts +1 -1
- package/lib/mjs/Webform.js +24 -27
- package/lib/mjs/WebformBuilder.js +6 -13
- package/lib/mjs/Wizard.js +2 -8
- package/lib/mjs/components/Components.d.ts +0 -7
- package/lib/mjs/components/Components.js +1 -32
- package/lib/mjs/components/_classes/component/Component.d.ts +39 -7
- package/lib/mjs/components/_classes/component/Component.js +99 -30
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +2 -2
- package/lib/mjs/components/_classes/componentModal/ComponentModal.d.ts +1 -0
- package/lib/mjs/components/_classes/componentModal/ComponentModal.js +1 -0
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +4 -19
- package/lib/mjs/components/_classes/nested/NestedComponent.js +55 -61
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.d.ts +2 -1
- package/lib/mjs/components/_classes/nestedarray/NestedArrayComponent.js +8 -43
- package/lib/mjs/components/datagrid/DataGrid.d.ts +0 -1
- package/lib/mjs/components/datagrid/DataGrid.js +1 -45
- package/lib/mjs/components/datamap/DataMap.js +2 -3
- package/lib/mjs/components/editgrid/EditGrid.d.ts +1 -1
- package/lib/mjs/components/editgrid/EditGrid.js +22 -14
- package/lib/mjs/components/form/Form.d.ts +1 -3
- package/lib/mjs/components/form/Form.js +22 -28
- package/lib/mjs/components/html/HTML.js +15 -3
- package/lib/mjs/components/number/Number.js +11 -4
- package/lib/mjs/components/radio/Radio.d.ts +0 -4
- package/lib/mjs/components/radio/Radio.js +23 -66
- package/lib/mjs/components/selectboxes/SelectBoxes.js +0 -1
- package/lib/mjs/formio.form.js +1 -0
- package/lib/mjs/utils/conditionOperators/DateGreaterThan.js +2 -2
- package/lib/mjs/utils/conditionOperators/IsEmptyValue.d.ts +2 -2
- package/lib/mjs/utils/conditionOperators/IsEmptyValue.js +2 -2
- package/lib/mjs/utils/conditionOperators/IsEqualTo.d.ts +2 -2
- package/lib/mjs/utils/conditionOperators/IsEqualTo.js +2 -2
- package/lib/mjs/utils/formUtils.d.ts +25 -14
- package/lib/mjs/utils/formUtils.js +2 -12
- package/lib/mjs/utils/utils.d.ts +1 -2
- package/lib/mjs/utils/utils.js +14 -29
- package/package.json +4 -4
|
@@ -3,7 +3,7 @@ import _ from 'lodash';
|
|
|
3
3
|
import Component from '../_classes/component/Component';
|
|
4
4
|
import ComponentModal from '../_classes/componentModal/ComponentModal';
|
|
5
5
|
import EventEmitter from 'eventemitter3';
|
|
6
|
-
import { isMongoId, eachComponent,
|
|
6
|
+
import { isMongoId, eachComponent, componentValueTypes } from '../../utils/utils';
|
|
7
7
|
import { Formio } from '../../Formio';
|
|
8
8
|
import Form from '../../Form';
|
|
9
9
|
export default class FormComponent extends Component {
|
|
@@ -127,15 +127,11 @@ export default class FormComponent extends Component {
|
|
|
127
127
|
this.subFormRevision = undefined;
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
getComponent(path
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
path.shift();
|
|
134
|
-
}
|
|
135
|
-
const originalPathStr = `${this.path}.data.${getStringFromComponentPath(path)}`;
|
|
136
|
-
if (this.subForm) {
|
|
137
|
-
return this.subForm.getComponent(path, fn, originalPathStr);
|
|
130
|
+
getComponent(path) {
|
|
131
|
+
if (!this.subForm) {
|
|
132
|
+
return null;
|
|
138
133
|
}
|
|
134
|
+
return this.subForm.getComponent(path);
|
|
139
135
|
}
|
|
140
136
|
/* eslint-disable max-statements */
|
|
141
137
|
getSubOptions(options = {}) {
|
|
@@ -203,6 +199,7 @@ export default class FormComponent extends Component {
|
|
|
203
199
|
if (this.options.skipDraftRestore) {
|
|
204
200
|
options.skipDraftRestore = this.options.skipDraftRestore;
|
|
205
201
|
}
|
|
202
|
+
options.parent = this;
|
|
206
203
|
return options;
|
|
207
204
|
}
|
|
208
205
|
/* eslint-enable max-statements */
|
|
@@ -294,6 +291,7 @@ export default class FormComponent extends Component {
|
|
|
294
291
|
const modalShouldBeOpened = this.componentModal ? this.componentModal.isOpened : false;
|
|
295
292
|
const currentValue = modalShouldBeOpened ? this.componentModal.currentValue : this.dataValue;
|
|
296
293
|
this.componentModal = new ComponentModal(this, element, modalShouldBeOpened, currentValue, this._referenceAttributeName);
|
|
294
|
+
this.subForm.element = this.componentModal.refs.componentContent || this.subForm.element;
|
|
297
295
|
this.setOpenModalElement();
|
|
298
296
|
}
|
|
299
297
|
this.calculateValue();
|
|
@@ -391,6 +389,10 @@ export default class FormComponent extends Component {
|
|
|
391
389
|
return (new Form(form, this.getSubOptions())).ready.then((instance) => {
|
|
392
390
|
this.subForm = instance;
|
|
393
391
|
this.subForm.currentForm = this;
|
|
392
|
+
const componentsMap = this.componentsMap;
|
|
393
|
+
const formComponentsMap = this.subForm.componentsMap;
|
|
394
|
+
_.assign(componentsMap, formComponentsMap);
|
|
395
|
+
this.component.components = this.subForm.components.map((comp) => comp.component);
|
|
394
396
|
this.subForm.parent = this;
|
|
395
397
|
this.subForm.parentVisible = this.visible;
|
|
396
398
|
this.subForm.on('change', () => {
|
|
@@ -409,6 +411,8 @@ export default class FormComponent extends Component {
|
|
|
409
411
|
this.valueChanged = this.hasSetValue;
|
|
410
412
|
this.onChange();
|
|
411
413
|
return this.subForm;
|
|
414
|
+
}).catch((err) => {
|
|
415
|
+
console.log(err);
|
|
412
416
|
});
|
|
413
417
|
}).then((subForm) => {
|
|
414
418
|
this.updateSubWizards(subForm);
|
|
@@ -417,10 +421,11 @@ export default class FormComponent extends Component {
|
|
|
417
421
|
return this.subFormReady;
|
|
418
422
|
}
|
|
419
423
|
hideSubmitButton(component) {
|
|
420
|
-
const isSubmitButton =
|
|
421
|
-
((component.action === 'submit') || !component.action);
|
|
424
|
+
const isSubmitButton = component.type === 'button' && (component.action === 'submit' || !component.action);
|
|
422
425
|
if (isSubmitButton) {
|
|
423
426
|
component.hidden = true;
|
|
427
|
+
// clearOnHide no longer clears from the JSON `hidden` flag, so we make the button conditionally hidden to clear its data
|
|
428
|
+
component.customConditional = 'show = false';
|
|
424
429
|
}
|
|
425
430
|
}
|
|
426
431
|
/**
|
|
@@ -429,7 +434,7 @@ export default class FormComponent extends Component {
|
|
|
429
434
|
* @returns {Promise} - The promise that resolves when the subform is loaded.
|
|
430
435
|
*/
|
|
431
436
|
loadSubForm(fromAttach) {
|
|
432
|
-
if (this.builderMode || this.
|
|
437
|
+
if (this.builderMode || this.conditionallyHidden || (this.isSubFormLazyLoad() && !fromAttach)) {
|
|
433
438
|
return Promise.resolve();
|
|
434
439
|
}
|
|
435
440
|
if (this.hasLoadedForm && !this.isRevisionChanged &&
|
|
@@ -464,17 +469,6 @@ export default class FormComponent extends Component {
|
|
|
464
469
|
}
|
|
465
470
|
return Promise.resolve();
|
|
466
471
|
}
|
|
467
|
-
get subFormData() {
|
|
468
|
-
return this.dataValue?.data || {};
|
|
469
|
-
}
|
|
470
|
-
checkComponentValidity(data, dirty, row, options, errors = []) {
|
|
471
|
-
options = options || {};
|
|
472
|
-
const silentCheck = options.silentCheck || false;
|
|
473
|
-
if (this.subForm) {
|
|
474
|
-
return this.subForm.checkValidity(this.subFormData, dirty, null, silentCheck, errors);
|
|
475
|
-
}
|
|
476
|
-
return super.checkComponentValidity(data, dirty, row, options, errors);
|
|
477
|
-
}
|
|
478
472
|
checkComponentConditions(data, flags, row) {
|
|
479
473
|
const visible = super.checkComponentConditions(data, flags, row);
|
|
480
474
|
// Return if already hidden
|
|
@@ -482,14 +476,14 @@ export default class FormComponent extends Component {
|
|
|
482
476
|
return visible;
|
|
483
477
|
}
|
|
484
478
|
if (this.subForm) {
|
|
485
|
-
return this.subForm.checkConditions(
|
|
479
|
+
return this.subForm.checkConditions(data, flags, row);
|
|
486
480
|
}
|
|
487
481
|
// There are few cases when subForm is not loaded when a change is triggered,
|
|
488
482
|
// so we need to perform checkConditions after it is ready, or some conditional fields might be hidden in View mode
|
|
489
483
|
else if (this.subFormReady) {
|
|
490
484
|
this.subFormReady.then(() => {
|
|
491
485
|
if (this.subForm) {
|
|
492
|
-
return this.subForm.checkConditions(
|
|
486
|
+
return this.subForm.checkConditions(data, flags, row);
|
|
493
487
|
}
|
|
494
488
|
});
|
|
495
489
|
}
|
|
@@ -497,7 +491,7 @@ export default class FormComponent extends Component {
|
|
|
497
491
|
}
|
|
498
492
|
calculateValue(data, flags, row) {
|
|
499
493
|
if (this.subForm) {
|
|
500
|
-
return this.subForm.calculateValue(
|
|
494
|
+
return this.subForm.calculateValue(data, flags, row);
|
|
501
495
|
}
|
|
502
496
|
return super.calculateValue(data, flags, row);
|
|
503
497
|
}
|
|
@@ -512,7 +506,7 @@ export default class FormComponent extends Component {
|
|
|
512
506
|
* @returns {*|boolean} - TRUE if the subform should be submitted, FALSE if it should not.
|
|
513
507
|
*/
|
|
514
508
|
get shouldSubmit() {
|
|
515
|
-
return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.
|
|
509
|
+
return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.conditionallyHidden;
|
|
516
510
|
}
|
|
517
511
|
/**
|
|
518
512
|
* Returns the data for the subform.
|
|
@@ -539,7 +533,7 @@ export default class FormComponent extends Component {
|
|
|
539
533
|
}
|
|
540
534
|
this.subForm.nosubmit = false;
|
|
541
535
|
this.subForm.submitted = true;
|
|
542
|
-
return this.subForm.submitForm().then(result => {
|
|
536
|
+
return this.subForm.submitForm({}, true).then(result => {
|
|
543
537
|
this.subForm.loading = false;
|
|
544
538
|
this.subForm.showAllErrors = false;
|
|
545
539
|
this.dataValue = result.submission;
|
|
@@ -51,9 +51,21 @@ export default class HTMLComponent extends Component {
|
|
|
51
51
|
}
|
|
52
52
|
checkRefreshOn(changed) {
|
|
53
53
|
super.checkRefreshOn(changed);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
this.
|
|
54
|
+
let visible;
|
|
55
|
+
if (this.hasCondition()) {
|
|
56
|
+
this._conditionallyHidden = this.checkConditionallyHidden();
|
|
57
|
+
visible = !this.conditionallyHidden;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
visible = !this.component.hidden;
|
|
61
|
+
}
|
|
62
|
+
const shouldSetContent = !this.builderMode
|
|
63
|
+
&& this.component.refreshOnChange
|
|
64
|
+
&& this.element
|
|
65
|
+
&& !_.isUndefined(changed)
|
|
66
|
+
&& ((_.isBoolean(changed) && changed) || !_.isEmpty(changed))
|
|
67
|
+
&& visible;
|
|
68
|
+
if (shouldSetContent) {
|
|
57
69
|
this.setContent(this.element, this.renderContent());
|
|
58
70
|
}
|
|
59
71
|
}
|
|
@@ -168,14 +168,21 @@ export default class NumberComponent extends Input {
|
|
|
168
168
|
if (typeof input === 'string') {
|
|
169
169
|
input = input.split(this.delimiter).join('').replace(this.decimalSeparator, '.');
|
|
170
170
|
}
|
|
171
|
-
let value
|
|
172
|
-
if (!_.isNaN(
|
|
171
|
+
let value;
|
|
172
|
+
if (!_.isNaN(input)) {
|
|
173
173
|
// Format scientific notation
|
|
174
|
-
if (/
|
|
174
|
+
if (/[0-9]+[eE]/.test(String(input))) {
|
|
175
|
+
// Convert to exponential notation will depend on the decimal limit set in the component
|
|
176
|
+
// Example: 1.23e-5 will be converted to 1.23e-5 if decimal limit is set to 2
|
|
177
|
+
// Example: 1.23e5 will be converted to 1.23e+5 if decimal limit is set to 2
|
|
178
|
+
// if decimal limit is 3, 1.23e5 will be converted to 1.230e+5
|
|
179
|
+
// if decimal limit is not set, 1.23e5 will be converted to 1.23000000000000000000e+5
|
|
180
|
+
value = parseFloat(input);
|
|
175
181
|
value = value.toExponential(this.decimalLimit);
|
|
176
182
|
}
|
|
177
183
|
else {
|
|
178
|
-
value =
|
|
184
|
+
value = parseFloat(input);
|
|
185
|
+
value = !_.isNaN(value) ? String(value).replace('.', this.decimalSeparator) : null;
|
|
179
186
|
}
|
|
180
187
|
}
|
|
181
188
|
else {
|
|
@@ -27,7 +27,6 @@ export default class RadioComponent extends ListComponent {
|
|
|
27
27
|
itemsLoadedResolve: ((value: any) => void) | undefined;
|
|
28
28
|
optionsLoaded: boolean | undefined;
|
|
29
29
|
loadedOptions: any[] | undefined;
|
|
30
|
-
valuesMap: Map<any, any> | undefined;
|
|
31
30
|
beforeSubmit(): Promise<any>;
|
|
32
31
|
render(): import("../_classes/field/Field").default;
|
|
33
32
|
attach(element: any): Promise<void>;
|
|
@@ -36,13 +35,10 @@ export default class RadioComponent extends ListComponent {
|
|
|
36
35
|
validateValueAvailability(setting: any, value: any): boolean;
|
|
37
36
|
getValueAsString(value: any, options?: {}): any;
|
|
38
37
|
setValueAt(index: any, value: any): void;
|
|
39
|
-
prepareValue(item: any, options?: {}): any;
|
|
40
|
-
getValueByInput(input: any): any;
|
|
41
38
|
loadItems(url: any, search: any, headers: any, options: any, method: any, body: any): void;
|
|
42
39
|
loadItemsFromMetadata(): void;
|
|
43
40
|
setItems(items: any): void;
|
|
44
41
|
setSelectedClasses(): void;
|
|
45
|
-
setMetadata(value: any): void;
|
|
46
42
|
updateValue(value: any, flags: any): boolean;
|
|
47
43
|
currentValue: any;
|
|
48
44
|
}
|
|
@@ -2,7 +2,6 @@ import _ from 'lodash';
|
|
|
2
2
|
import ListComponent from '../_classes/list/ListComponent';
|
|
3
3
|
import { Formio } from '../../Formio';
|
|
4
4
|
import { boolValue, componentValueTypes, getComponentSavedTypes } from '../../utils/utils';
|
|
5
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
6
5
|
export default class RadioComponent extends ListComponent {
|
|
7
6
|
static schema(...extend) {
|
|
8
7
|
return ListComponent.schema({
|
|
@@ -143,7 +142,6 @@ export default class RadioComponent extends ListComponent {
|
|
|
143
142
|
});
|
|
144
143
|
this.optionsLoaded = !this.component.dataSrc || this.component.dataSrc === 'values';
|
|
145
144
|
this.loadedOptions = [];
|
|
146
|
-
this.valuesMap = new Map();
|
|
147
145
|
if (!this.visible) {
|
|
148
146
|
this.itemsLoadedResolve();
|
|
149
147
|
}
|
|
@@ -183,12 +181,9 @@ export default class RadioComponent extends ListComponent {
|
|
|
183
181
|
if (!_.isString(this.dataValue)) {
|
|
184
182
|
dataValue = _.toString(this.dataValue);
|
|
185
183
|
}
|
|
186
|
-
if (this.isSelectURL) {
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
? this.valuesMap.get(valueKey)
|
|
190
|
-
: valueKey;
|
|
191
|
-
input.checked = _.isEqual(this.normalizeValue(optionValue), this.dataValue);
|
|
184
|
+
if (this.isSelectURL && _.isObject(this.loadedOptions[index].value)) {
|
|
185
|
+
const optionValue = this.component.dataType === 'string' ? JSON.stringify(this.loadedOptions[index].value) : this.loadedOptions[index].value;
|
|
186
|
+
input.checked = _.isEqual(optionValue, this.dataValue);
|
|
192
187
|
}
|
|
193
188
|
else {
|
|
194
189
|
input.checked = (dataValue === input.value && (input.value || this.component.dataSrc !== 'url'));
|
|
@@ -225,14 +220,9 @@ export default class RadioComponent extends ListComponent {
|
|
|
225
220
|
let value = this.component.inputType === 'checkbox' ? '' : this.dataValue;
|
|
226
221
|
this.refs.input.forEach((input, index) => {
|
|
227
222
|
if (input.checked) {
|
|
228
|
-
|
|
229
|
-
value
|
|
230
|
-
|
|
231
|
-
}
|
|
232
|
-
const optionValue = this.loadedOptions[index].value;
|
|
233
|
-
value = this.valuesMap.has(optionValue)
|
|
234
|
-
? this.valuesMap.get(optionValue)
|
|
235
|
-
: optionValue;
|
|
223
|
+
value = (this.isSelectURL && _.isObject(this.loadedOptions[index].value)) ?
|
|
224
|
+
this.loadedOptions[index].value :
|
|
225
|
+
input.value;
|
|
236
226
|
}
|
|
237
227
|
});
|
|
238
228
|
return value;
|
|
@@ -276,8 +266,8 @@ export default class RadioComponent extends ListComponent {
|
|
|
276
266
|
}
|
|
277
267
|
setValueAt(index, value) {
|
|
278
268
|
if (this.refs.input && this.refs.input[index] && value !== null && value !== undefined) {
|
|
279
|
-
const inputValue = this.
|
|
280
|
-
this.refs.input[index].checked =
|
|
269
|
+
const inputValue = this.refs.input[index].value;
|
|
270
|
+
this.refs.input[index].checked = (inputValue === value.toString());
|
|
281
271
|
}
|
|
282
272
|
}
|
|
283
273
|
get shouldLoad() {
|
|
@@ -287,23 +277,6 @@ export default class RadioComponent extends ListComponent {
|
|
|
287
277
|
}
|
|
288
278
|
return super.shouldLoad;
|
|
289
279
|
}
|
|
290
|
-
prepareValue(item, options = {}) {
|
|
291
|
-
const value = this.component.valueProperty && !options.skipValueProperty
|
|
292
|
-
? _.get(item, this.component.valueProperty)
|
|
293
|
-
: item;
|
|
294
|
-
if (this.component.type === 'radio' && typeof value !== 'string') {
|
|
295
|
-
const uuid = uuidv4();
|
|
296
|
-
this.valuesMap.set(uuid, value);
|
|
297
|
-
return uuid;
|
|
298
|
-
}
|
|
299
|
-
return value;
|
|
300
|
-
}
|
|
301
|
-
getValueByInput(input) {
|
|
302
|
-
const inputValue = input.value;
|
|
303
|
-
return this.valuesMap.has(inputValue)
|
|
304
|
-
? this.valuesMap.get(inputValue)
|
|
305
|
-
: inputValue;
|
|
306
|
-
}
|
|
307
280
|
loadItems(url, search, headers, options, method, body) {
|
|
308
281
|
if (this.optionsLoaded) {
|
|
309
282
|
this.itemsLoadedResolve();
|
|
@@ -354,7 +327,7 @@ export default class RadioComponent extends ListComponent {
|
|
|
354
327
|
label: this.itemTemplate(item)
|
|
355
328
|
};
|
|
356
329
|
if (_.isEqual(item, this.selectData || _.pick(this.dataValue, _.keys(item)))) {
|
|
357
|
-
this.loadedOptions[i].value = this.
|
|
330
|
+
this.loadedOptions[i].value = this.dataValue;
|
|
358
331
|
}
|
|
359
332
|
});
|
|
360
333
|
this.optionsLoaded = true;
|
|
@@ -364,15 +337,12 @@ export default class RadioComponent extends ListComponent {
|
|
|
364
337
|
const listData = [];
|
|
365
338
|
items?.forEach((item, i) => {
|
|
366
339
|
const valueAtProperty = _.get(item, this.component.valueProperty);
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
? this.itemTemplate(item, valueAtProperty, i)
|
|
370
|
-
|
|
371
|
-
this.
|
|
372
|
-
|
|
373
|
-
if (this.valuesMap.has(value)) {
|
|
374
|
-
this.templateData[value] = this.templateData[i];
|
|
375
|
-
}
|
|
340
|
+
this.loadedOptions[i] = {
|
|
341
|
+
value: this.component.valueProperty ? valueAtProperty : item,
|
|
342
|
+
label: this.component.valueProperty ? this.itemTemplate(item, valueAtProperty) : this.itemTemplate(item, item, i)
|
|
343
|
+
};
|
|
344
|
+
listData.push(this.templateData[this.component.valueProperty ? valueAtProperty : i]);
|
|
345
|
+
const value = this.loadedOptions[i].value;
|
|
376
346
|
if (!this.isRadio && (_.isObject(value) || _.isBoolean(value) || _.isUndefined(value))) {
|
|
377
347
|
this.loadedOptions[i].invalid = true;
|
|
378
348
|
}
|
|
@@ -395,9 +365,7 @@ export default class RadioComponent extends ListComponent {
|
|
|
395
365
|
const value = this.dataValue;
|
|
396
366
|
this.refs.wrapper.forEach((wrapper, index) => {
|
|
397
367
|
const input = this.refs.input[index];
|
|
398
|
-
const checked = (input.type === 'checkbox')
|
|
399
|
-
? value[input.value] || input.checked
|
|
400
|
-
: _.isEqual(this.normalizeValue(this.getValueByInput(input)), value);
|
|
368
|
+
const checked = (input.type === 'checkbox') ? value[input.value] || input.checked : (input.value.toString() === value.toString());
|
|
401
369
|
if (checked) {
|
|
402
370
|
//add class to container when selected
|
|
403
371
|
this.addClass(wrapper, this.optionSelectedClass);
|
|
@@ -411,25 +379,10 @@ export default class RadioComponent extends ListComponent {
|
|
|
411
379
|
});
|
|
412
380
|
}
|
|
413
381
|
}
|
|
414
|
-
setMetadata(value) {
|
|
415
|
-
let key = value;
|
|
416
|
-
if (typeof value !== 'string') {
|
|
417
|
-
const checkedInput = Array.prototype.find.call(this.refs.input, (input => input.type === 'radio' && input.getAttribute('checked')));
|
|
418
|
-
key = checkedInput?.value || key;
|
|
419
|
-
}
|
|
420
|
-
if (this.isSelectURL && this.templateData && this.templateData[key]) {
|
|
421
|
-
const submission = this.root.submission;
|
|
422
|
-
if (!submission.metadata.selectData) {
|
|
423
|
-
submission.metadata.selectData = {};
|
|
424
|
-
}
|
|
425
|
-
_.set(submission.metadata.selectData, this.path, this.templateData[key]);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
382
|
updateValue(value, flags) {
|
|
429
383
|
const changed = super.updateValue(value, flags);
|
|
430
384
|
if (changed) {
|
|
431
385
|
this.setSelectedClasses();
|
|
432
|
-
this.setMetadata(this.dataValue);
|
|
433
386
|
}
|
|
434
387
|
if (!flags || !flags.modified || !this.isRadio) {
|
|
435
388
|
if (changed) {
|
|
@@ -485,9 +438,13 @@ export default class RadioComponent extends ListComponent {
|
|
|
485
438
|
value = !(!value || value.toString() === 'false');
|
|
486
439
|
break;
|
|
487
440
|
}
|
|
441
|
+
if (this.isSelectURL && this.templateData && this.templateData[value]) {
|
|
442
|
+
const submission = this.root.submission;
|
|
443
|
+
if (!submission.metadata.selectData) {
|
|
444
|
+
submission.metadata.selectData = {};
|
|
445
|
+
}
|
|
446
|
+
_.set(submission.metadata.selectData, this.path, this.templateData[value]);
|
|
447
|
+
}
|
|
488
448
|
return super.normalizeValue(value);
|
|
489
449
|
}
|
|
490
|
-
isSingleInputValue() {
|
|
491
|
-
return true;
|
|
492
|
-
}
|
|
493
450
|
}
|
package/lib/mjs/formio.form.js
CHANGED
|
@@ -56,6 +56,7 @@ export function registerModule(mod, defaultFn = null, options = {}) {
|
|
|
56
56
|
case 'templates':
|
|
57
57
|
for (const framework of Object.keys(mod.templates)) {
|
|
58
58
|
Formio.Templates.extendTemplate(framework, mod.templates[framework]);
|
|
59
|
+
Formio.Templates.defaultTemplates = _.defaults(mod.templates[framework], Formio.Templates.defaultTemplates);
|
|
59
60
|
}
|
|
60
61
|
if (mod.templates[current]) {
|
|
61
62
|
Formio.Templates.current = mod.templates[current];
|
|
@@ -14,13 +14,13 @@ export default class DateGeaterThan extends ConditionOperator {
|
|
|
14
14
|
return { date, comparedDate };
|
|
15
15
|
}
|
|
16
16
|
execute(options, functionName = 'isAfter') {
|
|
17
|
-
const { value, instance,
|
|
17
|
+
const { value, instance, path } = options;
|
|
18
18
|
if (!value) {
|
|
19
19
|
return false;
|
|
20
20
|
}
|
|
21
21
|
let conditionTriggerComponent = null;
|
|
22
22
|
if (instance?.root?.getComponent) {
|
|
23
|
-
conditionTriggerComponent = instance.root.getComponent(
|
|
23
|
+
conditionTriggerComponent = instance.root.getComponent(path);
|
|
24
24
|
}
|
|
25
25
|
if (conditionTriggerComponent && conditionTriggerComponent.isPartialDay && conditionTriggerComponent.isPartialDay(value)) {
|
|
26
26
|
return false;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export default class IsEmptyValue extends ConditionOperator {
|
|
2
|
-
execute({ value, instance,
|
|
2
|
+
execute({ value, instance, path }: {
|
|
3
3
|
value: any;
|
|
4
4
|
instance: any;
|
|
5
|
-
|
|
5
|
+
path: any;
|
|
6
6
|
}): any;
|
|
7
7
|
getResult(options: any): any;
|
|
8
8
|
}
|
|
@@ -10,10 +10,10 @@ export default class IsEmptyValue extends ConditionOperator {
|
|
|
10
10
|
static get requireValue() {
|
|
11
11
|
return false;
|
|
12
12
|
}
|
|
13
|
-
execute({ value, instance,
|
|
13
|
+
execute({ value, instance, path }) {
|
|
14
14
|
const isEmptyValue = _.isEmpty(_.isNumber(value) ? String(value) : value);
|
|
15
15
|
if (instance?.root?.getComponent) {
|
|
16
|
-
const conditionTriggerComponent = instance.root.getComponent(
|
|
16
|
+
const conditionTriggerComponent = instance.root.getComponent(path);
|
|
17
17
|
return conditionTriggerComponent?.isEmpty ? conditionTriggerComponent.isEmpty() : isEmptyValue;
|
|
18
18
|
}
|
|
19
19
|
return isEmptyValue;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export default class IsEqualTo extends ConditionOperator {
|
|
2
|
-
execute({ value, comparedValue, instance,
|
|
2
|
+
execute({ value, comparedValue, instance, path }: {
|
|
3
3
|
value: any;
|
|
4
4
|
comparedValue: any;
|
|
5
5
|
instance: any;
|
|
6
|
-
|
|
6
|
+
path: any;
|
|
7
7
|
}): any;
|
|
8
8
|
}
|
|
9
9
|
import ConditionOperator from './ConditionOperator';
|
|
@@ -8,7 +8,7 @@ export default class IsEqualTo extends ConditionOperator {
|
|
|
8
8
|
static get displayedName() {
|
|
9
9
|
return 'Is Equal To';
|
|
10
10
|
}
|
|
11
|
-
execute({ value, comparedValue, instance,
|
|
11
|
+
execute({ value, comparedValue, instance, path }) {
|
|
12
12
|
if ((value || value === false) && comparedValue && typeof value !== typeof comparedValue && _.isString(comparedValue)) {
|
|
13
13
|
try {
|
|
14
14
|
comparedValue = JSON.parse(comparedValue);
|
|
@@ -17,7 +17,7 @@ export default class IsEqualTo extends ConditionOperator {
|
|
|
17
17
|
catch (e) { }
|
|
18
18
|
}
|
|
19
19
|
if (instance?.root?.getComponent) {
|
|
20
|
-
const conditionTriggerComponent = instance.root.getComponent(
|
|
20
|
+
const conditionTriggerComponent = instance.root.getComponent(path);
|
|
21
21
|
if (conditionTriggerComponent
|
|
22
22
|
&& isSelectResourceWithObjectValue(conditionTriggerComponent.component)
|
|
23
23
|
&& conditionTriggerComponent.component?.template) {
|
|
@@ -1,22 +1,33 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deprecated version of findComponents. Renamed to searchComponents.
|
|
3
|
-
* @param {import('@formio/core').Component[]} components - The components to find components within.
|
|
4
|
-
* @param {object} query - The query to use when searching for the components.
|
|
5
|
-
* @returns {import('@formio/core').Component[]} - The result of the component that is found.
|
|
6
|
-
*/
|
|
7
|
-
export function findComponents(components: import('@formio/core').Component[], query: object): import('@formio/core').Component[];
|
|
8
1
|
export const flattenComponents: typeof Utils.flattenComponents;
|
|
9
2
|
export const guid: typeof Utils.guid;
|
|
10
3
|
export const uniqueName: typeof Utils.uniqueName;
|
|
11
|
-
export const
|
|
4
|
+
export const MODEL_TYPES_OF_KNOWN_COMPONENTS: {
|
|
5
|
+
nestedArray: string[];
|
|
6
|
+
nestedDataArray: string[];
|
|
7
|
+
dataObject: string[];
|
|
8
|
+
object: string[];
|
|
9
|
+
map: string[];
|
|
10
|
+
content: string[];
|
|
11
|
+
string: string[];
|
|
12
|
+
number: string[];
|
|
13
|
+
boolean: string[];
|
|
14
|
+
none: string[];
|
|
15
|
+
any: string[];
|
|
16
|
+
};
|
|
12
17
|
export const getModelType: typeof Utils.getModelType;
|
|
13
|
-
export const
|
|
14
|
-
export const
|
|
18
|
+
export const getComponentPath: any;
|
|
19
|
+
export const setComponentScope: typeof Utils.setComponentScope;
|
|
20
|
+
export const resetComponentScope: typeof Utils.resetComponentScope;
|
|
15
21
|
export const isComponentNestedDataType: typeof Utils.isComponentNestedDataType;
|
|
16
22
|
export const componentPath: typeof Utils.componentPath;
|
|
17
|
-
export const
|
|
18
|
-
export const
|
|
19
|
-
export const
|
|
23
|
+
export const getComponentPaths: typeof Utils.getComponentPaths;
|
|
24
|
+
export const componentMatches: typeof Utils.componentMatches;
|
|
25
|
+
export const getBestMatch: typeof Utils.getBestMatch;
|
|
26
|
+
export const getComponentFromPath: typeof Utils.getComponentFromPath;
|
|
27
|
+
export const getComponentValue: typeof Utils.getComponentValue;
|
|
28
|
+
export const findComponents: typeof Utils.findComponents;
|
|
29
|
+
export const eachComponentDataAsync: (components: Component[], data: DataObject, fn: EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: any, parentPaths?: any) => Promise<void>;
|
|
30
|
+
export const eachComponentData: (components: Component[], data: DataObject, fn: EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: any, parentPaths?: any) => void;
|
|
20
31
|
export const getComponentKey: typeof Utils.getComponentKey;
|
|
21
32
|
export const getContextualRowPath: typeof Utils.getContextualRowPath;
|
|
22
33
|
export const getContextualRowData: typeof Utils.getContextualRowData;
|
|
@@ -24,7 +35,7 @@ export const componentInfo: typeof Utils.componentInfo;
|
|
|
24
35
|
export const eachComponent: typeof Utils.eachComponent;
|
|
25
36
|
export const eachComponentAsync: typeof Utils.eachComponentAsync;
|
|
26
37
|
export const getComponentData: typeof Utils.getComponentData;
|
|
27
|
-
export const getComponentActualValue:
|
|
38
|
+
export const getComponentActualValue: any;
|
|
28
39
|
export const isLayoutComponent: typeof Utils.isLayoutComponent;
|
|
29
40
|
export const matchComponent: typeof Utils.matchComponent;
|
|
30
41
|
export const getComponent: typeof Utils.getComponent;
|
|
@@ -1,13 +1,3 @@
|
|
|
1
1
|
import { Utils } from '@formio/core';
|
|
2
|
-
const { flattenComponents, guid, uniqueName,
|
|
3
|
-
|
|
4
|
-
* Deprecated version of findComponents. Renamed to searchComponents.
|
|
5
|
-
* @param {import('@formio/core').Component[]} components - The components to find components within.
|
|
6
|
-
* @param {object} query - The query to use when searching for the components.
|
|
7
|
-
* @returns {import('@formio/core').Component[]} - The result of the component that is found.
|
|
8
|
-
*/
|
|
9
|
-
export function findComponents(components, query) {
|
|
10
|
-
console.warn('formio.js/utils findComponents is deprecated. Use searchComponents instead.');
|
|
11
|
-
return searchComponents(components, query);
|
|
12
|
-
}
|
|
13
|
-
export { flattenComponents, guid, uniqueName, MODEL_TYPES, getModelType, getComponentAbsolutePath, getComponentPath, isComponentNestedDataType, componentPath, componentChildPath, eachComponentDataAsync, eachComponentData, getComponentKey, getContextualRowPath, getContextualRowData, componentInfo, eachComponent, eachComponentAsync, getComponentData, getComponentActualValue, isLayoutComponent, matchComponent, getComponent, searchComponents, removeComponent, hasCondition, parseFloatExt, formatAsCurrency, escapeRegExCharacters, getValue, getStrings, generateFormChange, applyFormChanges, findComponent, getEmptyValue, isComponentDataEmpty, isSelectResourceWithObjectValue, compareSelectResourceWithObjectTypeValues, getItemTemplateKeys };
|
|
2
|
+
const { flattenComponents, guid, uniqueName, MODEL_TYPES_OF_KNOWN_COMPONENTS, getModelType, getComponentPath, setComponentScope, resetComponentScope, isComponentNestedDataType, componentPath, getComponentPaths, componentMatches, getBestMatch, getComponentFromPath, getComponentValue, findComponents, eachComponentDataAsync, eachComponentData, getComponentKey, getContextualRowPath, getContextualRowData, componentInfo, eachComponent, eachComponentAsync, getComponentData, getComponentActualValue, isLayoutComponent, matchComponent, getComponent, searchComponents, removeComponent, hasCondition, parseFloatExt, formatAsCurrency, escapeRegExCharacters, getValue, getStrings, generateFormChange, applyFormChanges, findComponent, getEmptyValue, isComponentDataEmpty, isSelectResourceWithObjectValue, compareSelectResourceWithObjectTypeValues, getItemTemplateKeys } = Utils;
|
|
3
|
+
export { flattenComponents, guid, uniqueName, MODEL_TYPES_OF_KNOWN_COMPONENTS, getModelType, getComponentPath, setComponentScope, resetComponentScope, isComponentNestedDataType, componentPath, getComponentPaths, componentMatches, getBestMatch, getComponentFromPath, getComponentValue, findComponents, eachComponentDataAsync, eachComponentData, getComponentKey, getContextualRowPath, getContextualRowData, componentInfo, eachComponent, eachComponentAsync, getComponentData, getComponentActualValue, isLayoutComponent, matchComponent, getComponent, searchComponents, removeComponent, hasCondition, parseFloatExt, formatAsCurrency, escapeRegExCharacters, getValue, getStrings, generateFormChange, applyFormChanges, findComponent, getEmptyValue, isComponentDataEmpty, isSelectResourceWithObjectValue, compareSelectResourceWithObjectTypeValues, getItemTemplateKeys };
|
package/lib/mjs/utils/utils.d.ts
CHANGED
|
@@ -462,10 +462,9 @@ export function getComponentPathWithoutIndicies(path?: string): string;
|
|
|
462
462
|
/**
|
|
463
463
|
* Returns a path to the component which based on its schema
|
|
464
464
|
* @param {import('@formio/core').Component} component - Component containing link to its parent's schema in the 'parent' property
|
|
465
|
-
* @param {string} path - Path to the component
|
|
466
465
|
* @returns {string} - Path to the component
|
|
467
466
|
*/
|
|
468
|
-
export function getComponentPath(component: import('@formio/core').Component
|
|
467
|
+
export function getComponentPath(component: import('@formio/core').Component): string;
|
|
469
468
|
/**
|
|
470
469
|
* Returns a parent component of the passed component instance skipping all the Layout components
|
|
471
470
|
* @param {Component} componentInstance - The component to check for the parent.
|