@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.mjs
CHANGED
|
@@ -10900,7 +10900,6 @@ var QuestionnaireForm2 = ({
|
|
|
10900
10900
|
return true;
|
|
10901
10901
|
});
|
|
10902
10902
|
}, [questions, hasBookedBefore]);
|
|
10903
|
-
console.log(error, pageData);
|
|
10904
10903
|
useEffect(() => {
|
|
10905
10904
|
if (hasBookedBeforeInitialized.current) return;
|
|
10906
10905
|
if (hasBookedBeforeQuestion && hasBookedBeforeQuestionId) {
|
|
@@ -10973,7 +10972,7 @@ var QuestionnaireForm2 = ({
|
|
|
10973
10972
|
if (!emailRegex.test(value)) {
|
|
10974
10973
|
setErrors((prev) => ({
|
|
10975
10974
|
...prev,
|
|
10976
|
-
[questionId]: "Please enter a valid email address"
|
|
10975
|
+
[questionId]: pageData?.emailValidError || "Please enter a valid email address"
|
|
10977
10976
|
}));
|
|
10978
10977
|
}
|
|
10979
10978
|
};
|
|
@@ -11011,7 +11010,7 @@ var QuestionnaireForm2 = ({
|
|
|
11011
11010
|
const questionId = getQuestionId(question);
|
|
11012
11011
|
const value = responses[questionId];
|
|
11013
11012
|
if (!value || Array.isArray(value) && value.length === 0) {
|
|
11014
|
-
newErrors[questionId] = "This field is required";
|
|
11013
|
+
newErrors[questionId] = pageData?.fieldRuquired || "This field is required";
|
|
11015
11014
|
}
|
|
11016
11015
|
}
|
|
11017
11016
|
});
|
|
@@ -11022,7 +11021,7 @@ var QuestionnaireForm2 = ({
|
|
|
11022
11021
|
);
|
|
11023
11022
|
if (!allAgreed) {
|
|
11024
11023
|
setAgreementError(
|
|
11025
|
-
"Please agree to all terms and conditions to continue"
|
|
11024
|
+
pageData?.agreeRuquired || "Please agree to all terms and conditions to continue"
|
|
11026
11025
|
);
|
|
11027
11026
|
setErrors(newErrors);
|
|
11028
11027
|
return false;
|
|
@@ -11443,6 +11442,10 @@ var DateTimePicker2 = ({
|
|
|
11443
11442
|
);
|
|
11444
11443
|
const [isInitialized, setIsInitialized] = useState(() => !!booking);
|
|
11445
11444
|
const [hasResolvedBookingSlot, setHasResolvedBookingSlot] = useState(false);
|
|
11445
|
+
const autoSelectLockRef = useRef(false);
|
|
11446
|
+
useEffect(() => {
|
|
11447
|
+
autoSelectLockRef.current = false;
|
|
11448
|
+
}, [demoRoomCode]);
|
|
11446
11449
|
const {
|
|
11447
11450
|
createBooking,
|
|
11448
11451
|
loading: bookingLoading,
|
|
@@ -11454,13 +11457,17 @@ var DateTimePicker2 = ({
|
|
|
11454
11457
|
error: editError
|
|
11455
11458
|
} = useEditBooking(apiClient);
|
|
11456
11459
|
const isManagedByParent = demoRoomLoading !== void 0;
|
|
11457
|
-
const {
|
|
11460
|
+
const {
|
|
11461
|
+
data: fetchedDemoRoom,
|
|
11462
|
+
loading: fetchedDemoRoomLoading
|
|
11463
|
+
} = useDemoRoom(
|
|
11458
11464
|
apiClient,
|
|
11459
11465
|
demoRoomCode || "",
|
|
11460
11466
|
locale,
|
|
11461
11467
|
{ enabled: !isManagedByParent && !demoRoomProp && !!demoRoomCode }
|
|
11462
11468
|
);
|
|
11463
11469
|
const demoRoom = demoRoomProp ?? fetchedDemoRoom;
|
|
11470
|
+
const effectiveDemoRoomLoading = !demoRoom && !!(isManagedByParent ? demoRoomLoading : fetchedDemoRoomLoading);
|
|
11464
11471
|
const isPodPurpose = selectedPurposeType === "pod";
|
|
11465
11472
|
const effectiveQuestionnaireId = isPodPurpose && demoRoom?.pod_config?.questionnaire_id || demoRoom?.questionnaire_id;
|
|
11466
11473
|
const { data: questionnaire, loading: questionnaireLoading } = useQuestionnaire(
|
|
@@ -11509,7 +11516,28 @@ var DateTimePicker2 = ({
|
|
|
11509
11516
|
return dates;
|
|
11510
11517
|
}, [timeslotsData, demoRoom?.timezone, timezone5]);
|
|
11511
11518
|
useEffect(() => {
|
|
11512
|
-
if (
|
|
11519
|
+
if (booking || isInitialized || autoSelectLockRef.current || !demoRoom?.timeslots?.length)
|
|
11520
|
+
return;
|
|
11521
|
+
const tz = demoRoom?.timezone || timezone5;
|
|
11522
|
+
const now2 = tz ? dayjs4().tz(tz) : dayjs4();
|
|
11523
|
+
const nearestSlot = demoRoom.timeslots.filter((slot) => {
|
|
11524
|
+
const slotTime = tz ? dayjs4(slot.start_time).tz(tz) : dayjs4(slot.start_time);
|
|
11525
|
+
return slot.status === "available" && slotTime.isAfter(now2);
|
|
11526
|
+
}).sort((a, b) => {
|
|
11527
|
+
const timeA = tz ? dayjs4(a.start_time).tz(tz) : dayjs4(a.start_time);
|
|
11528
|
+
const timeB = tz ? dayjs4(b.start_time).tz(tz) : dayjs4(b.start_time);
|
|
11529
|
+
return timeA.unix() - timeB.unix();
|
|
11530
|
+
})[0];
|
|
11531
|
+
if (!nearestSlot) return;
|
|
11532
|
+
autoSelectLockRef.current = true;
|
|
11533
|
+
const nearestDate = tz ? dayjs4(nearestSlot.start_time).tz(tz) : dayjs4(nearestSlot.start_time);
|
|
11534
|
+
setSelectedDate(nearestDate);
|
|
11535
|
+
setCalendarValue(nearestDate);
|
|
11536
|
+
setSelectedTimeslotId(nearestSlot.id);
|
|
11537
|
+
setIsInitialized(true);
|
|
11538
|
+
}, [booking, isInitialized, demoRoom?.timeslots, demoRoom?.timezone, timezone5]);
|
|
11539
|
+
useEffect(() => {
|
|
11540
|
+
if (!timeslotsData?.timeslots || isInitialized || autoSelectLockRef.current) return;
|
|
11513
11541
|
const tz = demoRoom?.timezone || timezone5;
|
|
11514
11542
|
const now2 = tz ? dayjs4().tz(tz) : dayjs4();
|
|
11515
11543
|
const availableTimeslots = timeslotsData.timeslots.filter((slot) => {
|
|
@@ -11524,16 +11552,25 @@ var DateTimePicker2 = ({
|
|
|
11524
11552
|
});
|
|
11525
11553
|
const nearestSlot = sortedSlots[0];
|
|
11526
11554
|
const nearestDate = tz ? dayjs4(nearestSlot.start_time).tz(tz) : dayjs4(nearestSlot.start_time);
|
|
11555
|
+
autoSelectLockRef.current = true;
|
|
11527
11556
|
setSelectedDate(nearestDate);
|
|
11528
11557
|
setCalendarValue(nearestDate);
|
|
11529
11558
|
setSelectedTimeslotId(nearestSlot.id);
|
|
11530
11559
|
setIsInitialized(true);
|
|
11531
|
-
} else if (!selectedDate) {
|
|
11560
|
+
} else if (!selectedDate && !effectiveDemoRoomLoading) {
|
|
11561
|
+
autoSelectLockRef.current = true;
|
|
11532
11562
|
setSelectedDate(now2);
|
|
11533
11563
|
setCalendarValue(now2);
|
|
11534
11564
|
setIsInitialized(true);
|
|
11535
11565
|
}
|
|
11536
|
-
}, [
|
|
11566
|
+
}, [
|
|
11567
|
+
timeslotsData,
|
|
11568
|
+
isInitialized,
|
|
11569
|
+
selectedDate,
|
|
11570
|
+
demoRoom?.timezone,
|
|
11571
|
+
timezone5,
|
|
11572
|
+
effectiveDemoRoomLoading
|
|
11573
|
+
]);
|
|
11537
11574
|
useEffect(() => {
|
|
11538
11575
|
if (!timeslotsData?.timeslots || !isInitialized) return;
|
|
11539
11576
|
if (selectedDate && selectedDate.isSame(calendarValue, "month")) {
|
|
@@ -12507,6 +12544,9 @@ var BookingFormO2O = ({
|
|
|
12507
12544
|
const [selectedPurposeType, setSelectedPurposeType] = useState(
|
|
12508
12545
|
() => initialBusinessType || purposeOptions[0]?.type || ""
|
|
12509
12546
|
);
|
|
12547
|
+
const [isPurposeConfirmed, setIsPurposeConfirmed] = useState(
|
|
12548
|
+
() => !!initialBusinessType && purposeOptions.some((item) => item.type === initialBusinessType)
|
|
12549
|
+
);
|
|
12510
12550
|
useEffect(() => {
|
|
12511
12551
|
setSelectedPurposeType((currentType) => {
|
|
12512
12552
|
if (purposeOptions.some((item) => item.type === currentType)) {
|
|
@@ -12520,11 +12560,16 @@ var BookingFormO2O = ({
|
|
|
12520
12560
|
}
|
|
12521
12561
|
return purposeOptions[0]?.type || "";
|
|
12522
12562
|
});
|
|
12563
|
+
const resolvedFromExplicitSource = !!initialBusinessType && purposeOptions.some((item) => item.type === initialBusinessType) || !!booking?.business_type && purposeOptions.some((item) => item.type === booking.business_type);
|
|
12564
|
+
if (resolvedFromExplicitSource) {
|
|
12565
|
+
setIsPurposeConfirmed(true);
|
|
12566
|
+
}
|
|
12523
12567
|
}, [purposeOptions, initialBusinessType, booking?.business_type]);
|
|
12524
12568
|
const selectedPurpose = useMemo(() => {
|
|
12525
|
-
return purposeOptions.find((item) => item.type === selectedPurposeType) ||
|
|
12569
|
+
return purposeOptions.find((item) => item.type === selectedPurposeType) || {};
|
|
12526
12570
|
}, [purposeOptions, selectedPurposeType]);
|
|
12527
|
-
const
|
|
12571
|
+
const isPodSelected = isPurposeConfirmed && selectedPurpose?.type === "pod";
|
|
12572
|
+
const selectedPodContent = isPodSelected ? selectedPurpose?.podContent : void 0;
|
|
12528
12573
|
const selectedPodDescription = getPodContentDescription(selectedPodContent);
|
|
12529
12574
|
const podDesignId = useMemo(() => getQueryParam("design_id"), []);
|
|
12530
12575
|
const isPodDesignEditMode = !!podDesignId || !!booking?.design_project_id;
|
|
@@ -12606,85 +12651,95 @@ var BookingFormO2O = ({
|
|
|
12606
12651
|
}
|
|
12607
12652
|
) }),
|
|
12608
12653
|
/* @__PURE__ */ jsxs("div", { className: "bg-[#f5f5f5]", children: [
|
|
12609
|
-
!!purposeOptions.length && /* @__PURE__ */ jsx("div", { className: cn("py-[40px] l:py-[24px]", className), children: /* @__PURE__ */ jsxs(
|
|
12610
|
-
|
|
12611
|
-
|
|
12612
|
-
|
|
12613
|
-
|
|
12614
|
-
|
|
12615
|
-
className: "block text-[16px] font-bold text-[#080A0F] l:text-[14px]",
|
|
12616
|
-
children: getPurposeLabel(pageData)
|
|
12617
|
-
}
|
|
12618
|
-
),
|
|
12619
|
-
/* @__PURE__ */ jsxs("div", { className: "relative mt-[14px]", children: [
|
|
12620
|
-
/* @__PURE__ */ jsx(
|
|
12621
|
-
"select",
|
|
12622
|
-
{
|
|
12623
|
-
id: "booking-purpose-select",
|
|
12624
|
-
value: selectedPurpose?.type || "",
|
|
12625
|
-
onChange: (event2) => {
|
|
12626
|
-
setSelectedPurposeType(event2.target.value);
|
|
12627
|
-
},
|
|
12628
|
-
disabled: !!token,
|
|
12629
|
-
className: cn(
|
|
12630
|
-
"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]",
|
|
12631
|
-
token && "pointer-events-none cursor-not-allowed opacity-50"
|
|
12632
|
-
),
|
|
12633
|
-
children: purposeOptions.map((item, index) => /* @__PURE__ */ jsx(
|
|
12634
|
-
"option",
|
|
12635
|
-
{
|
|
12636
|
-
value: item.type || "",
|
|
12637
|
-
children: item.label || item.type
|
|
12638
|
-
},
|
|
12639
|
-
`${item.type || item.label || "purpose"}-${index}`
|
|
12640
|
-
))
|
|
12641
|
-
}
|
|
12642
|
-
),
|
|
12643
|
-
/* @__PURE__ */ jsx("span", { className: "pointer-events-none absolute right-[14px] top-1/2 flex -translate-y-1/2 text-[#080A0F]", children: /* @__PURE__ */ jsx(ChevronIcon2, {}) })
|
|
12644
|
-
] }),
|
|
12645
|
-
!!selectedPurpose?.purposeNote && /* @__PURE__ */ jsx("p", { className: "mt-[16px] max-w-[720px] text-[14px] font-medium leading-[1.35] text-[#080A0F] l:text-[13px]", children: selectedPurpose.purposeNote })
|
|
12646
|
-
] }),
|
|
12647
|
-
selectedPurpose?.type === "pod" && !!selectedPodContent && /* @__PURE__ */ jsxs("section", { className: "rounded-[16px] bg-white px-[28px] py-[20px] l:px-[16px] l:py-[20px]", children: [
|
|
12648
|
-
!!selectedPodContent.title && /* @__PURE__ */ jsx("h2", { className: "text-[16px] font-bold text-[#080A0F] l:text-[14px]", children: selectedPodContent.title }),
|
|
12649
|
-
!!selectedPodDescription && /* @__PURE__ */ jsx("p", { className: "mt-[6px] text-[13px] font-medium leading-[1.35] text-[#080A0F] l:text-[12px]", children: selectedPodDescription }),
|
|
12650
|
-
!!selectedPodImage && /* @__PURE__ */ jsx(
|
|
12651
|
-
"img",
|
|
12652
|
-
{
|
|
12653
|
-
src: selectedPodImage,
|
|
12654
|
-
alt: selectedPodContent.imageAlt || selectedPodContent.title || "",
|
|
12655
|
-
className: "mt-[12px] h-[220px] rounded-[8px] object-cover l:h-auto"
|
|
12656
|
-
}
|
|
12654
|
+
!!purposeOptions.length && /* @__PURE__ */ jsx("div", { className: cn("py-[40px] l:py-[24px]", className), children: /* @__PURE__ */ jsxs(
|
|
12655
|
+
"div",
|
|
12656
|
+
{
|
|
12657
|
+
className: cn(
|
|
12658
|
+
"grid gap-[16px] l:grid-cols-1",
|
|
12659
|
+
isPodSelected && "grid-cols-2"
|
|
12657
12660
|
),
|
|
12658
|
-
|
|
12659
|
-
"
|
|
12660
|
-
|
|
12661
|
-
|
|
12662
|
-
|
|
12663
|
-
|
|
12664
|
-
|
|
12665
|
-
|
|
12666
|
-
|
|
12667
|
-
rel: "noopener noreferrer",
|
|
12668
|
-
className: cn(
|
|
12669
|
-
"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]",
|
|
12670
|
-
isPodButtonDisabled && "pointer-events-none cursor-not-allowed opacity-50"
|
|
12661
|
+
children: [
|
|
12662
|
+
/* @__PURE__ */ jsxs("section", { className: "rounded-[16px] bg-white px-[28px] py-[24px] l:px-[16px] l:py-[20px]", children: [
|
|
12663
|
+
/* @__PURE__ */ jsx(
|
|
12664
|
+
"label",
|
|
12665
|
+
{
|
|
12666
|
+
htmlFor: "booking-purpose-select",
|
|
12667
|
+
className: "block text-[16px] font-bold text-[#080A0F] l:text-[14px]",
|
|
12668
|
+
children: getPurposeLabel(pageData)
|
|
12669
|
+
}
|
|
12671
12670
|
),
|
|
12672
|
-
children: [
|
|
12673
|
-
|
|
12674
|
-
"
|
|
12671
|
+
/* @__PURE__ */ jsxs("div", { className: "relative mt-[14px]", children: [
|
|
12672
|
+
/* @__PURE__ */ jsx(
|
|
12673
|
+
"select",
|
|
12675
12674
|
{
|
|
12676
|
-
|
|
12677
|
-
|
|
12678
|
-
|
|
12679
|
-
|
|
12675
|
+
id: "booking-purpose-select",
|
|
12676
|
+
value: selectedPurpose?.type || "",
|
|
12677
|
+
onChange: (event2) => {
|
|
12678
|
+
setSelectedPurposeType(event2.target.value);
|
|
12679
|
+
setIsPurposeConfirmed(true);
|
|
12680
|
+
},
|
|
12681
|
+
disabled: !!token,
|
|
12682
|
+
className: cn(
|
|
12683
|
+
"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]",
|
|
12684
|
+
token && "pointer-events-none cursor-not-allowed opacity-50"
|
|
12685
|
+
),
|
|
12686
|
+
children: purposeOptions.map((item, index) => /* @__PURE__ */ jsx(
|
|
12687
|
+
"option",
|
|
12688
|
+
{
|
|
12689
|
+
value: item.type || "",
|
|
12690
|
+
children: item.label || item.type
|
|
12691
|
+
},
|
|
12692
|
+
`${item.type || item.label || "purpose"}-${index}`
|
|
12693
|
+
))
|
|
12680
12694
|
}
|
|
12681
12695
|
),
|
|
12682
|
-
|
|
12683
|
-
]
|
|
12684
|
-
|
|
12685
|
-
|
|
12686
|
-
|
|
12687
|
-
|
|
12696
|
+
/* @__PURE__ */ jsx("span", { className: "pointer-events-none absolute right-[14px] top-1/2 flex -translate-y-1/2 text-[#080A0F]", children: /* @__PURE__ */ jsx(ChevronIcon2, {}) })
|
|
12697
|
+
] }),
|
|
12698
|
+
!!selectedPurpose?.purposeNote && /* @__PURE__ */ jsx("p", { className: "mt-[16px] max-w-[720px] text-[14px] font-medium leading-[1.35] text-[#080A0F] l:text-[13px]", children: selectedPurpose.purposeNote })
|
|
12699
|
+
] }),
|
|
12700
|
+
isPodSelected && !!selectedPodContent && /* @__PURE__ */ jsxs("section", { className: "rounded-[16px] bg-white px-[28px] py-[20px] l:px-[16px] l:py-[20px]", children: [
|
|
12701
|
+
!!selectedPodContent.title && /* @__PURE__ */ jsx("h2", { className: "text-[16px] font-bold text-[#080A0F] l:text-[14px]", children: selectedPodContent.title }),
|
|
12702
|
+
!!selectedPodDescription && /* @__PURE__ */ jsx("p", { className: "mt-[6px] text-[13px] font-medium leading-[1.35] text-[#080A0F] l:text-[12px]", children: selectedPodDescription }),
|
|
12703
|
+
!!selectedPodImage && /* @__PURE__ */ jsx(
|
|
12704
|
+
"img",
|
|
12705
|
+
{
|
|
12706
|
+
src: selectedPodImage,
|
|
12707
|
+
alt: selectedPodContent.imageAlt || selectedPodContent.title || "",
|
|
12708
|
+
className: "mt-[12px] h-[220px] rounded-[8px] object-cover l:h-auto"
|
|
12709
|
+
}
|
|
12710
|
+
),
|
|
12711
|
+
!!selectedPodButtonText && (booking?.print_status === "unprinted" && booking?.design_project_id || !token) && /* @__PURE__ */ jsxs(
|
|
12712
|
+
"a",
|
|
12713
|
+
{
|
|
12714
|
+
href: selectedPodButtonLink || "#",
|
|
12715
|
+
"aria-disabled": isPodButtonDisabled,
|
|
12716
|
+
tabIndex: isPodButtonDisabled ? -1 : void 0,
|
|
12717
|
+
onClick: (event2) => {
|
|
12718
|
+
if (isPodButtonDisabled) event2.preventDefault();
|
|
12719
|
+
},
|
|
12720
|
+
rel: "noopener noreferrer",
|
|
12721
|
+
className: cn(
|
|
12722
|
+
"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]",
|
|
12723
|
+
isPodButtonDisabled && "pointer-events-none cursor-not-allowed opacity-50"
|
|
12724
|
+
),
|
|
12725
|
+
children: [
|
|
12726
|
+
selectedPodButtonIcon && /* @__PURE__ */ jsx(
|
|
12727
|
+
"img",
|
|
12728
|
+
{
|
|
12729
|
+
src: selectedPodButtonIcon,
|
|
12730
|
+
alt: "",
|
|
12731
|
+
className: "h-[16px] w-[16px]",
|
|
12732
|
+
"aria-hidden": "true"
|
|
12733
|
+
}
|
|
12734
|
+
),
|
|
12735
|
+
selectedPodButtonText
|
|
12736
|
+
]
|
|
12737
|
+
}
|
|
12738
|
+
)
|
|
12739
|
+
] })
|
|
12740
|
+
]
|
|
12741
|
+
}
|
|
12742
|
+
) }),
|
|
12688
12743
|
/* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx(
|
|
12689
12744
|
DateTimePicker_default2,
|
|
12690
12745
|
{
|