@timardex/cluemart-shared 1.5.502 → 1.5.504
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/{chunk-6JRXEOO3.mjs → chunk-A3BCQJII.mjs} +2 -2
- package/dist/{chunk-PZZKQ3IV.mjs → chunk-XNMKWMNF.mjs} +84 -87
- package/dist/chunk-XNMKWMNF.mjs.map +1 -0
- package/dist/formFields/index.cjs +8 -11
- package/dist/formFields/index.cjs.map +1 -1
- package/dist/formFields/index.mjs +2 -2
- package/dist/hooks/index.cjs +21 -24
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.mjs +2 -2
- package/dist/index.cjs +95 -99
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +14 -11
- package/dist/index.d.ts +14 -11
- package/dist/index.mjs +94 -99
- package/dist/index.mjs.map +1 -1
- package/dist/utils/index.cjs +82 -88
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.mts +14 -11
- package/dist/utils/index.d.ts +14 -11
- package/dist/utils/index.mjs +3 -1
- package/package.json +1 -1
- package/dist/chunk-PZZKQ3IV.mjs.map +0 -1
- /package/dist/{chunk-6JRXEOO3.mjs.map → chunk-A3BCQJII.mjs.map} +0 -0
package/dist/hooks/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-A3BCQJII.mjs";
|
|
2
2
|
import "../chunk-RQDZX76B.mjs";
|
|
3
3
|
import "../chunk-DWO35OY4.mjs";
|
|
4
4
|
import "../chunk-I7WE3EBR.mjs";
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
dateFormat,
|
|
15
15
|
normalizeUrl,
|
|
16
16
|
timeFormat
|
|
17
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-XNMKWMNF.mjs";
|
|
18
18
|
import {
|
|
19
19
|
EnumEventDateStatus,
|
|
20
20
|
EnumEventType,
|
package/dist/index.cjs
CHANGED
|
@@ -102,6 +102,7 @@ __export(index_exports, {
|
|
|
102
102
|
getCurrentAndFutureDates: () => getCurrentAndFutureDates,
|
|
103
103
|
globalDefaultValues: () => globalDefaultValues,
|
|
104
104
|
isFutureDatesBeforeThreshold: () => isFutureDatesBeforeThreshold,
|
|
105
|
+
isIsoDateString: () => isIsoDateString,
|
|
105
106
|
licenseNiceNames: () => licenseNiceNames,
|
|
106
107
|
lightColors: () => lightColors,
|
|
107
108
|
loginFields: () => loginFields,
|
|
@@ -728,10 +729,6 @@ var priceUnits = [
|
|
|
728
729
|
{ label: "Half dozen", value: "HALF_DOZEN" }
|
|
729
730
|
];
|
|
730
731
|
|
|
731
|
-
// src/utils/dailyClueGame.ts
|
|
732
|
-
var import_dayjs = __toESM(require("dayjs"));
|
|
733
|
-
var import_utc = __toESM(require("dayjs/plugin/utc"));
|
|
734
|
-
|
|
735
732
|
// src/types/game.ts
|
|
736
733
|
var gameScreenIdentifierList = [
|
|
737
734
|
{
|
|
@@ -844,8 +841,76 @@ var EnumGameStatus = /* @__PURE__ */ ((EnumGameStatus2) => {
|
|
|
844
841
|
return EnumGameStatus2;
|
|
845
842
|
})(EnumGameStatus || {});
|
|
846
843
|
|
|
847
|
-
// src/utils/
|
|
844
|
+
// src/utils/date.ts
|
|
845
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
846
|
+
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat.js"));
|
|
847
|
+
var import_isSameOrAfter = __toESM(require("dayjs/plugin/isSameOrAfter.js"));
|
|
848
|
+
var import_timezone = __toESM(require("dayjs/plugin/timezone.js"));
|
|
849
|
+
var import_utc = __toESM(require("dayjs/plugin/utc.js"));
|
|
850
|
+
var dateFormat = "DD-MM-YYYY";
|
|
851
|
+
var timeFormat = "HH:mm";
|
|
852
|
+
import_dayjs.default.extend(import_customParseFormat.default);
|
|
848
853
|
import_dayjs.default.extend(import_utc.default);
|
|
854
|
+
import_dayjs.default.extend(import_timezone.default);
|
|
855
|
+
import_dayjs.default.extend(import_isSameOrAfter.default);
|
|
856
|
+
var NZ_TZ = "Pacific/Auckland";
|
|
857
|
+
function toNZTime(date3) {
|
|
858
|
+
return date3 ? (0, import_dayjs.default)(date3).tz(NZ_TZ) : (0, import_dayjs.default)().tz(NZ_TZ);
|
|
859
|
+
}
|
|
860
|
+
var formatDate = (dateStr, display = "datetime", timeStr) => {
|
|
861
|
+
const dateTimeStr = timeStr ? `${dateStr} ${timeStr}` : dateStr;
|
|
862
|
+
const dateTime = timeStr ? (0, import_dayjs.default)(dateTimeStr, `${dateFormat} ${timeFormat}`) : (0, import_dayjs.default)(dateStr, dateFormat);
|
|
863
|
+
const formattedDate = dateTime.format("dddd, D MMMM, YYYY");
|
|
864
|
+
const formattedTime = dateTime.format("h:mm a");
|
|
865
|
+
switch (display) {
|
|
866
|
+
case "date":
|
|
867
|
+
return formattedDate;
|
|
868
|
+
case "time":
|
|
869
|
+
return formattedTime;
|
|
870
|
+
case "datetime":
|
|
871
|
+
return `${formattedDate} at ${formattedTime}`;
|
|
872
|
+
default:
|
|
873
|
+
return formattedDate;
|
|
874
|
+
}
|
|
875
|
+
};
|
|
876
|
+
var getCurrentAndFutureDates = (dates) => {
|
|
877
|
+
const now = (0, import_dayjs.default)();
|
|
878
|
+
return dates.filter((dateObj) => {
|
|
879
|
+
const dateTime = (0, import_dayjs.default)(
|
|
880
|
+
`${dateObj.startDate} ${dateObj.startTime}`,
|
|
881
|
+
`${dateFormat} ${timeFormat}`
|
|
882
|
+
);
|
|
883
|
+
return dateTime.isSameOrAfter(now);
|
|
884
|
+
});
|
|
885
|
+
};
|
|
886
|
+
var isFutureDatesBeforeThreshold = (date3, minHoursFromNow) => {
|
|
887
|
+
const threshold = minHoursFromNow ? (0, import_dayjs.default)().add(minHoursFromNow, "hour") : (0, import_dayjs.default)().startOf("day");
|
|
888
|
+
const dateTime = (0, import_dayjs.default)(
|
|
889
|
+
`${date3.startDate} ${date3.startTime}`,
|
|
890
|
+
`${dateFormat} ${timeFormat}`
|
|
891
|
+
);
|
|
892
|
+
return dateTime.isSameOrAfter(threshold);
|
|
893
|
+
};
|
|
894
|
+
var formatTimestamp = (timestamp) => {
|
|
895
|
+
const formattedDate = toNZTime(timestamp).format(dateFormat);
|
|
896
|
+
return formatDate(formattedDate, "date");
|
|
897
|
+
};
|
|
898
|
+
var isIsoDateString = (value) => {
|
|
899
|
+
return typeof value === "string" && !isNaN(Date.parse(value));
|
|
900
|
+
};
|
|
901
|
+
function sortDatesChronologically(dates) {
|
|
902
|
+
if (!dates || !dates.length) {
|
|
903
|
+
return [];
|
|
904
|
+
}
|
|
905
|
+
return [...dates].sort((a, b) => {
|
|
906
|
+
const dateTimeFormat = `${dateFormat} ${timeFormat}`;
|
|
907
|
+
const dateA = (0, import_dayjs.default)(`${a.startDate} ${a.startTime}`, dateTimeFormat);
|
|
908
|
+
const dateB = (0, import_dayjs.default)(`${b.startDate} ${b.startTime}`, dateTimeFormat);
|
|
909
|
+
return dateA.valueOf() - dateB.valueOf();
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
// src/utils/dailyClueGame.ts
|
|
849
914
|
function createSeededRng(seed) {
|
|
850
915
|
let t = seed >>> 0;
|
|
851
916
|
return function random() {
|
|
@@ -873,15 +938,15 @@ function seededShuffle(array6, seed) {
|
|
|
873
938
|
}
|
|
874
939
|
return result;
|
|
875
940
|
}
|
|
876
|
-
function getDayIndex(
|
|
877
|
-
return
|
|
941
|
+
function getDayIndex(start, today) {
|
|
942
|
+
return today.diff(start, "day");
|
|
878
943
|
}
|
|
879
944
|
function computeDailyClueState(dailyClue) {
|
|
880
945
|
const { startDate, endDate } = dailyClue.gameFields.gameDate;
|
|
881
946
|
const { shuffled, collected } = dailyClue.letterInfo;
|
|
882
|
-
const today = (
|
|
883
|
-
const start = (
|
|
884
|
-
const end = (
|
|
947
|
+
const today = toNZTime().startOf("day");
|
|
948
|
+
const start = toNZTime(startDate).startOf("day");
|
|
949
|
+
const end = toNZTime(endDate).startOf("day");
|
|
885
950
|
const shuffledPlacements = seededShuffle(
|
|
886
951
|
gameScreenIdentifierList,
|
|
887
952
|
start.toISOString()
|
|
@@ -889,14 +954,6 @@ function computeDailyClueState(dailyClue) {
|
|
|
889
954
|
if (today.isBefore(start)) {
|
|
890
955
|
return null;
|
|
891
956
|
}
|
|
892
|
-
if (today.isAfter(end)) {
|
|
893
|
-
return null;
|
|
894
|
-
}
|
|
895
|
-
const index = getDayIndex(startDate);
|
|
896
|
-
if (index < 0 || index >= shuffled.length) return null;
|
|
897
|
-
if (collected?.includes(shuffled[index])) {
|
|
898
|
-
return null;
|
|
899
|
-
}
|
|
900
957
|
if (today.isAfter(end)) {
|
|
901
958
|
return {
|
|
902
959
|
gameHistory: {
|
|
@@ -910,6 +967,11 @@ function computeDailyClueState(dailyClue) {
|
|
|
910
967
|
todaysPlacement: null
|
|
911
968
|
};
|
|
912
969
|
}
|
|
970
|
+
const index = getDayIndex(start, today);
|
|
971
|
+
if (index < 0 || index >= shuffled.length) return null;
|
|
972
|
+
if (collected?.includes(shuffled[index])) {
|
|
973
|
+
return null;
|
|
974
|
+
}
|
|
913
975
|
return {
|
|
914
976
|
gameHistory: null,
|
|
915
977
|
todaysClue: shuffledPlacements[index].clue,
|
|
@@ -918,63 +980,7 @@ function computeDailyClueState(dailyClue) {
|
|
|
918
980
|
};
|
|
919
981
|
}
|
|
920
982
|
|
|
921
|
-
// src/utils/
|
|
922
|
-
var import_dayjs2 = __toESM(require("dayjs"));
|
|
923
|
-
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat.js"));
|
|
924
|
-
var import_isSameOrAfter = __toESM(require("dayjs/plugin/isSameOrAfter.js"));
|
|
925
|
-
var import_timezone = __toESM(require("dayjs/plugin/timezone.js"));
|
|
926
|
-
var import_utc2 = __toESM(require("dayjs/plugin/utc.js"));
|
|
927
|
-
var dateFormat = "DD-MM-YYYY";
|
|
928
|
-
var timeFormat = "HH:mm";
|
|
929
|
-
import_dayjs2.default.extend(import_customParseFormat.default);
|
|
930
|
-
import_dayjs2.default.extend(import_utc2.default);
|
|
931
|
-
import_dayjs2.default.extend(import_timezone.default);
|
|
932
|
-
import_dayjs2.default.extend(import_isSameOrAfter.default);
|
|
933
|
-
var NZ_TZ = "Pacific/Auckland";
|
|
934
|
-
function toNZTime(date3) {
|
|
935
|
-
return (0, import_dayjs2.default)(date3).tz(NZ_TZ).format();
|
|
936
|
-
}
|
|
937
|
-
var formatDate = (dateStr, display = "datetime", timeStr) => {
|
|
938
|
-
const dateTimeStr = timeStr ? `${dateStr} ${timeStr}` : dateStr;
|
|
939
|
-
const dateTime = timeStr ? (0, import_dayjs2.default)(dateTimeStr, `${dateFormat} ${timeFormat}`) : (0, import_dayjs2.default)(dateStr, dateFormat);
|
|
940
|
-
const formattedDate = dateTime.format("dddd, D MMMM, YYYY");
|
|
941
|
-
const formattedTime = dateTime.format("h:mm a");
|
|
942
|
-
switch (display) {
|
|
943
|
-
case "date":
|
|
944
|
-
return formattedDate;
|
|
945
|
-
case "time":
|
|
946
|
-
return formattedTime;
|
|
947
|
-
case "datetime":
|
|
948
|
-
return `${formattedDate} at ${formattedTime}`;
|
|
949
|
-
default:
|
|
950
|
-
return formattedDate;
|
|
951
|
-
}
|
|
952
|
-
};
|
|
953
|
-
var getCurrentAndFutureDates = (dates) => {
|
|
954
|
-
const now = (0, import_dayjs2.default)();
|
|
955
|
-
return dates.filter((dateObj) => {
|
|
956
|
-
const dateTime = (0, import_dayjs2.default)(
|
|
957
|
-
`${dateObj.startDate} ${dateObj.startTime}`,
|
|
958
|
-
`${dateFormat} ${timeFormat}`
|
|
959
|
-
);
|
|
960
|
-
return dateTime.isSameOrAfter(now);
|
|
961
|
-
});
|
|
962
|
-
};
|
|
963
|
-
var isFutureDatesBeforeThreshold = (date3, minHoursFromNow) => {
|
|
964
|
-
const threshold = minHoursFromNow ? (0, import_dayjs2.default)().add(minHoursFromNow, "hour") : (0, import_dayjs2.default)().startOf("day");
|
|
965
|
-
const dateTime = (0, import_dayjs2.default)(
|
|
966
|
-
`${date3.startDate} ${date3.startTime}`,
|
|
967
|
-
`${dateFormat} ${timeFormat}`
|
|
968
|
-
);
|
|
969
|
-
return dateTime.isSameOrAfter(threshold);
|
|
970
|
-
};
|
|
971
|
-
var formatTimestamp = (timestamp) => {
|
|
972
|
-
const formattedDate = (0, import_dayjs2.default)(timestamp).tz("Pacific/Auckland").format(dateFormat);
|
|
973
|
-
return formatDate(formattedDate, "date");
|
|
974
|
-
};
|
|
975
|
-
var isIsoDateString = (value) => {
|
|
976
|
-
return typeof value === "string" && !isNaN(Date.parse(value));
|
|
977
|
-
};
|
|
983
|
+
// src/utils/utils.ts
|
|
978
984
|
var removeTypename = (obj) => {
|
|
979
985
|
if (obj instanceof Date) {
|
|
980
986
|
return obj;
|
|
@@ -1014,17 +1020,6 @@ var statusOptions = [
|
|
|
1014
1020
|
})).sort((a, b) => a.label.localeCompare(b.label))
|
|
1015
1021
|
// Sort the options alphabetically
|
|
1016
1022
|
];
|
|
1017
|
-
function sortDatesChronologically(dates) {
|
|
1018
|
-
if (!dates || !dates.length) {
|
|
1019
|
-
return [];
|
|
1020
|
-
}
|
|
1021
|
-
return [...dates].sort((a, b) => {
|
|
1022
|
-
const dateTimeFormat = `${dateFormat} ${timeFormat}`;
|
|
1023
|
-
const dateA = (0, import_dayjs2.default)(`${a.startDate} ${a.startTime}`, dateTimeFormat);
|
|
1024
|
-
const dateB = (0, import_dayjs2.default)(`${b.startDate} ${b.startTime}`, dateTimeFormat);
|
|
1025
|
-
return dateA.valueOf() - dateB.valueOf();
|
|
1026
|
-
});
|
|
1027
|
-
}
|
|
1028
1023
|
var availableRegionTypes = Object.values(EnumRegions);
|
|
1029
1024
|
var availableRegionOptions = mapArrayToOptions(availableRegionTypes);
|
|
1030
1025
|
var paymentMethodOptions = mapArrayToOptions(
|
|
@@ -6508,7 +6503,7 @@ var React = __toESM(require("react"));
|
|
|
6508
6503
|
var import_react_hook_form = require("react-hook-form");
|
|
6509
6504
|
|
|
6510
6505
|
// src/yupSchema/global.ts
|
|
6511
|
-
var
|
|
6506
|
+
var import_dayjs2 = __toESM(require("dayjs"));
|
|
6512
6507
|
var import_customParseFormat2 = __toESM(require("dayjs/plugin/customParseFormat.js"));
|
|
6513
6508
|
var import_isSameOrAfter2 = __toESM(require("dayjs/plugin/isSameOrAfter.js"));
|
|
6514
6509
|
var yup = __toESM(require("yup"));
|
|
@@ -6537,8 +6532,8 @@ var noLeadingZeros = (fieldName, options = {}) => {
|
|
|
6537
6532
|
return true;
|
|
6538
6533
|
};
|
|
6539
6534
|
};
|
|
6540
|
-
|
|
6541
|
-
|
|
6535
|
+
import_dayjs2.default.extend(import_isSameOrAfter2.default);
|
|
6536
|
+
import_dayjs2.default.extend(import_customParseFormat2.default);
|
|
6542
6537
|
var emailRequiredSchema = yup.string().email("Invalid email address").required("Email is required").label("Email").transform(
|
|
6543
6538
|
(value) => typeof value === "string" ? value.trim().toLowerCase() : value
|
|
6544
6539
|
);
|
|
@@ -6569,12 +6564,12 @@ var contactDetailsSchema = yup.object({
|
|
|
6569
6564
|
landlinePhone: landlinePhoneSchema
|
|
6570
6565
|
}).nullable().default(void 0);
|
|
6571
6566
|
var endDateNotInPastTest = yup.string().test("not-in-past", "End date cannot be in the past", (value) => {
|
|
6572
|
-
const now = (0,
|
|
6573
|
-
return value ? (0,
|
|
6567
|
+
const now = (0, import_dayjs2.default)();
|
|
6568
|
+
return value ? (0, import_dayjs2.default)(value, dateFormat, true).isSameOrAfter(now, "day") : false;
|
|
6574
6569
|
});
|
|
6575
6570
|
var startDateNotInPastTest = yup.string().test("not-in-past", "Start date cannot be in the past", (value) => {
|
|
6576
|
-
const now = (0,
|
|
6577
|
-
return value ? (0,
|
|
6571
|
+
const now = (0, import_dayjs2.default)();
|
|
6572
|
+
return value ? (0, import_dayjs2.default)(value, dateFormat, true).isSameOrAfter(now, "day") : false;
|
|
6578
6573
|
});
|
|
6579
6574
|
var endDateAfterStartDateTest = yup.string().test(
|
|
6580
6575
|
"end-after-start",
|
|
@@ -6582,8 +6577,8 @@ var endDateAfterStartDateTest = yup.string().test(
|
|
|
6582
6577
|
function(value) {
|
|
6583
6578
|
const { startDate } = this.parent;
|
|
6584
6579
|
if (!startDate || !value) return false;
|
|
6585
|
-
return (0,
|
|
6586
|
-
(0,
|
|
6580
|
+
return (0, import_dayjs2.default)(value, dateFormat, true).isSameOrAfter(
|
|
6581
|
+
(0, import_dayjs2.default)(startDate, dateFormat, true),
|
|
6587
6582
|
"day"
|
|
6588
6583
|
);
|
|
6589
6584
|
}
|
|
@@ -6594,12 +6589,12 @@ var endTimeMustBeAfterStartTimeTest = yup.string().test(
|
|
|
6594
6589
|
function(value) {
|
|
6595
6590
|
const { startDate, endDate, startTime } = this.parent;
|
|
6596
6591
|
if (!startDate || !endDate || !startTime || !value) return false;
|
|
6597
|
-
const startDateTime = (0,
|
|
6592
|
+
const startDateTime = (0, import_dayjs2.default)(
|
|
6598
6593
|
`${startDate} ${startTime}`,
|
|
6599
6594
|
`${dateFormat} ${timeFormat}`,
|
|
6600
6595
|
true
|
|
6601
6596
|
);
|
|
6602
|
-
const endDateTime = (0,
|
|
6597
|
+
const endDateTime = (0, import_dayjs2.default)(
|
|
6603
6598
|
`${endDate} ${value}`,
|
|
6604
6599
|
`${dateFormat} ${timeFormat}`,
|
|
6605
6600
|
true
|
|
@@ -6611,10 +6606,10 @@ var startTimeCannotBeInPastTest = yup.string().test(
|
|
|
6611
6606
|
"valid-start-time",
|
|
6612
6607
|
"Start time cannot be in the past",
|
|
6613
6608
|
function(value) {
|
|
6614
|
-
const now = (0,
|
|
6609
|
+
const now = (0, import_dayjs2.default)();
|
|
6615
6610
|
const { startDate } = this.parent;
|
|
6616
6611
|
if (!startDate || !value) return false;
|
|
6617
|
-
const startDateTime = (0,
|
|
6612
|
+
const startDateTime = (0, import_dayjs2.default)(
|
|
6618
6613
|
`${startDate} ${value}`,
|
|
6619
6614
|
`${dateFormat} ${timeFormat}`,
|
|
6620
6615
|
true
|
|
@@ -8294,6 +8289,7 @@ var EnumActivity = /* @__PURE__ */ ((EnumActivity2) => {
|
|
|
8294
8289
|
getCurrentAndFutureDates,
|
|
8295
8290
|
globalDefaultValues,
|
|
8296
8291
|
isFutureDatesBeforeThreshold,
|
|
8292
|
+
isIsoDateString,
|
|
8297
8293
|
licenseNiceNames,
|
|
8298
8294
|
lightColors,
|
|
8299
8295
|
loginFields,
|