@bookinglab/booking-ui-react 1.8.0 → 1.9.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/README.md CHANGED
@@ -72,6 +72,7 @@ interface Question {
72
72
  name: string;
73
73
  detail_type: 'heading' | 'text_field' | 'text_area' | 'select' | 'date' | 'number' | 'check';
74
74
  required?: boolean;
75
+ disabled?: boolean;
75
76
  help_text?: string;
76
77
  options?: QuestionOption[]; // For select type
77
78
  settings?: QuestionSettings;
package/dist/index.d.cts CHANGED
@@ -328,6 +328,8 @@ interface Question {
328
328
  price_per_booking?: boolean;
329
329
  outcome?: boolean;
330
330
  hide_on_customer_journey?: boolean;
331
+ /** Whether the question field is disabled */
332
+ disabled?: boolean;
331
333
  }
332
334
  type FormValues = Record<number, string | number | boolean>;
333
335
  type FormErrors = Record<number, string>;
package/dist/index.d.ts CHANGED
@@ -328,6 +328,8 @@ interface Question {
328
328
  price_per_booking?: boolean;
329
329
  outcome?: boolean;
330
330
  hide_on_customer_journey?: boolean;
331
+ /** Whether the question field is disabled */
332
+ disabled?: boolean;
331
333
  }
332
334
  type FormValues = Record<number, string | number | boolean>;
333
335
  type FormErrors = Record<number, string>;
package/dist/index.js CHANGED
@@ -830,6 +830,7 @@ var ContactDetailsForm = react.forwardRef(
830
830
  }, [fieldSettings]);
831
831
  const validateQuestionField = react.useCallback((question, value) => {
832
832
  if (question.detail_type === "heading") return null;
833
+ if (question.disabled) return null;
833
834
  if (question.required) {
834
835
  if (value === void 0 || value === "" || value === null) {
835
836
  return `${question.name} is required`;
@@ -1040,6 +1041,7 @@ var ContactDetailsForm = react.forwardRef(
1040
1041
  const value = questionValues[question.id];
1041
1042
  const error = questionTouched[question.id] ? questionErrors[question.id] : void 0;
1042
1043
  const hasError = !!error;
1044
+ const isDisabled = !!question.disabled;
1043
1045
  const ariaProps = {
1044
1046
  "aria-invalid": hasError ? true : void 0,
1045
1047
  "aria-describedby": hasError ? errorId : void 0,
@@ -1060,10 +1062,11 @@ var ContactDetailsForm = react.forwardRef(
1060
1062
  id: fieldId,
1061
1063
  type: "text",
1062
1064
  value: value || "",
1065
+ disabled: isDisabled,
1063
1066
  onChange: (e) => handleQuestionChange(question.id, e.target.value),
1064
1067
  onBlur: () => handleQuestionBlur(question.id),
1065
1068
  placeholder: question.settings?.placeholder,
1066
- className: inputClasses(hasError),
1069
+ className: cx2(inputClasses(hasError), isDisabled ? "opacity-50 cursor-not-allowed" : ""),
1067
1070
  ...ariaProps
1068
1071
  }
1069
1072
  ),
@@ -1081,11 +1084,12 @@ var ContactDetailsForm = react.forwardRef(
1081
1084
  {
1082
1085
  id: fieldId,
1083
1086
  value: value || "",
1087
+ disabled: isDisabled,
1084
1088
  onChange: (e) => handleQuestionChange(question.id, e.target.value),
1085
1089
  onBlur: () => handleQuestionBlur(question.id),
1086
1090
  placeholder: question.settings?.placeholder,
1087
1091
  rows: 4,
1088
- className: inputClasses(hasError),
1092
+ className: cx2(inputClasses(hasError), isDisabled ? "opacity-50 cursor-not-allowed" : ""),
1089
1093
  ...ariaProps
1090
1094
  }
1091
1095
  ),
@@ -1103,9 +1107,10 @@ var ContactDetailsForm = react.forwardRef(
1103
1107
  {
1104
1108
  id: fieldId,
1105
1109
  value: value ?? "",
1110
+ disabled: isDisabled,
1106
1111
  onChange: (e) => handleQuestionChange(question.id, e.target.value),
1107
1112
  onBlur: () => handleQuestionBlur(question.id),
1108
- className: inputClasses(hasError),
1113
+ className: cx2(inputClasses(hasError), isDisabled ? "opacity-50 cursor-not-allowed" : ""),
1109
1114
  ...ariaProps,
1110
1115
  children: [
1111
1116
  /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: "Select an option" }),
@@ -1128,12 +1133,13 @@ var ContactDetailsForm = react.forwardRef(
1128
1133
  id: fieldId,
1129
1134
  type: "number",
1130
1135
  value: value ?? "",
1136
+ disabled: isDisabled,
1131
1137
  onChange: (e) => handleQuestionChange(question.id, e.target.value ? Number(e.target.value) : ""),
1132
1138
  onBlur: () => handleQuestionBlur(question.id),
1133
1139
  min: question.settings?.min,
1134
1140
  max: question.settings?.max,
1135
1141
  placeholder: question.settings?.placeholder,
1136
- className: inputClasses(hasError),
1142
+ className: cx2(inputClasses(hasError), isDisabled ? "opacity-50 cursor-not-allowed" : ""),
1137
1143
  ...ariaProps
1138
1144
  }
1139
1145
  ),
@@ -1152,9 +1158,10 @@ var ContactDetailsForm = react.forwardRef(
1152
1158
  id: fieldId,
1153
1159
  type: "date",
1154
1160
  value: value || "",
1161
+ disabled: isDisabled,
1155
1162
  onChange: (e) => handleQuestionChange(question.id, e.target.value),
1156
1163
  onBlur: () => handleQuestionBlur(question.id),
1157
- className: inputClasses(hasError),
1164
+ className: cx2(inputClasses(hasError), isDisabled ? "opacity-50 cursor-not-allowed" : ""),
1158
1165
  ...ariaProps
1159
1166
  }
1160
1167
  ),
@@ -1170,9 +1177,10 @@ var ContactDetailsForm = react.forwardRef(
1170
1177
  id: fieldId,
1171
1178
  type: "checkbox",
1172
1179
  checked: !!value,
1180
+ disabled: isDisabled,
1173
1181
  onChange: (e) => handleQuestionChange(question.id, e.target.checked),
1174
1182
  onBlur: () => handleQuestionBlur(question.id),
1175
- className: styles.checkbox,
1183
+ className: cx2(styles.checkbox, isDisabled ? "opacity-50 cursor-not-allowed" : ""),
1176
1184
  ...ariaProps
1177
1185
  }
1178
1186
  ),