@bookinglab/booking-ui-react 1.12.1 → 1.14.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 +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +41 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -18,7 +18,11 @@ function DateInputGroup({
|
|
|
18
18
|
itemCls,
|
|
19
19
|
sublabelCls,
|
|
20
20
|
dateInputCls,
|
|
21
|
-
|
|
21
|
+
dayInputCls,
|
|
22
|
+
monthInputCls,
|
|
23
|
+
yearInputCls,
|
|
24
|
+
helpTextAbove,
|
|
25
|
+
helpTextBelow,
|
|
22
26
|
renderError
|
|
23
27
|
}) {
|
|
24
28
|
const parseValue = (raw) => {
|
|
@@ -56,8 +60,9 @@ function DateInputGroup({
|
|
|
56
60
|
return /* @__PURE__ */ jsxs("fieldset", { className: fieldsetCls, "aria-describedby": hasError ? errorId : void 0, children: [
|
|
57
61
|
/* @__PURE__ */ jsxs("legend", { className: legendCls, children: [
|
|
58
62
|
question.name,
|
|
59
|
-
question.required && /* @__PURE__ */ jsx("span", { className: "
|
|
63
|
+
question.required && /* @__PURE__ */ jsx("span", { className: "ml-1", style: { color: "#DD2D1D" }, "aria-hidden": "true", children: "*" })
|
|
60
64
|
] }),
|
|
65
|
+
helpTextAbove,
|
|
61
66
|
/* @__PURE__ */ jsxs("div", { className: groupCls, role: "group", children: [
|
|
62
67
|
/* @__PURE__ */ jsxs("div", { className: itemCls, children: [
|
|
63
68
|
/* @__PURE__ */ jsx("label", { htmlFor: dayId, className: sublabelCls, children: "Day" }),
|
|
@@ -71,7 +76,7 @@ function DateInputGroup({
|
|
|
71
76
|
maxLength: 2,
|
|
72
77
|
value: parts.day,
|
|
73
78
|
onChange: (e) => handleSubChange("day", e.target.value),
|
|
74
|
-
className: cx(dateInputCls, "w-16"),
|
|
79
|
+
className: cx(dayInputCls ?? dateInputCls, "w-16"),
|
|
75
80
|
"aria-invalid": hasError ? true : void 0,
|
|
76
81
|
"aria-required": question.required || void 0
|
|
77
82
|
}
|
|
@@ -89,7 +94,7 @@ function DateInputGroup({
|
|
|
89
94
|
maxLength: 2,
|
|
90
95
|
value: parts.month,
|
|
91
96
|
onChange: (e) => handleSubChange("month", e.target.value),
|
|
92
|
-
className: cx(dateInputCls, "w-16"),
|
|
97
|
+
className: cx(monthInputCls ?? dateInputCls, "w-16"),
|
|
93
98
|
"aria-invalid": hasError ? true : void 0,
|
|
94
99
|
"aria-required": question.required || void 0
|
|
95
100
|
}
|
|
@@ -107,14 +112,14 @@ function DateInputGroup({
|
|
|
107
112
|
maxLength: 4,
|
|
108
113
|
value: parts.year,
|
|
109
114
|
onChange: (e) => handleSubChange("year", e.target.value),
|
|
110
|
-
className: cx(dateInputCls, "w-24"),
|
|
115
|
+
className: cx(yearInputCls ?? dateInputCls, "w-24"),
|
|
111
116
|
"aria-invalid": hasError ? true : void 0,
|
|
112
117
|
"aria-required": question.required || void 0
|
|
113
118
|
}
|
|
114
119
|
)
|
|
115
120
|
] })
|
|
116
121
|
] }),
|
|
117
|
-
|
|
122
|
+
helpTextBelow,
|
|
118
123
|
renderError()
|
|
119
124
|
] });
|
|
120
125
|
}
|
|
@@ -123,7 +128,8 @@ function FormField({
|
|
|
123
128
|
value,
|
|
124
129
|
error,
|
|
125
130
|
onChange,
|
|
126
|
-
classNames
|
|
131
|
+
classNames,
|
|
132
|
+
displayHelpTextBelowLabel = false
|
|
127
133
|
}) {
|
|
128
134
|
const inputId = `question-${question.id}`;
|
|
129
135
|
const errorId = `${inputId}-error`;
|
|
@@ -143,7 +149,7 @@ function FormField({
|
|
|
143
149
|
if (question.detail_type === "heading") return null;
|
|
144
150
|
return /* @__PURE__ */ jsxs("label", { htmlFor: inputId, className: labelClasses, children: [
|
|
145
151
|
question.name,
|
|
146
|
-
question.required && /* @__PURE__ */ jsx("span", { className: "
|
|
152
|
+
question.required && /* @__PURE__ */ jsx("span", { className: "ml-1", style: { color: "#DD2D1D" }, "aria-hidden": "true", children: "*" })
|
|
147
153
|
] });
|
|
148
154
|
};
|
|
149
155
|
const renderHelpText = () => {
|
|
@@ -156,6 +162,8 @@ function FormField({
|
|
|
156
162
|
}
|
|
157
163
|
);
|
|
158
164
|
};
|
|
165
|
+
const helpTextAbove = displayHelpTextBelowLabel ? renderHelpText() : null;
|
|
166
|
+
const helpTextBelow = displayHelpTextBelowLabel ? null : renderHelpText();
|
|
159
167
|
const renderError = () => {
|
|
160
168
|
if (!error) return null;
|
|
161
169
|
return /* @__PURE__ */ jsx("p", { id: errorId, className: classNames?.errorText ?? defaultErrorText, role: "alert", children: error });
|
|
@@ -174,6 +182,7 @@ function FormField({
|
|
|
174
182
|
case "text_field":
|
|
175
183
|
return /* @__PURE__ */ jsxs("div", { className: classNames?.fieldWrapper ?? defaultFieldWrapper, children: [
|
|
176
184
|
renderLabel(),
|
|
185
|
+
helpTextAbove,
|
|
177
186
|
/* @__PURE__ */ jsx(
|
|
178
187
|
"input",
|
|
179
188
|
{
|
|
@@ -186,12 +195,13 @@ function FormField({
|
|
|
186
195
|
...ariaProps
|
|
187
196
|
}
|
|
188
197
|
),
|
|
189
|
-
|
|
198
|
+
helpTextBelow,
|
|
190
199
|
renderError()
|
|
191
200
|
] });
|
|
192
201
|
case "text_area":
|
|
193
202
|
return /* @__PURE__ */ jsxs("div", { className: classNames?.fieldWrapper ?? defaultFieldWrapper, children: [
|
|
194
203
|
renderLabel(),
|
|
204
|
+
helpTextAbove,
|
|
195
205
|
/* @__PURE__ */ jsx(
|
|
196
206
|
"textarea",
|
|
197
207
|
{
|
|
@@ -204,12 +214,13 @@ function FormField({
|
|
|
204
214
|
...ariaProps
|
|
205
215
|
}
|
|
206
216
|
),
|
|
207
|
-
|
|
217
|
+
helpTextBelow,
|
|
208
218
|
renderError()
|
|
209
219
|
] });
|
|
210
220
|
case "select":
|
|
211
221
|
return /* @__PURE__ */ jsxs("div", { className: classNames?.fieldWrapper ?? defaultFieldWrapper, children: [
|
|
212
222
|
renderLabel(),
|
|
223
|
+
helpTextAbove,
|
|
213
224
|
/* @__PURE__ */ jsxs(
|
|
214
225
|
"select",
|
|
215
226
|
{
|
|
@@ -224,12 +235,13 @@ function FormField({
|
|
|
224
235
|
]
|
|
225
236
|
}
|
|
226
237
|
),
|
|
227
|
-
|
|
238
|
+
helpTextBelow,
|
|
228
239
|
renderError()
|
|
229
240
|
] });
|
|
230
241
|
case "radio":
|
|
231
242
|
return /* @__PURE__ */ jsxs("div", { className: classNames?.fieldWrapper ?? defaultFieldWrapper, children: [
|
|
232
243
|
renderLabel(),
|
|
244
|
+
helpTextAbove,
|
|
233
245
|
/* @__PURE__ */ jsx(
|
|
234
246
|
"div",
|
|
235
247
|
{
|
|
@@ -257,7 +269,7 @@ function FormField({
|
|
|
257
269
|
})
|
|
258
270
|
}
|
|
259
271
|
),
|
|
260
|
-
|
|
272
|
+
helpTextBelow,
|
|
261
273
|
renderError()
|
|
262
274
|
] });
|
|
263
275
|
case "date": {
|
|
@@ -268,6 +280,10 @@ function FormField({
|
|
|
268
280
|
const groupCls = classNames?.dateInputGroup ?? "flex flex-row gap-3 items-end";
|
|
269
281
|
const legendCls = classNames?.dateLegend ?? labelClasses;
|
|
270
282
|
const fieldsetCls = classNames?.dateFieldset ?? (classNames?.fieldWrapper ?? defaultFieldWrapper);
|
|
283
|
+
const wrapPerInput = (cls) => cls === void 0 ? void 0 : hasError ? cx(cls, classNames?.inputError ?? defaultInputError) : cls;
|
|
284
|
+
const dayInputCls = wrapPerInput(classNames?.dateInputDay);
|
|
285
|
+
const monthInputCls = wrapPerInput(classNames?.dateInputMonth);
|
|
286
|
+
const yearInputCls = wrapPerInput(classNames?.dateInputYear);
|
|
271
287
|
return /* @__PURE__ */ jsx(
|
|
272
288
|
DateInputGroup,
|
|
273
289
|
{
|
|
@@ -283,7 +299,11 @@ function FormField({
|
|
|
283
299
|
itemCls,
|
|
284
300
|
sublabelCls,
|
|
285
301
|
dateInputCls,
|
|
286
|
-
|
|
302
|
+
dayInputCls,
|
|
303
|
+
monthInputCls,
|
|
304
|
+
yearInputCls,
|
|
305
|
+
helpTextAbove,
|
|
306
|
+
helpTextBelow,
|
|
287
307
|
renderError
|
|
288
308
|
}
|
|
289
309
|
);
|
|
@@ -291,6 +311,7 @@ function FormField({
|
|
|
291
311
|
case "number":
|
|
292
312
|
return /* @__PURE__ */ jsxs("div", { className: classNames?.fieldWrapper ?? defaultFieldWrapper, children: [
|
|
293
313
|
renderLabel(),
|
|
314
|
+
helpTextAbove,
|
|
294
315
|
/* @__PURE__ */ jsx(
|
|
295
316
|
"input",
|
|
296
317
|
{
|
|
@@ -305,11 +326,12 @@ function FormField({
|
|
|
305
326
|
...ariaProps
|
|
306
327
|
}
|
|
307
328
|
),
|
|
308
|
-
|
|
329
|
+
helpTextBelow,
|
|
309
330
|
renderError()
|
|
310
331
|
] });
|
|
311
332
|
case "check":
|
|
312
333
|
return /* @__PURE__ */ jsxs("div", { className: classNames?.fieldWrapper ?? defaultFieldWrapper, children: [
|
|
334
|
+
helpTextAbove,
|
|
313
335
|
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
314
336
|
/* @__PURE__ */ jsx(
|
|
315
337
|
"input",
|
|
@@ -324,10 +346,10 @@ function FormField({
|
|
|
324
346
|
),
|
|
325
347
|
/* @__PURE__ */ jsxs("label", { htmlFor: inputId, className: checkboxLabelClasses, children: [
|
|
326
348
|
question.name,
|
|
327
|
-
question.required && /* @__PURE__ */ jsx("span", { className: "
|
|
349
|
+
question.required && /* @__PURE__ */ jsx("span", { className: "ml-1", style: { color: "#DD2D1D" }, "aria-hidden": "true", children: "*" })
|
|
328
350
|
] })
|
|
329
351
|
] }),
|
|
330
|
-
|
|
352
|
+
helpTextBelow,
|
|
331
353
|
renderError()
|
|
332
354
|
] });
|
|
333
355
|
default:
|
|
@@ -339,6 +361,7 @@ function BookingForm({
|
|
|
339
361
|
onSubmit,
|
|
340
362
|
submitLabel = "Submit",
|
|
341
363
|
isAdmin = false,
|
|
364
|
+
displayHelpTextBelowLabel = false,
|
|
342
365
|
className = "",
|
|
343
366
|
labelClassName,
|
|
344
367
|
classNames: classNamesProp
|
|
@@ -535,7 +558,8 @@ function BookingForm({
|
|
|
535
558
|
value: values[question.id],
|
|
536
559
|
error: touched[question.id] ? errors[question.id] : void 0,
|
|
537
560
|
onChange: (value) => handleChange(question.id, value),
|
|
538
|
-
classNames
|
|
561
|
+
classNames,
|
|
562
|
+
displayHelpTextBelowLabel
|
|
539
563
|
},
|
|
540
564
|
question.id
|
|
541
565
|
)),
|