@bookinglab/booking-ui-react 1.9.0 → 1.10.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.d.cts CHANGED
@@ -232,6 +232,8 @@ interface ContactDetailsFormProps {
232
232
  fieldSettings?: ContactDetailsFieldSettings;
233
233
  /** When true, the submit button is hidden and form values are emitted via `onChange` on every change */
234
234
  hideSubmitButton?: boolean;
235
+ /** When true, all validation errors are shown immediately (useful for external submit triggers) */
236
+ isSubmitted?: boolean;
235
237
  }
236
238
  /**
237
239
  * Imperative handle methods exposed via ref
package/dist/index.d.ts CHANGED
@@ -232,6 +232,8 @@ interface ContactDetailsFormProps {
232
232
  fieldSettings?: ContactDetailsFieldSettings;
233
233
  /** When true, the submit button is hidden and form values are emitted via `onChange` on every change */
234
234
  hideSubmitButton?: boolean;
235
+ /** When true, all validation errors are shown immediately (useful for external submit triggers) */
236
+ isSubmitted?: boolean;
235
237
  }
236
238
  /**
237
239
  * Imperative handle methods exposed via ref
package/dist/index.js CHANGED
@@ -789,7 +789,8 @@ var ContactDetailsForm = react.forwardRef(
789
789
  className = "",
790
790
  classNames = {},
791
791
  fieldSettings = {},
792
- hideSubmitButton = false
792
+ hideSubmitButton = false,
793
+ isSubmitted = false
793
794
  }, ref) => {
794
795
  const formId = react.useId();
795
796
  const [firstName, setFirstName] = react.useState(initialValues?.firstName || "");
@@ -1009,7 +1010,7 @@ var ContactDetailsForm = react.forwardRef(
1009
1010
  const errorId = `${fieldId}-error`;
1010
1011
  const isDisabled = getFieldDisabled(name);
1011
1012
  const isRequired = getFieldRequired(name);
1012
- const error = contactTouched[name] ? contactErrors[name] : void 0;
1013
+ const error = contactTouched[name] || isSubmitted ? contactErrors[name] : void 0;
1013
1014
  const hasError = !!error;
1014
1015
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.fieldWrapper, children: [
1015
1016
  /* @__PURE__ */ jsxRuntime.jsxs("label", { htmlFor: fieldId, className: styles.label, children: [
@@ -1039,7 +1040,7 @@ var ContactDetailsForm = react.forwardRef(
1039
1040
  const fieldId = `${formId}-q-${question.id}`;
1040
1041
  const errorId = `${fieldId}-error`;
1041
1042
  const value = questionValues[question.id];
1042
- const error = questionTouched[question.id] ? questionErrors[question.id] : void 0;
1043
+ const error = questionTouched[question.id] || isSubmitted ? questionErrors[question.id] : void 0;
1043
1044
  const hasError = !!error;
1044
1045
  const isDisabled = !!question.disabled;
1045
1046
  const ariaProps = {
@@ -1196,6 +1197,12 @@ var ContactDetailsForm = react.forwardRef(
1196
1197
  return null;
1197
1198
  }
1198
1199
  };
1200
+ react.useEffect(() => {
1201
+ if (isSubmitted) {
1202
+ validateAllContacts();
1203
+ validateAllQuestions();
1204
+ }
1205
+ }, [isSubmitted]);
1199
1206
  react.useEffect(() => {
1200
1207
  if (hideSubmitButton && _onChange) {
1201
1208
  const contactValid = !contactFields.some((f) => {