@bookinglab/booking-ui-react 1.7.0 → 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.d.cts CHANGED
@@ -230,6 +230,8 @@ interface ContactDetailsFormProps {
230
230
  classNames?: ContactDetailsFormClassNames;
231
231
  /** Per-field settings for the default contact fields (required, disabled) */
232
232
  fieldSettings?: ContactDetailsFieldSettings;
233
+ /** When true, the submit button is hidden and form values are emitted via `onChange` on every change */
234
+ hideSubmitButton?: boolean;
233
235
  }
234
236
  /**
235
237
  * Imperative handle methods exposed via ref
package/dist/index.d.ts CHANGED
@@ -230,6 +230,8 @@ interface ContactDetailsFormProps {
230
230
  classNames?: ContactDetailsFormClassNames;
231
231
  /** Per-field settings for the default contact fields (required, disabled) */
232
232
  fieldSettings?: ContactDetailsFieldSettings;
233
+ /** When true, the submit button is hidden and form values are emitted via `onChange` on every change */
234
+ hideSubmitButton?: boolean;
233
235
  }
234
236
  /**
235
237
  * Imperative handle methods exposed via ref
package/dist/index.js CHANGED
@@ -435,6 +435,13 @@ var DEFAULT_FIELDS = [
435
435
  // Cross-field validation is handled in the component
436
436
  validate: required
437
437
  },
438
+ {
439
+ name: "phone",
440
+ label: "Contact number",
441
+ type: "tel",
442
+ required: false,
443
+ validate: phone
444
+ },
438
445
  {
439
446
  name: "password",
440
447
  label: "Password",
@@ -449,13 +456,6 @@ var DEFAULT_FIELDS = [
449
456
  required: true,
450
457
  validate: required
451
458
  },
452
- {
453
- name: "phone",
454
- label: "Contact number",
455
- type: "tel",
456
- required: false,
457
- validate: phone
458
- },
459
459
  {
460
460
  name: "address1",
461
461
  label: "Address 1",
@@ -788,7 +788,8 @@ var ContactDetailsForm = react.forwardRef(
788
788
  submitLabel = "Submit",
789
789
  className = "",
790
790
  classNames = {},
791
- fieldSettings = {}
791
+ fieldSettings = {},
792
+ hideSubmitButton = false
792
793
  }, ref) => {
793
794
  const formId = react.useId();
794
795
  const [firstName, setFirstName] = react.useState(initialValues?.firstName || "");
@@ -1187,12 +1188,24 @@ var ContactDetailsForm = react.forwardRef(
1187
1188
  return null;
1188
1189
  }
1189
1190
  };
1191
+ react.useEffect(() => {
1192
+ if (hideSubmitButton && _onChange) {
1193
+ const contactValid = !contactFields.some((f) => {
1194
+ if (getFieldDisabled(f.name)) return false;
1195
+ return !!validateContactField(f.name, f.value);
1196
+ });
1197
+ const questionsValid = !questions.some(
1198
+ (q) => !!validateQuestionField(q, questionValues[q.id])
1199
+ );
1200
+ _onChange(buildOutput(), contactValid && questionsValid);
1201
+ }
1202
+ }, [hideSubmitButton, firstName, lastName, emailValue, questionValues]);
1190
1203
  return /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, className, noValidate: true, children: [
1191
1204
  renderContactField("firstName", "First name", firstName),
1192
1205
  renderContactField("lastName", "Last name", lastName),
1193
1206
  renderContactField("email", "Email", emailValue, "email"),
1194
1207
  questions.map(renderQuestionField),
1195
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", className: styles.button, children: submitLabel })
1208
+ !hideSubmitButton && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", className: styles.button, children: submitLabel })
1196
1209
  ] });
1197
1210
  }
1198
1211
  );