@bookinglab/booking-ui-react 1.14.0 → 1.15.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 +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -810,6 +810,15 @@ interface QuestionSettings {
|
|
|
810
810
|
max?: number;
|
|
811
811
|
placeholder?: string;
|
|
812
812
|
}
|
|
813
|
+
interface DateLimiter {
|
|
814
|
+
enabled: boolean;
|
|
815
|
+
/** ISO date string (e.g. "2025-01-01" or full ISO 8601). Only the date portion is used. */
|
|
816
|
+
minimumDate?: string;
|
|
817
|
+
/** ISO date string (e.g. "2025-12-31" or full ISO 8601). Only the date portion is used. */
|
|
818
|
+
maximumDate?: string;
|
|
819
|
+
/** Custom error message shown when the entered date falls outside the configured range. */
|
|
820
|
+
errorText?: string;
|
|
821
|
+
}
|
|
813
822
|
interface Question {
|
|
814
823
|
id: number;
|
|
815
824
|
name: string;
|
|
@@ -828,6 +837,8 @@ interface Question {
|
|
|
828
837
|
hide_on_customer_journey?: boolean;
|
|
829
838
|
/** Whether the question field is disabled */
|
|
830
839
|
disabled?: boolean;
|
|
840
|
+
/** Optional date validation config. Only applies when detail_type is 'date'. */
|
|
841
|
+
dateLimiter?: DateLimiter;
|
|
831
842
|
}
|
|
832
843
|
type FormValues = Record<number, string | number | boolean>;
|
|
833
844
|
type FormErrors = Record<number, string>;
|
|
@@ -1023,4 +1034,4 @@ declare function minLen(min: number): (value: string) => string | null;
|
|
|
1023
1034
|
*/
|
|
1024
1035
|
declare function compose(...validators: Array<(value: string) => string | null>): (value: string) => string | null;
|
|
1025
1036
|
|
|
1026
|
-
export { type AppConfig, type AwsLookupConfig, type AwsLookupMatchEntry, type AwsLookupSetPayload, BookingForm, type BookingFormClassNames, type BookingFormProps, type BookingUIConfig, type ConditionClause, type ContactDetailsAnswerEntry, type ContactDetailsFieldSettings, ContactDetailsForm, type ContactDetailsFormClassNames, type ContactDetailsFormProps, type ContactDetailsFormRef, type ContactDetailsInitialValues, type ContactDetailsQuestionEntry, type ContactDetailsValues, type ContactFieldSettings, type CopyDataConfig, type DropdownOption, type ExtraItemEntry, type FieldConfig, type FieldError, type FieldOption, type FormErrors, type FormReadyPayload, type FormSchemaStatus, type FormValues, type Question, type QuestionOption, type QuestionSettings, type RadioOption, type RawSchemaField, type RegistrationFieldSettings, RegistrationForm, type RegistrationFormClassNames, type RegistrationFormErrors, type RegistrationFormProps, type RegistrationFormRef, type RegistrationFormValues, ResetPasswordForm, type ResetPasswordFormClassNames, type ResetPasswordFormProps, type ResetPasswordFormRef, type ResetPasswordFormValues, type SchemaField, SchemaFormBuilder, type SchemaFormBuilderProps, type ShowRules, type UpdateDatastorePayload, type ValidationMaxDate, type ValidationMaxLength, type ValidationMinDate, type ValidationMinLength, type ValidationRule, type ValidationShorthand, type VenueSetPayload, compose, email, hydrateField, minLen, phone, required, ukPostcode };
|
|
1037
|
+
export { type AppConfig, type AwsLookupConfig, type AwsLookupMatchEntry, type AwsLookupSetPayload, BookingForm, type BookingFormClassNames, type BookingFormProps, type BookingUIConfig, type ConditionClause, type ContactDetailsAnswerEntry, type ContactDetailsFieldSettings, ContactDetailsForm, type ContactDetailsFormClassNames, type ContactDetailsFormProps, type ContactDetailsFormRef, type ContactDetailsInitialValues, type ContactDetailsQuestionEntry, type ContactDetailsValues, type ContactFieldSettings, type CopyDataConfig, type DateLimiter, type DropdownOption, type ExtraItemEntry, type FieldConfig, type FieldError, type FieldOption, type FormErrors, type FormReadyPayload, type FormSchemaStatus, type FormValues, type Question, type QuestionOption, type QuestionSettings, type RadioOption, type RawSchemaField, type RegistrationFieldSettings, RegistrationForm, type RegistrationFormClassNames, type RegistrationFormErrors, type RegistrationFormProps, type RegistrationFormRef, type RegistrationFormValues, ResetPasswordForm, type ResetPasswordFormClassNames, type ResetPasswordFormProps, type ResetPasswordFormRef, type ResetPasswordFormValues, type SchemaField, SchemaFormBuilder, type SchemaFormBuilderProps, type ShowRules, type UpdateDatastorePayload, type ValidationMaxDate, type ValidationMaxLength, type ValidationMinDate, type ValidationMinLength, type ValidationRule, type ValidationShorthand, type VenueSetPayload, compose, email, hydrateField, minLen, phone, required, ukPostcode };
|
package/dist/index.d.ts
CHANGED
|
@@ -810,6 +810,15 @@ interface QuestionSettings {
|
|
|
810
810
|
max?: number;
|
|
811
811
|
placeholder?: string;
|
|
812
812
|
}
|
|
813
|
+
interface DateLimiter {
|
|
814
|
+
enabled: boolean;
|
|
815
|
+
/** ISO date string (e.g. "2025-01-01" or full ISO 8601). Only the date portion is used. */
|
|
816
|
+
minimumDate?: string;
|
|
817
|
+
/** ISO date string (e.g. "2025-12-31" or full ISO 8601). Only the date portion is used. */
|
|
818
|
+
maximumDate?: string;
|
|
819
|
+
/** Custom error message shown when the entered date falls outside the configured range. */
|
|
820
|
+
errorText?: string;
|
|
821
|
+
}
|
|
813
822
|
interface Question {
|
|
814
823
|
id: number;
|
|
815
824
|
name: string;
|
|
@@ -828,6 +837,8 @@ interface Question {
|
|
|
828
837
|
hide_on_customer_journey?: boolean;
|
|
829
838
|
/** Whether the question field is disabled */
|
|
830
839
|
disabled?: boolean;
|
|
840
|
+
/** Optional date validation config. Only applies when detail_type is 'date'. */
|
|
841
|
+
dateLimiter?: DateLimiter;
|
|
831
842
|
}
|
|
832
843
|
type FormValues = Record<number, string | number | boolean>;
|
|
833
844
|
type FormErrors = Record<number, string>;
|
|
@@ -1023,4 +1034,4 @@ declare function minLen(min: number): (value: string) => string | null;
|
|
|
1023
1034
|
*/
|
|
1024
1035
|
declare function compose(...validators: Array<(value: string) => string | null>): (value: string) => string | null;
|
|
1025
1036
|
|
|
1026
|
-
export { type AppConfig, type AwsLookupConfig, type AwsLookupMatchEntry, type AwsLookupSetPayload, BookingForm, type BookingFormClassNames, type BookingFormProps, type BookingUIConfig, type ConditionClause, type ContactDetailsAnswerEntry, type ContactDetailsFieldSettings, ContactDetailsForm, type ContactDetailsFormClassNames, type ContactDetailsFormProps, type ContactDetailsFormRef, type ContactDetailsInitialValues, type ContactDetailsQuestionEntry, type ContactDetailsValues, type ContactFieldSettings, type CopyDataConfig, type DropdownOption, type ExtraItemEntry, type FieldConfig, type FieldError, type FieldOption, type FormErrors, type FormReadyPayload, type FormSchemaStatus, type FormValues, type Question, type QuestionOption, type QuestionSettings, type RadioOption, type RawSchemaField, type RegistrationFieldSettings, RegistrationForm, type RegistrationFormClassNames, type RegistrationFormErrors, type RegistrationFormProps, type RegistrationFormRef, type RegistrationFormValues, ResetPasswordForm, type ResetPasswordFormClassNames, type ResetPasswordFormProps, type ResetPasswordFormRef, type ResetPasswordFormValues, type SchemaField, SchemaFormBuilder, type SchemaFormBuilderProps, type ShowRules, type UpdateDatastorePayload, type ValidationMaxDate, type ValidationMaxLength, type ValidationMinDate, type ValidationMinLength, type ValidationRule, type ValidationShorthand, type VenueSetPayload, compose, email, hydrateField, minLen, phone, required, ukPostcode };
|
|
1037
|
+
export { type AppConfig, type AwsLookupConfig, type AwsLookupMatchEntry, type AwsLookupSetPayload, BookingForm, type BookingFormClassNames, type BookingFormProps, type BookingUIConfig, type ConditionClause, type ContactDetailsAnswerEntry, type ContactDetailsFieldSettings, ContactDetailsForm, type ContactDetailsFormClassNames, type ContactDetailsFormProps, type ContactDetailsFormRef, type ContactDetailsInitialValues, type ContactDetailsQuestionEntry, type ContactDetailsValues, type ContactFieldSettings, type CopyDataConfig, type DateLimiter, type DropdownOption, type ExtraItemEntry, type FieldConfig, type FieldError, type FieldOption, type FormErrors, type FormReadyPayload, type FormSchemaStatus, type FormValues, type Question, type QuestionOption, type QuestionSettings, type RadioOption, type RawSchemaField, type RegistrationFieldSettings, RegistrationForm, type RegistrationFormClassNames, type RegistrationFormErrors, type RegistrationFormProps, type RegistrationFormRef, type RegistrationFormValues, ResetPasswordForm, type ResetPasswordFormClassNames, type ResetPasswordFormProps, type ResetPasswordFormRef, type ResetPasswordFormValues, type SchemaField, SchemaFormBuilder, type SchemaFormBuilderProps, type ShowRules, type UpdateDatastorePayload, type ValidationMaxDate, type ValidationMaxLength, type ValidationMinDate, type ValidationMinLength, type ValidationRule, type ValidationShorthand, type VenueSetPayload, compose, email, hydrateField, minLen, phone, required, ukPostcode };
|
package/dist/index.js
CHANGED
|
@@ -491,6 +491,24 @@ function BookingForm({
|
|
|
491
491
|
return `Maximum value is ${question.settings.max}`;
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
|
+
if (question.detail_type === "date" && question.dateLimiter?.enabled && typeof value === "string" && value !== "") {
|
|
495
|
+
const toDatePart = (iso) => {
|
|
496
|
+
if (!iso || typeof iso !== "string") return null;
|
|
497
|
+
const m = iso.match(/^(\d{4}-\d{2}-\d{2})/);
|
|
498
|
+
return m ? m[1] : null;
|
|
499
|
+
};
|
|
500
|
+
const min = toDatePart(question.dateLimiter.minimumDate);
|
|
501
|
+
const max = toDatePart(question.dateLimiter.maximumDate);
|
|
502
|
+
const v = value;
|
|
503
|
+
const outOfRange = min && v < min || max && v > max;
|
|
504
|
+
if (outOfRange) {
|
|
505
|
+
if (question.dateLimiter.errorText) return question.dateLimiter.errorText;
|
|
506
|
+
if (min && max) return `Date must be between ${min} and ${max}`;
|
|
507
|
+
if (min) return `Date must be on or after ${min}`;
|
|
508
|
+
if (max) return `Date must be on or before ${max}`;
|
|
509
|
+
return "Date is outside the allowed range";
|
|
510
|
+
}
|
|
511
|
+
}
|
|
494
512
|
return null;
|
|
495
513
|
}, []);
|
|
496
514
|
const validateAll = React.useCallback(() => {
|