@timardex/cluemart-shared 2.2.1 → 2.2.12

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.
Files changed (36) hide show
  1. package/dist/auth/index.cjs +6 -3
  2. package/dist/auth/index.cjs.map +1 -1
  3. package/dist/auth/index.d.mts +2 -1
  4. package/dist/auth/index.d.ts +2 -1
  5. package/dist/auth/index.mjs +5 -3
  6. package/dist/auth/index.mjs.map +1 -1
  7. package/dist/{chunk-576YBZYO.mjs → chunk-4DFWOUOT.mjs} +2 -2
  8. package/dist/{chunk-UIG4A4U3.mjs → chunk-KGYLNZQW.mjs} +2 -2
  9. package/dist/{chunk-2DTCLBHT.mjs → chunk-MTBH5LMV.mjs} +95 -21
  10. package/dist/chunk-MTBH5LMV.mjs.map +1 -0
  11. package/dist/{chunk-VWGCXGEL.mjs → chunk-YKJAOTF7.mjs} +2 -2
  12. package/dist/formFields/index.cjs +16 -7
  13. package/dist/formFields/index.cjs.map +1 -1
  14. package/dist/formFields/index.mjs +3 -3
  15. package/dist/hooks/index.cjs +36 -25
  16. package/dist/hooks/index.cjs.map +1 -1
  17. package/dist/hooks/index.mjs +4 -4
  18. package/dist/index.cjs +98 -22
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.mts +17 -1
  21. package/dist/index.d.ts +17 -1
  22. package/dist/index.mjs +96 -22
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/sharing/index.cjs +20 -9
  25. package/dist/sharing/index.cjs.map +1 -1
  26. package/dist/sharing/index.mjs +2 -2
  27. package/dist/utils/index.cjs +98 -22
  28. package/dist/utils/index.cjs.map +1 -1
  29. package/dist/utils/index.d.mts +17 -1
  30. package/dist/utils/index.d.ts +17 -1
  31. package/dist/utils/index.mjs +7 -3
  32. package/package.json +1 -1
  33. package/dist/chunk-2DTCLBHT.mjs.map +0 -1
  34. /package/dist/{chunk-576YBZYO.mjs.map → chunk-4DFWOUOT.mjs.map} +0 -0
  35. /package/dist/{chunk-UIG4A4U3.mjs.map → chunk-KGYLNZQW.mjs.map} +0 -0
  36. /package/dist/{chunk-VWGCXGEL.mjs.map → chunk-YKJAOTF7.mjs.map} +0 -0
@@ -1,18 +1,18 @@
1
- import "../chunk-VWGCXGEL.mjs";
1
+ import "../chunk-YKJAOTF7.mjs";
2
2
  import "../chunk-VA5YN2K3.mjs";
3
3
  import "../chunk-VPANTTZI.mjs";
4
4
  import "../chunk-DWO35OY4.mjs";
5
- import "../chunk-576YBZYO.mjs";
5
+ import "../chunk-4DFWOUOT.mjs";
6
6
  import {
7
7
  SCHOOL_MIN_STUDENT_COUNT,
8
8
  isValidIrdNumber,
9
9
  normalizeUrl
10
- } from "../chunk-UIG4A4U3.mjs";
10
+ } from "../chunk-KGYLNZQW.mjs";
11
11
  import "../chunk-RE4NZPYY.mjs";
12
12
  import {
13
13
  dateFormat,
14
14
  timeFormat
15
- } from "../chunk-2DTCLBHT.mjs";
15
+ } from "../chunk-MTBH5LMV.mjs";
16
16
  import {
17
17
  EnumAdShowOn,
18
18
  EnumAdStatus,
package/dist/index.cjs CHANGED
@@ -271,6 +271,7 @@ __export(index_exports, {
271
271
  getEventScheduleStatusPresentation: () => getEventScheduleStatusPresentation,
272
272
  getEventScheduleStatusTone: () => getEventScheduleStatusTone,
273
273
  getEventStallholderEmptyMessage: () => getEventStallholderEmptyMessage,
274
+ getFutureEventStatus: () => getFutureEventStatus,
274
275
  getPermissionsForRoles: () => getPermissionsForRoles,
275
276
  getRegisteredVendorCategoryNames: () => getRegisteredVendorCategoryNames,
276
277
  getRegisteredVendorStartDates: () => getRegisteredVendorStartDates,
@@ -361,6 +362,7 @@ __export(index_exports, {
361
362
  toShareSocialImageCacheVersion: () => toShareSocialImageCacheVersion,
362
363
  toUserFacingErrorMessage: () => toUserFacingErrorMessage,
363
364
  truncateText: () => truncateText,
365
+ updateSingleDateTimeStatus: () => updateSingleDateTimeStatus,
364
366
  useActivateVendorClaim: () => useActivateVendorClaim,
365
367
  useAddParticipantToChat: () => useAddParticipantToChat,
366
368
  useAddUserFavouriteResource: () => useAddUserFavouriteResource,
@@ -1125,13 +1127,22 @@ var gameScreenIdentifierList = [
1125
1127
  ];
1126
1128
 
1127
1129
  // src/utils/date.ts
1128
- var import_dayjs = __toESM(require("dayjs"));
1129
- var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat.js"));
1130
+ var import_dayjs2 = __toESM(require("dayjs"));
1131
+ var import_customParseFormat2 = __toESM(require("dayjs/plugin/customParseFormat.js"));
1130
1132
  var import_isSameOrAfter = __toESM(require("dayjs/plugin/isSameOrAfter.js"));
1131
1133
  var import_timezone = __toESM(require("dayjs/plugin/timezone.js"));
1132
1134
  var import_utc = __toESM(require("dayjs/plugin/utc.js"));
1133
1135
 
1136
+ // src/utils/dateFormats.ts
1137
+ var dateFormat = "DD-MM-YYYY";
1138
+ var timeFormat = "HH:mm";
1139
+
1134
1140
  // src/utils/eventDateStatus.ts
1141
+ var import_dayjs = __toESM(require("dayjs"));
1142
+ var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat.js"));
1143
+ var import_isoWeek = __toESM(require("dayjs/plugin/isoWeek.js"));
1144
+ import_dayjs.default.extend(import_customParseFormat.default);
1145
+ import_dayjs.default.extend(import_isoWeek.default);
1135
1146
  var EVENT_DATE_STATUS_PERIOD_MAP = {
1136
1147
  ["Today" /* TODAY */]: [
1137
1148
  "Started" /* STARTED */,
@@ -1172,27 +1183,90 @@ function isFutureEventDateStatus(dateStatus) {
1172
1183
  function filterDatesByFutureStatus(dates) {
1173
1184
  return dates.filter((date) => isFutureEventDateStatus(date.dateStatus));
1174
1185
  }
1186
+ var MANUAL_DATE_STATUSES = /* @__PURE__ */ new Set([
1187
+ "Canceled" /* CANCELED */,
1188
+ "Rescheduled" /* RE_SCHEDULED */
1189
+ ]);
1190
+ function getFutureEventStatus(startDateTime, now) {
1191
+ const hoursUntilStart = startDateTime.diff(now, "hour", true);
1192
+ if (hoursUntilStart > 0 && hoursUntilStart <= 4) {
1193
+ return "Starting_Soon" /* STARTING_SOON */;
1194
+ }
1195
+ if (startDateTime.isSame(now, "day")) {
1196
+ return "Today" /* TODAY */;
1197
+ }
1198
+ if (startDateTime.isSame(now.add(1, "day"), "day")) {
1199
+ return "Tomorrow" /* TOMORROW */;
1200
+ }
1201
+ if (startDateTime.isSame(now, "isoWeek")) {
1202
+ return "This_Week" /* THIS_WEEK */;
1203
+ }
1204
+ if (startDateTime.isSame(now.add(1, "week"), "isoWeek")) {
1205
+ return "Next_Week" /* NEXT_WEEK */;
1206
+ }
1207
+ return "Upcoming" /* UPCOMING */;
1208
+ }
1209
+ function updateSingleDateTimeStatus(dateTime, now = (0, import_dayjs.default)()) {
1210
+ if (MANUAL_DATE_STATUSES.has(dateTime.dateStatus)) {
1211
+ return dateTime;
1212
+ }
1213
+ const dateTimeFormat = `${dateFormat} ${timeFormat}`;
1214
+ const startDateTime = (0, import_dayjs.default)(
1215
+ `${dateTime.startDate} ${dateTime.startTime}`,
1216
+ dateTimeFormat,
1217
+ true
1218
+ );
1219
+ const endDateTime = (0, import_dayjs.default)(
1220
+ `${dateTime.endDate} ${dateTime.endTime}`,
1221
+ dateTimeFormat,
1222
+ true
1223
+ );
1224
+ if (!startDateTime.isValid() || !endDateTime.isValid()) {
1225
+ return {
1226
+ ...dateTime,
1227
+ dateStatus: "Invalid" /* INVALID */
1228
+ };
1229
+ }
1230
+ if (endDateTime.isBefore(startDateTime)) {
1231
+ return {
1232
+ ...dateTime,
1233
+ dateStatus: "Invalid" /* INVALID */
1234
+ };
1235
+ }
1236
+ let dateStatus;
1237
+ if (endDateTime.isAfter(now)) {
1238
+ if (startDateTime.isAfter(now)) {
1239
+ dateStatus = getFutureEventStatus(startDateTime, now);
1240
+ } else {
1241
+ dateStatus = "Started" /* STARTED */;
1242
+ }
1243
+ } else {
1244
+ dateStatus = "Ended" /* ENDED */;
1245
+ }
1246
+ return {
1247
+ ...dateTime,
1248
+ dateStatus
1249
+ };
1250
+ }
1175
1251
 
1176
1252
  // src/utils/date.ts
1177
- var dateFormat = "DD-MM-YYYY";
1178
- var timeFormat = "HH:mm";
1179
- import_dayjs.default.extend(import_customParseFormat.default);
1180
- import_dayjs.default.extend(import_utc.default);
1181
- import_dayjs.default.extend(import_timezone.default);
1182
- import_dayjs.default.extend(import_isSameOrAfter.default);
1253
+ import_dayjs2.default.extend(import_customParseFormat2.default);
1254
+ import_dayjs2.default.extend(import_utc.default);
1255
+ import_dayjs2.default.extend(import_timezone.default);
1256
+ import_dayjs2.default.extend(import_isSameOrAfter.default);
1183
1257
  var NZ_TZ = "Pacific/Auckland";
1184
1258
  function toNZTime(date) {
1185
- return date ? (0, import_dayjs.default)(date).tz(NZ_TZ) : (0, import_dayjs.default)().tz(NZ_TZ);
1259
+ return date ? (0, import_dayjs2.default)(date).tz(NZ_TZ) : (0, import_dayjs2.default)().tz(NZ_TZ);
1186
1260
  }
1187
1261
  function nzStartOfDay(input) {
1188
1262
  if (input == null) {
1189
- return (0, import_dayjs.default)().tz(NZ_TZ).startOf("day");
1263
+ return (0, import_dayjs2.default)().tz(NZ_TZ).startOf("day");
1190
1264
  }
1191
- return import_dayjs.default.tz(input, NZ_TZ).startOf("day");
1265
+ return import_dayjs2.default.tz(input, NZ_TZ).startOf("day");
1192
1266
  }
1193
1267
  var formatDate = (dateStr, display = "datetime", timeStr) => {
1194
1268
  const dateTimeStr = timeStr ? `${dateStr} ${timeStr}` : dateStr;
1195
- const dateTime = timeStr ? (0, import_dayjs.default)(dateTimeStr, `${dateFormat} ${timeFormat}`) : (0, import_dayjs.default)(dateStr, dateFormat);
1269
+ const dateTime = timeStr ? (0, import_dayjs2.default)(dateTimeStr, `${dateFormat} ${timeFormat}`) : (0, import_dayjs2.default)(dateStr, dateFormat);
1196
1270
  const formattedDate = dateTime.format("dddd, D MMMM, YYYY");
1197
1271
  const formattedTime = dateTime.format("h:mm a");
1198
1272
  switch (display) {
@@ -1207,12 +1281,12 @@ var formatDate = (dateStr, display = "datetime", timeStr) => {
1207
1281
  }
1208
1282
  };
1209
1283
  var getCurrentAndFutureDates = (dates) => {
1210
- const now = (0, import_dayjs.default)();
1284
+ const now = (0, import_dayjs2.default)();
1211
1285
  return dates.filter((dateObj) => {
1212
1286
  if (!dateObj.startDate || !dateObj.startTime) {
1213
1287
  return false;
1214
1288
  }
1215
- const dateTime = (0, import_dayjs.default)(
1289
+ const dateTime = (0, import_dayjs2.default)(
1216
1290
  `${dateObj.startDate} ${dateObj.startTime}`,
1217
1291
  `${dateFormat} ${timeFormat}`
1218
1292
  );
@@ -1223,8 +1297,8 @@ var isFutureDatesBeforeThreshold = (date, minHoursFromNow) => {
1223
1297
  if (!date.startDate || !date.startTime) {
1224
1298
  return false;
1225
1299
  }
1226
- const threshold = minHoursFromNow ? (0, import_dayjs.default)().add(minHoursFromNow, "hour") : (0, import_dayjs.default)().startOf("day");
1227
- const dateTime = (0, import_dayjs.default)(
1300
+ const threshold = minHoursFromNow ? (0, import_dayjs2.default)().add(minHoursFromNow, "hour") : (0, import_dayjs2.default)().startOf("day");
1301
+ const dateTime = (0, import_dayjs2.default)(
1228
1302
  `${date.startDate} ${date.startTime}`,
1229
1303
  `${dateFormat} ${timeFormat}`
1230
1304
  );
@@ -1243,8 +1317,8 @@ function sortDatesChronologically(dates) {
1243
1317
  }
1244
1318
  return [...dates].sort((a, b) => {
1245
1319
  const dateTimeFormat = `${dateFormat} ${timeFormat}`;
1246
- const dateA = a.startDate && a.startTime ? (0, import_dayjs.default)(`${a.startDate} ${a.startTime}`, dateTimeFormat) : null;
1247
- const dateB = b.startDate && b.startTime ? (0, import_dayjs.default)(`${b.startDate} ${b.startTime}`, dateTimeFormat) : null;
1320
+ const dateA = a.startDate && a.startTime ? (0, import_dayjs2.default)(`${a.startDate} ${a.startTime}`, dateTimeFormat) : null;
1321
+ const dateB = b.startDate && b.startTime ? (0, import_dayjs2.default)(`${b.startDate} ${b.startTime}`, dateTimeFormat) : null;
1248
1322
  if (dateA && dateB) {
1249
1323
  return dateA.valueOf() - dateB.valueOf();
1250
1324
  }
@@ -1873,13 +1947,13 @@ var SCHOOL_MIN_STUDENT_COUNT = 300;
1873
1947
  var SCHOOL_MAX_STUDENT_COUNT = 0;
1874
1948
 
1875
1949
  // src/calendar/eventCalendar.ts
1876
- var import_dayjs2 = __toESM(require("dayjs"));
1950
+ var import_dayjs3 = __toESM(require("dayjs"));
1877
1951
  function toCalendarIsoDate(startDate) {
1878
- const formatted = (0, import_dayjs2.default)(startDate, dateFormat).format("YYYY-MM-DD");
1879
- return (0, import_dayjs2.default)(formatted, "YYYY-MM-DD", true).isValid() ? formatted : null;
1952
+ const formatted = (0, import_dayjs3.default)(startDate, dateFormat).format("YYYY-MM-DD");
1953
+ return (0, import_dayjs3.default)(formatted, "YYYY-MM-DD", true).isValid() ? formatted : null;
1880
1954
  }
1881
1955
  function fromCalendarIsoDate(isoDate) {
1882
- return (0, import_dayjs2.default)(isoDate, "YYYY-MM-DD").format(dateFormat);
1956
+ return (0, import_dayjs3.default)(isoDate, "YYYY-MM-DD").format(dateFormat);
1883
1957
  }
1884
1958
  function getEventCalendarIsoDates(dateTimes) {
1885
1959
  return dateTimes?.map(
@@ -10259,6 +10333,7 @@ function canAccessAdminPath(roles, pathname) {
10259
10333
  getEventScheduleStatusPresentation,
10260
10334
  getEventScheduleStatusTone,
10261
10335
  getEventStallholderEmptyMessage,
10336
+ getFutureEventStatus,
10262
10337
  getPermissionsForRoles,
10263
10338
  getRegisteredVendorCategoryNames,
10264
10339
  getRegisteredVendorStartDates,
@@ -10349,6 +10424,7 @@ function canAccessAdminPath(roles, pathname) {
10349
10424
  toShareSocialImageCacheVersion,
10350
10425
  toUserFacingErrorMessage,
10351
10426
  truncateText,
10427
+ updateSingleDateTimeStatus,
10352
10428
  useActivateVendorClaim,
10353
10429
  useAddParticipantToChat,
10354
10430
  useAddUserFavouriteResource,