@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 +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +22 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -433,6 +433,13 @@ var DEFAULT_FIELDS = [
|
|
|
433
433
|
// Cross-field validation is handled in the component
|
|
434
434
|
validate: required
|
|
435
435
|
},
|
|
436
|
+
{
|
|
437
|
+
name: "phone",
|
|
438
|
+
label: "Contact number",
|
|
439
|
+
type: "tel",
|
|
440
|
+
required: false,
|
|
441
|
+
validate: phone
|
|
442
|
+
},
|
|
436
443
|
{
|
|
437
444
|
name: "password",
|
|
438
445
|
label: "Password",
|
|
@@ -447,13 +454,6 @@ var DEFAULT_FIELDS = [
|
|
|
447
454
|
required: true,
|
|
448
455
|
validate: required
|
|
449
456
|
},
|
|
450
|
-
{
|
|
451
|
-
name: "phone",
|
|
452
|
-
label: "Contact number",
|
|
453
|
-
type: "tel",
|
|
454
|
-
required: false,
|
|
455
|
-
validate: phone
|
|
456
|
-
},
|
|
457
457
|
{
|
|
458
458
|
name: "address1",
|
|
459
459
|
label: "Address 1",
|
|
@@ -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
|
);
|