@formio/js 5.1.0-dev.6040.debc859 → 5.1.0-dev.6042.6e62a7a
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 +140 -6
- package/dist/formio.form.js +591 -580
- package/dist/formio.form.min.js +1 -1
- package/dist/formio.full.js +613 -602
- package/dist/formio.full.min.js +1 -1
- package/dist/formio.js +47 -14
- package/dist/formio.min.js +1 -1
- package/dist/formio.utils.js +48 -15
- package/dist/formio.utils.min.js +1 -1
- package/lib/cjs/Element.d.ts +2 -1
- package/lib/cjs/Element.js +6 -4
- package/lib/cjs/Webform.d.ts +2 -2
- package/lib/cjs/Webform.js +9 -9
- package/lib/cjs/WebformBuilder.js +5 -1
- package/lib/cjs/Wizard.d.ts +1 -0
- package/lib/cjs/Wizard.js +23 -3
- package/lib/cjs/components/_classes/component/Component.d.ts +50 -15
- package/lib/cjs/components/_classes/component/Component.js +153 -69
- package/lib/cjs/components/_classes/component/editForm/Component.edit.data.js +19 -0
- package/lib/cjs/components/_classes/component/editForm/utils.js +1 -1
- package/lib/cjs/components/_classes/list/ListComponent.js +2 -2
- package/lib/cjs/components/_classes/nested/NestedComponent.d.ts +0 -1
- package/lib/cjs/components/_classes/nested/NestedComponent.form.js +13 -0
- package/lib/cjs/components/_classes/nested/NestedComponent.js +10 -18
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.d.ts +0 -2
- package/lib/cjs/components/_classes/nesteddata/NestedDataComponent.js +0 -11
- package/lib/cjs/components/address/Address.d.ts +9 -0
- package/lib/cjs/components/address/Address.js +31 -8
- package/lib/cjs/components/address/editForm/Address.edit.display.d.ts +4 -0
- package/lib/cjs/components/address/editForm/Address.edit.display.js +1 -0
- package/lib/cjs/components/address/editForm/Address.edit.provider.js +8 -8
- package/lib/cjs/components/content/editForm/Content.edit.display.js +8 -0
- package/lib/cjs/components/currency/editForm/Currency.edit.display.js +12 -0
- package/lib/cjs/components/datagrid/DataGrid.js +0 -3
- package/lib/cjs/components/datamap/DataMap.js +2 -6
- package/lib/cjs/components/datetime/editForm/DateTime.edit.validation.d.ts +66 -15
- package/lib/cjs/components/datetime/editForm/DateTime.edit.validation.js +68 -47
- package/lib/cjs/components/day/editForm/Day.edit.display.js +8 -0
- package/lib/cjs/components/editgrid/EditGrid.js +3 -13
- package/lib/cjs/components/email/editForm/Email.edit.display.js +12 -0
- package/lib/cjs/components/fieldset/editForm/Fieldset.edit.display.js +8 -0
- package/lib/cjs/components/file/File.js +7 -2
- package/lib/cjs/components/file/editForm/File.edit.file.d.ts +13 -0
- package/lib/cjs/components/file/editForm/File.edit.file.js +1 -0
- package/lib/cjs/components/form/Form.d.ts +0 -1
- package/lib/cjs/components/form/Form.js +18 -22
- package/lib/cjs/components/hidden/editForm/Hidden.edit.display.js +8 -0
- package/lib/cjs/components/html/HTML.js +1 -2
- package/lib/cjs/components/html/editForm/HTML.edit.display.js +8 -0
- package/lib/cjs/components/number/editForm/Number.edit.display.js +12 -0
- package/lib/cjs/components/password/editForm/Password.edit.display.js +13 -1
- package/lib/cjs/components/phonenumber/PhoneNumber.form.js +9 -1
- package/lib/cjs/components/radio/Radio.js +1 -1
- package/lib/cjs/components/select/Select.js +1 -1
- package/lib/cjs/components/select/editForm/Select.edit.data.d.ts +68 -110
- package/lib/cjs/components/select/editForm/Select.edit.data.js +2 -37
- package/lib/cjs/components/selectboxes/SelectBoxes.js +3 -0
- package/lib/cjs/components/survey/Survey.js +1 -1
- package/lib/cjs/components/tabs/Tabs.js +1 -0
- package/lib/cjs/components/tabs/editForm/Tabs.edit.display.js +8 -0
- package/lib/cjs/components/textarea/TextArea.js +9 -1
- package/lib/cjs/components/textarea/editForm/TextArea.edit.display.js +12 -0
- package/lib/cjs/components/textfield/TextField.js +2 -2
- package/lib/cjs/components/unknown/Unknown.form.d.ts +2 -1
- package/lib/cjs/components/unknown/Unknown.form.js +13 -9
- package/lib/cjs/components/url/editForm/Url.edit.display.js +12 -0
- package/lib/cjs/components/well/editForm/Well.edit.display.js +8 -0
- package/lib/cjs/formio.form.js +2 -2
- package/lib/cjs/providers/storage/uploadAdapter.js +5 -3
- package/lib/cjs/translations/en.d.ts +1 -234
- package/lib/cjs/translations/en.js +4 -2
- package/lib/cjs/utils/formUtils.d.ts +2 -2
- package/lib/cjs/utils/utils.d.ts +9 -8
- package/lib/cjs/utils/utils.js +18 -23
- package/lib/cjs/widgets/CalendarWidget.js +6 -1
- package/lib/mjs/Element.d.ts +2 -1
- package/lib/mjs/Element.js +6 -4
- package/lib/mjs/Webform.d.ts +2 -2
- package/lib/mjs/Webform.js +9 -9
- package/lib/mjs/WebformBuilder.js +5 -1
- package/lib/mjs/Wizard.d.ts +1 -0
- package/lib/mjs/Wizard.js +22 -2
- package/lib/mjs/components/_classes/component/Component.d.ts +50 -15
- package/lib/mjs/components/_classes/component/Component.js +154 -70
- package/lib/mjs/components/_classes/component/editForm/Component.edit.data.js +19 -0
- package/lib/mjs/components/_classes/component/editForm/utils.js +1 -1
- package/lib/mjs/components/_classes/list/ListComponent.js +2 -2
- package/lib/mjs/components/_classes/nested/NestedComponent.d.ts +0 -1
- package/lib/mjs/components/_classes/nested/NestedComponent.form.js +13 -0
- package/lib/mjs/components/_classes/nested/NestedComponent.js +10 -18
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.d.ts +0 -2
- package/lib/mjs/components/_classes/nesteddata/NestedDataComponent.js +0 -11
- package/lib/mjs/components/address/Address.d.ts +9 -0
- package/lib/mjs/components/address/Address.js +31 -8
- package/lib/mjs/components/address/editForm/Address.edit.display.d.ts +4 -0
- package/lib/mjs/components/address/editForm/Address.edit.display.js +1 -0
- package/lib/mjs/components/address/editForm/Address.edit.provider.js +8 -8
- package/lib/mjs/components/content/editForm/Content.edit.display.js +8 -0
- package/lib/mjs/components/currency/editForm/Currency.edit.display.js +12 -0
- package/lib/mjs/components/datagrid/DataGrid.js +0 -3
- package/lib/mjs/components/datamap/DataMap.js +2 -6
- package/lib/mjs/components/datetime/editForm/DateTime.edit.validation.d.ts +66 -15
- package/lib/mjs/components/datetime/editForm/DateTime.edit.validation.js +68 -47
- package/lib/mjs/components/day/editForm/Day.edit.display.js +8 -0
- package/lib/mjs/components/editgrid/EditGrid.js +3 -12
- package/lib/mjs/components/email/editForm/Email.edit.display.js +12 -0
- package/lib/mjs/components/fieldset/editForm/Fieldset.edit.display.js +8 -0
- package/lib/mjs/components/file/File.js +7 -2
- package/lib/mjs/components/file/editForm/File.edit.file.d.ts +13 -0
- package/lib/mjs/components/file/editForm/File.edit.file.js +1 -0
- package/lib/mjs/components/form/Form.d.ts +0 -1
- package/lib/mjs/components/form/Form.js +18 -22
- package/lib/mjs/components/hidden/editForm/Hidden.edit.display.js +8 -0
- package/lib/mjs/components/html/HTML.js +1 -2
- package/lib/mjs/components/html/editForm/HTML.edit.display.js +8 -0
- package/lib/mjs/components/number/editForm/Number.edit.display.js +12 -0
- package/lib/mjs/components/password/editForm/Password.edit.display.js +13 -1
- package/lib/mjs/components/phonenumber/PhoneNumber.form.js +9 -1
- package/lib/mjs/components/radio/Radio.js +1 -1
- package/lib/mjs/components/select/Select.js +1 -1
- package/lib/mjs/components/select/editForm/Select.edit.data.d.ts +68 -110
- package/lib/mjs/components/select/editForm/Select.edit.data.js +2 -37
- package/lib/mjs/components/selectboxes/SelectBoxes.js +3 -0
- package/lib/mjs/components/survey/Survey.js +1 -1
- package/lib/mjs/components/tabs/Tabs.js +1 -0
- package/lib/mjs/components/tabs/editForm/Tabs.edit.display.js +8 -0
- package/lib/mjs/components/textarea/TextArea.js +9 -1
- package/lib/mjs/components/textarea/editForm/TextArea.edit.display.js +12 -0
- package/lib/mjs/components/textfield/TextField.js +2 -2
- package/lib/mjs/components/unknown/Unknown.form.d.ts +2 -1
- package/lib/mjs/components/unknown/Unknown.form.js +13 -9
- package/lib/mjs/components/url/editForm/Url.edit.display.js +12 -0
- package/lib/mjs/components/well/editForm/Well.edit.display.js +8 -0
- package/lib/mjs/formio.form.js +1 -1
- package/lib/mjs/providers/storage/uploadAdapter.js +5 -3
- package/lib/mjs/translations/en.d.ts +1 -234
- package/lib/mjs/translations/en.js +5 -47
- package/lib/mjs/utils/formUtils.d.ts +2 -2
- package/lib/mjs/utils/utils.d.ts +9 -8
- package/lib/mjs/utils/utils.js +16 -21
- package/lib/mjs/widgets/CalendarWidget.js +7 -2
- package/package.json +2 -2
- package/lib/cjs/i18n.d.ts +0 -13
- package/lib/cjs/i18n.js +0 -19
- package/lib/cjs/utils/i18n.d.ts +0 -19
- package/lib/cjs/utils/i18n.js +0 -120
- package/lib/mjs/i18n.d.ts +0 -13
- package/lib/mjs/i18n.js +0 -14
- package/lib/mjs/utils/i18n.d.ts +0 -19
- package/lib/mjs/utils/i18n.js +0 -112
@@ -351,18 +351,11 @@ class Component extends Element_1.default {
|
|
351
351
|
this._path = '';
|
352
352
|
// Needs for Nextgen Rules Engine
|
353
353
|
this.resetCaches();
|
354
|
-
/**
|
355
|
-
* Determines if this component is conditionally hidden. Should generally not be set outside of conditional logic pipeline.
|
356
|
-
* This is necessary because of clearOnHide behavior that only clears when conditionally hidden - we need to track
|
357
|
-
* conditionallyHidden separately from "regular" visibility.
|
358
|
-
*/
|
359
|
-
this._parentConditionallyHidden = this.options.hasOwnProperty('parentConditionallyHidden') ? this.options.parentConditionallyHidden : false;
|
360
|
-
this._conditionallyHidden = this.checkConditionallyHidden(null, data) || this._parentConditionallyHidden;
|
361
354
|
/**
|
362
355
|
* Determines if this component is visible, or not.
|
363
356
|
*/
|
364
357
|
this._parentVisible = this.options.hasOwnProperty('parentVisible') ? this.options.parentVisible : true;
|
365
|
-
this._visible = this._parentVisible && (this.hasCondition() ? !this.
|
358
|
+
this._visible = this._parentVisible && (this.hasCondition() ? !this.conditionallyHidden() : !this.component.hidden);
|
366
359
|
this._parentDisabled = false;
|
367
360
|
/**
|
368
361
|
* The reference attribute name for this component
|
@@ -431,7 +424,7 @@ class Component extends Element_1.default {
|
|
431
424
|
if (this.allowData && this.key) {
|
432
425
|
this.options.name += `[${this.key}]`;
|
433
426
|
// If component is visible or not set to clear on hide, set the default value.
|
434
|
-
if (!
|
427
|
+
if (!this.shouldConditionallyClear()) {
|
435
428
|
if (!this.hasValue()) {
|
436
429
|
if (this.shouldAddDefaultValue) {
|
437
430
|
this.dataValue = this.defaultValue;
|
@@ -465,6 +458,46 @@ class Component extends Element_1.default {
|
|
465
458
|
var _a;
|
466
459
|
return ((_a = this.root) === null || _a === void 0 ? void 0 : _a.childComponentsMap) || {};
|
467
460
|
}
|
461
|
+
/**
|
462
|
+
* Returns if the parent should conditionally clear.
|
463
|
+
*
|
464
|
+
* @returns {boolean} - If the parent should conditionally clear.
|
465
|
+
*/
|
466
|
+
parentShouldConditionallyClear() {
|
467
|
+
let currentParent = this.parent;
|
468
|
+
while (currentParent) {
|
469
|
+
if ((currentParent.allowData && currentParent._conditionallyClear) ||
|
470
|
+
(!currentParent.allowData && currentParent._conditionallyHidden)) {
|
471
|
+
return true;
|
472
|
+
}
|
473
|
+
currentParent = currentParent.parent;
|
474
|
+
}
|
475
|
+
return false;
|
476
|
+
}
|
477
|
+
parentConditionallyHidden() {
|
478
|
+
let currentParent = this.parent;
|
479
|
+
while (currentParent) {
|
480
|
+
if (currentParent._conditionallyHidden) {
|
481
|
+
return true;
|
482
|
+
}
|
483
|
+
currentParent = currentParent.parent;
|
484
|
+
}
|
485
|
+
return false;
|
486
|
+
}
|
487
|
+
/**
|
488
|
+
* Returns true if any of the parents default their component "hidden" property to true.
|
489
|
+
* @returns {boolean} - If any parent defaults the hidden property to true.
|
490
|
+
*/
|
491
|
+
anyParentDefaultsHidden() {
|
492
|
+
let currentParent = this.parent;
|
493
|
+
while (currentParent) {
|
494
|
+
if (currentParent.component.hidden) {
|
495
|
+
return true;
|
496
|
+
}
|
497
|
+
currentParent = currentParent.parent;
|
498
|
+
}
|
499
|
+
return false;
|
500
|
+
}
|
468
501
|
get data() {
|
469
502
|
return this._data;
|
470
503
|
}
|
@@ -505,8 +538,7 @@ class Component extends Element_1.default {
|
|
505
538
|
init() {
|
506
539
|
var _a;
|
507
540
|
this.disabled = this.shouldDisabled;
|
508
|
-
this.
|
509
|
-
this._visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
|
541
|
+
this._visible = (this.hasCondition() ? !this.conditionallyHidden() : !this.component.hidden);
|
510
542
|
if ((_a = this.component.addons) === null || _a === void 0 ? void 0 : _a.length) {
|
511
543
|
this.component.addons.forEach((addon) => this.createAddon(addon));
|
512
544
|
}
|
@@ -671,20 +703,64 @@ class Component extends Element_1.default {
|
|
671
703
|
}
|
672
704
|
return this._visible && this._parentVisible;
|
673
705
|
}
|
674
|
-
get
|
675
|
-
|
706
|
+
get logicallyHidden() {
|
707
|
+
if (this._logicallyHidden && !this.component.hidden) {
|
708
|
+
this._logicallyHidden = false;
|
709
|
+
}
|
710
|
+
return this._logicallyHidden;
|
676
711
|
}
|
677
712
|
/**
|
678
|
-
*
|
679
|
-
* @
|
680
|
-
* @param {object} row - The row object to evaluate the condition against.
|
681
|
-
* @returns {boolean} - Whether the component is conditionally hidden.
|
713
|
+
* Determines if the component should clear its value when the root form is pristine.
|
714
|
+
* @returns {boolean} - If the component should clear its value when the root form is pristine.
|
682
715
|
*/
|
683
|
-
|
684
|
-
|
685
|
-
|
716
|
+
shouldConditionallyClearOnPristine() {
|
717
|
+
// If the form is pristine, we should NOT clear the value of a conditionally hidden child component
|
718
|
+
// of a layout component that defaults to hidden using the "hidden" component property.
|
719
|
+
return !this.anyParentDefaultsHidden();
|
720
|
+
}
|
721
|
+
/**
|
722
|
+
* Returns if the component should clear its value when conditionally hidden.
|
723
|
+
* @returns {boolean} - If the component should clear its value when conditionally hidden.
|
724
|
+
*/
|
725
|
+
shouldConditionallyClear() {
|
726
|
+
// Skip if this component has clearOnHide set to false.
|
727
|
+
if (this.component.clearOnHide === false) {
|
728
|
+
this._conditionallyClear = false;
|
729
|
+
return this._conditionallyClear;
|
686
730
|
}
|
687
|
-
|
731
|
+
// If the component is logically hidden, then it is conditionally hidden and should clear.
|
732
|
+
if (this.logicallyHidden) {
|
733
|
+
this._conditionallyClear = true;
|
734
|
+
return this._conditionallyClear;
|
735
|
+
}
|
736
|
+
// If we have a condition and it is not conditionally visible, the it should conditionally clear.
|
737
|
+
if (this.hasCondition() &&
|
738
|
+
!this.conditionallyVisible() &&
|
739
|
+
(!this.rootPristine || this.shouldConditionallyClearOnPristine())) {
|
740
|
+
this._conditionallyClear = true;
|
741
|
+
return this._conditionallyClear;
|
742
|
+
}
|
743
|
+
this._conditionallyClear = this.hasSetValue ? false : this.parentShouldConditionallyClear();
|
744
|
+
return this._conditionallyClear;
|
745
|
+
}
|
746
|
+
/**
|
747
|
+
* Returns if the component is conditionally hidden.
|
748
|
+
* @returns {boolean} - If the component is conditionally hidden.
|
749
|
+
*/
|
750
|
+
conditionallyHidden() {
|
751
|
+
// If it is logically hidden, then it is conditionally hidden.
|
752
|
+
if (this.logicallyHidden) {
|
753
|
+
this._conditionallyHidden = true;
|
754
|
+
return this._conditionallyHidden;
|
755
|
+
}
|
756
|
+
// If it has a condition, and is not conditionally visible, then it is conditionally hidden.
|
757
|
+
if (this.hasCondition() && !this.conditionallyVisible()) {
|
758
|
+
this._conditionallyHidden = true;
|
759
|
+
return this._conditionallyHidden;
|
760
|
+
}
|
761
|
+
// It is conditionally hidden if its parent is conditionally hidden.
|
762
|
+
this._conditionallyHidden = this.parentConditionallyHidden();
|
763
|
+
return this._conditionallyHidden;
|
688
764
|
}
|
689
765
|
get currentForm() {
|
690
766
|
return this._currentForm;
|
@@ -1852,7 +1928,7 @@ class Component extends Element_1.default {
|
|
1852
1928
|
rebuild() {
|
1853
1929
|
this.destroy();
|
1854
1930
|
this.init();
|
1855
|
-
this.visible = this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden;
|
1931
|
+
this.visible = this.hasCondition() ? !this.conditionallyHidden() : !this.component.hidden;
|
1856
1932
|
return this.redraw();
|
1857
1933
|
}
|
1858
1934
|
/**
|
@@ -1950,23 +2026,12 @@ class Component extends Element_1.default {
|
|
1950
2026
|
if (!this.builderMode & !this.previewMode && this.fieldLogic(data, row)) {
|
1951
2027
|
this.redraw();
|
1952
2028
|
}
|
1953
|
-
// Check advanced conditions (and cache the result)
|
1954
|
-
const isConditionallyHidden = this.checkConditionallyHidden(data, row) || this._parentConditionallyHidden;
|
1955
|
-
let shouldClear = false;
|
1956
|
-
if (isConditionallyHidden !== this._conditionallyHidden) {
|
1957
|
-
this._conditionallyHidden = isConditionallyHidden;
|
1958
|
-
shouldClear = true;
|
1959
|
-
}
|
1960
2029
|
// Check visibility
|
1961
|
-
const visible = (this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden);
|
2030
|
+
const visible = (this.hasCondition() ? !this.conditionallyHidden() : !this.component.hidden);
|
1962
2031
|
if (this.visible !== visible) {
|
1963
2032
|
this.visible = visible;
|
1964
2033
|
}
|
1965
|
-
|
1966
|
-
// calling clearOnHide
|
1967
|
-
if (shouldClear) {
|
1968
|
-
this.clearOnHide();
|
1969
|
-
}
|
2034
|
+
this.clearComponentOnHide();
|
1970
2035
|
return visible;
|
1971
2036
|
}
|
1972
2037
|
/**
|
@@ -2075,9 +2140,9 @@ class Component extends Element_1.default {
|
|
2075
2140
|
if (!lodash_1.default.isEqual(lodash_1.default.get(this.component, property), lodash_1.default.get(newComponent, property))) {
|
2076
2141
|
// Advanced Logic can modify the component's hidden property; because we track conditionally hidden state
|
2077
2142
|
// separately from the component's hidden property, and technically this Advanced Logic conditionally hides
|
2078
|
-
// a component, we need to set
|
2143
|
+
// a component, we need to set a temporary variable to the new value
|
2079
2144
|
if (property === 'hidden') {
|
2080
|
-
this.
|
2145
|
+
this._logicallyHidden = newComponent.hidden;
|
2081
2146
|
}
|
2082
2147
|
changed = true;
|
2083
2148
|
}
|
@@ -2092,7 +2157,7 @@ class Component extends Element_1.default {
|
|
2092
2157
|
component: newComponent,
|
2093
2158
|
result,
|
2094
2159
|
});
|
2095
|
-
if (!lodash_1.default.isEqual(oldValue, newValue) && !
|
2160
|
+
if (!lodash_1.default.isEqual(oldValue, newValue) && !this.shouldConditionallyClear()) {
|
2096
2161
|
this.setValue(newValue);
|
2097
2162
|
if (this.viewOnly) {
|
2098
2163
|
this.dataValue = newValue;
|
@@ -2125,7 +2190,7 @@ class Component extends Element_1.default {
|
|
2125
2190
|
component: newComponent,
|
2126
2191
|
result,
|
2127
2192
|
}, 'value');
|
2128
|
-
if (!lodash_1.default.isEqual(oldValue, newValue) && !
|
2193
|
+
if (!lodash_1.default.isEqual(oldValue, newValue) && !this.shouldConditionallyClear()) {
|
2129
2194
|
this.setValue(newValue);
|
2130
2195
|
if (this.viewOnly) {
|
2131
2196
|
this.dataValue = newValue;
|
@@ -2226,17 +2291,12 @@ class Component extends Element_1.default {
|
|
2226
2291
|
element.setAttribute('aria-invalid', invalid ? 'true' : 'false');
|
2227
2292
|
}
|
2228
2293
|
/**
|
2229
|
-
*
|
2294
|
+
* Clear any conditionally hidden components for this component only.
|
2230
2295
|
*/
|
2231
|
-
|
2296
|
+
clearComponentOnHide() {
|
2232
2297
|
// clearOnHide defaults to true for old forms (without the value set) so only trigger if the value is false.
|
2233
|
-
if (
|
2234
|
-
|
2235
|
-
(!this.rootPristine || this.options.server || (0, utils_1.isInsideScopingComponent)(this)) &&
|
2236
|
-
this.component.clearOnHide !== false &&
|
2237
|
-
!this.options.readOnly &&
|
2238
|
-
!this.options.showHiddenFields) {
|
2239
|
-
if (this.conditionallyHidden) {
|
2298
|
+
if (this.component.clearOnHide !== false && !this.options.readOnly && !this.options.showHiddenFields) {
|
2299
|
+
if (this.shouldConditionallyClear()) {
|
2240
2300
|
this.deleteValue();
|
2241
2301
|
}
|
2242
2302
|
else if (!this.hasValue() && this.shouldAddDefaultValue) {
|
@@ -2247,6 +2307,12 @@ class Component extends Element_1.default {
|
|
2247
2307
|
}
|
2248
2308
|
}
|
2249
2309
|
}
|
2310
|
+
/**
|
2311
|
+
* Clears the components data if it is conditionally hidden AND clearOnHide is set to true for this component.
|
2312
|
+
*/
|
2313
|
+
clearOnHide() {
|
2314
|
+
this.clearComponentOnHide();
|
2315
|
+
}
|
2250
2316
|
/**
|
2251
2317
|
* Triggers a debounced onChange event for the root component (usually Webform).
|
2252
2318
|
* @param {...any} args - The arguments to pass to the onChange event.
|
@@ -2494,27 +2560,17 @@ class Component extends Element_1.default {
|
|
2494
2560
|
* @returns {*} - The value for this component.
|
2495
2561
|
*/
|
2496
2562
|
get dataValue() {
|
2497
|
-
if (!this.key
|
2498
|
-
|
2499
|
-
return this.emptyValue;
|
2500
|
-
}
|
2501
|
-
if (!this.hasValue() && this.shouldAddDefaultValue) {
|
2502
|
-
const empty = this.component.multiple ? [] : this.emptyValue;
|
2503
|
-
if (!this.rootPristine) {
|
2504
|
-
this.dataValue = empty;
|
2505
|
-
}
|
2506
|
-
return empty;
|
2563
|
+
if (!this.key) {
|
2564
|
+
return this.component.multiple ? [] : this.emptyValue;
|
2507
2565
|
}
|
2508
|
-
return lodash_1.default.get(this._data, this.key);
|
2566
|
+
return lodash_1.default.get(this._data, this.key, this.component.multiple ? [] : this.emptyValue);
|
2509
2567
|
}
|
2510
2568
|
/**
|
2511
2569
|
* Sets the static value of this component.
|
2512
2570
|
* @param {*} value - The value to set for this component.
|
2513
2571
|
*/
|
2514
2572
|
set dataValue(value) {
|
2515
|
-
if (!this.allowData ||
|
2516
|
-
!this.key ||
|
2517
|
-
(this.conditionallyHidden && this.component.clearOnHide && !this.rootPristine)) {
|
2573
|
+
if (!this.allowData || !this.key) {
|
2518
2574
|
return;
|
2519
2575
|
}
|
2520
2576
|
if ((value !== null) && (value !== undefined)) {
|
@@ -2557,13 +2613,30 @@ class Component extends Element_1.default {
|
|
2557
2613
|
}
|
2558
2614
|
getCustomDefaultValue(defaultValue) {
|
2559
2615
|
if (this.component.customDefaultValue && !this.options.preview) {
|
2560
|
-
defaultValue = this.evaluate(this.component.customDefaultValue, { value:
|
2616
|
+
defaultValue = this.evaluate(this.component.customDefaultValue, { value: this.dataValue }, 'value');
|
2561
2617
|
}
|
2562
2618
|
return defaultValue;
|
2563
2619
|
}
|
2620
|
+
/**
|
2621
|
+
* Returns if a component has a default value set.
|
2622
|
+
* @returns {boolean} - TRUE if a default value is set.
|
2623
|
+
*/
|
2624
|
+
get hasDefaultValue() {
|
2625
|
+
return this.component.customDefaultValue || (this.component.hasOwnProperty('defaultValue') &&
|
2626
|
+
(this.component.defaultValue !== null) &&
|
2627
|
+
(this.component.defaultValue !== undefined));
|
2628
|
+
}
|
2629
|
+
/**
|
2630
|
+
* Determine if we should add a default value for this component.
|
2631
|
+
* @returns {boolean} - TRUE if a default value should be set
|
2632
|
+
*/
|
2564
2633
|
get shouldAddDefaultValue() {
|
2565
|
-
return
|
2634
|
+
return this.pristine && this.allowData && (this.hasDefaultValue || !this.options.noDefaults);
|
2566
2635
|
}
|
2636
|
+
/**
|
2637
|
+
* Get the default value of this component.
|
2638
|
+
* @returns {*} - The default value for this component.
|
2639
|
+
*/
|
2567
2640
|
get defaultValue() {
|
2568
2641
|
let defaultValue = this.emptyValue;
|
2569
2642
|
if (this.component.defaultValue) {
|
@@ -2834,10 +2907,8 @@ class Component extends Element_1.default {
|
|
2834
2907
|
}
|
2835
2908
|
// If no calculated value or
|
2836
2909
|
// hidden and set to clearOnHide (Don't calculate a value for a hidden field set to clear when hidden)
|
2837
|
-
const { clearOnHide } = this.component;
|
2838
|
-
const shouldBeCleared = this.conditionallyHidden && clearOnHide;
|
2839
2910
|
const allowOverride = lodash_1.default.get(this.component, 'allowCalculateOverride', false);
|
2840
|
-
if (
|
2911
|
+
if (this.shouldConditionallyClear()) {
|
2841
2912
|
// remove calculated value so that the value is recalculated once component becomes visible
|
2842
2913
|
if (this.hasOwnProperty('calculatedValue') && allowOverride) {
|
2843
2914
|
lodash_1.default.unset(this, 'calculatedValue');
|
@@ -2958,10 +3029,12 @@ class Component extends Element_1.default {
|
|
2958
3029
|
* @param {boolean} dirty - If the component is dirty.
|
2959
3030
|
* @param {boolean} ignoreCondition - If conditions for the component should be ignored when checking validity.
|
2960
3031
|
* @param {*} row - Contextual row data for this component.
|
3032
|
+
* @param {*} options - Additional options for validation.
|
2961
3033
|
* @returns {string} - The message to show when the component is invalid.
|
2962
3034
|
*/
|
2963
|
-
invalidMessage(data, dirty, ignoreCondition, row) {
|
3035
|
+
invalidMessage(data, dirty, ignoreCondition, row, options = {}) {
|
2964
3036
|
var _a;
|
3037
|
+
const { local } = options;
|
2965
3038
|
if (!row) {
|
2966
3039
|
row = (0, utils_1.getContextualRowData)(this.component, data, this.paths);
|
2967
3040
|
}
|
@@ -2981,6 +3054,7 @@ class Component extends Element_1.default {
|
|
2981
3054
|
component: this.component,
|
2982
3055
|
data,
|
2983
3056
|
row,
|
3057
|
+
local,
|
2984
3058
|
path: this.path || this.component.key,
|
2985
3059
|
parent: (_a = this.parent) === null || _a === void 0 ? void 0 : _a.component,
|
2986
3060
|
paths: this.paths,
|
@@ -3157,6 +3231,14 @@ class Component extends Element_1.default {
|
|
3157
3231
|
data = data || this.rootValue;
|
3158
3232
|
flags = flags || {};
|
3159
3233
|
row = row || this.data;
|
3234
|
+
// Some components (for legacy reasons) have calls to "checkData" in inappropriate places such
|
3235
|
+
// as setValue. Historically, this was bypassed by a series of cached states around the data model
|
3236
|
+
// which caused its own problems. We need to ensure that premium and custom components do not fall into
|
3237
|
+
// an infinite loop by only checking this component once.
|
3238
|
+
if (this.checkingData) {
|
3239
|
+
return;
|
3240
|
+
}
|
3241
|
+
this.checkingData = true;
|
3160
3242
|
// Needs for Nextgen Rules Engine
|
3161
3243
|
this.resetCaches();
|
3162
3244
|
// Do not trigger refresh if change was triggered on blur event since components with Refresh on Blur have their own listeners
|
@@ -3170,6 +3252,8 @@ class Component extends Element_1.default {
|
|
3170
3252
|
if (this.id !== flags.triggeredComponentId) {
|
3171
3253
|
this.calculateComponentValue(data, flags, row);
|
3172
3254
|
}
|
3255
|
+
// We are done checking data.
|
3256
|
+
this.checkingData = false;
|
3173
3257
|
}
|
3174
3258
|
checkModal(errors = [], dirty = false) {
|
3175
3259
|
const messages = errors.filter(error => !error.fromServer);
|
@@ -3485,7 +3569,7 @@ class Component extends Element_1.default {
|
|
3485
3569
|
// If component definition changed, replace it.
|
3486
3570
|
if (!lodash_1.default.isEqual(this.component, newComponent)) {
|
3487
3571
|
this.component = newComponent;
|
3488
|
-
const visible = this.hasCondition() ? !this.conditionallyHidden : !this.component.hidden;
|
3572
|
+
const visible = this.hasCondition() ? !this.conditionallyHidden() : !this.component.hidden;
|
3489
3573
|
const disabled = this.shouldDisabled;
|
3490
3574
|
// Change states which won't be recalculated during redrawing
|
3491
3575
|
if (this.visible !== visible) {
|
@@ -81,6 +81,25 @@ exports.default = [
|
|
81
81
|
}
|
82
82
|
]
|
83
83
|
},
|
84
|
+
{
|
85
|
+
name: 'hide',
|
86
|
+
trigger: {
|
87
|
+
type: 'javascript',
|
88
|
+
javascript: 'result = instance.root.options.editJson === false;'
|
89
|
+
},
|
90
|
+
actions: [
|
91
|
+
{
|
92
|
+
name: 'hide',
|
93
|
+
type: 'property',
|
94
|
+
property: {
|
95
|
+
label: 'Hidden',
|
96
|
+
value: 'hidden',
|
97
|
+
type: 'boolean'
|
98
|
+
},
|
99
|
+
state: true
|
100
|
+
}
|
101
|
+
]
|
102
|
+
},
|
84
103
|
{
|
85
104
|
name: 'disabledToolTip',
|
86
105
|
trigger: {
|
@@ -11,7 +11,7 @@ const EditFormUtils = {
|
|
11
11
|
},
|
12
12
|
unifyComponents(objValue, srcValue) {
|
13
13
|
if (objValue.key && srcValue.key) {
|
14
|
-
if (objValue.skipMerge || srcValue.skipMerge) {
|
14
|
+
if ((objValue.skipMerge || srcValue.skipMerge) && !objValue.ignore) {
|
15
15
|
return false;
|
16
16
|
}
|
17
17
|
if (objValue.key === srcValue.key) {
|
@@ -29,9 +29,9 @@ class ListComponent extends Field_1.default {
|
|
29
29
|
get dataReady() {
|
30
30
|
// If the root submission has been set, and we are still not attached, then assume
|
31
31
|
// that our data is ready.
|
32
|
-
if (this.root &&
|
32
|
+
if ((this.root &&
|
33
33
|
this.root.submissionSet &&
|
34
|
-
!this.attached) {
|
34
|
+
!this.attached) || !this.visible) {
|
35
35
|
return Promise.resolve();
|
36
36
|
}
|
37
37
|
return this.itemsLoaded;
|
@@ -181,7 +181,6 @@ export default class NestedComponent extends Field {
|
|
181
181
|
checkData(data: any, flags: any, row: any, components: any): true | undefined;
|
182
182
|
checkConditions(data: any, flags: any, row: any): boolean;
|
183
183
|
clearOnHide(show: any): void;
|
184
|
-
restoreComponentsContext(): void;
|
185
184
|
/**
|
186
185
|
* Allow components to hook into the next page trigger to perform their own logic.
|
187
186
|
* @param {Function} next - The callback to continue to the next page.
|
@@ -11,6 +11,19 @@ const Components_1 = __importDefault(require("../../Components"));
|
|
11
11
|
*/
|
12
12
|
function default_1(...extend) {
|
13
13
|
return Components_1.default.baseEditForm([
|
14
|
+
{
|
15
|
+
key: 'display',
|
16
|
+
components: [
|
17
|
+
{
|
18
|
+
key: 'labelWidth',
|
19
|
+
ignore: true
|
20
|
+
},
|
21
|
+
{
|
22
|
+
key: 'labelMargin',
|
23
|
+
ignore: true
|
24
|
+
}
|
25
|
+
]
|
26
|
+
},
|
14
27
|
{
|
15
28
|
key: 'data',
|
16
29
|
ignore: true
|
@@ -85,18 +85,15 @@ class NestedComponent extends Field_1.default {
|
|
85
85
|
const visibilityChanged = this._visible !== value;
|
86
86
|
this._visible = value;
|
87
87
|
const isVisible = this.visible;
|
88
|
-
const isConditionallyHidden = this.checkConditionallyHidden();
|
89
88
|
const forceShow = this.shouldForceShow();
|
90
89
|
const forceHide = this.shouldForceHide();
|
91
90
|
this.components.forEach((component) => {
|
92
91
|
// Set the parent visibility first since we may have nested components within nested components
|
93
92
|
// and they need to be able to determine their visibility based on the parent visibility.
|
94
93
|
component.parentVisible = isVisible;
|
95
|
-
component._parentConditionallyHidden = isConditionallyHidden;
|
96
94
|
let visible;
|
97
95
|
if (component.hasCondition()) {
|
98
|
-
|
99
|
-
visible = !component.conditionallyHidden;
|
96
|
+
visible = !component.conditionallyHidden();
|
100
97
|
}
|
101
98
|
else {
|
102
99
|
visible = !component.component.hidden;
|
@@ -377,7 +374,6 @@ class NestedComponent extends Field_1.default {
|
|
377
374
|
data = data || this.data;
|
378
375
|
options.parent = this;
|
379
376
|
options.parentVisible = this.visible;
|
380
|
-
options.parentConditionallyHidden = this.conditionallyHidden;
|
381
377
|
options.root = (options === null || options === void 0 ? void 0 : options.root) || this.root || this;
|
382
378
|
options.localRoot = this.localRoot;
|
383
379
|
options.skipInit = true;
|
@@ -635,19 +631,8 @@ class NestedComponent extends Field_1.default {
|
|
635
631
|
}
|
636
632
|
clearOnHide(show) {
|
637
633
|
super.clearOnHide(show);
|
638
|
-
if (this.component.clearOnHide) {
|
639
|
-
if (this.allowData && !this.hasValue() && !this.conditionallyHidden) {
|
640
|
-
this.dataValue = this.defaultValue;
|
641
|
-
}
|
642
|
-
if (this.hasValue()) {
|
643
|
-
this.restoreComponentsContext();
|
644
|
-
}
|
645
|
-
}
|
646
634
|
this.getComponents().forEach(component => component.clearOnHide(show));
|
647
635
|
}
|
648
|
-
restoreComponentsContext() {
|
649
|
-
this.getComponents().forEach((component) => component.data = this.dataValue);
|
650
|
-
}
|
651
636
|
/**
|
652
637
|
* Allow components to hook into the next page trigger to perform their own logic.
|
653
638
|
* @param {Function} next - The callback to continue to the next page.
|
@@ -665,7 +650,7 @@ class NestedComponent extends Field_1.default {
|
|
665
650
|
}
|
666
651
|
calculateValue(data, flags, row) {
|
667
652
|
// Do not iterate into children and calculateValues if this nested component is conditionally hidden.
|
668
|
-
if (this.conditionallyHidden) {
|
653
|
+
if (this.conditionallyHidden()) {
|
669
654
|
return false;
|
670
655
|
}
|
671
656
|
return this.getComponents().reduce((changed, comp) => comp.calculateValue(data, flags, row) || changed, super.calculateValue(data, flags, row));
|
@@ -836,7 +821,7 @@ class NestedComponent extends Field_1.default {
|
|
836
821
|
else if (value && component.hasValue(value)) {
|
837
822
|
return component.setValue(lodash_1.default.get(value, component.key), flags);
|
838
823
|
}
|
839
|
-
else if ((!this.rootPristine || component.visible) && component.shouldAddDefaultValue) {
|
824
|
+
else if ((!this.rootPristine || component.visible) && (flags.resetValue || component.shouldAddDefaultValue)) {
|
840
825
|
flags.noValidate = !flags.dirty;
|
841
826
|
flags.resetValue = true;
|
842
827
|
return component.setValue(component.defaultValue, flags);
|
@@ -846,6 +831,13 @@ class NestedComponent extends Field_1.default {
|
|
846
831
|
if (!value) {
|
847
832
|
return false;
|
848
833
|
}
|
834
|
+
// If the value is equal to the empty value, then this means we need to reset the values.
|
835
|
+
if (lodash_1.default.isEqual(value, this.emptyValue)) {
|
836
|
+
// TO-DO: For a future major release, we need to investigate removing the need for the
|
837
|
+
// "resetValue" flag. This seems like a hack that is no longer necessary and the renderer
|
838
|
+
// may behave more deterministically without it.
|
839
|
+
flags.resetValue = true;
|
840
|
+
}
|
849
841
|
return this.getComponents().reduce((changed, component) => {
|
850
842
|
return this.setNestedValue(component, value, flags, changed) || changed;
|
851
843
|
}, false);
|
@@ -3,11 +3,9 @@ export default class NestedDataComponent extends NestedComponent {
|
|
3
3
|
hasChanged(newValue: any, oldValue: any): boolean;
|
4
4
|
get allowData(): boolean;
|
5
5
|
get emptyValue(): {};
|
6
|
-
get shouldAddDefaultValue(): boolean;
|
7
6
|
componentContext(): any;
|
8
7
|
getValueAsString(value: any, options: any): string;
|
9
8
|
getDataValueAsTable(value: any, options: any): string;
|
10
|
-
everyComponent(fn: any, options?: {}): void;
|
11
9
|
/**
|
12
10
|
* Get the value of this component.
|
13
11
|
* @returns {any} - Return the value of this component.
|
@@ -88,17 +88,6 @@ class NestedDataComponent extends NestedComponent_1.default {
|
|
88
88
|
`);
|
89
89
|
return result;
|
90
90
|
}
|
91
|
-
everyComponent(fn, options = {}) {
|
92
|
-
if (options === null || options === void 0 ? void 0 : options.email) {
|
93
|
-
if (options.fromRoot) {
|
94
|
-
delete options.fromRoot;
|
95
|
-
}
|
96
|
-
else {
|
97
|
-
return;
|
98
|
-
}
|
99
|
-
}
|
100
|
-
return super.everyComponent(fn, options);
|
101
|
-
}
|
102
91
|
/**
|
103
92
|
* Get the value of this component.
|
104
93
|
* @returns {any} - Return the value of this component.
|
@@ -36,12 +36,21 @@ export default class AddressComponent extends ContainerComponent {
|
|
36
36
|
get autocompleteMode(): boolean;
|
37
37
|
get manualMode(): boolean;
|
38
38
|
get manualModeEnabled(): boolean;
|
39
|
+
restoreComponentsContext(): void;
|
39
40
|
get isMultiple(): boolean;
|
40
41
|
set address(value: any);
|
41
42
|
get address(): any;
|
42
43
|
isValueInLegacyFormat(value: any): any;
|
43
44
|
normalizeValue(value: any): any;
|
44
45
|
get modeSwitcher(): any;
|
46
|
+
get providerOptions(): {
|
47
|
+
params: any;
|
48
|
+
url: any;
|
49
|
+
queryProperty: any;
|
50
|
+
responseProperty: any;
|
51
|
+
displayValueProperty: any;
|
52
|
+
autocompleteOptions: any;
|
53
|
+
};
|
45
54
|
get removeValueIcon(): any;
|
46
55
|
get searchInput(): any;
|
47
56
|
get addRowButton(): any;
|