@anker-in/ui 0.3.4 → 0.3.6

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 CHANGED
@@ -730,6 +730,10 @@ interface BookingFormO2OProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
730
730
  baseUrl: string;
731
731
  apiKey: string;
732
732
  locale?: string;
733
+ /** MIR 欢迎页语言代码(POD 场景,透传给 buildMirWelcomeUrl 的 language) */
734
+ podLanguage?: string;
735
+ /** MIR 欢迎页国家代码(POD 场景,透传给 buildMirWelcomeUrl 的 countrycode) */
736
+ podCountry?: string;
733
737
  };
734
738
  /**
735
739
  * 门店代码(可选,可以从 URL 参数或 props 传入)
package/dist/index.d.ts CHANGED
@@ -730,6 +730,10 @@ interface BookingFormO2OProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
730
730
  baseUrl: string;
731
731
  apiKey: string;
732
732
  locale?: string;
733
+ /** MIR 欢迎页语言代码(POD 场景,透传给 buildMirWelcomeUrl 的 language) */
734
+ podLanguage?: string;
735
+ /** MIR 欢迎页国家代码(POD 场景,透传给 buildMirWelcomeUrl 的 countrycode) */
736
+ podCountry?: string;
733
737
  };
734
738
  /**
735
739
  * 门店代码(可选,可以从 URL 参数或 props 传入)
package/dist/index.js CHANGED
@@ -3247,7 +3247,7 @@ var RoomsList2 = ({
3247
3247
  }
3248
3248
  ) })
3249
3249
  ] }),
3250
- !!mergedPageData?.note && /* @__PURE__ */ jsxRuntime.jsx("div", { children: mergedPageData?.note })
3250
+ !!mergedPageData?.note && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-[32px] xl:mt-[16px]", children: mergedPageData?.note })
3251
3251
  ] });
3252
3252
  };
3253
3253
  RoomsList2.displayName = "RoomsList";
@@ -11449,13 +11449,21 @@ var DateTimePicker2 = ({
11449
11449
  podDesignId
11450
11450
  }) => {
11451
11451
  const { token: themeToken } = antd.theme.useToken();
11452
- const [selectedDate, setSelectedDate] = React15.useState(() => booking ? dayjs4__default.default(booking.booking_date) : null);
11453
- const [calendarValue, setCalendarValue] = React15.useState(() => booking ? dayjs4__default.default(booking.booking_date) : dayjs4__default.default());
11452
+ const [selectedDate, setSelectedDate] = React15.useState(
11453
+ () => booking ? dayjs4__default.default(booking.booking_date) : null
11454
+ );
11455
+ const [calendarValue, setCalendarValue] = React15.useState(
11456
+ () => booking ? dayjs4__default.default(booking.booking_date) : dayjs4__default.default()
11457
+ );
11454
11458
  const [selectedTimeslotId, setSelectedTimeslotId] = React15.useState(
11455
11459
  null
11456
11460
  );
11457
11461
  const [isInitialized, setIsInitialized] = React15.useState(() => !!booking);
11458
11462
  const [hasResolvedBookingSlot, setHasResolvedBookingSlot] = React15.useState(false);
11463
+ const autoSelectLockRef = React15.useRef(false);
11464
+ React15.useEffect(() => {
11465
+ autoSelectLockRef.current = false;
11466
+ }, [demoRoomCode]);
11459
11467
  const {
11460
11468
  createBooking,
11461
11469
  loading: bookingLoading,
@@ -11467,13 +11475,11 @@ var DateTimePicker2 = ({
11467
11475
  error: editError
11468
11476
  } = useEditBooking(apiClient);
11469
11477
  const isManagedByParent = demoRoomLoading !== void 0;
11470
- const { data: fetchedDemoRoom } = useDemoRoom(
11471
- apiClient,
11472
- demoRoomCode || "",
11473
- locale,
11474
- { enabled: !isManagedByParent && !demoRoomProp && !!demoRoomCode }
11475
- );
11478
+ const { data: fetchedDemoRoom, loading: fetchedDemoRoomLoading } = useDemoRoom(apiClient, demoRoomCode || "", locale, {
11479
+ enabled: !isManagedByParent && !demoRoomProp && !!demoRoomCode
11480
+ });
11476
11481
  const demoRoom = demoRoomProp ?? fetchedDemoRoom;
11482
+ const effectiveDemoRoomLoading = !demoRoom && !!(isManagedByParent ? demoRoomLoading : fetchedDemoRoomLoading);
11477
11483
  const isPodPurpose = selectedPurposeType === "pod";
11478
11484
  const effectiveQuestionnaireId = isPodPurpose && demoRoom?.pod_config?.questionnaire_id || demoRoom?.questionnaire_id;
11479
11485
  const { data: questionnaire, loading: questionnaireLoading } = useQuestionnaire(
@@ -11522,7 +11528,8 @@ var DateTimePicker2 = ({
11522
11528
  return dates;
11523
11529
  }, [timeslotsData, demoRoom?.timezone, timezone5]);
11524
11530
  React15.useEffect(() => {
11525
- if (booking || isInitialized || !demoRoom?.timeslots?.length) return;
11531
+ if (booking || isInitialized || autoSelectLockRef.current || !demoRoom?.timeslots?.length)
11532
+ return;
11526
11533
  const tz = demoRoom?.timezone || timezone5;
11527
11534
  const now2 = tz ? dayjs4__default.default().tz(tz) : dayjs4__default.default();
11528
11535
  const nearestSlot = demoRoom.timeslots.filter((slot) => {
@@ -11534,14 +11541,22 @@ var DateTimePicker2 = ({
11534
11541
  return timeA.unix() - timeB.unix();
11535
11542
  })[0];
11536
11543
  if (!nearestSlot) return;
11544
+ autoSelectLockRef.current = true;
11537
11545
  const nearestDate = tz ? dayjs4__default.default(nearestSlot.start_time).tz(tz) : dayjs4__default.default(nearestSlot.start_time);
11538
11546
  setSelectedDate(nearestDate);
11539
11547
  setCalendarValue(nearestDate);
11540
11548
  setSelectedTimeslotId(nearestSlot.id);
11541
11549
  setIsInitialized(true);
11542
- }, [booking, isInitialized, demoRoom?.timeslots, demoRoom?.timezone, timezone5]);
11550
+ }, [
11551
+ booking,
11552
+ isInitialized,
11553
+ demoRoom?.timeslots,
11554
+ demoRoom?.timezone,
11555
+ timezone5
11556
+ ]);
11543
11557
  React15.useEffect(() => {
11544
- if (!timeslotsData?.timeslots || isInitialized) return;
11558
+ if (!timeslotsData?.timeslots || isInitialized || autoSelectLockRef.current)
11559
+ return;
11545
11560
  const tz = demoRoom?.timezone || timezone5;
11546
11561
  const now2 = tz ? dayjs4__default.default().tz(tz) : dayjs4__default.default();
11547
11562
  const availableTimeslots = timeslotsData.timeslots.filter((slot) => {
@@ -11556,16 +11571,25 @@ var DateTimePicker2 = ({
11556
11571
  });
11557
11572
  const nearestSlot = sortedSlots[0];
11558
11573
  const nearestDate = tz ? dayjs4__default.default(nearestSlot.start_time).tz(tz) : dayjs4__default.default(nearestSlot.start_time);
11574
+ autoSelectLockRef.current = true;
11559
11575
  setSelectedDate(nearestDate);
11560
11576
  setCalendarValue(nearestDate);
11561
11577
  setSelectedTimeslotId(nearestSlot.id);
11562
11578
  setIsInitialized(true);
11563
- } else if (!selectedDate) {
11579
+ } else if (!selectedDate && !effectiveDemoRoomLoading) {
11580
+ autoSelectLockRef.current = true;
11564
11581
  setSelectedDate(now2);
11565
11582
  setCalendarValue(now2);
11566
11583
  setIsInitialized(true);
11567
11584
  }
11568
- }, [timeslotsData, isInitialized, selectedDate, demoRoom?.timezone, timezone5]);
11585
+ }, [
11586
+ timeslotsData,
11587
+ isInitialized,
11588
+ selectedDate,
11589
+ demoRoom?.timezone,
11590
+ timezone5,
11591
+ effectiveDemoRoomLoading
11592
+ ]);
11569
11593
  React15.useEffect(() => {
11570
11594
  if (!timeslotsData?.timeslots || !isInitialized) return;
11571
11595
  if (selectedDate && selectedDate.isSame(calendarValue, "month")) {
@@ -11632,7 +11656,13 @@ var DateTimePicker2 = ({
11632
11656
  setSelectedTimeslotId(match.id);
11633
11657
  setHasResolvedBookingSlot(true);
11634
11658
  }
11635
- }, [booking, dayTimeslots, hasResolvedBookingSlot, demoRoom?.timezone, timezone5]);
11659
+ }, [
11660
+ booking,
11661
+ dayTimeslots,
11662
+ hasResolvedBookingSlot,
11663
+ demoRoom?.timezone,
11664
+ timezone5
11665
+ ]);
11636
11666
  const initialResponses = React15.useMemo(() => {
11637
11667
  if (!booking) return void 0;
11638
11668
  return {
@@ -11653,7 +11683,6 @@ var DateTimePicker2 = ({
11653
11683
  borderRadius: 16
11654
11684
  };
11655
11685
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11656
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[48px] l:text-[32px] py-[64px] l:py-[24px] l:pt-[64px] font-bold text-center", children: pageData?.scheduleYourVisit }),
11657
11686
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-4 l:flex-col", children: [
11658
11687
  /* @__PURE__ */ jsxRuntime.jsx(
11659
11688
  antd.ConfigProvider,
@@ -12023,7 +12052,7 @@ var DateTimePicker2 = ({
12023
12052
  ] }),
12024
12053
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 mt-[40px] gap-4 l:mt-[16px] l:flex l:flex-col l:gap-2", children: timeslotsLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-2 text-center text-[#767880] py-8", children: pageData?.loadingTimeSlots }) : timeslotsError ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-2 text-center text-red-600 py-8", children: pageData?.failedToLoadTimeSlots }) : dayTimeslots.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-2 text-center text-[#767880] py-8", children: pageData?.noAvailableTimeSlots }) : dayTimeslots.map((slot) => {
12025
12054
  const isAvailable = slot.status === "available";
12026
- const isFull = slot.status === "full";
12055
+ slot.status === "full";
12027
12056
  const isSelected = selectedTimeslotId === slot.id;
12028
12057
  return /* @__PURE__ */ jsxRuntime.jsx(
12029
12058
  "button",
@@ -12039,20 +12068,7 @@ var DateTimePicker2 = ({
12039
12068
  border text-center transition-colors
12040
12069
  ${isSelected ? "border-[#3ADB67] bg-[#3ADB67] cursor-pointer" : isAvailable ? "border-[#E4E5E6] hover:border-[#3ADB67] hover:bg-[#3ADB67] cursor-pointer" : "border-[#E4E5E6] bg-[#F5F5F5] text-[#767880] cursor-not-allowed"}
12041
12070
  `,
12042
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center", children: [
12043
- /* @__PURE__ */ jsxRuntime.jsx("div", { children: formatTimeslot(slot) }),
12044
- isFull && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[16px] l:text-[14px] text-[#767880] mt-[2px]", children: pageData?.full }),
12045
- isAvailable && !isSelected && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-[16px] l:text-[14px] text-[#767880] mt-1", children: [
12046
- slot.capacity - slot.booked_count,
12047
- " ",
12048
- pageData?.spotsLeft
12049
- ] }),
12050
- isAvailable && isSelected && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-[16px] l:text-[14px] mt-1", children: [
12051
- slot.capacity - slot.booked_count,
12052
- " ",
12053
- pageData?.spotsLeft
12054
- ] })
12055
- ] })
12071
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col items-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: formatTimeslot(slot) }) })
12056
12072
  },
12057
12073
  slot.id
12058
12074
  );
@@ -12063,8 +12079,16 @@ var DateTimePicker2 = ({
12063
12079
  ) })
12064
12080
  ] })
12065
12081
  ] }),
12066
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-12", children: [
12067
- !!questionnaire?.questions?.length && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[48px] font-bold text-center mb-8 l:mb-[24px] l:text-[32px] l:text-left", children: pageData?.fillOutForm }),
12082
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
12083
+ !!questionnaire?.questions?.length && /* @__PURE__ */ jsxRuntime.jsx(
12084
+ "div",
12085
+ {
12086
+ className: cn(
12087
+ "text-[48px] l:text-[32px] pb-[24px] pt-[64px] l:pt-[32px] font-bold"
12088
+ ),
12089
+ children: pageData?.fillOutForm
12090
+ }
12091
+ ),
12068
12092
  questionnaireLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center text-[#767880] py-8", children: pageData?.loadingQuestionnaire }) : /* @__PURE__ */ jsxRuntime.jsx(
12069
12093
  QuestionnaireForm2,
12070
12094
  {
@@ -12405,6 +12429,7 @@ function sanitizeRedirectSource(source) {
12405
12429
  function buildMirWelcomeUrl({
12406
12430
  baseUrl,
12407
12431
  language,
12432
+ countrycode = "US",
12408
12433
  managerId,
12409
12434
  credential,
12410
12435
  currentUrl,
@@ -12415,7 +12440,7 @@ function buildMirWelcomeUrl({
12415
12440
  if (language) {
12416
12441
  url.searchParams.set("language", language);
12417
12442
  }
12418
- url.searchParams.set("countrycode", "US");
12443
+ url.searchParams.set("countrycode", countrycode);
12419
12444
  url.searchParams.set(managerIdParam, managerId);
12420
12445
  url.searchParams.set(credentialParam, credential);
12421
12446
  const redirectSource = sanitizeRedirectSource(
@@ -12481,12 +12506,12 @@ var normalizePurposeData = (purposeData) => {
12481
12506
  return normalizePurposeSource(purposeData);
12482
12507
  };
12483
12508
  var filterPurposeOptionsByBusinessTypes = (purposeOptions, businessTypes) => {
12484
- if (!businessTypes?.length) return purposeOptions;
12509
+ if (!businessTypes?.length) return [];
12485
12510
  const allowedTypes = new Set(businessTypes);
12486
12511
  const filtered = purposeOptions.filter(
12487
12512
  (item) => !!item.type && allowedTypes.has(item.type)
12488
12513
  );
12489
- return filtered.length ? filtered : purposeOptions;
12514
+ return filtered.length ? filtered : [];
12490
12515
  };
12491
12516
  var getPurposeLabel = (pageData) => {
12492
12517
  const purposeData = pageData?.purposeData;
@@ -12556,7 +12581,7 @@ var BookingFormO2O = ({
12556
12581
  return purposeOptions[0]?.type || "";
12557
12582
  });
12558
12583
  const resolvedFromExplicitSource = !!initialBusinessType && purposeOptions.some((item) => item.type === initialBusinessType) || !!booking?.business_type && purposeOptions.some((item) => item.type === booking.business_type);
12559
- if (resolvedFromExplicitSource) {
12584
+ if (resolvedFromExplicitSource || purposeOptions.length > 0) {
12560
12585
  setIsPurposeConfirmed(true);
12561
12586
  }
12562
12587
  }, [purposeOptions, initialBusinessType, booking?.business_type]);
@@ -12599,7 +12624,8 @@ var BookingFormO2O = ({
12599
12624
  }
12600
12625
  return buildMirWelcomeUrl({
12601
12626
  baseUrl: editBaseUrl,
12602
- language: apiConfig.locale,
12627
+ language: apiConfig?.podLanguage,
12628
+ countrycode: apiConfig?.podCountry,
12603
12629
  managerId: effectiveStoreManagerId,
12604
12630
  credential: effectiveMirSessionId,
12605
12631
  managerIdParam: "store_manager_id",
@@ -12611,17 +12637,20 @@ var BookingFormO2O = ({
12611
12637
  if (!baseUrl) return void 0;
12612
12638
  return buildMirWelcomeUrl({
12613
12639
  baseUrl,
12614
- language: apiConfig.locale,
12640
+ language: apiConfig?.podLanguage,
12641
+ countrycode: apiConfig?.podCountry,
12615
12642
  managerId,
12616
12643
  credential: mirCredential
12617
12644
  });
12618
12645
  }, [
12619
- selectedPodContent,
12620
- apiConfig.locale,
12621
- managerId,
12622
12646
  isPodButtonDisabled,
12623
- mirCredential,
12624
12647
  isPodDesignEditMode,
12648
+ managerId,
12649
+ selectedPodContent?.buttonLink,
12650
+ selectedPodContent?.buttonEditLink,
12651
+ apiConfig?.podLanguage,
12652
+ apiConfig?.podCountry,
12653
+ mirCredential,
12625
12654
  effectiveStoreManagerId,
12626
12655
  effectiveMirSessionId
12627
12656
  ]);
@@ -12633,7 +12662,7 @@ var BookingFormO2O = ({
12633
12662
  [pageData?.dateTimePicker, pageData?.questionnaireForm]
12634
12663
  );
12635
12664
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
12636
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("w-full", className), ...props, children: /* @__PURE__ */ jsxRuntime.jsx(
12665
+ !token && /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("w-full", className), ...props, children: /* @__PURE__ */ jsxRuntime.jsx(
12637
12666
  DemoRoomDetail2,
12638
12667
  {
12639
12668
  className: cn("min-l:mt-8", layoutClassName),
@@ -12646,7 +12675,17 @@ var BookingFormO2O = ({
12646
12675
  }
12647
12676
  ) }),
12648
12677
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-[#f5f5f5]", children: [
12649
- !!purposeOptions.length && /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("py-[40px] l:py-[24px]", className), children: /* @__PURE__ */ jsxRuntime.jsxs(
12678
+ /* @__PURE__ */ jsxRuntime.jsx(
12679
+ "div",
12680
+ {
12681
+ className: cn(
12682
+ "text-[48px] l:text-[32px] pb-[24px] pt-[128px] l:pt-[64px] font-bold",
12683
+ className
12684
+ ),
12685
+ children: dateTimePickerPageData?.scheduleYourVisit
12686
+ }
12687
+ ),
12688
+ !!purposeOptions.length && /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("pb-[40px] l:pb-[24px]", className), children: /* @__PURE__ */ jsxRuntime.jsxs(
12650
12689
  "div",
12651
12690
  {
12652
12691
  className: cn(
@@ -12700,7 +12739,7 @@ var BookingFormO2O = ({
12700
12739
  {
12701
12740
  src: selectedPodImage,
12702
12741
  alt: selectedPodContent.imageAlt || selectedPodContent.title || "",
12703
- className: "mt-[12px] h-[220px] rounded-[8px] object-cover l:h-auto"
12742
+ className: "mt-[12px] h-[220px] rounded-[8px] object-cover max-h-[360px]"
12704
12743
  }
12705
12744
  ),
12706
12745
  !!selectedPodButtonText && (booking?.print_status === "unprinted" && booking?.design_project_id || !token) && /* @__PURE__ */ jsxRuntime.jsxs(
@@ -13170,7 +13209,7 @@ var BookingSuccessO2O = ({
13170
13209
  ]
13171
13210
  }
13172
13211
  ),
13173
- isPending && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-[64px] pb-4 print:hidden", children: [
13212
+ isPending && !isCancelled && !isStore && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-[64px] pb-4 print:hidden", children: [
13174
13213
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex md:w-full gap-4 md:flex-col md:items-center md:justify-center", children: [
13175
13214
  onEditBooking && token && /* @__PURE__ */ jsxRuntime.jsx(
13176
13215
  "button",