@bigbinary/neeto-form-frontend 3.12.4 → 3.12.6

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/BuildForm.js CHANGED
@@ -980,6 +980,10 @@ var Form$1 = function Form(_ref) {
980
980
  additionalQuestionKindPattern = _ref.additionalQuestionKindPattern,
981
981
  _ref$isEdit = _ref.isEdit,
982
982
  isEdit = _ref$isEdit === void 0 ? false : _ref$isEdit;
983
+ var _useState = useState(false),
984
+ _useState2 = _slicedToArray(_useState, 2),
985
+ isFieldCodeInvalid = _useState2[0],
986
+ setIsFieldCodeInvalid = _useState2[1];
983
987
  var _useTranslation = useTranslation(),
984
988
  t = _useTranslation.t;
985
989
  var _useFormikContext = useFormikContext(),
@@ -987,7 +991,9 @@ var Form$1 = function Form(_ref) {
987
991
  setValues = _useFormikContext.setValues,
988
992
  setErrors = _useFormikContext.setErrors,
989
993
  setTouched = _useFormikContext.setTouched,
990
- setFieldValue = _useFormikContext.setFieldValue;
994
+ setFieldValue = _useFormikContext.setFieldValue,
995
+ errors = _useFormikContext.errors,
996
+ submitCount = _useFormikContext.submitCount;
991
997
  var hideQuestionHelpDoc = useBuildFormStore(path(["formState", "helpDocUrls", "hideQuestion"]));
992
998
  var readOnlyHelpDoc = useBuildFormStore(path(["formState", "helpDocUrls", "readOnly"]));
993
999
  var responseVisibleOnlyToHostHelpDoc = useBuildFormStore(path(["formState", "helpDocUrls", "responseVisibleOnlyToHost"]));
@@ -1018,6 +1024,11 @@ var Form$1 = function Form(_ref) {
1018
1024
  }) : {},
1019
1025
  _ref2$questionProps = _ref2.questionProps,
1020
1026
  questionProps = _ref2$questionProps === void 0 ? {} : _ref2$questionProps;
1027
+ useEffect(function () {
1028
+ if (submitCount > 0 && isPresent(errors === null || errors === void 0 ? void 0 : errors.fieldCode)) {
1029
+ setIsFieldCodeInvalid(true);
1030
+ }
1031
+ }, [submitCount]);
1021
1032
  var isRequired = questionKind && isRequiredField(questionKind);
1022
1033
  var isLabelDisabled = questionKind && isDisabledFieldLabel(questionKind);
1023
1034
  var isImmutable = questionKind && isImmutableField(questionKind);
@@ -1100,6 +1111,8 @@ var Form$1 = function Form(_ref) {
1100
1111
  labelProps: responseVisibleOnlyToHostSwitchLabelProps(responseVisibleOnlyToHostHelpDoc)
1101
1112
  })]
1102
1113
  }), (shouldShowFieldCode || shouldShowReadOnlySwitch) && /*#__PURE__*/jsx(Accordion, {
1114
+ defaultActiveKey: isFieldCodeInvalid ? 0 : null // This is to open the accordion when field code is invalid
1115
+ ,
1103
1116
  className: "neeto-form-nano-advanced-properties-accordion",
1104
1117
  "data-cy": "advanced-properties-card",
1105
1118
  children: /*#__PURE__*/jsx(Accordion.Item, {