@anker-in/ui 0.2.0 → 0.2.2

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.mjs CHANGED
@@ -6,14 +6,14 @@ import IndexBar from 'antd-mobile/es/components/index-bar';
6
6
  import List from 'antd-mobile/es/components/list';
7
7
  import 'antd-mobile/es/components/index-bar/index-bar.css';
8
8
  import 'antd-mobile/es/components/list/list.css';
9
- import dayjs from 'dayjs';
9
+ import dayjs2 from 'dayjs';
10
+ import utc from 'dayjs/plugin/utc';
11
+ import timezone from 'dayjs/plugin/timezone';
10
12
  import 'dayjs/locale/zh-cn';
11
13
  import { theme, ConfigProvider, Calendar, Select } from 'antd';
12
14
  import dayLocaleData from 'dayjs/plugin/localeData';
13
15
  import weekday from 'dayjs/plugin/weekday';
14
16
  import weekOfYear from 'dayjs/plugin/weekOfYear';
15
- import timezone from 'dayjs/plugin/timezone';
16
- import utc from 'dayjs/plugin/utc';
17
17
 
18
18
  function cn(...inputs) {
19
19
  return twMerge(clsx(inputs));
@@ -1103,6 +1103,8 @@ var LocationFilter = ({
1103
1103
  );
1104
1104
  };
1105
1105
  LocationFilter.displayName = "LocationFilter";
1106
+ dayjs2.extend(utc);
1107
+ dayjs2.extend(timezone);
1106
1108
  var defaultPageData = {
1107
1109
  title: "Find a Studio Near You",
1108
1110
  loadingText: "Loading demo rooms...",
@@ -1282,6 +1284,20 @@ var RoomsList = ({
1282
1284
  const city = room.location?.city || "";
1283
1285
  const addressParts = [room.address, city, state, country].filter(Boolean);
1284
1286
  const fullAddress = addressParts.join(", ");
1287
+ let formattedTime = mergedPageData.noAvailableTime;
1288
+ if (nextAvailableTimeslot) {
1289
+ try {
1290
+ const timeInZone = dayjs2(nextAvailableTimeslot.start_time).tz(
1291
+ room.timezone || "America/Los_Angeles"
1292
+ );
1293
+ const month = timeInZone.format("MMM");
1294
+ const day = timeInZone.format("D");
1295
+ const time = timeInZone.format("h:mm A");
1296
+ formattedTime = `${month}.${day}, ${time}`;
1297
+ } catch (error2) {
1298
+ formattedTime = nextAvailableTimeslot.start_time;
1299
+ }
1300
+ }
1285
1301
  return {
1286
1302
  id: room.code,
1287
1303
  name: room.name,
@@ -1292,7 +1308,7 @@ var RoomsList = ({
1292
1308
  country,
1293
1309
  lat: Number(room.latitude) || 0,
1294
1310
  lng: Number(room.longitude) || 0,
1295
- availableTime: nextAvailableTimeslot ? `${nextAvailableTimeslot.start_time}` : mergedPageData.noAvailableTime,
1311
+ availableTime: formattedTime,
1296
1312
  euifyMakeModel: room?.equipment?.join(", ") || ""
1297
1313
  };
1298
1314
  });
@@ -1671,7 +1687,12 @@ var QuestionnaireForm = ({
1671
1687
  const [phoneCountryCodes, setPhoneCountryCodes] = useState({});
1672
1688
  const [otherInputs, setOtherInputs] = useState({});
1673
1689
  const prevHasBookedBeforeRef = useRef(false);
1674
- const hasBookedBefore = responses["has_booked_before"] === "option2";
1690
+ const hasBookedBeforeInitialized = useRef(false);
1691
+ const hasBookedBeforeQuestion = questions.find(
1692
+ (q) => (q.key || q.id) === "has_booked_before"
1693
+ );
1694
+ const hasBookedBeforeQuestionId = hasBookedBeforeQuestion ? hasBookedBeforeQuestion.key || hasBookedBeforeQuestion.id || "" : "has_booked_before";
1695
+ const hasBookedBefore = responses[hasBookedBeforeQuestionId] === "option2";
1675
1696
  const hiddenQuestionIds = useMemo(() => {
1676
1697
  if (!hasBookedBefore) return [];
1677
1698
  return questions.filter((q) => q.is_default === false).map((q) => q.key || q.id || "");
@@ -1684,6 +1705,21 @@ var QuestionnaireForm = ({
1684
1705
  return true;
1685
1706
  });
1686
1707
  }, [questions, hasBookedBefore]);
1708
+ useEffect(() => {
1709
+ if (hasBookedBeforeInitialized.current) return;
1710
+ if (hasBookedBeforeQuestion && hasBookedBeforeQuestionId) {
1711
+ setResponses((prev) => {
1712
+ if (!prev[hasBookedBeforeQuestionId]) {
1713
+ return {
1714
+ ...prev,
1715
+ [hasBookedBeforeQuestionId]: "option1"
1716
+ };
1717
+ }
1718
+ return prev;
1719
+ });
1720
+ hasBookedBeforeInitialized.current = true;
1721
+ }
1722
+ }, [hasBookedBeforeQuestion, hasBookedBeforeQuestionId]);
1687
1723
  useEffect(() => {
1688
1724
  if (hasBookedBefore && !prevHasBookedBeforeRef.current) {
1689
1725
  if (hiddenQuestionIds.length > 0) {
@@ -2181,15 +2217,15 @@ var QuestionnaireForm = ({
2181
2217
  ] })
2182
2218
  ] });
2183
2219
  };
2184
- dayjs.extend(dayLocaleData);
2185
- dayjs.extend(weekday);
2186
- dayjs.extend(weekOfYear);
2187
- dayjs.extend(utc);
2188
- dayjs.extend(timezone);
2220
+ dayjs2.extend(dayLocaleData);
2221
+ dayjs2.extend(weekday);
2222
+ dayjs2.extend(weekOfYear);
2223
+ dayjs2.extend(utc);
2224
+ dayjs2.extend(timezone);
2189
2225
  var DateTimePicker = ({
2190
2226
  apiClient,
2191
2227
  demoRoomCode,
2192
- timezone: timezone2,
2228
+ timezone: timezone3,
2193
2229
  pageData = {
2194
2230
  scheduleYourVisit: "Schedule Your Visit",
2195
2231
  timeSlot: "Time Slot",
@@ -2208,7 +2244,7 @@ var DateTimePicker = ({
2208
2244
  }) => {
2209
2245
  const { token } = theme.useToken();
2210
2246
  const [selectedDate, setSelectedDate] = useState(null);
2211
- const [calendarValue, setCalendarValue] = useState(dayjs());
2247
+ const [calendarValue, setCalendarValue] = useState(dayjs2());
2212
2248
  const [selectedTimeslotId, setSelectedTimeslotId] = useState(
2213
2249
  null
2214
2250
  );
@@ -2243,47 +2279,47 @@ var DateTimePicker = ({
2243
2279
  {
2244
2280
  start_date: startDate,
2245
2281
  end_date: endDate,
2246
- timezone: timezone2
2282
+ timezone: timezone3
2247
2283
  },
2248
2284
  { enabled: !!demoRoomCode }
2249
2285
  );
2250
2286
  const dayTimeslots = useMemo(() => {
2251
2287
  if (!timeslotsData?.timeslots || !selectedDate) return [];
2252
- const tz = demoRoom?.timezone || timezone2;
2288
+ const tz = demoRoom?.timezone || timezone3;
2253
2289
  const selectedDateStr = selectedDate.format("YYYY-MM-DD");
2254
2290
  return timeslotsData.timeslots.filter((slot) => {
2255
- const slotDate = tz ? dayjs(slot.start_time).tz(tz).format("YYYY-MM-DD") : dayjs(slot.start_time).format("YYYY-MM-DD");
2291
+ const slotDate = tz ? dayjs2(slot.start_time).tz(tz).format("YYYY-MM-DD") : dayjs2(slot.start_time).format("YYYY-MM-DD");
2256
2292
  return slotDate === selectedDateStr;
2257
2293
  });
2258
- }, [timeslotsData, selectedDate, demoRoom?.timezone, timezone2]);
2294
+ }, [timeslotsData, selectedDate, demoRoom?.timezone, timezone3]);
2259
2295
  const availableDates = useMemo(() => {
2260
2296
  if (!timeslotsData?.timeslots) return /* @__PURE__ */ new Set();
2261
- const tz = demoRoom?.timezone || timezone2;
2297
+ const tz = demoRoom?.timezone || timezone3;
2262
2298
  const dates = /* @__PURE__ */ new Set();
2263
2299
  timeslotsData.timeslots.forEach((slot) => {
2264
2300
  if (slot.status === "available") {
2265
- const dateStr = tz ? dayjs(slot.start_time).tz(tz).format("YYYY-MM-DD") : dayjs(slot.start_time).format("YYYY-MM-DD");
2301
+ const dateStr = tz ? dayjs2(slot.start_time).tz(tz).format("YYYY-MM-DD") : dayjs2(slot.start_time).format("YYYY-MM-DD");
2266
2302
  dates.add(dateStr);
2267
2303
  }
2268
2304
  });
2269
2305
  return dates;
2270
- }, [timeslotsData, demoRoom?.timezone, timezone2]);
2306
+ }, [timeslotsData, demoRoom?.timezone, timezone3]);
2271
2307
  useEffect(() => {
2272
2308
  if (!timeslotsData?.timeslots || isInitialized) return;
2273
- const tz = demoRoom?.timezone || timezone2;
2274
- const now2 = tz ? dayjs().tz(tz) : dayjs();
2309
+ const tz = demoRoom?.timezone || timezone3;
2310
+ const now2 = tz ? dayjs2().tz(tz) : dayjs2();
2275
2311
  const availableTimeslots = timeslotsData.timeslots.filter((slot) => {
2276
- const slotTime = tz ? dayjs(slot.start_time).tz(tz) : dayjs(slot.start_time);
2312
+ const slotTime = tz ? dayjs2(slot.start_time).tz(tz) : dayjs2(slot.start_time);
2277
2313
  return slot.status === "available" && slotTime.isAfter(now2);
2278
2314
  });
2279
2315
  if (availableTimeslots.length > 0) {
2280
2316
  const sortedSlots = [...availableTimeslots].sort((a, b) => {
2281
- const timeA = tz ? dayjs(a.start_time).tz(tz) : dayjs(a.start_time);
2282
- const timeB = tz ? dayjs(b.start_time).tz(tz) : dayjs(b.start_time);
2317
+ const timeA = tz ? dayjs2(a.start_time).tz(tz) : dayjs2(a.start_time);
2318
+ const timeB = tz ? dayjs2(b.start_time).tz(tz) : dayjs2(b.start_time);
2283
2319
  return timeA.unix() - timeB.unix();
2284
2320
  });
2285
2321
  const nearestSlot = sortedSlots[0];
2286
- const nearestDate = tz ? dayjs(nearestSlot.start_time).tz(tz) : dayjs(nearestSlot.start_time);
2322
+ const nearestDate = tz ? dayjs2(nearestSlot.start_time).tz(tz) : dayjs2(nearestSlot.start_time);
2287
2323
  setSelectedDate(nearestDate);
2288
2324
  setCalendarValue(nearestDate);
2289
2325
  setSelectedTimeslotId(nearestSlot.id);
@@ -2293,28 +2329,28 @@ var DateTimePicker = ({
2293
2329
  setCalendarValue(now2);
2294
2330
  setIsInitialized(true);
2295
2331
  }
2296
- }, [timeslotsData, isInitialized, selectedDate, demoRoom?.timezone, timezone2]);
2332
+ }, [timeslotsData, isInitialized, selectedDate, demoRoom?.timezone, timezone3]);
2297
2333
  useEffect(() => {
2298
2334
  if (!timeslotsData?.timeslots || !isInitialized) return;
2299
2335
  if (selectedDate && selectedDate.isSame(calendarValue, "month")) {
2300
2336
  return;
2301
2337
  }
2302
- const tz = demoRoom?.timezone || timezone2;
2338
+ const tz = demoRoom?.timezone || timezone3;
2303
2339
  const currentMonthStart = calendarValue.startOf("month");
2304
2340
  const currentMonthEnd = calendarValue.endOf("month");
2305
- const now2 = tz ? dayjs().tz(tz) : dayjs();
2341
+ const now2 = tz ? dayjs2().tz(tz) : dayjs2();
2306
2342
  const availableTimeslots = timeslotsData.timeslots.filter((slot) => {
2307
- const slotDate = tz ? dayjs(slot.start_time).tz(tz) : dayjs(slot.start_time);
2343
+ const slotDate = tz ? dayjs2(slot.start_time).tz(tz) : dayjs2(slot.start_time);
2308
2344
  return slot.status === "available" && slotDate.isAfter(now2) && (slotDate.isAfter(currentMonthStart) || slotDate.isSame(currentMonthStart, "day")) && (slotDate.isBefore(currentMonthEnd) || slotDate.isSame(currentMonthEnd, "day"));
2309
2345
  });
2310
2346
  if (availableTimeslots.length > 0) {
2311
2347
  const sortedSlots = [...availableTimeslots].sort((a, b) => {
2312
- const timeA = tz ? dayjs(a.start_time).tz(tz) : dayjs(a.start_time);
2313
- const timeB = tz ? dayjs(b.start_time).tz(tz) : dayjs(b.start_time);
2348
+ const timeA = tz ? dayjs2(a.start_time).tz(tz) : dayjs2(a.start_time);
2349
+ const timeB = tz ? dayjs2(b.start_time).tz(tz) : dayjs2(b.start_time);
2314
2350
  return timeA.unix() - timeB.unix();
2315
2351
  });
2316
2352
  const firstSlot = sortedSlots[0];
2317
- const firstDate = tz ? dayjs(firstSlot.start_time).tz(tz) : dayjs(firstSlot.start_time);
2353
+ const firstDate = tz ? dayjs2(firstSlot.start_time).tz(tz) : dayjs2(firstSlot.start_time);
2318
2354
  setSelectedDate(firstDate);
2319
2355
  setSelectedTimeslotId(firstSlot.id);
2320
2356
  }
@@ -2324,12 +2360,12 @@ var DateTimePicker = ({
2324
2360
  isInitialized,
2325
2361
  selectedDate,
2326
2362
  demoRoom?.timezone,
2327
- timezone2
2363
+ timezone3
2328
2364
  ]);
2329
2365
  const formatTimeslot = (slot) => {
2330
- const tz = demoRoom?.timezone || timezone2;
2331
- const start = tz ? dayjs(slot.start_time).tz(tz).format("h:mm A") : dayjs(slot.start_time).format("h:mm A");
2332
- const end = tz ? dayjs(slot.end_time).tz(tz).format("h:mm A") : dayjs(slot.end_time).format("h:mm A");
2366
+ const tz = demoRoom?.timezone || timezone3;
2367
+ const start = tz ? dayjs2(slot.start_time).tz(tz).format("h:mm A") : dayjs2(slot.start_time).format("h:mm A");
2368
+ const end = tz ? dayjs2(slot.end_time).tz(tz).format("h:mm A") : dayjs2(slot.end_time).format("h:mm A");
2333
2369
  return `${start} - ${end}`;
2334
2370
  };
2335
2371
  const wrapperStyle = {
@@ -2490,16 +2526,16 @@ var DateTimePicker = ({
2490
2526
  },
2491
2527
  disabledDate: (current) => {
2492
2528
  if (!current) return false;
2493
- if (current.isSame(dayjs(), "day")) return false;
2494
- if (current.isBefore(dayjs(), "day")) return true;
2529
+ if (current.isSame(dayjs2(), "day")) return false;
2530
+ if (current.isBefore(dayjs2(), "day")) return true;
2495
2531
  const dateStr = current.format("YYYY-MM-DD");
2496
2532
  return !availableDates.has(dateStr);
2497
2533
  },
2498
2534
  fullCellRender: (date) => {
2499
2535
  const isSelected = selectedDate && date.isSame(selectedDate, "day");
2500
- const isToday = date.isSame(dayjs(), "day");
2536
+ const isToday = date.isSame(dayjs2(), "day");
2501
2537
  const dateStr = date.format("YYYY-MM-DD");
2502
- const isDisabled = !isToday && (date.isBefore(dayjs(), "day") || !availableDates.has(dateStr));
2538
+ const isDisabled = !isToday && (date.isBefore(dayjs2(), "day") || !availableDates.has(dateStr));
2503
2539
  return /* @__PURE__ */ jsx(
2504
2540
  "div",
2505
2541
  {
@@ -2645,13 +2681,13 @@ var DateTimePicker = ({
2645
2681
  onClick: () => {
2646
2682
  if (selectedDate) {
2647
2683
  const newDate = selectedDate.subtract(1, "day");
2648
- if (!newDate.isBefore(dayjs(), "day")) {
2684
+ if (!newDate.isBefore(dayjs2(), "day")) {
2649
2685
  setSelectedDate(newDate);
2650
2686
  setCalendarValue(newDate);
2651
2687
  }
2652
2688
  }
2653
2689
  },
2654
- disabled: !selectedDate || selectedDate.isSame(dayjs(), "day") || selectedDate.isBefore(dayjs(), "day"),
2690
+ disabled: !selectedDate || selectedDate.isSame(dayjs2(), "day") || selectedDate.isBefore(dayjs2(), "day"),
2655
2691
  className: "w-8 h-8 flex items-center justify-center hover:bg-gray-100 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
2656
2692
  children: /* @__PURE__ */ jsx(
2657
2693
  "svg",
@@ -2744,7 +2780,7 @@ var DateTimePicker = ({
2744
2780
  }) }),
2745
2781
  !timeslotsLoading && dayTimeslots?.length > 0 && /* @__PURE__ */ jsx("div", { className: "pt-[24px] text-[#6d6d6F] text-center", children: pageData?.timezone?.replace(
2746
2782
  "{{timezone}}",
2747
- demoRoom?.timezone || timezone2 || ""
2783
+ demoRoom?.timezone || timezone3 || ""
2748
2784
  ) })
2749
2785
  ] })
2750
2786
  ] }),
@@ -8848,7 +8884,7 @@ var BookingForm = ({
8848
8884
  apiConfig,
8849
8885
  demoRoomCode,
8850
8886
  pageData,
8851
- timezone: timezone2,
8887
+ timezone: timezone3,
8852
8888
  handleBookingSuccess,
8853
8889
  onQuestionnaireSubmit,
8854
8890
  ...props
@@ -8880,7 +8916,7 @@ var BookingForm = ({
8880
8916
  {
8881
8917
  apiClient,
8882
8918
  demoRoomCode,
8883
- timezone: timezone2,
8919
+ timezone: timezone3,
8884
8920
  locale: apiConfig.locale,
8885
8921
  onBookingSuccess: handleBookingSuccess,
8886
8922
  onQuestionnaireSubmit,