@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/demo-room.js +23 -1
- package/dist/demo-room.js.map +1 -1
- package/dist/demo-room.mjs +20 -1
- package/dist/demo-room.mjs.map +1 -1
- package/dist/index.js +84 -48
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -45
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8,26 +8,26 @@ var IndexBar = require('antd-mobile/es/components/index-bar');
|
|
|
8
8
|
var List = require('antd-mobile/es/components/list');
|
|
9
9
|
require('antd-mobile/es/components/index-bar/index-bar.css');
|
|
10
10
|
require('antd-mobile/es/components/list/list.css');
|
|
11
|
-
var
|
|
11
|
+
var dayjs2 = require('dayjs');
|
|
12
|
+
var utc = require('dayjs/plugin/utc');
|
|
13
|
+
var timezone = require('dayjs/plugin/timezone');
|
|
12
14
|
require('dayjs/locale/zh-cn');
|
|
13
15
|
var antd = require('antd');
|
|
14
16
|
var dayLocaleData = require('dayjs/plugin/localeData');
|
|
15
17
|
var weekday = require('dayjs/plugin/weekday');
|
|
16
18
|
var weekOfYear = require('dayjs/plugin/weekOfYear');
|
|
17
|
-
var timezone = require('dayjs/plugin/timezone');
|
|
18
|
-
var utc = require('dayjs/plugin/utc');
|
|
19
19
|
|
|
20
20
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
21
|
|
|
22
22
|
var React9__default = /*#__PURE__*/_interopDefault(React9);
|
|
23
23
|
var IndexBar__default = /*#__PURE__*/_interopDefault(IndexBar);
|
|
24
24
|
var List__default = /*#__PURE__*/_interopDefault(List);
|
|
25
|
-
var
|
|
25
|
+
var dayjs2__default = /*#__PURE__*/_interopDefault(dayjs2);
|
|
26
|
+
var utc__default = /*#__PURE__*/_interopDefault(utc);
|
|
27
|
+
var timezone__default = /*#__PURE__*/_interopDefault(timezone);
|
|
26
28
|
var dayLocaleData__default = /*#__PURE__*/_interopDefault(dayLocaleData);
|
|
27
29
|
var weekday__default = /*#__PURE__*/_interopDefault(weekday);
|
|
28
30
|
var weekOfYear__default = /*#__PURE__*/_interopDefault(weekOfYear);
|
|
29
|
-
var timezone__default = /*#__PURE__*/_interopDefault(timezone);
|
|
30
|
-
var utc__default = /*#__PURE__*/_interopDefault(utc);
|
|
31
31
|
|
|
32
32
|
function cn(...inputs) {
|
|
33
33
|
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
@@ -1117,6 +1117,8 @@ var LocationFilter = ({
|
|
|
1117
1117
|
);
|
|
1118
1118
|
};
|
|
1119
1119
|
LocationFilter.displayName = "LocationFilter";
|
|
1120
|
+
dayjs2__default.default.extend(utc__default.default);
|
|
1121
|
+
dayjs2__default.default.extend(timezone__default.default);
|
|
1120
1122
|
var defaultPageData = {
|
|
1121
1123
|
title: "Find a Studio Near You",
|
|
1122
1124
|
loadingText: "Loading demo rooms...",
|
|
@@ -1296,6 +1298,20 @@ var RoomsList = ({
|
|
|
1296
1298
|
const city = room.location?.city || "";
|
|
1297
1299
|
const addressParts = [room.address, city, state, country].filter(Boolean);
|
|
1298
1300
|
const fullAddress = addressParts.join(", ");
|
|
1301
|
+
let formattedTime = mergedPageData.noAvailableTime;
|
|
1302
|
+
if (nextAvailableTimeslot) {
|
|
1303
|
+
try {
|
|
1304
|
+
const timeInZone = dayjs2__default.default(nextAvailableTimeslot.start_time).tz(
|
|
1305
|
+
room.timezone || "America/Los_Angeles"
|
|
1306
|
+
);
|
|
1307
|
+
const month = timeInZone.format("MMM");
|
|
1308
|
+
const day = timeInZone.format("D");
|
|
1309
|
+
const time = timeInZone.format("h:mm A");
|
|
1310
|
+
formattedTime = `${month}.${day}, ${time}`;
|
|
1311
|
+
} catch (error2) {
|
|
1312
|
+
formattedTime = nextAvailableTimeslot.start_time;
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1299
1315
|
return {
|
|
1300
1316
|
id: room.code,
|
|
1301
1317
|
name: room.name,
|
|
@@ -1306,7 +1322,7 @@ var RoomsList = ({
|
|
|
1306
1322
|
country,
|
|
1307
1323
|
lat: Number(room.latitude) || 0,
|
|
1308
1324
|
lng: Number(room.longitude) || 0,
|
|
1309
|
-
availableTime:
|
|
1325
|
+
availableTime: formattedTime,
|
|
1310
1326
|
euifyMakeModel: room?.equipment?.join(", ") || ""
|
|
1311
1327
|
};
|
|
1312
1328
|
});
|
|
@@ -1685,7 +1701,12 @@ var QuestionnaireForm = ({
|
|
|
1685
1701
|
const [phoneCountryCodes, setPhoneCountryCodes] = React9.useState({});
|
|
1686
1702
|
const [otherInputs, setOtherInputs] = React9.useState({});
|
|
1687
1703
|
const prevHasBookedBeforeRef = React9.useRef(false);
|
|
1688
|
-
const
|
|
1704
|
+
const hasBookedBeforeInitialized = React9.useRef(false);
|
|
1705
|
+
const hasBookedBeforeQuestion = questions.find(
|
|
1706
|
+
(q) => (q.key || q.id) === "has_booked_before"
|
|
1707
|
+
);
|
|
1708
|
+
const hasBookedBeforeQuestionId = hasBookedBeforeQuestion ? hasBookedBeforeQuestion.key || hasBookedBeforeQuestion.id || "" : "has_booked_before";
|
|
1709
|
+
const hasBookedBefore = responses[hasBookedBeforeQuestionId] === "option2";
|
|
1689
1710
|
const hiddenQuestionIds = React9.useMemo(() => {
|
|
1690
1711
|
if (!hasBookedBefore) return [];
|
|
1691
1712
|
return questions.filter((q) => q.is_default === false).map((q) => q.key || q.id || "");
|
|
@@ -1698,6 +1719,21 @@ var QuestionnaireForm = ({
|
|
|
1698
1719
|
return true;
|
|
1699
1720
|
});
|
|
1700
1721
|
}, [questions, hasBookedBefore]);
|
|
1722
|
+
React9.useEffect(() => {
|
|
1723
|
+
if (hasBookedBeforeInitialized.current) return;
|
|
1724
|
+
if (hasBookedBeforeQuestion && hasBookedBeforeQuestionId) {
|
|
1725
|
+
setResponses((prev) => {
|
|
1726
|
+
if (!prev[hasBookedBeforeQuestionId]) {
|
|
1727
|
+
return {
|
|
1728
|
+
...prev,
|
|
1729
|
+
[hasBookedBeforeQuestionId]: "option1"
|
|
1730
|
+
};
|
|
1731
|
+
}
|
|
1732
|
+
return prev;
|
|
1733
|
+
});
|
|
1734
|
+
hasBookedBeforeInitialized.current = true;
|
|
1735
|
+
}
|
|
1736
|
+
}, [hasBookedBeforeQuestion, hasBookedBeforeQuestionId]);
|
|
1701
1737
|
React9.useEffect(() => {
|
|
1702
1738
|
if (hasBookedBefore && !prevHasBookedBeforeRef.current) {
|
|
1703
1739
|
if (hiddenQuestionIds.length > 0) {
|
|
@@ -2195,15 +2231,15 @@ var QuestionnaireForm = ({
|
|
|
2195
2231
|
] })
|
|
2196
2232
|
] });
|
|
2197
2233
|
};
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2234
|
+
dayjs2__default.default.extend(dayLocaleData__default.default);
|
|
2235
|
+
dayjs2__default.default.extend(weekday__default.default);
|
|
2236
|
+
dayjs2__default.default.extend(weekOfYear__default.default);
|
|
2237
|
+
dayjs2__default.default.extend(utc__default.default);
|
|
2238
|
+
dayjs2__default.default.extend(timezone__default.default);
|
|
2203
2239
|
var DateTimePicker = ({
|
|
2204
2240
|
apiClient,
|
|
2205
2241
|
demoRoomCode,
|
|
2206
|
-
timezone:
|
|
2242
|
+
timezone: timezone3,
|
|
2207
2243
|
pageData = {
|
|
2208
2244
|
scheduleYourVisit: "Schedule Your Visit",
|
|
2209
2245
|
timeSlot: "Time Slot",
|
|
@@ -2222,7 +2258,7 @@ var DateTimePicker = ({
|
|
|
2222
2258
|
}) => {
|
|
2223
2259
|
const { token } = antd.theme.useToken();
|
|
2224
2260
|
const [selectedDate, setSelectedDate] = React9.useState(null);
|
|
2225
|
-
const [calendarValue, setCalendarValue] = React9.useState(
|
|
2261
|
+
const [calendarValue, setCalendarValue] = React9.useState(dayjs2__default.default());
|
|
2226
2262
|
const [selectedTimeslotId, setSelectedTimeslotId] = React9.useState(
|
|
2227
2263
|
null
|
|
2228
2264
|
);
|
|
@@ -2257,47 +2293,47 @@ var DateTimePicker = ({
|
|
|
2257
2293
|
{
|
|
2258
2294
|
start_date: startDate,
|
|
2259
2295
|
end_date: endDate,
|
|
2260
|
-
timezone:
|
|
2296
|
+
timezone: timezone3
|
|
2261
2297
|
},
|
|
2262
2298
|
{ enabled: !!demoRoomCode }
|
|
2263
2299
|
);
|
|
2264
2300
|
const dayTimeslots = React9.useMemo(() => {
|
|
2265
2301
|
if (!timeslotsData?.timeslots || !selectedDate) return [];
|
|
2266
|
-
const tz = demoRoom?.timezone ||
|
|
2302
|
+
const tz = demoRoom?.timezone || timezone3;
|
|
2267
2303
|
const selectedDateStr = selectedDate.format("YYYY-MM-DD");
|
|
2268
2304
|
return timeslotsData.timeslots.filter((slot) => {
|
|
2269
|
-
const slotDate = tz ?
|
|
2305
|
+
const slotDate = tz ? dayjs2__default.default(slot.start_time).tz(tz).format("YYYY-MM-DD") : dayjs2__default.default(slot.start_time).format("YYYY-MM-DD");
|
|
2270
2306
|
return slotDate === selectedDateStr;
|
|
2271
2307
|
});
|
|
2272
|
-
}, [timeslotsData, selectedDate, demoRoom?.timezone,
|
|
2308
|
+
}, [timeslotsData, selectedDate, demoRoom?.timezone, timezone3]);
|
|
2273
2309
|
const availableDates = React9.useMemo(() => {
|
|
2274
2310
|
if (!timeslotsData?.timeslots) return /* @__PURE__ */ new Set();
|
|
2275
|
-
const tz = demoRoom?.timezone ||
|
|
2311
|
+
const tz = demoRoom?.timezone || timezone3;
|
|
2276
2312
|
const dates = /* @__PURE__ */ new Set();
|
|
2277
2313
|
timeslotsData.timeslots.forEach((slot) => {
|
|
2278
2314
|
if (slot.status === "available") {
|
|
2279
|
-
const dateStr = tz ?
|
|
2315
|
+
const dateStr = tz ? dayjs2__default.default(slot.start_time).tz(tz).format("YYYY-MM-DD") : dayjs2__default.default(slot.start_time).format("YYYY-MM-DD");
|
|
2280
2316
|
dates.add(dateStr);
|
|
2281
2317
|
}
|
|
2282
2318
|
});
|
|
2283
2319
|
return dates;
|
|
2284
|
-
}, [timeslotsData, demoRoom?.timezone,
|
|
2320
|
+
}, [timeslotsData, demoRoom?.timezone, timezone3]);
|
|
2285
2321
|
React9.useEffect(() => {
|
|
2286
2322
|
if (!timeslotsData?.timeslots || isInitialized) return;
|
|
2287
|
-
const tz = demoRoom?.timezone ||
|
|
2288
|
-
const now2 = tz ?
|
|
2323
|
+
const tz = demoRoom?.timezone || timezone3;
|
|
2324
|
+
const now2 = tz ? dayjs2__default.default().tz(tz) : dayjs2__default.default();
|
|
2289
2325
|
const availableTimeslots = timeslotsData.timeslots.filter((slot) => {
|
|
2290
|
-
const slotTime = tz ?
|
|
2326
|
+
const slotTime = tz ? dayjs2__default.default(slot.start_time).tz(tz) : dayjs2__default.default(slot.start_time);
|
|
2291
2327
|
return slot.status === "available" && slotTime.isAfter(now2);
|
|
2292
2328
|
});
|
|
2293
2329
|
if (availableTimeslots.length > 0) {
|
|
2294
2330
|
const sortedSlots = [...availableTimeslots].sort((a, b) => {
|
|
2295
|
-
const timeA = tz ?
|
|
2296
|
-
const timeB = tz ?
|
|
2331
|
+
const timeA = tz ? dayjs2__default.default(a.start_time).tz(tz) : dayjs2__default.default(a.start_time);
|
|
2332
|
+
const timeB = tz ? dayjs2__default.default(b.start_time).tz(tz) : dayjs2__default.default(b.start_time);
|
|
2297
2333
|
return timeA.unix() - timeB.unix();
|
|
2298
2334
|
});
|
|
2299
2335
|
const nearestSlot = sortedSlots[0];
|
|
2300
|
-
const nearestDate = tz ?
|
|
2336
|
+
const nearestDate = tz ? dayjs2__default.default(nearestSlot.start_time).tz(tz) : dayjs2__default.default(nearestSlot.start_time);
|
|
2301
2337
|
setSelectedDate(nearestDate);
|
|
2302
2338
|
setCalendarValue(nearestDate);
|
|
2303
2339
|
setSelectedTimeslotId(nearestSlot.id);
|
|
@@ -2307,28 +2343,28 @@ var DateTimePicker = ({
|
|
|
2307
2343
|
setCalendarValue(now2);
|
|
2308
2344
|
setIsInitialized(true);
|
|
2309
2345
|
}
|
|
2310
|
-
}, [timeslotsData, isInitialized, selectedDate, demoRoom?.timezone,
|
|
2346
|
+
}, [timeslotsData, isInitialized, selectedDate, demoRoom?.timezone, timezone3]);
|
|
2311
2347
|
React9.useEffect(() => {
|
|
2312
2348
|
if (!timeslotsData?.timeslots || !isInitialized) return;
|
|
2313
2349
|
if (selectedDate && selectedDate.isSame(calendarValue, "month")) {
|
|
2314
2350
|
return;
|
|
2315
2351
|
}
|
|
2316
|
-
const tz = demoRoom?.timezone ||
|
|
2352
|
+
const tz = demoRoom?.timezone || timezone3;
|
|
2317
2353
|
const currentMonthStart = calendarValue.startOf("month");
|
|
2318
2354
|
const currentMonthEnd = calendarValue.endOf("month");
|
|
2319
|
-
const now2 = tz ?
|
|
2355
|
+
const now2 = tz ? dayjs2__default.default().tz(tz) : dayjs2__default.default();
|
|
2320
2356
|
const availableTimeslots = timeslotsData.timeslots.filter((slot) => {
|
|
2321
|
-
const slotDate = tz ?
|
|
2357
|
+
const slotDate = tz ? dayjs2__default.default(slot.start_time).tz(tz) : dayjs2__default.default(slot.start_time);
|
|
2322
2358
|
return slot.status === "available" && slotDate.isAfter(now2) && (slotDate.isAfter(currentMonthStart) || slotDate.isSame(currentMonthStart, "day")) && (slotDate.isBefore(currentMonthEnd) || slotDate.isSame(currentMonthEnd, "day"));
|
|
2323
2359
|
});
|
|
2324
2360
|
if (availableTimeslots.length > 0) {
|
|
2325
2361
|
const sortedSlots = [...availableTimeslots].sort((a, b) => {
|
|
2326
|
-
const timeA = tz ?
|
|
2327
|
-
const timeB = tz ?
|
|
2362
|
+
const timeA = tz ? dayjs2__default.default(a.start_time).tz(tz) : dayjs2__default.default(a.start_time);
|
|
2363
|
+
const timeB = tz ? dayjs2__default.default(b.start_time).tz(tz) : dayjs2__default.default(b.start_time);
|
|
2328
2364
|
return timeA.unix() - timeB.unix();
|
|
2329
2365
|
});
|
|
2330
2366
|
const firstSlot = sortedSlots[0];
|
|
2331
|
-
const firstDate = tz ?
|
|
2367
|
+
const firstDate = tz ? dayjs2__default.default(firstSlot.start_time).tz(tz) : dayjs2__default.default(firstSlot.start_time);
|
|
2332
2368
|
setSelectedDate(firstDate);
|
|
2333
2369
|
setSelectedTimeslotId(firstSlot.id);
|
|
2334
2370
|
}
|
|
@@ -2338,12 +2374,12 @@ var DateTimePicker = ({
|
|
|
2338
2374
|
isInitialized,
|
|
2339
2375
|
selectedDate,
|
|
2340
2376
|
demoRoom?.timezone,
|
|
2341
|
-
|
|
2377
|
+
timezone3
|
|
2342
2378
|
]);
|
|
2343
2379
|
const formatTimeslot = (slot) => {
|
|
2344
|
-
const tz = demoRoom?.timezone ||
|
|
2345
|
-
const start = tz ?
|
|
2346
|
-
const end = tz ?
|
|
2380
|
+
const tz = demoRoom?.timezone || timezone3;
|
|
2381
|
+
const start = tz ? dayjs2__default.default(slot.start_time).tz(tz).format("h:mm A") : dayjs2__default.default(slot.start_time).format("h:mm A");
|
|
2382
|
+
const end = tz ? dayjs2__default.default(slot.end_time).tz(tz).format("h:mm A") : dayjs2__default.default(slot.end_time).format("h:mm A");
|
|
2347
2383
|
return `${start} - ${end}`;
|
|
2348
2384
|
};
|
|
2349
2385
|
const wrapperStyle = {
|
|
@@ -2504,16 +2540,16 @@ var DateTimePicker = ({
|
|
|
2504
2540
|
},
|
|
2505
2541
|
disabledDate: (current) => {
|
|
2506
2542
|
if (!current) return false;
|
|
2507
|
-
if (current.isSame(
|
|
2508
|
-
if (current.isBefore(
|
|
2543
|
+
if (current.isSame(dayjs2__default.default(), "day")) return false;
|
|
2544
|
+
if (current.isBefore(dayjs2__default.default(), "day")) return true;
|
|
2509
2545
|
const dateStr = current.format("YYYY-MM-DD");
|
|
2510
2546
|
return !availableDates.has(dateStr);
|
|
2511
2547
|
},
|
|
2512
2548
|
fullCellRender: (date) => {
|
|
2513
2549
|
const isSelected = selectedDate && date.isSame(selectedDate, "day");
|
|
2514
|
-
const isToday = date.isSame(
|
|
2550
|
+
const isToday = date.isSame(dayjs2__default.default(), "day");
|
|
2515
2551
|
const dateStr = date.format("YYYY-MM-DD");
|
|
2516
|
-
const isDisabled = !isToday && (date.isBefore(
|
|
2552
|
+
const isDisabled = !isToday && (date.isBefore(dayjs2__default.default(), "day") || !availableDates.has(dateStr));
|
|
2517
2553
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2518
2554
|
"div",
|
|
2519
2555
|
{
|
|
@@ -2659,13 +2695,13 @@ var DateTimePicker = ({
|
|
|
2659
2695
|
onClick: () => {
|
|
2660
2696
|
if (selectedDate) {
|
|
2661
2697
|
const newDate = selectedDate.subtract(1, "day");
|
|
2662
|
-
if (!newDate.isBefore(
|
|
2698
|
+
if (!newDate.isBefore(dayjs2__default.default(), "day")) {
|
|
2663
2699
|
setSelectedDate(newDate);
|
|
2664
2700
|
setCalendarValue(newDate);
|
|
2665
2701
|
}
|
|
2666
2702
|
}
|
|
2667
2703
|
},
|
|
2668
|
-
disabled: !selectedDate || selectedDate.isSame(
|
|
2704
|
+
disabled: !selectedDate || selectedDate.isSame(dayjs2__default.default(), "day") || selectedDate.isBefore(dayjs2__default.default(), "day"),
|
|
2669
2705
|
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",
|
|
2670
2706
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2671
2707
|
"svg",
|
|
@@ -2758,7 +2794,7 @@ var DateTimePicker = ({
|
|
|
2758
2794
|
}) }),
|
|
2759
2795
|
!timeslotsLoading && dayTimeslots?.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pt-[24px] text-[#6d6d6F] text-center", children: pageData?.timezone?.replace(
|
|
2760
2796
|
"{{timezone}}",
|
|
2761
|
-
demoRoom?.timezone ||
|
|
2797
|
+
demoRoom?.timezone || timezone3 || ""
|
|
2762
2798
|
) })
|
|
2763
2799
|
] })
|
|
2764
2800
|
] }),
|
|
@@ -8862,7 +8898,7 @@ var BookingForm = ({
|
|
|
8862
8898
|
apiConfig,
|
|
8863
8899
|
demoRoomCode,
|
|
8864
8900
|
pageData,
|
|
8865
|
-
timezone:
|
|
8901
|
+
timezone: timezone3,
|
|
8866
8902
|
handleBookingSuccess,
|
|
8867
8903
|
onQuestionnaireSubmit,
|
|
8868
8904
|
...props
|
|
@@ -8894,7 +8930,7 @@ var BookingForm = ({
|
|
|
8894
8930
|
{
|
|
8895
8931
|
apiClient,
|
|
8896
8932
|
demoRoomCode,
|
|
8897
|
-
timezone:
|
|
8933
|
+
timezone: timezone3,
|
|
8898
8934
|
locale: apiConfig.locale,
|
|
8899
8935
|
onBookingSuccess: handleBookingSuccess,
|
|
8900
8936
|
onQuestionnaireSubmit,
|