@bookinglab/booking-ui-react 1.12.1 → 1.13.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
@@ -878,6 +878,8 @@ interface BookingFormProps {
878
878
  submitLabel?: string;
879
879
  /** Whether the current user is an admin. When false (default), questions with admin_only=true are hidden. */
880
880
  isAdmin?: boolean;
881
+ /** When true, renders each question's help_text directly below the label (or legend/heading) instead of below the input. Defaults to false. */
882
+ displayHelpTextBelowLabel?: boolean;
881
883
  /** Class name for the form element */
882
884
  className?: string;
883
885
  /** @deprecated Use classNames.label instead */
@@ -907,7 +909,7 @@ interface BookingUIConfig {
907
909
  * />
908
910
  * ```
909
911
  */
910
- declare function BookingForm({ questions, onSubmit, submitLabel, isAdmin, className, labelClassName, classNames: classNamesProp, }: BookingFormProps): react_jsx_runtime.JSX.Element;
912
+ declare function BookingForm({ questions, onSubmit, submitLabel, isAdmin, displayHelpTextBelowLabel, className, labelClassName, classNames: classNamesProp, }: BookingFormProps): react_jsx_runtime.JSX.Element;
911
913
 
912
914
  /**
913
915
  * A reusable, accessible registration form component.
package/dist/index.d.ts CHANGED
@@ -878,6 +878,8 @@ interface BookingFormProps {
878
878
  submitLabel?: string;
879
879
  /** Whether the current user is an admin. When false (default), questions with admin_only=true are hidden. */
880
880
  isAdmin?: boolean;
881
+ /** When true, renders each question's help_text directly below the label (or legend/heading) instead of below the input. Defaults to false. */
882
+ displayHelpTextBelowLabel?: boolean;
881
883
  /** Class name for the form element */
882
884
  className?: string;
883
885
  /** @deprecated Use classNames.label instead */
@@ -907,7 +909,7 @@ interface BookingUIConfig {
907
909
  * />
908
910
  * ```
909
911
  */
910
- declare function BookingForm({ questions, onSubmit, submitLabel, isAdmin, className, labelClassName, classNames: classNamesProp, }: BookingFormProps): react_jsx_runtime.JSX.Element;
912
+ declare function BookingForm({ questions, onSubmit, submitLabel, isAdmin, displayHelpTextBelowLabel, className, labelClassName, classNames: classNamesProp, }: BookingFormProps): react_jsx_runtime.JSX.Element;
911
913
 
912
914
  /**
913
915
  * A reusable, accessible registration form component.
package/dist/index.js CHANGED
@@ -24,7 +24,8 @@ function DateInputGroup({
24
24
  itemCls,
25
25
  sublabelCls,
26
26
  dateInputCls,
27
- renderHelpText,
27
+ helpTextAbove,
28
+ helpTextBelow,
28
29
  renderError
29
30
  }) {
30
31
  const parseValue = (raw) => {
@@ -64,6 +65,7 @@ function DateInputGroup({
64
65
  question.name,
65
66
  question.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500 ml-1", "aria-hidden": "true", children: "*" })
66
67
  ] }),
68
+ helpTextAbove,
67
69
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: groupCls, role: "group", children: [
68
70
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: itemCls, children: [
69
71
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: dayId, className: sublabelCls, children: "Day" }),
@@ -120,7 +122,7 @@ function DateInputGroup({
120
122
  )
121
123
  ] })
122
124
  ] }),
123
- renderHelpText(),
125
+ helpTextBelow,
124
126
  renderError()
125
127
  ] });
126
128
  }
@@ -129,7 +131,8 @@ function FormField({
129
131
  value,
130
132
  error,
131
133
  onChange,
132
- classNames
134
+ classNames,
135
+ displayHelpTextBelowLabel = false
133
136
  }) {
134
137
  const inputId = `question-${question.id}`;
135
138
  const errorId = `${inputId}-error`;
@@ -162,6 +165,8 @@ function FormField({
162
165
  }
163
166
  );
164
167
  };
168
+ const helpTextAbove = displayHelpTextBelowLabel ? renderHelpText() : null;
169
+ const helpTextBelow = displayHelpTextBelowLabel ? null : renderHelpText();
165
170
  const renderError = () => {
166
171
  if (!error) return null;
167
172
  return /* @__PURE__ */ jsxRuntime.jsx("p", { id: errorId, className: classNames?.errorText ?? defaultErrorText, role: "alert", children: error });
@@ -180,6 +185,7 @@ function FormField({
180
185
  case "text_field":
181
186
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classNames?.fieldWrapper ?? defaultFieldWrapper, children: [
182
187
  renderLabel(),
188
+ helpTextAbove,
183
189
  /* @__PURE__ */ jsxRuntime.jsx(
184
190
  "input",
185
191
  {
@@ -192,12 +198,13 @@ function FormField({
192
198
  ...ariaProps
193
199
  }
194
200
  ),
195
- renderHelpText(),
201
+ helpTextBelow,
196
202
  renderError()
197
203
  ] });
198
204
  case "text_area":
199
205
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classNames?.fieldWrapper ?? defaultFieldWrapper, children: [
200
206
  renderLabel(),
207
+ helpTextAbove,
201
208
  /* @__PURE__ */ jsxRuntime.jsx(
202
209
  "textarea",
203
210
  {
@@ -210,12 +217,13 @@ function FormField({
210
217
  ...ariaProps
211
218
  }
212
219
  ),
213
- renderHelpText(),
220
+ helpTextBelow,
214
221
  renderError()
215
222
  ] });
216
223
  case "select":
217
224
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classNames?.fieldWrapper ?? defaultFieldWrapper, children: [
218
225
  renderLabel(),
226
+ helpTextAbove,
219
227
  /* @__PURE__ */ jsxRuntime.jsxs(
220
228
  "select",
221
229
  {
@@ -230,12 +238,13 @@ function FormField({
230
238
  ]
231
239
  }
232
240
  ),
233
- renderHelpText(),
241
+ helpTextBelow,
234
242
  renderError()
235
243
  ] });
236
244
  case "radio":
237
245
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classNames?.fieldWrapper ?? defaultFieldWrapper, children: [
238
246
  renderLabel(),
247
+ helpTextAbove,
239
248
  /* @__PURE__ */ jsxRuntime.jsx(
240
249
  "div",
241
250
  {
@@ -263,7 +272,7 @@ function FormField({
263
272
  })
264
273
  }
265
274
  ),
266
- renderHelpText(),
275
+ helpTextBelow,
267
276
  renderError()
268
277
  ] });
269
278
  case "date": {
@@ -289,7 +298,8 @@ function FormField({
289
298
  itemCls,
290
299
  sublabelCls,
291
300
  dateInputCls,
292
- renderHelpText,
301
+ helpTextAbove,
302
+ helpTextBelow,
293
303
  renderError
294
304
  }
295
305
  );
@@ -297,6 +307,7 @@ function FormField({
297
307
  case "number":
298
308
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classNames?.fieldWrapper ?? defaultFieldWrapper, children: [
299
309
  renderLabel(),
310
+ helpTextAbove,
300
311
  /* @__PURE__ */ jsxRuntime.jsx(
301
312
  "input",
302
313
  {
@@ -311,11 +322,12 @@ function FormField({
311
322
  ...ariaProps
312
323
  }
313
324
  ),
314
- renderHelpText(),
325
+ helpTextBelow,
315
326
  renderError()
316
327
  ] });
317
328
  case "check":
318
329
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classNames?.fieldWrapper ?? defaultFieldWrapper, children: [
330
+ helpTextAbove,
319
331
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-2", children: [
320
332
  /* @__PURE__ */ jsxRuntime.jsx(
321
333
  "input",
@@ -333,7 +345,7 @@ function FormField({
333
345
  question.required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500 ml-1", "aria-hidden": "true", children: "*" })
334
346
  ] })
335
347
  ] }),
336
- renderHelpText(),
348
+ helpTextBelow,
337
349
  renderError()
338
350
  ] });
339
351
  default:
@@ -345,6 +357,7 @@ function BookingForm({
345
357
  onSubmit,
346
358
  submitLabel = "Submit",
347
359
  isAdmin = false,
360
+ displayHelpTextBelowLabel = false,
348
361
  className = "",
349
362
  labelClassName,
350
363
  classNames: classNamesProp
@@ -541,7 +554,8 @@ function BookingForm({
541
554
  value: values[question.id],
542
555
  error: touched[question.id] ? errors[question.id] : void 0,
543
556
  onChange: (value) => handleChange(question.id, value),
544
- classNames
557
+ classNames,
558
+ displayHelpTextBelowLabel
545
559
  },
546
560
  question.id
547
561
  )),