@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 +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +25 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -18,7 +18,8 @@ function DateInputGroup({
|
|
|
18
18
|
itemCls,
|
|
19
19
|
sublabelCls,
|
|
20
20
|
dateInputCls,
|
|
21
|
-
|
|
21
|
+
helpTextAbove,
|
|
22
|
+
helpTextBelow,
|
|
22
23
|
renderError
|
|
23
24
|
}) {
|
|
24
25
|
const parseValue = (raw) => {
|
|
@@ -58,6 +59,7 @@ function DateInputGroup({
|
|
|
58
59
|
question.name,
|
|
59
60
|
question.required && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-1", "aria-hidden": "true", children: "*" })
|
|
60
61
|
] }),
|
|
62
|
+
helpTextAbove,
|
|
61
63
|
/* @__PURE__ */ jsxs("div", { className: groupCls, role: "group", children: [
|
|
62
64
|
/* @__PURE__ */ jsxs("div", { className: itemCls, children: [
|
|
63
65
|
/* @__PURE__ */ jsx("label", { htmlFor: dayId, className: sublabelCls, children: "Day" }),
|
|
@@ -114,7 +116,7 @@ function DateInputGroup({
|
|
|
114
116
|
)
|
|
115
117
|
] })
|
|
116
118
|
] }),
|
|
117
|
-
|
|
119
|
+
helpTextBelow,
|
|
118
120
|
renderError()
|
|
119
121
|
] });
|
|
120
122
|
}
|
|
@@ -123,7 +125,8 @@ function FormField({
|
|
|
123
125
|
value,
|
|
124
126
|
error,
|
|
125
127
|
onChange,
|
|
126
|
-
classNames
|
|
128
|
+
classNames,
|
|
129
|
+
displayHelpTextBelowLabel = false
|
|
127
130
|
}) {
|
|
128
131
|
const inputId = `question-${question.id}`;
|
|
129
132
|
const errorId = `${inputId}-error`;
|
|
@@ -156,6 +159,8 @@ function FormField({
|
|
|
156
159
|
}
|
|
157
160
|
);
|
|
158
161
|
};
|
|
162
|
+
const helpTextAbove = displayHelpTextBelowLabel ? renderHelpText() : null;
|
|
163
|
+
const helpTextBelow = displayHelpTextBelowLabel ? null : renderHelpText();
|
|
159
164
|
const renderError = () => {
|
|
160
165
|
if (!error) return null;
|
|
161
166
|
return /* @__PURE__ */ jsx("p", { id: errorId, className: classNames?.errorText ?? defaultErrorText, role: "alert", children: error });
|
|
@@ -174,6 +179,7 @@ function FormField({
|
|
|
174
179
|
case "text_field":
|
|
175
180
|
return /* @__PURE__ */ jsxs("div", { className: classNames?.fieldWrapper ?? defaultFieldWrapper, children: [
|
|
176
181
|
renderLabel(),
|
|
182
|
+
helpTextAbove,
|
|
177
183
|
/* @__PURE__ */ jsx(
|
|
178
184
|
"input",
|
|
179
185
|
{
|
|
@@ -186,12 +192,13 @@ function FormField({
|
|
|
186
192
|
...ariaProps
|
|
187
193
|
}
|
|
188
194
|
),
|
|
189
|
-
|
|
195
|
+
helpTextBelow,
|
|
190
196
|
renderError()
|
|
191
197
|
] });
|
|
192
198
|
case "text_area":
|
|
193
199
|
return /* @__PURE__ */ jsxs("div", { className: classNames?.fieldWrapper ?? defaultFieldWrapper, children: [
|
|
194
200
|
renderLabel(),
|
|
201
|
+
helpTextAbove,
|
|
195
202
|
/* @__PURE__ */ jsx(
|
|
196
203
|
"textarea",
|
|
197
204
|
{
|
|
@@ -204,12 +211,13 @@ function FormField({
|
|
|
204
211
|
...ariaProps
|
|
205
212
|
}
|
|
206
213
|
),
|
|
207
|
-
|
|
214
|
+
helpTextBelow,
|
|
208
215
|
renderError()
|
|
209
216
|
] });
|
|
210
217
|
case "select":
|
|
211
218
|
return /* @__PURE__ */ jsxs("div", { className: classNames?.fieldWrapper ?? defaultFieldWrapper, children: [
|
|
212
219
|
renderLabel(),
|
|
220
|
+
helpTextAbove,
|
|
213
221
|
/* @__PURE__ */ jsxs(
|
|
214
222
|
"select",
|
|
215
223
|
{
|
|
@@ -224,12 +232,13 @@ function FormField({
|
|
|
224
232
|
]
|
|
225
233
|
}
|
|
226
234
|
),
|
|
227
|
-
|
|
235
|
+
helpTextBelow,
|
|
228
236
|
renderError()
|
|
229
237
|
] });
|
|
230
238
|
case "radio":
|
|
231
239
|
return /* @__PURE__ */ jsxs("div", { className: classNames?.fieldWrapper ?? defaultFieldWrapper, children: [
|
|
232
240
|
renderLabel(),
|
|
241
|
+
helpTextAbove,
|
|
233
242
|
/* @__PURE__ */ jsx(
|
|
234
243
|
"div",
|
|
235
244
|
{
|
|
@@ -257,7 +266,7 @@ function FormField({
|
|
|
257
266
|
})
|
|
258
267
|
}
|
|
259
268
|
),
|
|
260
|
-
|
|
269
|
+
helpTextBelow,
|
|
261
270
|
renderError()
|
|
262
271
|
] });
|
|
263
272
|
case "date": {
|
|
@@ -283,7 +292,8 @@ function FormField({
|
|
|
283
292
|
itemCls,
|
|
284
293
|
sublabelCls,
|
|
285
294
|
dateInputCls,
|
|
286
|
-
|
|
295
|
+
helpTextAbove,
|
|
296
|
+
helpTextBelow,
|
|
287
297
|
renderError
|
|
288
298
|
}
|
|
289
299
|
);
|
|
@@ -291,6 +301,7 @@ function FormField({
|
|
|
291
301
|
case "number":
|
|
292
302
|
return /* @__PURE__ */ jsxs("div", { className: classNames?.fieldWrapper ?? defaultFieldWrapper, children: [
|
|
293
303
|
renderLabel(),
|
|
304
|
+
helpTextAbove,
|
|
294
305
|
/* @__PURE__ */ jsx(
|
|
295
306
|
"input",
|
|
296
307
|
{
|
|
@@ -305,11 +316,12 @@ function FormField({
|
|
|
305
316
|
...ariaProps
|
|
306
317
|
}
|
|
307
318
|
),
|
|
308
|
-
|
|
319
|
+
helpTextBelow,
|
|
309
320
|
renderError()
|
|
310
321
|
] });
|
|
311
322
|
case "check":
|
|
312
323
|
return /* @__PURE__ */ jsxs("div", { className: classNames?.fieldWrapper ?? defaultFieldWrapper, children: [
|
|
324
|
+
helpTextAbove,
|
|
313
325
|
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
314
326
|
/* @__PURE__ */ jsx(
|
|
315
327
|
"input",
|
|
@@ -327,7 +339,7 @@ function FormField({
|
|
|
327
339
|
question.required && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-1", "aria-hidden": "true", children: "*" })
|
|
328
340
|
] })
|
|
329
341
|
] }),
|
|
330
|
-
|
|
342
|
+
helpTextBelow,
|
|
331
343
|
renderError()
|
|
332
344
|
] });
|
|
333
345
|
default:
|
|
@@ -339,6 +351,7 @@ function BookingForm({
|
|
|
339
351
|
onSubmit,
|
|
340
352
|
submitLabel = "Submit",
|
|
341
353
|
isAdmin = false,
|
|
354
|
+
displayHelpTextBelowLabel = false,
|
|
342
355
|
className = "",
|
|
343
356
|
labelClassName,
|
|
344
357
|
classNames: classNamesProp
|
|
@@ -535,7 +548,8 @@ function BookingForm({
|
|
|
535
548
|
value: values[question.id],
|
|
536
549
|
error: touched[question.id] ? errors[question.id] : void 0,
|
|
537
550
|
onChange: (value) => handleChange(question.id, value),
|
|
538
|
-
classNames
|
|
551
|
+
classNames,
|
|
552
|
+
displayHelpTextBelowLabel
|
|
539
553
|
},
|
|
540
554
|
question.id
|
|
541
555
|
)),
|