@anker-in/ui 0.1.15 → 0.1.17

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
@@ -12,6 +12,8 @@ import { theme, ConfigProvider, Calendar, Select } from 'antd';
12
12
  import dayLocaleData from 'dayjs/plugin/localeData';
13
13
  import weekday from 'dayjs/plugin/weekday';
14
14
  import weekOfYear from 'dayjs/plugin/weekOfYear';
15
+ import timezone from 'dayjs/plugin/timezone';
16
+ import utc from 'dayjs/plugin/utc';
15
17
 
16
18
  function cn(...inputs) {
17
19
  return twMerge(clsx(inputs));
@@ -1659,7 +1661,8 @@ var QuestionnaireForm = ({
1659
1661
  pageData,
1660
1662
  selectedTimeslotId,
1661
1663
  loading = false,
1662
- className
1664
+ className,
1665
+ error
1663
1666
  }) => {
1664
1667
  const [responses, setResponses] = useState({});
1665
1668
  const [errors, setErrors] = useState({});
@@ -2105,17 +2108,20 @@ var QuestionnaireForm = ({
2105
2108
  ),
2106
2109
  children: loading ? pageData?.submitting || "Submitting..." : pageData?.submit || "Submit Booking"
2107
2110
  }
2108
- )
2111
+ ),
2112
+ error && /* @__PURE__ */ jsx("div", { className: "text-center w-full p-4", children: /* @__PURE__ */ jsx("p", { className: "text-[#FF4D4D] font-bold", children: error.message }) })
2109
2113
  ] })
2110
2114
  ] });
2111
2115
  };
2112
2116
  dayjs.extend(dayLocaleData);
2113
2117
  dayjs.extend(weekday);
2114
2118
  dayjs.extend(weekOfYear);
2119
+ dayjs.extend(utc);
2120
+ dayjs.extend(timezone);
2115
2121
  var DateTimePicker = ({
2116
2122
  apiClient,
2117
2123
  demoRoomCode,
2118
- timezone,
2124
+ timezone: timezone2,
2119
2125
  pageData = {
2120
2126
  scheduleYourVisit: "Schedule Your Visit",
2121
2127
  timeSlot: "Time Slot",
@@ -2169,41 +2175,47 @@ var DateTimePicker = ({
2169
2175
  {
2170
2176
  start_date: startDate,
2171
2177
  end_date: endDate,
2172
- timezone
2178
+ timezone: timezone2
2173
2179
  },
2174
2180
  { enabled: !!demoRoomCode }
2175
2181
  );
2176
2182
  const dayTimeslots = useMemo(() => {
2177
2183
  if (!timeslotsData?.timeslots || !selectedDate) return [];
2184
+ const tz = demoRoom?.timezone || timezone2;
2178
2185
  const selectedDateStr = selectedDate.format("YYYY-MM-DD");
2179
2186
  return timeslotsData.timeslots.filter((slot) => {
2180
- const slotDate = dayjs(slot.start_time).format("YYYY-MM-DD");
2187
+ const slotDate = tz ? dayjs(slot.start_time).tz(tz).format("YYYY-MM-DD") : dayjs(slot.start_time).format("YYYY-MM-DD");
2181
2188
  return slotDate === selectedDateStr;
2182
2189
  });
2183
- }, [timeslotsData, selectedDate]);
2190
+ }, [timeslotsData, selectedDate, demoRoom?.timezone, timezone2]);
2184
2191
  const availableDates = useMemo(() => {
2185
2192
  if (!timeslotsData?.timeslots) return /* @__PURE__ */ new Set();
2193
+ const tz = demoRoom?.timezone || timezone2;
2186
2194
  const dates = /* @__PURE__ */ new Set();
2187
2195
  timeslotsData.timeslots.forEach((slot) => {
2188
2196
  if (slot.status === "available") {
2189
- const dateStr = dayjs(slot.start_time).format("YYYY-MM-DD");
2197
+ const dateStr = tz ? dayjs(slot.start_time).tz(tz).format("YYYY-MM-DD") : dayjs(slot.start_time).format("YYYY-MM-DD");
2190
2198
  dates.add(dateStr);
2191
2199
  }
2192
2200
  });
2193
2201
  return dates;
2194
- }, [timeslotsData]);
2202
+ }, [timeslotsData, demoRoom?.timezone, timezone2]);
2195
2203
  useEffect(() => {
2196
2204
  if (!timeslotsData?.timeslots || isInitialized) return;
2197
- const now2 = dayjs();
2198
- const availableTimeslots = timeslotsData.timeslots.filter(
2199
- (slot) => slot.status === "available" && dayjs(slot.start_time).isAfter(now2)
2200
- );
2205
+ const tz = demoRoom?.timezone || timezone2;
2206
+ const now2 = tz ? dayjs().tz(tz) : dayjs();
2207
+ const availableTimeslots = timeslotsData.timeslots.filter((slot) => {
2208
+ const slotTime = tz ? dayjs(slot.start_time).tz(tz) : dayjs(slot.start_time);
2209
+ return slot.status === "available" && slotTime.isAfter(now2);
2210
+ });
2201
2211
  if (availableTimeslots.length > 0) {
2202
- const sortedSlots = [...availableTimeslots].sort(
2203
- (a, b) => dayjs(a.start_time).unix() - dayjs(b.start_time).unix()
2204
- );
2212
+ const sortedSlots = [...availableTimeslots].sort((a, b) => {
2213
+ const timeA = tz ? dayjs(a.start_time).tz(tz) : dayjs(a.start_time);
2214
+ const timeB = tz ? dayjs(b.start_time).tz(tz) : dayjs(b.start_time);
2215
+ return timeA.unix() - timeB.unix();
2216
+ });
2205
2217
  const nearestSlot = sortedSlots[0];
2206
- const nearestDate = dayjs(nearestSlot.start_time);
2218
+ const nearestDate = tz ? dayjs(nearestSlot.start_time).tz(tz) : dayjs(nearestSlot.start_time);
2207
2219
  setSelectedDate(nearestDate);
2208
2220
  setCalendarValue(nearestDate);
2209
2221
  setSelectedTimeslotId(nearestSlot.id);
@@ -2213,32 +2225,43 @@ var DateTimePicker = ({
2213
2225
  setCalendarValue(now2);
2214
2226
  setIsInitialized(true);
2215
2227
  }
2216
- }, [timeslotsData, isInitialized, selectedDate]);
2228
+ }, [timeslotsData, isInitialized, selectedDate, demoRoom?.timezone, timezone2]);
2217
2229
  useEffect(() => {
2218
2230
  if (!timeslotsData?.timeslots || !isInitialized) return;
2219
2231
  if (selectedDate && selectedDate.isSame(calendarValue, "month")) {
2220
2232
  return;
2221
2233
  }
2234
+ const tz = demoRoom?.timezone || timezone2;
2222
2235
  const currentMonthStart = calendarValue.startOf("month");
2223
2236
  const currentMonthEnd = calendarValue.endOf("month");
2224
- const now2 = dayjs();
2237
+ const now2 = tz ? dayjs().tz(tz) : dayjs();
2225
2238
  const availableTimeslots = timeslotsData.timeslots.filter((slot) => {
2226
- const slotDate = dayjs(slot.start_time);
2239
+ const slotDate = tz ? dayjs(slot.start_time).tz(tz) : dayjs(slot.start_time);
2227
2240
  return slot.status === "available" && slotDate.isAfter(now2) && (slotDate.isAfter(currentMonthStart) || slotDate.isSame(currentMonthStart, "day")) && (slotDate.isBefore(currentMonthEnd) || slotDate.isSame(currentMonthEnd, "day"));
2228
2241
  });
2229
2242
  if (availableTimeslots.length > 0) {
2230
- const sortedSlots = [...availableTimeslots].sort(
2231
- (a, b) => dayjs(a.start_time).unix() - dayjs(b.start_time).unix()
2232
- );
2243
+ const sortedSlots = [...availableTimeslots].sort((a, b) => {
2244
+ const timeA = tz ? dayjs(a.start_time).tz(tz) : dayjs(a.start_time);
2245
+ const timeB = tz ? dayjs(b.start_time).tz(tz) : dayjs(b.start_time);
2246
+ return timeA.unix() - timeB.unix();
2247
+ });
2233
2248
  const firstSlot = sortedSlots[0];
2234
- const firstDate = dayjs(firstSlot.start_time);
2249
+ const firstDate = tz ? dayjs(firstSlot.start_time).tz(tz) : dayjs(firstSlot.start_time);
2235
2250
  setSelectedDate(firstDate);
2236
2251
  setSelectedTimeslotId(firstSlot.id);
2237
2252
  }
2238
- }, [calendarValue, timeslotsData, isInitialized, selectedDate]);
2253
+ }, [
2254
+ calendarValue,
2255
+ timeslotsData,
2256
+ isInitialized,
2257
+ selectedDate,
2258
+ demoRoom?.timezone,
2259
+ timezone2
2260
+ ]);
2239
2261
  const formatTimeslot = (slot) => {
2240
- const start = dayjs(slot.start_time).format("h:mm A");
2241
- const end = dayjs(slot.end_time).format("h:mm A");
2262
+ const tz = demoRoom?.timezone || timezone2;
2263
+ const start = tz ? dayjs(slot.start_time).tz(tz).format("h:mm A") : dayjs(slot.start_time).format("h:mm A");
2264
+ const end = tz ? dayjs(slot.end_time).tz(tz).format("h:mm A") : dayjs(slot.end_time).format("h:mm A");
2242
2265
  return `${start} - ${end}`;
2243
2266
  };
2244
2267
  const wrapperStyle = {
@@ -2653,7 +2676,7 @@ var DateTimePicker = ({
2653
2676
  }) }),
2654
2677
  !timeslotsLoading && dayTimeslots?.length > 0 && /* @__PURE__ */ jsx("div", { className: "pt-[24px] text-[#6d6d6F] text-center", children: pageData?.timezone?.replace(
2655
2678
  "{{timezone}}",
2656
- demoRoom?.timezone || timezone || ""
2679
+ demoRoom?.timezone || timezone2 || ""
2657
2680
  ) })
2658
2681
  ] })
2659
2682
  ] }),
@@ -2666,6 +2689,7 @@ var DateTimePicker = ({
2666
2689
  loading: bookingLoading,
2667
2690
  pageData,
2668
2691
  selectedTimeslotId,
2692
+ error: bookingError,
2669
2693
  onSubmit: async (responses) => {
2670
2694
  if (onQuestionnaireSubmit) {
2671
2695
  await onQuestionnaireSubmit(responses);
@@ -2701,7 +2725,7 @@ var DateTimePicker = ({
2701
2725
  };
2702
2726
  var DateTimePicker_default = DateTimePicker;
2703
2727
 
2704
- // node_modules/swiper/shared/ssr-window.esm.mjs
2728
+ // ../../node_modules/swiper/shared/ssr-window.esm.mjs
2705
2729
  function isObject(obj) {
2706
2730
  return obj !== null && typeof obj === "object" && "constructor" in obj && obj.constructor === Object;
2707
2731
  }
@@ -2845,7 +2869,7 @@ function getWindow() {
2845
2869
  return win;
2846
2870
  }
2847
2871
 
2848
- // node_modules/swiper/shared/utils.mjs
2872
+ // ../../node_modules/swiper/shared/utils.mjs
2849
2873
  function classesToTokens(classes2 = "") {
2850
2874
  return classes2.trim().split(" ").filter((c) => !!c.trim());
2851
2875
  }
@@ -3116,7 +3140,7 @@ function setInnerHTML(el, html = "") {
3116
3140
  }
3117
3141
  }
3118
3142
 
3119
- // node_modules/swiper/shared/swiper-core.mjs
3143
+ // ../../node_modules/swiper/shared/swiper-core.mjs
3120
3144
  var support;
3121
3145
  function calcSupport() {
3122
3146
  const window2 = getWindow();
@@ -6750,7 +6774,7 @@ Object.keys(prototypes).forEach((prototypeGroup) => {
6750
6774
  });
6751
6775
  Swiper.use([Resize, Observer]);
6752
6776
 
6753
- // node_modules/swiper/shared/update-swiper.mjs
6777
+ // ../../node_modules/swiper/shared/update-swiper.mjs
6754
6778
  var paramsList = [
6755
6779
  "eventsPrefix",
6756
6780
  "injectStyles",
@@ -7079,7 +7103,7 @@ function updateSwiper({
7079
7103
  swiper.update();
7080
7104
  }
7081
7105
 
7082
- // node_modules/swiper/shared/update-on-virtual-data.mjs
7106
+ // ../../node_modules/swiper/shared/update-on-virtual-data.mjs
7083
7107
  function getParams(obj = {}, splitEvents = true) {
7084
7108
  const params = {
7085
7109
  on: {}
@@ -7197,7 +7221,7 @@ var updateOnVirtualData = (swiper) => {
7197
7221
  }
7198
7222
  };
7199
7223
 
7200
- // node_modules/swiper/swiper-react.mjs
7224
+ // ../../node_modules/swiper/swiper-react.mjs
7201
7225
  function _extends() {
7202
7226
  _extends = Object.assign ? Object.assign.bind() : function(target) {
7203
7227
  for (var i = 1; i < arguments.length; i++) {
@@ -7543,7 +7567,7 @@ var SwiperSlide = /* @__PURE__ */ forwardRef(({
7543
7567
  });
7544
7568
  SwiperSlide.displayName = "SwiperSlide";
7545
7569
 
7546
- // node_modules/swiper/shared/create-element-if-not-defined.mjs
7570
+ // ../../node_modules/swiper/shared/create-element-if-not-defined.mjs
7547
7571
  function createElementIfNotDefined(swiper, originalParams, params, checkProps) {
7548
7572
  if (swiper.params.createElements) {
7549
7573
  Object.keys(checkProps).forEach((key) => {
@@ -7562,7 +7586,7 @@ function createElementIfNotDefined(swiper, originalParams, params, checkProps) {
7562
7586
  return params;
7563
7587
  }
7564
7588
 
7565
- // node_modules/swiper/modules/navigation.mjs
7589
+ // ../../node_modules/swiper/modules/navigation.mjs
7566
7590
  var arrowSvg = `<svg class="swiper-navigation-icon" width="11" height="20" viewBox="0 0 11 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0.38296 20.0762C0.111788 19.805 0.111788 19.3654 0.38296 19.0942L9.19758 10.2796L0.38296 1.46497C0.111788 1.19379 0.111788 0.754138 0.38296 0.482966C0.654131 0.211794 1.09379 0.211794 1.36496 0.482966L10.4341 9.55214C10.8359 9.9539 10.8359 10.6053 10.4341 11.007L1.36496 20.0762C1.09379 20.3474 0.654131 20.3474 0.38296 20.0762Z" fill="currentColor"/></svg>`;
7567
7591
  function Navigation({
7568
7592
  swiper,
@@ -7764,12 +7788,12 @@ function Navigation({
7764
7788
  });
7765
7789
  }
7766
7790
 
7767
- // node_modules/swiper/shared/classes-to-selector.mjs
7791
+ // ../../node_modules/swiper/shared/classes-to-selector.mjs
7768
7792
  function classesToSelector(classes2 = "") {
7769
7793
  return `.${classes2.trim().replace(/([\.:!+\/()[\]])/g, "\\$1").replace(/ /g, ".")}`;
7770
7794
  }
7771
7795
 
7772
- // node_modules/swiper/modules/pagination.mjs
7796
+ // ../../node_modules/swiper/modules/pagination.mjs
7773
7797
  function Pagination({
7774
7798
  swiper,
7775
7799
  extendParams,
@@ -8217,7 +8241,7 @@ function Pagination({
8217
8241
  });
8218
8242
  }
8219
8243
 
8220
- // node_modules/swiper/modules/autoplay.mjs
8244
+ // ../../node_modules/swiper/modules/autoplay.mjs
8221
8245
  function Autoplay({
8222
8246
  swiper,
8223
8247
  extendParams,
@@ -8754,7 +8778,7 @@ var BookingForm = ({
8754
8778
  apiConfig,
8755
8779
  demoRoomCode,
8756
8780
  pageData,
8757
- timezone,
8781
+ timezone: timezone2,
8758
8782
  handleBookingSuccess,
8759
8783
  onQuestionnaireSubmit,
8760
8784
  ...props
@@ -8786,7 +8810,7 @@ var BookingForm = ({
8786
8810
  {
8787
8811
  apiClient,
8788
8812
  demoRoomCode,
8789
- timezone,
8813
+ timezone: timezone2,
8790
8814
  locale: apiConfig.locale,
8791
8815
  onBookingSuccess: handleBookingSuccess,
8792
8816
  onQuestionnaireSubmit,