@formio/js 5.0.0-dev.5947.acce78f → 5.0.0-dev.5950.723a551
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 +11 -11
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +11 -11
- package/dist/formio.full.min.js +1 -1
- package/lib/cjs/components/_classes/component/Component.d.ts +15 -0
- package/lib/cjs/components/_classes/component/Component.js +50 -16
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +2 -2
- package/lib/cjs/components/_classes/nested/NestedComponent.js +16 -7
- package/lib/cjs/components/datamap/DataMap.js +1 -1
- package/lib/cjs/components/datetime/DateTime.js +4 -0
- package/lib/cjs/components/editgrid/EditGrid.d.ts +1 -1
- package/lib/cjs/components/editgrid/EditGrid.js +9 -7
- package/lib/cjs/components/form/Form.js +5 -4
- package/lib/cjs/components/html/HTML.js +15 -3
- package/lib/cjs/components/number/Number.js +11 -4
- package/lib/cjs/components/textfield/TextField.js +3 -0
- package/lib/cjs/formio.form.js +1 -0
- package/lib/mjs/components/_classes/component/Component.d.ts +15 -0
- package/lib/mjs/components/_classes/component/Component.js +50 -16
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +2 -2
- package/lib/mjs/components/_classes/nested/NestedComponent.js +16 -7
- package/lib/mjs/components/datamap/DataMap.js +1 -1
- package/lib/mjs/components/datetime/DateTime.js +5 -1
- package/lib/mjs/components/editgrid/EditGrid.d.ts +1 -1
- package/lib/mjs/components/editgrid/EditGrid.js +9 -7
- package/lib/mjs/components/form/Form.js +5 -4
- package/lib/mjs/components/html/HTML.js +15 -3
- package/lib/mjs/components/number/Number.js +11 -4
- package/lib/mjs/components/textfield/TextField.js +3 -0
- package/lib/mjs/formio.form.js +1 -0
- package/package.json +1 -1
@@ -315,11 +315,18 @@ export default class Component extends Element {
|
|
315
315
|
this._path = '';
|
316
316
|
// Needs for Nextgen Rules Engine
|
317
317
|
this.resetCaches();
|
318
|
+
/**
|
319
|
+
* Determines if this component is conditionally hidden. Should generally not be set outside of conditional logic pipeline.
|
320
|
+
* This is necessary because of clearOnHide behavior that only clears when conditionally hidden - we need to track
|
321
|
+
* conditionallyHidden separately from "regular" visibility.
|
322
|
+
*/
|
323
|
+
this._parentConditionallyHidden = this.options.hasOwnProperty('parentConditionallyHidden') ? this.options.parentConditionallyHidden : false;
|
324
|
+
this._conditionallyHidden = this.checkConditionallyHidden(null, data) || this._parentConditionallyHidden;
|
318
325
|
/**
|
319
326
|
* Determines if this component is visible, or not.
|
320
327
|
*/
|
321
328
|
this._parentVisible = this.options.hasOwnProperty('parentVisible') ? this.options.parentVisible : true;
|
322
|
-
this._visible = this._parentVisible && this.
|
329
|
+
this._visible = this._parentVisible && (this.hasCondition() ? !this._conditionallyHidden : !this.component.hidden);
|
323
330
|
this._parentDisabled = false;
|
324
331
|
/**
|
325
332
|
* The reference attribute name for this component
|
@@ -388,7 +395,7 @@ export default class Component extends Element {
|
|
388
395
|
if (this.allowData && this.key) {
|
389
396
|
this.options.name += `[${this.key}]`;
|
390
397
|
// If component is visible or not set to clear on hide, set the default value.
|
391
|
-
if (this.
|
398
|
+
if (!(this.conditionallyHidden && this.component.clearOnHide)) {
|
392
399
|
if (!this.hasValue()) {
|
393
400
|
if (this.shouldAddDefaultValue) {
|
394
401
|
this.dataValue = this.defaultValue;
|
@@ -457,7 +464,8 @@ export default class Component extends Element {
|
|
457
464
|
}
|
458
465
|
init() {
|
459
466
|
this.disabled = this.shouldDisabled;
|
460
|
-
this.
|
467
|
+
this._conditionallyHidden = this.checkConditionallyHidden();
|
468
|
+
this._visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
|
461
469
|
if (this.component.addons?.length) {
|
462
470
|
this.component.addons.forEach((addon) => this.createAddon(addon));
|
463
471
|
}
|
@@ -600,7 +608,6 @@ export default class Component extends Element {
|
|
600
608
|
return;
|
601
609
|
}
|
602
610
|
this._visible = value;
|
603
|
-
this.clearOnHide();
|
604
611
|
this.redraw();
|
605
612
|
}
|
606
613
|
}
|
@@ -621,6 +628,21 @@ export default class Component extends Element {
|
|
621
628
|
}
|
622
629
|
return this._visible && this._parentVisible;
|
623
630
|
}
|
631
|
+
get conditionallyHidden() {
|
632
|
+
return this._conditionallyHidden || this._parentConditionallyHidden;
|
633
|
+
}
|
634
|
+
/**
|
635
|
+
* Evaluates whether the component is conditionally hidden (as opposed to intentionally hidden, e.g. via the `hidden` component schema property).
|
636
|
+
* @param {object} data - The data object to evaluate the condition against.
|
637
|
+
* @param {object} row - The row object to evaluate the condition against.
|
638
|
+
* @returns {boolean} - Whether the component is conditionally hidden.
|
639
|
+
*/
|
640
|
+
checkConditionallyHidden(data = null, row = null) {
|
641
|
+
if (!this.hasCondition()) {
|
642
|
+
return false;
|
643
|
+
}
|
644
|
+
return !this.conditionallyVisible(data, row);
|
645
|
+
}
|
624
646
|
get currentForm() {
|
625
647
|
return this._currentForm;
|
626
648
|
}
|
@@ -1791,7 +1813,7 @@ export default class Component extends Element {
|
|
1791
1813
|
rebuild() {
|
1792
1814
|
this.destroy();
|
1793
1815
|
this.init();
|
1794
|
-
this.visible = this.
|
1816
|
+
this.visible = this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden;
|
1795
1817
|
return this.redraw();
|
1796
1818
|
}
|
1797
1819
|
/**
|
@@ -1858,8 +1880,8 @@ export default class Component extends Element {
|
|
1858
1880
|
conditionallyVisible(data, row) {
|
1859
1881
|
data = data || this.rootValue;
|
1860
1882
|
row = row || this.data;
|
1861
|
-
if (this.builderMode || this.previewMode
|
1862
|
-
return
|
1883
|
+
if (this.builderMode || this.previewMode) {
|
1884
|
+
return true;
|
1863
1885
|
}
|
1864
1886
|
data = data || (this.root ? this.root.data : {});
|
1865
1887
|
return this.checkCondition(row, data);
|
@@ -1889,8 +1911,14 @@ export default class Component extends Element {
|
|
1889
1911
|
if (!this.builderMode & !this.previewMode && this.fieldLogic(data, row)) {
|
1890
1912
|
this.redraw();
|
1891
1913
|
}
|
1892
|
-
// Check advanced conditions
|
1893
|
-
const
|
1914
|
+
// Check advanced conditions (and cache the result)
|
1915
|
+
const isConditionallyHidden = this.checkConditionallyHidden(data, row) || this._parentConditionallyHidden;
|
1916
|
+
if (isConditionallyHidden !== this._conditionallyHidden) {
|
1917
|
+
this._conditionallyHidden = isConditionallyHidden;
|
1918
|
+
this.clearOnHide();
|
1919
|
+
}
|
1920
|
+
// Check visibility
|
1921
|
+
const visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
|
1894
1922
|
if (this.visible !== visible) {
|
1895
1923
|
this.visible = visible;
|
1896
1924
|
}
|
@@ -2000,6 +2028,12 @@ export default class Component extends Element {
|
|
2000
2028
|
FormioUtils.setActionProperty(newComponent, action, result, row, data, this);
|
2001
2029
|
const property = action.property.value;
|
2002
2030
|
if (!_.isEqual(_.get(this.component, property), _.get(newComponent, property))) {
|
2031
|
+
// Advanced Logic can modify the component's hidden property; because we track conditionally hidden state
|
2032
|
+
// separately from the component's hidden property, and technically this Advanced Logic conditionally hides
|
2033
|
+
// a component, we need to set _conditionallyHidden to the new value
|
2034
|
+
if (property === 'hidden') {
|
2035
|
+
this._conditionallyHidden = newComponent.hidden;
|
2036
|
+
}
|
2003
2037
|
changed = true;
|
2004
2038
|
}
|
2005
2039
|
break;
|
@@ -2013,7 +2047,7 @@ export default class Component extends Element {
|
|
2013
2047
|
component: newComponent,
|
2014
2048
|
result,
|
2015
2049
|
});
|
2016
|
-
if (!_.isEqual(oldValue, newValue) && !(this.component.clearOnHide &&
|
2050
|
+
if (!_.isEqual(oldValue, newValue) && !(this.component.clearOnHide && this.conditionallyHidden)) {
|
2017
2051
|
this.setValue(newValue);
|
2018
2052
|
if (this.viewOnly) {
|
2019
2053
|
this.dataValue = newValue;
|
@@ -2046,7 +2080,7 @@ export default class Component extends Element {
|
|
2046
2080
|
component: newComponent,
|
2047
2081
|
result,
|
2048
2082
|
}, 'value');
|
2049
|
-
if (!_.isEqual(oldValue, newValue) && !(this.component.clearOnHide &&
|
2083
|
+
if (!_.isEqual(oldValue, newValue) && !(this.component.clearOnHide && this.conditionallyHidden)) {
|
2050
2084
|
this.setValue(newValue);
|
2051
2085
|
if (this.viewOnly) {
|
2052
2086
|
this.dataValue = newValue;
|
@@ -2157,7 +2191,7 @@ export default class Component extends Element {
|
|
2157
2191
|
this.component.clearOnHide !== false &&
|
2158
2192
|
!this.options.readOnly &&
|
2159
2193
|
!this.options.showHiddenFields) {
|
2160
|
-
if (
|
2194
|
+
if (this.conditionallyHidden) {
|
2161
2195
|
this.deleteValue();
|
2162
2196
|
}
|
2163
2197
|
else if (!this.hasValue() && this.shouldAddDefaultValue) {
|
@@ -2419,7 +2453,7 @@ export default class Component extends Element {
|
|
2419
2453
|
*/
|
2420
2454
|
get dataValue() {
|
2421
2455
|
if (!this.key ||
|
2422
|
-
(
|
2456
|
+
(this.conditionallyHidden && this.component.clearOnHide && !this.rootPristine)) {
|
2423
2457
|
return this.emptyValue;
|
2424
2458
|
}
|
2425
2459
|
if (!this.hasValue() && this.shouldAddDefaultValue) {
|
@@ -2438,7 +2472,7 @@ export default class Component extends Element {
|
|
2438
2472
|
set dataValue(value) {
|
2439
2473
|
if (!this.allowData ||
|
2440
2474
|
!this.key ||
|
2441
|
-
(
|
2475
|
+
(this.conditionallyHidden && this.component.clearOnHide && !this.rootPristine)) {
|
2442
2476
|
return;
|
2443
2477
|
}
|
2444
2478
|
if ((value !== null) && (value !== undefined)) {
|
@@ -2758,7 +2792,7 @@ export default class Component extends Element {
|
|
2758
2792
|
// If no calculated value or
|
2759
2793
|
// hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
|
2760
2794
|
const { clearOnHide } = this.component;
|
2761
|
-
const shouldBeCleared =
|
2795
|
+
const shouldBeCleared = this.conditionallyHidden && clearOnHide;
|
2762
2796
|
const allowOverride = _.get(this.component, 'allowCalculateOverride', false);
|
2763
2797
|
if (shouldBeCleared) {
|
2764
2798
|
// remove calculated value so that the value is recalculated once component becomes visible
|
@@ -3403,7 +3437,7 @@ export default class Component extends Element {
|
|
3403
3437
|
// If component definition changed, replace it.
|
3404
3438
|
if (!_.isEqual(this.component, newComponent)) {
|
3405
3439
|
this.component = newComponent;
|
3406
|
-
const visible = this.
|
3440
|
+
const visible = this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden;
|
3407
3441
|
const disabled = this.shouldDisabled;
|
3408
3442
|
// Change states which won't be recalculated during redrawing
|
3409
3443
|
if (this.visible !== visible) {
|
@@ -128,10 +128,10 @@ export default [
|
|
128
128
|
{
|
129
129
|
weight: 700,
|
130
130
|
type: 'checkbox',
|
131
|
-
label: '
|
131
|
+
label: 'Omit Value From Submission Data When Conditionally Hidden',
|
132
132
|
key: 'clearOnHide',
|
133
133
|
defaultValue: true,
|
134
|
-
tooltip: 'When a field is hidden,
|
134
|
+
tooltip: 'When a field is conditionally hidden, omit the value from the submission data.',
|
135
135
|
input: true
|
136
136
|
},
|
137
137
|
EditFormUtils.javaScriptValue('Custom Default Value', 'customDefaultValue', 'customDefaultValue', 1000, '<p><h4>Example:</h4><pre>value = data.firstName + " " + data.lastName;</pre></p>', '<p><h4>Example:</h4><pre>{"cat": [{"var": "data.firstName"}, " ", {"var": "data.lastName"}]}</pre>'),
|
@@ -81,17 +81,26 @@ export default class NestedComponent extends Field {
|
|
81
81
|
const visibilityChanged = this._visible !== value;
|
82
82
|
this._visible = value;
|
83
83
|
const isVisible = this.visible;
|
84
|
+
const isConditionallyHidden = this.checkConditionallyHidden();
|
84
85
|
const forceShow = this.shouldForceShow();
|
85
86
|
const forceHide = this.shouldForceHide();
|
86
|
-
this.components.forEach(component => {
|
87
|
+
this.components.forEach((component) => {
|
87
88
|
// Set the parent visibility first since we may have nested components within nested components
|
88
89
|
// and they need to be able to determine their visibility based on the parent visibility.
|
89
90
|
component.parentVisible = isVisible;
|
90
|
-
|
91
|
-
|
91
|
+
component._parentConditionallyHidden = isConditionallyHidden;
|
92
|
+
let visible;
|
93
|
+
if (component.hasCondition()) {
|
94
|
+
component._conditionallyHidden = component.checkConditionallyHidden() || component._parentConditionallyHidden;
|
95
|
+
visible = !component.conditionallyHidden;
|
96
|
+
}
|
97
|
+
else {
|
98
|
+
visible = !component.component.hidden;
|
99
|
+
}
|
100
|
+
if (forceShow || visible) {
|
92
101
|
component.visible = true;
|
93
102
|
}
|
94
|
-
else if (forceHide || !isVisible || !
|
103
|
+
else if (forceHide || !isVisible || !visible) {
|
95
104
|
component.visible = false;
|
96
105
|
}
|
97
106
|
// If hiding a nested component, clear all errors below.
|
@@ -100,7 +109,6 @@ export default class NestedComponent extends Field {
|
|
100
109
|
}
|
101
110
|
});
|
102
111
|
if (visibilityChanged) {
|
103
|
-
this.clearOnHide();
|
104
112
|
this.redraw();
|
105
113
|
}
|
106
114
|
}
|
@@ -365,6 +373,7 @@ export default class NestedComponent extends Field {
|
|
365
373
|
data = data || this.data;
|
366
374
|
options.parent = this;
|
367
375
|
options.parentVisible = this.visible;
|
376
|
+
options.parentConditionallyHidden = this.conditionallyHidden;
|
368
377
|
options.root = options?.root || this.root || this;
|
369
378
|
options.localRoot = this.localRoot;
|
370
379
|
options.skipInit = true;
|
@@ -623,7 +632,7 @@ export default class NestedComponent extends Field {
|
|
623
632
|
clearOnHide(show) {
|
624
633
|
super.clearOnHide(show);
|
625
634
|
if (this.component.clearOnHide) {
|
626
|
-
if (this.allowData && !this.hasValue() && !
|
635
|
+
if (this.allowData && !this.hasValue() && !this.conditionallyHidden) {
|
627
636
|
this.dataValue = this.defaultValue;
|
628
637
|
}
|
629
638
|
if (this.hasValue()) {
|
@@ -652,7 +661,7 @@ export default class NestedComponent extends Field {
|
|
652
661
|
}
|
653
662
|
calculateValue(data, flags, row) {
|
654
663
|
// Do not iterate into children and calculateValues if this nested component is conditionally hidden.
|
655
|
-
if (
|
664
|
+
if (this.conditionallyHidden) {
|
656
665
|
return false;
|
657
666
|
}
|
658
667
|
return this.getComponents().reduce((changed, comp) => comp.calculateValue(data, flags, row) || changed, super.calculateValue(data, flags, row));
|
@@ -69,7 +69,7 @@ export default class DataMapComponent extends DataGridComponent {
|
|
69
69
|
}
|
70
70
|
get dataValue() {
|
71
71
|
if (!this.key ||
|
72
|
-
(
|
72
|
+
(this.conditionallyHidden && this.component.clearOnHide)) {
|
73
73
|
return this.emptyValue;
|
74
74
|
}
|
75
75
|
if (!this.hasValue() && this.shouldAddDefaultValue) {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import _ from 'lodash';
|
2
2
|
import moment from 'moment';
|
3
3
|
import FormioUtils from '../../utils';
|
4
|
-
import { componentValueTypes, getComponentSavedTypes } from '../../utils/utils';
|
4
|
+
import { componentValueTypes, fastCloneDeep, getComponentSavedTypes } from '../../utils/utils';
|
5
5
|
import Input from '../_classes/input/Input';
|
6
6
|
export default class DateTimeComponent extends Input {
|
7
7
|
static schema(...extend) {
|
@@ -127,6 +127,10 @@ export default class DateTimeComponent extends Input {
|
|
127
127
|
maxDate: _.get(this.component, 'datePicker.maxDate'),
|
128
128
|
...customOptions,
|
129
129
|
};
|
130
|
+
// update originalComponent to include widget and other updated settings
|
131
|
+
// it is done here since these settings depend on properties present after the component is initialized
|
132
|
+
// originalComponent is used to restore the component (and widget) after evaluating field logic
|
133
|
+
this.originalComponent = fastCloneDeep(this.component);
|
130
134
|
/* eslint-enable camelcase */
|
131
135
|
}
|
132
136
|
get defaultSchema() {
|
@@ -43,7 +43,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
43
43
|
get defaultValue(): any[];
|
44
44
|
hasRemoveButtons(): boolean;
|
45
45
|
editRows: any;
|
46
|
-
checkRowVariableTypeComponents(editRow: any, rowIndex: any):
|
46
|
+
checkRowVariableTypeComponents(editRow: any, rowIndex: any): boolean;
|
47
47
|
setVariableTypeComponents(): void;
|
48
48
|
variableTypeComponentsIndexes: any[] | undefined;
|
49
49
|
isOpen(editRow: any): boolean;
|
@@ -289,12 +289,15 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
289
289
|
}
|
290
290
|
checkRowVariableTypeComponents(editRow, rowIndex) {
|
291
291
|
const rowComponents = editRow.components;
|
292
|
+
let typeChanged = false;
|
292
293
|
if (_.some(this.variableTypeComponentsIndexes, (compIndex) => {
|
293
294
|
const variableTypeComp = rowComponents[compIndex];
|
294
295
|
return variableTypeComp.type !== variableTypeComp.component.type;
|
295
296
|
})) {
|
296
297
|
editRow.components = this.createRowComponents(editRow.data, rowIndex, true);
|
298
|
+
typeChanged = true;
|
297
299
|
}
|
300
|
+
return typeChanged;
|
298
301
|
}
|
299
302
|
setVariableTypeComponents() {
|
300
303
|
//set components which type is changing within a row (e.g.,by mergeComponentSchema action)
|
@@ -943,8 +946,10 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
943
946
|
this.validateRow(editRow, false, false);
|
944
947
|
}
|
945
948
|
if (this.variableTypeComponentsIndexes.length) {
|
946
|
-
this.checkRowVariableTypeComponents(editRow, rowIndex);
|
947
|
-
|
949
|
+
const typeChanged = this.checkRowVariableTypeComponents(editRow, rowIndex);
|
950
|
+
if (typeChanged) {
|
951
|
+
this.redraw();
|
952
|
+
}
|
948
953
|
}
|
949
954
|
};
|
950
955
|
const comp = this.createComponent(_.assign({}, column, { row: options.row }), options, row, null, recreatePartially && currentRowComponents ? currentRowComponents[colIndex] : null);
|
@@ -1145,7 +1150,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
1145
1150
|
}
|
1146
1151
|
}
|
1147
1152
|
const changed = this.hasChanged(value, this.dataValue);
|
1148
|
-
if (this.parent
|
1153
|
+
if (this.parent) {
|
1149
1154
|
this.parent.checkComponentConditions();
|
1150
1155
|
}
|
1151
1156
|
this.dataValue = value;
|
@@ -1178,10 +1183,7 @@ export default class EditGridComponent extends NestedArrayComponent {
|
|
1178
1183
|
this.editRows = this.editRows.slice(0, dataLength);
|
1179
1184
|
this.openWhenEmpty();
|
1180
1185
|
this.updateOnChange(flags, changed);
|
1181
|
-
|
1182
|
-
if (!this.options.server) {
|
1183
|
-
this.checkData();
|
1184
|
-
}
|
1186
|
+
this.checkData();
|
1185
1187
|
this.changeState(changed, flags);
|
1186
1188
|
return changed;
|
1187
1189
|
}
|
@@ -421,10 +421,11 @@ export default class FormComponent extends Component {
|
|
421
421
|
return this.subFormReady;
|
422
422
|
}
|
423
423
|
hideSubmitButton(component) {
|
424
|
-
const isSubmitButton =
|
425
|
-
((component.action === 'submit') || !component.action);
|
424
|
+
const isSubmitButton = component.type === 'button' && (component.action === 'submit' || !component.action);
|
426
425
|
if (isSubmitButton) {
|
427
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';
|
428
429
|
}
|
429
430
|
}
|
430
431
|
/**
|
@@ -433,7 +434,7 @@ export default class FormComponent extends Component {
|
|
433
434
|
* @returns {Promise} - The promise that resolves when the subform is loaded.
|
434
435
|
*/
|
435
436
|
loadSubForm(fromAttach) {
|
436
|
-
if (this.builderMode || this.
|
437
|
+
if (this.builderMode || this.conditionallyHidden || (this.isSubFormLazyLoad() && !fromAttach)) {
|
437
438
|
return Promise.resolve();
|
438
439
|
}
|
439
440
|
if (this.hasLoadedForm && !this.isRevisionChanged &&
|
@@ -505,7 +506,7 @@ export default class FormComponent extends Component {
|
|
505
506
|
* @returns {*|boolean} - TRUE if the subform should be submitted, FALSE if it should not.
|
506
507
|
*/
|
507
508
|
get shouldSubmit() {
|
508
|
-
return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.
|
509
|
+
return this.subFormReady && (!this.component.hasOwnProperty('reference') || this.component.reference) && !this.conditionallyHidden;
|
509
510
|
}
|
510
511
|
/**
|
511
512
|
* Returns the data for the subform.
|
@@ -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 {
|
@@ -86,6 +86,9 @@ export default class TextFieldComponent extends Input {
|
|
86
86
|
locale: this.component.widget.locale || this.options.language,
|
87
87
|
saveAs: 'text'
|
88
88
|
};
|
89
|
+
// update originalComponent to include widget settings after component initialization
|
90
|
+
// originalComponent is used to restore the component (and widget) after evaluating field logic
|
91
|
+
this.originalComponent = FormioUtils.fastCloneDeep(this.component);
|
89
92
|
}
|
90
93
|
}
|
91
94
|
attach(element) {
|
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];
|