@bookinglab/booking-ui-react 1.13.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 +19 -2
- package/dist/index.d.ts +19 -2
- package/dist/index.js +34 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -18,6 +18,9 @@ function DateInputGroup({
|
|
|
18
18
|
itemCls,
|
|
19
19
|
sublabelCls,
|
|
20
20
|
dateInputCls,
|
|
21
|
+
dayInputCls,
|
|
22
|
+
monthInputCls,
|
|
23
|
+
yearInputCls,
|
|
21
24
|
helpTextAbove,
|
|
22
25
|
helpTextBelow,
|
|
23
26
|
renderError
|
|
@@ -57,7 +60,7 @@ function DateInputGroup({
|
|
|
57
60
|
return /* @__PURE__ */ jsxs("fieldset", { className: fieldsetCls, "aria-describedby": hasError ? errorId : void 0, children: [
|
|
58
61
|
/* @__PURE__ */ jsxs("legend", { className: legendCls, children: [
|
|
59
62
|
question.name,
|
|
60
|
-
question.required && /* @__PURE__ */ jsx("span", { className: "
|
|
63
|
+
question.required && /* @__PURE__ */ jsx("span", { className: "ml-1", style: { color: "#DD2D1D" }, "aria-hidden": "true", children: "*" })
|
|
61
64
|
] }),
|
|
62
65
|
helpTextAbove,
|
|
63
66
|
/* @__PURE__ */ jsxs("div", { className: groupCls, role: "group", children: [
|
|
@@ -73,7 +76,7 @@ function DateInputGroup({
|
|
|
73
76
|
maxLength: 2,
|
|
74
77
|
value: parts.day,
|
|
75
78
|
onChange: (e) => handleSubChange("day", e.target.value),
|
|
76
|
-
className: cx(dateInputCls, "w-16"),
|
|
79
|
+
className: cx(dayInputCls ?? dateInputCls, "w-16"),
|
|
77
80
|
"aria-invalid": hasError ? true : void 0,
|
|
78
81
|
"aria-required": question.required || void 0
|
|
79
82
|
}
|
|
@@ -91,7 +94,7 @@ function DateInputGroup({
|
|
|
91
94
|
maxLength: 2,
|
|
92
95
|
value: parts.month,
|
|
93
96
|
onChange: (e) => handleSubChange("month", e.target.value),
|
|
94
|
-
className: cx(dateInputCls, "w-16"),
|
|
97
|
+
className: cx(monthInputCls ?? dateInputCls, "w-16"),
|
|
95
98
|
"aria-invalid": hasError ? true : void 0,
|
|
96
99
|
"aria-required": question.required || void 0
|
|
97
100
|
}
|
|
@@ -109,7 +112,7 @@ function DateInputGroup({
|
|
|
109
112
|
maxLength: 4,
|
|
110
113
|
value: parts.year,
|
|
111
114
|
onChange: (e) => handleSubChange("year", e.target.value),
|
|
112
|
-
className: cx(dateInputCls, "w-24"),
|
|
115
|
+
className: cx(yearInputCls ?? dateInputCls, "w-24"),
|
|
113
116
|
"aria-invalid": hasError ? true : void 0,
|
|
114
117
|
"aria-required": question.required || void 0
|
|
115
118
|
}
|
|
@@ -146,7 +149,7 @@ function FormField({
|
|
|
146
149
|
if (question.detail_type === "heading") return null;
|
|
147
150
|
return /* @__PURE__ */ jsxs("label", { htmlFor: inputId, className: labelClasses, children: [
|
|
148
151
|
question.name,
|
|
149
|
-
question.required && /* @__PURE__ */ jsx("span", { className: "
|
|
152
|
+
question.required && /* @__PURE__ */ jsx("span", { className: "ml-1", style: { color: "#DD2D1D" }, "aria-hidden": "true", children: "*" })
|
|
150
153
|
] });
|
|
151
154
|
};
|
|
152
155
|
const renderHelpText = () => {
|
|
@@ -277,6 +280,10 @@ function FormField({
|
|
|
277
280
|
const groupCls = classNames?.dateInputGroup ?? "flex flex-row gap-3 items-end";
|
|
278
281
|
const legendCls = classNames?.dateLegend ?? labelClasses;
|
|
279
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);
|
|
280
287
|
return /* @__PURE__ */ jsx(
|
|
281
288
|
DateInputGroup,
|
|
282
289
|
{
|
|
@@ -292,6 +299,9 @@ function FormField({
|
|
|
292
299
|
itemCls,
|
|
293
300
|
sublabelCls,
|
|
294
301
|
dateInputCls,
|
|
302
|
+
dayInputCls,
|
|
303
|
+
monthInputCls,
|
|
304
|
+
yearInputCls,
|
|
295
305
|
helpTextAbove,
|
|
296
306
|
helpTextBelow,
|
|
297
307
|
renderError
|
|
@@ -336,7 +346,7 @@ function FormField({
|
|
|
336
346
|
),
|
|
337
347
|
/* @__PURE__ */ jsxs("label", { htmlFor: inputId, className: checkboxLabelClasses, children: [
|
|
338
348
|
question.name,
|
|
339
|
-
question.required && /* @__PURE__ */ jsx("span", { className: "
|
|
349
|
+
question.required && /* @__PURE__ */ jsx("span", { className: "ml-1", style: { color: "#DD2D1D" }, "aria-hidden": "true", children: "*" })
|
|
340
350
|
] })
|
|
341
351
|
] }),
|
|
342
352
|
helpTextBelow,
|
|
@@ -475,6 +485,24 @@ function BookingForm({
|
|
|
475
485
|
return `Maximum value is ${question.settings.max}`;
|
|
476
486
|
}
|
|
477
487
|
}
|
|
488
|
+
if (question.detail_type === "date" && question.dateLimiter?.enabled && typeof value === "string" && value !== "") {
|
|
489
|
+
const toDatePart = (iso) => {
|
|
490
|
+
if (!iso || typeof iso !== "string") return null;
|
|
491
|
+
const m = iso.match(/^(\d{4}-\d{2}-\d{2})/);
|
|
492
|
+
return m ? m[1] : null;
|
|
493
|
+
};
|
|
494
|
+
const min = toDatePart(question.dateLimiter.minimumDate);
|
|
495
|
+
const max = toDatePart(question.dateLimiter.maximumDate);
|
|
496
|
+
const v = value;
|
|
497
|
+
const outOfRange = min && v < min || max && v > max;
|
|
498
|
+
if (outOfRange) {
|
|
499
|
+
if (question.dateLimiter.errorText) return question.dateLimiter.errorText;
|
|
500
|
+
if (min && max) return `Date must be between ${min} and ${max}`;
|
|
501
|
+
if (min) return `Date must be on or after ${min}`;
|
|
502
|
+
if (max) return `Date must be on or before ${max}`;
|
|
503
|
+
return "Date is outside the allowed range";
|
|
504
|
+
}
|
|
505
|
+
}
|
|
478
506
|
return null;
|
|
479
507
|
}, []);
|
|
480
508
|
const validateAll = useCallback(() => {
|