@bookinglab/booking-ui-react 1.7.1 → 1.8.0

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/index.mjs CHANGED
@@ -786,7 +786,8 @@ var ContactDetailsForm = forwardRef(
786
786
  submitLabel = "Submit",
787
787
  className = "",
788
788
  classNames = {},
789
- fieldSettings = {}
789
+ fieldSettings = {},
790
+ hideSubmitButton = false
790
791
  }, ref) => {
791
792
  const formId = useId();
792
793
  const [firstName, setFirstName] = useState(initialValues?.firstName || "");
@@ -1185,12 +1186,24 @@ var ContactDetailsForm = forwardRef(
1185
1186
  return null;
1186
1187
  }
1187
1188
  };
1189
+ useEffect(() => {
1190
+ if (hideSubmitButton && _onChange) {
1191
+ const contactValid = !contactFields.some((f) => {
1192
+ if (getFieldDisabled(f.name)) return false;
1193
+ return !!validateContactField(f.name, f.value);
1194
+ });
1195
+ const questionsValid = !questions.some(
1196
+ (q) => !!validateQuestionField(q, questionValues[q.id])
1197
+ );
1198
+ _onChange(buildOutput(), contactValid && questionsValid);
1199
+ }
1200
+ }, [hideSubmitButton, firstName, lastName, emailValue, questionValues]);
1188
1201
  return /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, className, noValidate: true, children: [
1189
1202
  renderContactField("firstName", "First name", firstName),
1190
1203
  renderContactField("lastName", "Last name", lastName),
1191
1204
  renderContactField("email", "Email", emailValue, "email"),
1192
1205
  questions.map(renderQuestionField),
1193
- /* @__PURE__ */ jsx("button", { type: "submit", className: styles.button, children: submitLabel })
1206
+ !hideSubmitButton && /* @__PURE__ */ jsx("button", { type: "submit", className: styles.button, children: submitLabel })
1194
1207
  ] });
1195
1208
  }
1196
1209
  );