@anker-in/ui 0.3.3 → 0.3.5
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.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +139 -84
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +139 -84
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -10914,7 +10914,6 @@ var QuestionnaireForm2 = ({
|
|
|
10914
10914
|
return true;
|
|
10915
10915
|
});
|
|
10916
10916
|
}, [questions, hasBookedBefore]);
|
|
10917
|
-
console.log(error, pageData);
|
|
10918
10917
|
React15.useEffect(() => {
|
|
10919
10918
|
if (hasBookedBeforeInitialized.current) return;
|
|
10920
10919
|
if (hasBookedBeforeQuestion && hasBookedBeforeQuestionId) {
|
|
@@ -10987,7 +10986,7 @@ var QuestionnaireForm2 = ({
|
|
|
10987
10986
|
if (!emailRegex.test(value)) {
|
|
10988
10987
|
setErrors((prev) => ({
|
|
10989
10988
|
...prev,
|
|
10990
|
-
[questionId]: "Please enter a valid email address"
|
|
10989
|
+
[questionId]: pageData?.emailValidError || "Please enter a valid email address"
|
|
10991
10990
|
}));
|
|
10992
10991
|
}
|
|
10993
10992
|
};
|
|
@@ -11025,7 +11024,7 @@ var QuestionnaireForm2 = ({
|
|
|
11025
11024
|
const questionId = getQuestionId(question);
|
|
11026
11025
|
const value = responses[questionId];
|
|
11027
11026
|
if (!value || Array.isArray(value) && value.length === 0) {
|
|
11028
|
-
newErrors[questionId] = "This field is required";
|
|
11027
|
+
newErrors[questionId] = pageData?.fieldRuquired || "This field is required";
|
|
11029
11028
|
}
|
|
11030
11029
|
}
|
|
11031
11030
|
});
|
|
@@ -11036,7 +11035,7 @@ var QuestionnaireForm2 = ({
|
|
|
11036
11035
|
);
|
|
11037
11036
|
if (!allAgreed) {
|
|
11038
11037
|
setAgreementError(
|
|
11039
|
-
"Please agree to all terms and conditions to continue"
|
|
11038
|
+
pageData?.agreeRuquired || "Please agree to all terms and conditions to continue"
|
|
11040
11039
|
);
|
|
11041
11040
|
setErrors(newErrors);
|
|
11042
11041
|
return false;
|
|
@@ -11457,6 +11456,10 @@ var DateTimePicker2 = ({
|
|
|
11457
11456
|
);
|
|
11458
11457
|
const [isInitialized, setIsInitialized] = React15.useState(() => !!booking);
|
|
11459
11458
|
const [hasResolvedBookingSlot, setHasResolvedBookingSlot] = React15.useState(false);
|
|
11459
|
+
const autoSelectLockRef = React15.useRef(false);
|
|
11460
|
+
React15.useEffect(() => {
|
|
11461
|
+
autoSelectLockRef.current = false;
|
|
11462
|
+
}, [demoRoomCode]);
|
|
11460
11463
|
const {
|
|
11461
11464
|
createBooking,
|
|
11462
11465
|
loading: bookingLoading,
|
|
@@ -11468,13 +11471,17 @@ var DateTimePicker2 = ({
|
|
|
11468
11471
|
error: editError
|
|
11469
11472
|
} = useEditBooking(apiClient);
|
|
11470
11473
|
const isManagedByParent = demoRoomLoading !== void 0;
|
|
11471
|
-
const {
|
|
11474
|
+
const {
|
|
11475
|
+
data: fetchedDemoRoom,
|
|
11476
|
+
loading: fetchedDemoRoomLoading
|
|
11477
|
+
} = useDemoRoom(
|
|
11472
11478
|
apiClient,
|
|
11473
11479
|
demoRoomCode || "",
|
|
11474
11480
|
locale,
|
|
11475
11481
|
{ enabled: !isManagedByParent && !demoRoomProp && !!demoRoomCode }
|
|
11476
11482
|
);
|
|
11477
11483
|
const demoRoom = demoRoomProp ?? fetchedDemoRoom;
|
|
11484
|
+
const effectiveDemoRoomLoading = !demoRoom && !!(isManagedByParent ? demoRoomLoading : fetchedDemoRoomLoading);
|
|
11478
11485
|
const isPodPurpose = selectedPurposeType === "pod";
|
|
11479
11486
|
const effectiveQuestionnaireId = isPodPurpose && demoRoom?.pod_config?.questionnaire_id || demoRoom?.questionnaire_id;
|
|
11480
11487
|
const { data: questionnaire, loading: questionnaireLoading } = useQuestionnaire(
|
|
@@ -11523,7 +11530,28 @@ var DateTimePicker2 = ({
|
|
|
11523
11530
|
return dates;
|
|
11524
11531
|
}, [timeslotsData, demoRoom?.timezone, timezone5]);
|
|
11525
11532
|
React15.useEffect(() => {
|
|
11526
|
-
if (
|
|
11533
|
+
if (booking || isInitialized || autoSelectLockRef.current || !demoRoom?.timeslots?.length)
|
|
11534
|
+
return;
|
|
11535
|
+
const tz = demoRoom?.timezone || timezone5;
|
|
11536
|
+
const now2 = tz ? dayjs4__default.default().tz(tz) : dayjs4__default.default();
|
|
11537
|
+
const nearestSlot = demoRoom.timeslots.filter((slot) => {
|
|
11538
|
+
const slotTime = tz ? dayjs4__default.default(slot.start_time).tz(tz) : dayjs4__default.default(slot.start_time);
|
|
11539
|
+
return slot.status === "available" && slotTime.isAfter(now2);
|
|
11540
|
+
}).sort((a, b) => {
|
|
11541
|
+
const timeA = tz ? dayjs4__default.default(a.start_time).tz(tz) : dayjs4__default.default(a.start_time);
|
|
11542
|
+
const timeB = tz ? dayjs4__default.default(b.start_time).tz(tz) : dayjs4__default.default(b.start_time);
|
|
11543
|
+
return timeA.unix() - timeB.unix();
|
|
11544
|
+
})[0];
|
|
11545
|
+
if (!nearestSlot) return;
|
|
11546
|
+
autoSelectLockRef.current = true;
|
|
11547
|
+
const nearestDate = tz ? dayjs4__default.default(nearestSlot.start_time).tz(tz) : dayjs4__default.default(nearestSlot.start_time);
|
|
11548
|
+
setSelectedDate(nearestDate);
|
|
11549
|
+
setCalendarValue(nearestDate);
|
|
11550
|
+
setSelectedTimeslotId(nearestSlot.id);
|
|
11551
|
+
setIsInitialized(true);
|
|
11552
|
+
}, [booking, isInitialized, demoRoom?.timeslots, demoRoom?.timezone, timezone5]);
|
|
11553
|
+
React15.useEffect(() => {
|
|
11554
|
+
if (!timeslotsData?.timeslots || isInitialized || autoSelectLockRef.current) return;
|
|
11527
11555
|
const tz = demoRoom?.timezone || timezone5;
|
|
11528
11556
|
const now2 = tz ? dayjs4__default.default().tz(tz) : dayjs4__default.default();
|
|
11529
11557
|
const availableTimeslots = timeslotsData.timeslots.filter((slot) => {
|
|
@@ -11538,16 +11566,25 @@ var DateTimePicker2 = ({
|
|
|
11538
11566
|
});
|
|
11539
11567
|
const nearestSlot = sortedSlots[0];
|
|
11540
11568
|
const nearestDate = tz ? dayjs4__default.default(nearestSlot.start_time).tz(tz) : dayjs4__default.default(nearestSlot.start_time);
|
|
11569
|
+
autoSelectLockRef.current = true;
|
|
11541
11570
|
setSelectedDate(nearestDate);
|
|
11542
11571
|
setCalendarValue(nearestDate);
|
|
11543
11572
|
setSelectedTimeslotId(nearestSlot.id);
|
|
11544
11573
|
setIsInitialized(true);
|
|
11545
|
-
} else if (!selectedDate) {
|
|
11574
|
+
} else if (!selectedDate && !effectiveDemoRoomLoading) {
|
|
11575
|
+
autoSelectLockRef.current = true;
|
|
11546
11576
|
setSelectedDate(now2);
|
|
11547
11577
|
setCalendarValue(now2);
|
|
11548
11578
|
setIsInitialized(true);
|
|
11549
11579
|
}
|
|
11550
|
-
}, [
|
|
11580
|
+
}, [
|
|
11581
|
+
timeslotsData,
|
|
11582
|
+
isInitialized,
|
|
11583
|
+
selectedDate,
|
|
11584
|
+
demoRoom?.timezone,
|
|
11585
|
+
timezone5,
|
|
11586
|
+
effectiveDemoRoomLoading
|
|
11587
|
+
]);
|
|
11551
11588
|
React15.useEffect(() => {
|
|
11552
11589
|
if (!timeslotsData?.timeslots || !isInitialized) return;
|
|
11553
11590
|
if (selectedDate && selectedDate.isSame(calendarValue, "month")) {
|
|
@@ -12521,6 +12558,9 @@ var BookingFormO2O = ({
|
|
|
12521
12558
|
const [selectedPurposeType, setSelectedPurposeType] = React15.useState(
|
|
12522
12559
|
() => initialBusinessType || purposeOptions[0]?.type || ""
|
|
12523
12560
|
);
|
|
12561
|
+
const [isPurposeConfirmed, setIsPurposeConfirmed] = React15.useState(
|
|
12562
|
+
() => !!initialBusinessType && purposeOptions.some((item) => item.type === initialBusinessType)
|
|
12563
|
+
);
|
|
12524
12564
|
React15.useEffect(() => {
|
|
12525
12565
|
setSelectedPurposeType((currentType) => {
|
|
12526
12566
|
if (purposeOptions.some((item) => item.type === currentType)) {
|
|
@@ -12534,11 +12574,16 @@ var BookingFormO2O = ({
|
|
|
12534
12574
|
}
|
|
12535
12575
|
return purposeOptions[0]?.type || "";
|
|
12536
12576
|
});
|
|
12577
|
+
const resolvedFromExplicitSource = !!initialBusinessType && purposeOptions.some((item) => item.type === initialBusinessType) || !!booking?.business_type && purposeOptions.some((item) => item.type === booking.business_type);
|
|
12578
|
+
if (resolvedFromExplicitSource) {
|
|
12579
|
+
setIsPurposeConfirmed(true);
|
|
12580
|
+
}
|
|
12537
12581
|
}, [purposeOptions, initialBusinessType, booking?.business_type]);
|
|
12538
12582
|
const selectedPurpose = React15.useMemo(() => {
|
|
12539
|
-
return purposeOptions.find((item) => item.type === selectedPurposeType) ||
|
|
12583
|
+
return purposeOptions.find((item) => item.type === selectedPurposeType) || {};
|
|
12540
12584
|
}, [purposeOptions, selectedPurposeType]);
|
|
12541
|
-
const
|
|
12585
|
+
const isPodSelected = isPurposeConfirmed && selectedPurpose?.type === "pod";
|
|
12586
|
+
const selectedPodContent = isPodSelected ? selectedPurpose?.podContent : void 0;
|
|
12542
12587
|
const selectedPodDescription = getPodContentDescription(selectedPodContent);
|
|
12543
12588
|
const podDesignId = React15.useMemo(() => getQueryParam("design_id"), []);
|
|
12544
12589
|
const isPodDesignEditMode = !!podDesignId || !!booking?.design_project_id;
|
|
@@ -12620,85 +12665,95 @@ var BookingFormO2O = ({
|
|
|
12620
12665
|
}
|
|
12621
12666
|
) }),
|
|
12622
12667
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-[#f5f5f5]", children: [
|
|
12623
|
-
!!purposeOptions.length && /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("py-[40px] l:py-[24px]", className), children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12624
|
-
|
|
12625
|
-
|
|
12626
|
-
|
|
12627
|
-
|
|
12628
|
-
|
|
12629
|
-
className: "block text-[16px] font-bold text-[#080A0F] l:text-[14px]",
|
|
12630
|
-
children: getPurposeLabel(pageData)
|
|
12631
|
-
}
|
|
12632
|
-
),
|
|
12633
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative mt-[14px]", children: [
|
|
12634
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12635
|
-
"select",
|
|
12636
|
-
{
|
|
12637
|
-
id: "booking-purpose-select",
|
|
12638
|
-
value: selectedPurpose?.type || "",
|
|
12639
|
-
onChange: (event2) => {
|
|
12640
|
-
setSelectedPurposeType(event2.target.value);
|
|
12641
|
-
},
|
|
12642
|
-
disabled: !!token,
|
|
12643
|
-
className: cn(
|
|
12644
|
-
"h-[48px] w-full appearance-none rounded-[8px] border border-[#D9DCE1] bg-white px-[16px] pr-[48px] text-[16px] font-medium text-[#2A2C32] outline-none transition-colors focus:border-[#080A0F] focus:ring-2 focus:ring-[#3ADB67]/30 l:text-[14px]",
|
|
12645
|
-
token && "pointer-events-none cursor-not-allowed opacity-50"
|
|
12646
|
-
),
|
|
12647
|
-
children: purposeOptions.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
12648
|
-
"option",
|
|
12649
|
-
{
|
|
12650
|
-
value: item.type || "",
|
|
12651
|
-
children: item.label || item.type
|
|
12652
|
-
},
|
|
12653
|
-
`${item.type || item.label || "purpose"}-${index}`
|
|
12654
|
-
))
|
|
12655
|
-
}
|
|
12656
|
-
),
|
|
12657
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pointer-events-none absolute right-[14px] top-1/2 flex -translate-y-1/2 text-[#080A0F]", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronIcon2, {}) })
|
|
12658
|
-
] }),
|
|
12659
|
-
!!selectedPurpose?.purposeNote && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-[16px] max-w-[720px] text-[14px] font-medium leading-[1.35] text-[#080A0F] l:text-[13px]", children: selectedPurpose.purposeNote })
|
|
12660
|
-
] }),
|
|
12661
|
-
selectedPurpose?.type === "pod" && !!selectedPodContent && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "rounded-[16px] bg-white px-[28px] py-[20px] l:px-[16px] l:py-[20px]", children: [
|
|
12662
|
-
!!selectedPodContent.title && /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-[16px] font-bold text-[#080A0F] l:text-[14px]", children: selectedPodContent.title }),
|
|
12663
|
-
!!selectedPodDescription && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-[6px] text-[13px] font-medium leading-[1.35] text-[#080A0F] l:text-[12px]", children: selectedPodDescription }),
|
|
12664
|
-
!!selectedPodImage && /* @__PURE__ */ jsxRuntime.jsx(
|
|
12665
|
-
"img",
|
|
12666
|
-
{
|
|
12667
|
-
src: selectedPodImage,
|
|
12668
|
-
alt: selectedPodContent.imageAlt || selectedPodContent.title || "",
|
|
12669
|
-
className: "mt-[12px] h-[220px] rounded-[8px] object-cover l:h-auto"
|
|
12670
|
-
}
|
|
12668
|
+
!!purposeOptions.length && /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("py-[40px] l:py-[24px]", className), children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12669
|
+
"div",
|
|
12670
|
+
{
|
|
12671
|
+
className: cn(
|
|
12672
|
+
"grid gap-[16px] l:grid-cols-1",
|
|
12673
|
+
isPodSelected && "grid-cols-2"
|
|
12671
12674
|
),
|
|
12672
|
-
|
|
12673
|
-
"
|
|
12674
|
-
|
|
12675
|
-
|
|
12676
|
-
|
|
12677
|
-
|
|
12678
|
-
|
|
12679
|
-
|
|
12680
|
-
|
|
12681
|
-
rel: "noopener noreferrer",
|
|
12682
|
-
className: cn(
|
|
12683
|
-
"mt-[12px] inline-flex h-[42px] items-center justify-center gap-[6px] rounded-full bg-[#080A0F] px-[24px] text-[14px] font-bold text-white transition-colors hover:bg-[#2A2C32]",
|
|
12684
|
-
isPodButtonDisabled && "pointer-events-none cursor-not-allowed opacity-50"
|
|
12675
|
+
children: [
|
|
12676
|
+
/* @__PURE__ */ jsxRuntime.jsxs("section", { className: "rounded-[16px] bg-white px-[28px] py-[24px] l:px-[16px] l:py-[20px]", children: [
|
|
12677
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12678
|
+
"label",
|
|
12679
|
+
{
|
|
12680
|
+
htmlFor: "booking-purpose-select",
|
|
12681
|
+
className: "block text-[16px] font-bold text-[#080A0F] l:text-[14px]",
|
|
12682
|
+
children: getPurposeLabel(pageData)
|
|
12683
|
+
}
|
|
12685
12684
|
),
|
|
12686
|
-
children: [
|
|
12687
|
-
|
|
12688
|
-
"
|
|
12685
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative mt-[14px]", children: [
|
|
12686
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12687
|
+
"select",
|
|
12689
12688
|
{
|
|
12690
|
-
|
|
12691
|
-
|
|
12692
|
-
|
|
12693
|
-
|
|
12689
|
+
id: "booking-purpose-select",
|
|
12690
|
+
value: selectedPurpose?.type || "",
|
|
12691
|
+
onChange: (event2) => {
|
|
12692
|
+
setSelectedPurposeType(event2.target.value);
|
|
12693
|
+
setIsPurposeConfirmed(true);
|
|
12694
|
+
},
|
|
12695
|
+
disabled: !!token,
|
|
12696
|
+
className: cn(
|
|
12697
|
+
"h-[48px] w-full appearance-none rounded-[8px] border border-[#D9DCE1] bg-white px-[16px] pr-[48px] text-[16px] font-medium text-[#2A2C32] outline-none transition-colors focus:border-[#080A0F] focus:ring-2 focus:ring-[#3ADB67]/30 l:text-[14px]",
|
|
12698
|
+
token && "pointer-events-none cursor-not-allowed opacity-50"
|
|
12699
|
+
),
|
|
12700
|
+
children: purposeOptions.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
12701
|
+
"option",
|
|
12702
|
+
{
|
|
12703
|
+
value: item.type || "",
|
|
12704
|
+
children: item.label || item.type
|
|
12705
|
+
},
|
|
12706
|
+
`${item.type || item.label || "purpose"}-${index}`
|
|
12707
|
+
))
|
|
12694
12708
|
}
|
|
12695
12709
|
),
|
|
12696
|
-
|
|
12697
|
-
]
|
|
12698
|
-
|
|
12699
|
-
|
|
12700
|
-
|
|
12701
|
-
|
|
12710
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pointer-events-none absolute right-[14px] top-1/2 flex -translate-y-1/2 text-[#080A0F]", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronIcon2, {}) })
|
|
12711
|
+
] }),
|
|
12712
|
+
!!selectedPurpose?.purposeNote && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-[16px] max-w-[720px] text-[14px] font-medium leading-[1.35] text-[#080A0F] l:text-[13px]", children: selectedPurpose.purposeNote })
|
|
12713
|
+
] }),
|
|
12714
|
+
isPodSelected && !!selectedPodContent && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "rounded-[16px] bg-white px-[28px] py-[20px] l:px-[16px] l:py-[20px]", children: [
|
|
12715
|
+
!!selectedPodContent.title && /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-[16px] font-bold text-[#080A0F] l:text-[14px]", children: selectedPodContent.title }),
|
|
12716
|
+
!!selectedPodDescription && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-[6px] text-[13px] font-medium leading-[1.35] text-[#080A0F] l:text-[12px]", children: selectedPodDescription }),
|
|
12717
|
+
!!selectedPodImage && /* @__PURE__ */ jsxRuntime.jsx(
|
|
12718
|
+
"img",
|
|
12719
|
+
{
|
|
12720
|
+
src: selectedPodImage,
|
|
12721
|
+
alt: selectedPodContent.imageAlt || selectedPodContent.title || "",
|
|
12722
|
+
className: "mt-[12px] h-[220px] rounded-[8px] object-cover l:h-auto"
|
|
12723
|
+
}
|
|
12724
|
+
),
|
|
12725
|
+
!!selectedPodButtonText && (booking?.print_status === "unprinted" && booking?.design_project_id || !token) && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12726
|
+
"a",
|
|
12727
|
+
{
|
|
12728
|
+
href: selectedPodButtonLink || "#",
|
|
12729
|
+
"aria-disabled": isPodButtonDisabled,
|
|
12730
|
+
tabIndex: isPodButtonDisabled ? -1 : void 0,
|
|
12731
|
+
onClick: (event2) => {
|
|
12732
|
+
if (isPodButtonDisabled) event2.preventDefault();
|
|
12733
|
+
},
|
|
12734
|
+
rel: "noopener noreferrer",
|
|
12735
|
+
className: cn(
|
|
12736
|
+
"mt-[12px] inline-flex h-[42px] items-center justify-center gap-[6px] rounded-full bg-[#080A0F] px-[24px] text-[14px] font-bold text-white transition-colors hover:bg-[#2A2C32]",
|
|
12737
|
+
isPodButtonDisabled && "pointer-events-none cursor-not-allowed opacity-50"
|
|
12738
|
+
),
|
|
12739
|
+
children: [
|
|
12740
|
+
selectedPodButtonIcon && /* @__PURE__ */ jsxRuntime.jsx(
|
|
12741
|
+
"img",
|
|
12742
|
+
{
|
|
12743
|
+
src: selectedPodButtonIcon,
|
|
12744
|
+
alt: "",
|
|
12745
|
+
className: "h-[16px] w-[16px]",
|
|
12746
|
+
"aria-hidden": "true"
|
|
12747
|
+
}
|
|
12748
|
+
),
|
|
12749
|
+
selectedPodButtonText
|
|
12750
|
+
]
|
|
12751
|
+
}
|
|
12752
|
+
)
|
|
12753
|
+
] })
|
|
12754
|
+
]
|
|
12755
|
+
}
|
|
12756
|
+
) }),
|
|
12702
12757
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12703
12758
|
DateTimePicker_default2,
|
|
12704
12759
|
{
|