@timardex/cluemart-shared 1.0.15 → 1.0.16

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 (54) hide show
  1. package/dist/auth-CdcH8nqw.d.mts +84 -0
  2. package/dist/auth-TM_XttY3.d.ts +84 -0
  3. package/dist/chat-NGx5Emrr.d.mts +27 -0
  4. package/dist/chat-NGx5Emrr.d.ts +27 -0
  5. package/dist/chunk-K5NK2CK5.mjs +133 -0
  6. package/dist/chunk-K5NK2CK5.mjs.map +1 -0
  7. package/dist/chunk-L2H5WFGC.mjs +100 -0
  8. package/dist/chunk-L2H5WFGC.mjs.map +1 -0
  9. package/dist/enums/index.cjs +134 -0
  10. package/dist/enums/index.cjs.map +1 -0
  11. package/dist/enums/index.d.mts +75 -0
  12. package/dist/enums/index.d.ts +75 -0
  13. package/dist/enums/index.mjs +27 -0
  14. package/dist/enums/index.mjs.map +1 -0
  15. package/dist/formFields/index.cjs +888 -0
  16. package/dist/formFields/index.cjs.map +1 -0
  17. package/dist/formFields/index.d.mts +60 -0
  18. package/dist/formFields/index.d.ts +60 -0
  19. package/dist/formFields/index.mjs +754 -0
  20. package/dist/formFields/index.mjs.map +1 -0
  21. package/dist/global-B7gB8cvC.d.ts +338 -0
  22. package/dist/global-B8kYikwQ.d.mts +338 -0
  23. package/dist/graphql/index.cjs +1634 -0
  24. package/dist/graphql/index.cjs.map +1 -0
  25. package/dist/graphql/index.d.mts +299 -0
  26. package/dist/graphql/index.d.ts +299 -0
  27. package/dist/graphql/index.mjs +1558 -0
  28. package/dist/graphql/index.mjs.map +1 -0
  29. package/dist/hooks/index.cjs +1090 -0
  30. package/dist/hooks/index.cjs.map +1 -0
  31. package/dist/hooks/index.d.mts +78 -0
  32. package/dist/hooks/index.d.ts +78 -0
  33. package/dist/hooks/index.mjs +970 -0
  34. package/dist/hooks/index.mjs.map +1 -0
  35. package/dist/index.cjs +10 -48
  36. package/dist/index.cjs.map +1 -0
  37. package/dist/index.d.mts +1 -287
  38. package/dist/index.d.ts +1 -287
  39. package/dist/index.mjs +8 -26
  40. package/dist/index.mjs.map +1 -1
  41. package/dist/types/index.cjs +19 -0
  42. package/dist/types/index.cjs.map +1 -0
  43. package/dist/types/index.d.mts +12 -0
  44. package/dist/types/index.d.ts +12 -0
  45. package/dist/types/index.mjs +1 -0
  46. package/dist/types/index.mjs.map +1 -0
  47. package/dist/utils/index.cjs +215 -0
  48. package/dist/utils/index.cjs.map +1 -0
  49. package/dist/utils/index.d.mts +66 -0
  50. package/dist/utils/index.d.ts +66 -0
  51. package/dist/utils/index.mjs +38 -0
  52. package/dist/utils/index.mjs.map +1 -0
  53. package/package.json +37 -4
  54. package/dist/index.js.map +0 -1
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/types/index.ts
17
+ var types_exports = {};
18
+ module.exports = __toCommonJS(types_exports);
19
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["export * from \"./auth\";\nexport * from \"./chat\";\nexport * from \"./global\";\nexport * from \"./market\";\nexport * from \"./poster\";\nexport * from \"./relation\";\nexport * from \"./stallholder\";\nexport * from \"./user\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,12 @@
1
+ export { C as CreateLoginFormData, a as CreateRegisterFormData, c as CreateRequestPasswordResetFormData, e as CreateResetPasswordFormData, f as CreateValidateTokenFormData, L as LoginFormData, R as RegisterFormData, b as RequestPasswordResetFormData, d as ResetPasswordFormData, V as ValidateTokenFormData } from '../auth-CdcH8nqw.mjs';
2
+ export { C as ChatInput, a as ChatMessageInput, b as ChatMessageType, c as ChatType } from '../chat-NGx5Emrr.mjs';
3
+ export { a as BaseResourceType, B as BaseResourceTypeFormData, C as Category, i as CreateMarketFormData, t as CreateStallholderApplyFormFormData, q as CreateStallholderFormData, x as CreateUserFormData, D as DateTimeType, f as DateTimeWithPrice, c as FormDateField, F as FormField, G as GeocodeLocation, I as ImageObjectType, L as LocationType, M as MapMultiLocation, h as MarketFormData, j as MarketType, k as MarketWithConnectionDatesType, d as NotificationType, N as Nullable, O as OptionItem, b as Region, m as RelationDate, l as RelationLog, n as RelationType, e as ResourceConnectionsType, R as ResourceImageType, w as SatllholderWithConnectionDatesType, g as StallApplicationInfoType, s as StallholderApplyFormFormData, v as StallholderApplyFormType, r as StallholderAttributes, p as StallholderFormData, o as StallholderLocation, u as StallholderType, S as Subcategory, U as UserFormData, y as UserType } from '../global-B8kYikwQ.mjs';
4
+ import { EnumResourceType } from '../enums/index.mjs';
5
+ import 'react-hook-form';
6
+
7
+ interface PosterInputType {
8
+ resourceId: string;
9
+ resourceType: EnumResourceType;
10
+ }
11
+
12
+ export type { PosterInputType };
@@ -0,0 +1,12 @@
1
+ export { C as CreateLoginFormData, a as CreateRegisterFormData, c as CreateRequestPasswordResetFormData, e as CreateResetPasswordFormData, f as CreateValidateTokenFormData, L as LoginFormData, R as RegisterFormData, b as RequestPasswordResetFormData, d as ResetPasswordFormData, V as ValidateTokenFormData } from '../auth-TM_XttY3.js';
2
+ export { C as ChatInput, a as ChatMessageInput, b as ChatMessageType, c as ChatType } from '../chat-NGx5Emrr.js';
3
+ export { a as BaseResourceType, B as BaseResourceTypeFormData, C as Category, i as CreateMarketFormData, t as CreateStallholderApplyFormFormData, q as CreateStallholderFormData, x as CreateUserFormData, D as DateTimeType, f as DateTimeWithPrice, c as FormDateField, F as FormField, G as GeocodeLocation, I as ImageObjectType, L as LocationType, M as MapMultiLocation, h as MarketFormData, j as MarketType, k as MarketWithConnectionDatesType, d as NotificationType, N as Nullable, O as OptionItem, b as Region, m as RelationDate, l as RelationLog, n as RelationType, e as ResourceConnectionsType, R as ResourceImageType, w as SatllholderWithConnectionDatesType, g as StallApplicationInfoType, s as StallholderApplyFormFormData, v as StallholderApplyFormType, r as StallholderAttributes, p as StallholderFormData, o as StallholderLocation, u as StallholderType, S as Subcategory, U as UserFormData, y as UserType } from '../global-B7gB8cvC.js';
4
+ import { EnumResourceType } from '../enums/index.js';
5
+ import 'react-hook-form';
6
+
7
+ interface PosterInputType {
8
+ resourceId: string;
9
+ resourceType: EnumResourceType;
10
+ }
11
+
12
+ export type { PosterInputType };
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,215 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/utils/index.ts
31
+ var utils_exports = {};
32
+ __export(utils_exports, {
33
+ availableRegionOptions: () => availableRegionOptions,
34
+ availableRegionTypes: () => availableRegionTypes,
35
+ capitalizeFirstLetter: () => capitalizeFirstLetter,
36
+ dateFormat: () => dateFormat,
37
+ defaultRegion: () => defaultRegion,
38
+ formatDate: () => formatDate,
39
+ formatTimestamp: () => formatTimestamp,
40
+ getCurrentAndFutureDates: () => getCurrentAndFutureDates,
41
+ getFutureDatesAfterThreshold: () => getFutureDatesAfterThreshold,
42
+ mapArrayToOptions: () => mapArrayToOptions,
43
+ paymentMethodOptions: () => paymentMethodOptions,
44
+ removeTypename: () => removeTypename,
45
+ sortDatesByProximity: () => sortDatesByProximity,
46
+ statusOptions: () => statusOptions,
47
+ timeFormat: () => timeFormat,
48
+ truncateText: () => truncateText
49
+ });
50
+ module.exports = __toCommonJS(utils_exports);
51
+ var import_dayjs = __toESM(require("dayjs"));
52
+ var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
53
+ var import_isSameOrAfter = __toESM(require("dayjs/plugin/isSameOrAfter"));
54
+ var import_timezone = __toESM(require("dayjs/plugin/timezone"));
55
+ var import_utc = __toESM(require("dayjs/plugin/utc"));
56
+
57
+ // src/enums/index.ts
58
+ var EnumInviteStatus = /* @__PURE__ */ ((EnumInviteStatus2) => {
59
+ EnumInviteStatus2["ACCEPTED"] = "Accepted";
60
+ EnumInviteStatus2["COMPLETED"] = "Completed";
61
+ EnumInviteStatus2["EXPIRED"] = "Expired";
62
+ EnumInviteStatus2["NO_STATUS"] = "No_Status";
63
+ EnumInviteStatus2["PENDING"] = "Pending";
64
+ EnumInviteStatus2["REJECTED"] = "Rejected";
65
+ EnumInviteStatus2["WAITING"] = "Waiting";
66
+ return EnumInviteStatus2;
67
+ })(EnumInviteStatus || {});
68
+ var EnumPaymentMethod = /* @__PURE__ */ ((EnumPaymentMethod2) => {
69
+ EnumPaymentMethod2["CASH"] = "cash";
70
+ EnumPaymentMethod2["EFTPOS"] = "eftpos";
71
+ EnumPaymentMethod2["BANK_TRANSFER"] = "bank_transfer";
72
+ EnumPaymentMethod2["PAYPAL"] = "paypal";
73
+ EnumPaymentMethod2["STRIPE"] = "stripe";
74
+ return EnumPaymentMethod2;
75
+ })(EnumPaymentMethod || {});
76
+ var EnumRegions = /* @__PURE__ */ ((EnumRegions2) => {
77
+ EnumRegions2["Auckland"] = "Auckland";
78
+ EnumRegions2["BayOfPlenty"] = "Bay of Plenty";
79
+ EnumRegions2["Canterbury"] = "Canterbury";
80
+ EnumRegions2["Gisborne"] = "Gisborne";
81
+ EnumRegions2["HawkesBay"] = "Hawke's Bay";
82
+ EnumRegions2["ManawatuWanganui"] = "Manawatu-Wanganui";
83
+ EnumRegions2["Marlborough"] = "Marlborough";
84
+ EnumRegions2["Nelson"] = "Nelson";
85
+ EnumRegions2["Northland"] = "Northland";
86
+ EnumRegions2["Otago"] = "Otago";
87
+ EnumRegions2["Southland"] = "Southland";
88
+ EnumRegions2["Taranaki"] = "Taranaki";
89
+ EnumRegions2["Waikato"] = "Waikato";
90
+ EnumRegions2["Wellington"] = "Wellington";
91
+ return EnumRegions2;
92
+ })(EnumRegions || {});
93
+
94
+ // src/utils/index.ts
95
+ var dateFormat = "DD-MM-YYYY";
96
+ var timeFormat = "HH:mm";
97
+ (0, import_dayjs.extend)(import_customParseFormat.default);
98
+ (0, import_dayjs.extend)(import_utc.default);
99
+ (0, import_dayjs.extend)(import_timezone.default);
100
+ (0, import_dayjs.extend)(import_isSameOrAfter.default);
101
+ var formatDate = (dateStr, display = "datetime", timeStr) => {
102
+ const dateTimeStr = timeStr ? `${dateStr} ${timeStr}` : dateStr;
103
+ const dateTime = timeStr ? (0, import_dayjs.default)(dateTimeStr, `${dateFormat} ${timeFormat}`) : (0, import_dayjs.default)(dateStr, dateFormat);
104
+ const formattedDate = dateTime.format("dddd, D MMMM, YYYY");
105
+ const formattedTime = dateTime.format("h:mm a");
106
+ switch (display) {
107
+ case "date":
108
+ return formattedDate;
109
+ case "time":
110
+ return formattedTime;
111
+ case "datetime":
112
+ return `${formattedDate} at ${formattedTime}`;
113
+ default:
114
+ return formattedDate;
115
+ }
116
+ };
117
+ var getCurrentAndFutureDates = (dates) => {
118
+ const today = (0, import_dayjs.default)().startOf("day");
119
+ return dates.filter((dateObj) => {
120
+ const dateTime = (0, import_dayjs.default)(dateObj.startDate, dateFormat);
121
+ return dateTime.isSameOrAfter(today);
122
+ });
123
+ };
124
+ var getFutureDatesAfterThreshold = (dates, minHoursFromNow) => {
125
+ const threshold = minHoursFromNow ? (0, import_dayjs.default)().add(minHoursFromNow, "hour") : (0, import_dayjs.default)().startOf("day");
126
+ return dates.filter((dateObj) => {
127
+ const dateTime = (0, import_dayjs.default)(
128
+ `${dateObj.startDate} ${dateObj.startTime}`,
129
+ `${dateFormat} ${timeFormat}`
130
+ );
131
+ return dateTime.isSameOrAfter(threshold);
132
+ });
133
+ };
134
+ var formatTimestamp = (timestamp) => {
135
+ const formattedDate = (0, import_dayjs.default)(timestamp).tz("Pacific/Auckland").format(dateFormat);
136
+ const formattedTime = (0, import_dayjs.default)(timestamp).tz("Pacific/Auckland").format(timeFormat);
137
+ return formatDate(formattedDate, "date");
138
+ };
139
+ var defaultRegion = {
140
+ latitude: -36.8624942,
141
+ // Default: New Zealand
142
+ latitudeDelta: 5,
143
+ longitude: 174.7450494,
144
+ longitudeDelta: 5
145
+ };
146
+ var removeTypename = (obj) => {
147
+ if (Array.isArray(obj)) {
148
+ return obj.map((item) => removeTypename(item));
149
+ } else if (obj !== null && typeof obj === "object") {
150
+ const { __typename, ...cleanedObj } = obj;
151
+ return Object.keys(cleanedObj).reduce(
152
+ (acc, key) => {
153
+ acc[key] = removeTypename(cleanedObj[key]);
154
+ return acc;
155
+ },
156
+ {}
157
+ );
158
+ }
159
+ return obj;
160
+ };
161
+ var truncateText = (text, maxLength = 30) => {
162
+ return text.length > maxLength ? text.substring(0, maxLength) + "..." : text;
163
+ };
164
+ var mapArrayToOptions = (items) => items.map((item) => ({
165
+ label: item.replace(/_/g, " "),
166
+ value: item.replace(/\s+/g, "_").toLowerCase()
167
+ }));
168
+ var capitalizeFirstLetter = (str) => {
169
+ return str.split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
170
+ };
171
+ var statusOptions = [
172
+ ...Object.values(EnumInviteStatus).map((status) => ({
173
+ label: status,
174
+ value: status
175
+ })).sort((a, b) => a.label.localeCompare(b.label))
176
+ // Sort the options alphabetically
177
+ ];
178
+ function sortDatesByProximity(dates) {
179
+ if (!dates || !dates.length) {
180
+ return [];
181
+ }
182
+ const reference = (0, import_dayjs.default)();
183
+ return [...dates].sort((a, b) => {
184
+ const dateA = (0, import_dayjs.default)(a.startDate, dateFormat);
185
+ const dateB = (0, import_dayjs.default)(b.startDate, dateFormat);
186
+ const diffA = Math.abs(dateA.diff(reference));
187
+ const diffB = Math.abs(dateB.diff(reference));
188
+ return diffA - diffB;
189
+ });
190
+ }
191
+ var availableRegionTypes = Object.values(EnumRegions);
192
+ var availableRegionOptions = mapArrayToOptions(availableRegionTypes);
193
+ var paymentMethodOptions = mapArrayToOptions(
194
+ Object.values(EnumPaymentMethod)
195
+ );
196
+ // Annotate the CommonJS export names for ESM import in node:
197
+ 0 && (module.exports = {
198
+ availableRegionOptions,
199
+ availableRegionTypes,
200
+ capitalizeFirstLetter,
201
+ dateFormat,
202
+ defaultRegion,
203
+ formatDate,
204
+ formatTimestamp,
205
+ getCurrentAndFutureDates,
206
+ getFutureDatesAfterThreshold,
207
+ mapArrayToOptions,
208
+ paymentMethodOptions,
209
+ removeTypename,
210
+ sortDatesByProximity,
211
+ statusOptions,
212
+ timeFormat,
213
+ truncateText
214
+ });
215
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/index.ts","../../src/enums/index.ts"],"sourcesContent":["import dayjs, { extend } from \"dayjs\";\nimport customParseFormat from \"dayjs/plugin/customParseFormat\";\nimport isSameOrAfter from \"dayjs/plugin/isSameOrAfter\";\nimport timezone from \"dayjs/plugin/timezone\";\nimport utc from \"dayjs/plugin/utc\";\n\nimport { EnumInviteStatus, EnumPaymentMethod, EnumRegions } from \"../enums\";\nimport { OptionItem, Region } from \"../types/global\";\n\nexport const dateFormat = \"DD-MM-YYYY\";\nexport const timeFormat = \"HH:mm\";\n\n// Enable custom format parsing\nextend(customParseFormat);\nextend(utc);\nextend(timezone);\nextend(isSameOrAfter);\n\ntype DateFormat = \"date\" | \"time\" | \"datetime\";\n\n/**\n * Format a date string to a more readable format.\n * @param dateStr - the date string\n * @param timeStr - optional time string\n * @param display - 'date' | 'time' | 'datetime'\n * @returns formatted string based on display option\n */\nexport const formatDate = (\n dateStr: string,\n display: DateFormat = \"datetime\",\n timeStr?: string,\n) => {\n // Combine date and time into a single string if time is provided\n const dateTimeStr = timeStr ? `${dateStr} ${timeStr}` : dateStr;\n\n // Parse with formats\n const dateTime = timeStr\n ? dayjs(dateTimeStr, `${dateFormat} ${timeFormat}`)\n : dayjs(dateStr, dateFormat);\n\n // Format parts\n const formattedDate = dateTime.format(\"dddd, D MMMM, YYYY\");\n const formattedTime = dateTime.format(\"h:mm a\");\n\n // Return based on display option\n switch (display) {\n case \"date\":\n return formattedDate;\n case \"time\":\n return formattedTime;\n case \"datetime\":\n return `${formattedDate} at ${formattedTime}`;\n default:\n return formattedDate;\n }\n};\n\nexport const getCurrentAndFutureDates = <\n T extends { startDate: string; startTime: string },\n>(\n dates: T[],\n): T[] => {\n const today = dayjs().startOf(\"day\");\n return dates.filter((dateObj) => {\n const dateTime = dayjs(dateObj.startDate, dateFormat);\n return dateTime.isSameOrAfter(today);\n });\n};\n\nexport const getFutureDatesAfterThreshold = (\n dates: {\n startDate: string;\n startTime: string;\n }[],\n minHoursFromNow?: number, // Optional\n) => {\n const threshold = minHoursFromNow\n ? dayjs().add(minHoursFromNow, \"hour\")\n : dayjs().startOf(\"day\");\n\n return dates.filter((dateObj) => {\n const dateTime = dayjs(\n `${dateObj.startDate} ${dateObj.startTime}`,\n `${dateFormat} ${timeFormat}`,\n );\n return dateTime.isSameOrAfter(threshold);\n });\n};\n\nexport const formatTimestamp = (timestamp: string) => {\n const formattedDate = dayjs(timestamp)\n .tz(\"Pacific/Auckland\")\n .format(dateFormat);\n\n const formattedTime = dayjs(timestamp)\n .tz(\"Pacific/Auckland\")\n .format(timeFormat);\n\n return formatDate(formattedDate, \"date\");\n};\n\nexport const defaultRegion: Region = {\n latitude: -36.8624942, // Default: New Zealand\n latitudeDelta: 5.0,\n longitude: 174.7450494,\n longitudeDelta: 5.0,\n};\n\n/**\n * Function to remove __typename from an object or array of objects.\n * @param obj - The object or array to clean.\n * @returns - The cleaned object or array.\n */\nexport const removeTypename = (obj: any): any => {\n if (Array.isArray(obj)) {\n return obj.map((item) => removeTypename(item)); // Recursively clean arrays\n } else if (obj !== null && typeof obj === \"object\") {\n const { __typename, ...cleanedObj } = obj; // Remove __typename\n return Object.keys(cleanedObj).reduce(\n (acc: { [key: string]: any }, key) => {\n acc[key] = removeTypename(cleanedObj[key]); // Recursively clean nested objects\n return acc;\n },\n {},\n );\n }\n return obj; // Return value as-is if it's not an object/array\n};\n\n/**\n * Truncate text to a specified length and append ellipsis if necessary.\n * @param text\n * @param maxLength\n * @returns\n */\nexport const truncateText = (text: string, maxLength: number = 30): string => {\n return text.length > maxLength ? text.substring(0, maxLength) + \"...\" : text;\n};\n\n/**\n * Convert an array of strings to an array of objects with label and value properties.\n * @param items - The array of strings to convert.\n * @returns - The converted array of objects.\n */\nexport const mapArrayToOptions = (items: string[]): OptionItem[] =>\n items.map((item) => ({\n label: item.replace(/_/g, \" \"),\n value: item.replace(/\\s+/g, \"_\").toLowerCase(),\n }));\n\nexport const capitalizeFirstLetter = (str: string): string => {\n return str\n .split(\" \")\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(\" \");\n};\n\nexport const statusOptions = [\n ...Object.values(EnumInviteStatus)\n .map((status) => ({\n label: status,\n value: status,\n }))\n .sort((a, b) => a.label.localeCompare(b.label)), // Sort the options alphabetically\n];\n\n/**\n * Sort an array of date strings by their proximity to the current date.\n * @param dates - The array of date strings to sort.\n * @returns - The sorted array of date strings.\n */\nexport function sortDatesByProximity<\n T extends { startDate: string; startTime: string },\n>(dates: T[]): T[] {\n if (!dates || !dates.length) {\n return [];\n }\n const reference = dayjs();\n return [...dates].sort((a, b) => {\n const dateA = dayjs(a.startDate, dateFormat);\n const dateB = dayjs(b.startDate, dateFormat);\n const diffA = Math.abs(dateA.diff(reference));\n const diffB = Math.abs(dateB.diff(reference));\n return diffA - diffB;\n });\n}\n\nexport const availableRegionTypes = Object.values(EnumRegions);\nexport const availableRegionOptions: OptionItem[] =\n mapArrayToOptions(availableRegionTypes);\n\nexport const paymentMethodOptions: OptionItem[] = mapArrayToOptions(\n Object.values(EnumPaymentMethod),\n);\n","export enum EnumInviteStatus {\n ACCEPTED = \"Accepted\",\n COMPLETED = \"Completed\",\n EXPIRED = \"Expired\",\n NO_STATUS = \"No_Status\",\n PENDING = \"Pending\",\n REJECTED = \"Rejected\",\n WAITING = \"Waiting\",\n}\n\nexport enum EnumRejectionPolicy {\n SINGLE_DATE_ALLOWED = \"single_date_allowed\",\n MULTI_DATE_ALLOWED = \"multi_date_allowed\",\n}\n\nexport enum EnumPaymentMethod {\n CASH = \"cash\",\n EFTPOS = \"eftpos\",\n BANK_TRANSFER = \"bank_transfer\",\n PAYPAL = \"paypal\",\n STRIPE = \"stripe\",\n}\n\nexport enum EnumResourceType {\n MARKET = \"market\",\n STALLHOLDER = \"stallholder\",\n}\n\nexport enum EnumRelationResource {\n MARKET_INVITE_STALLHOLDER = \"market_invite_stallholder\",\n STALLHOLDER_APPLICATION_TO_MARKET = \"stallholder_application_to_market\",\n}\n\nexport enum EnumNotification {\n CREATED_MARKET = \"created_market\",\n CREATED_STALLHOLDER = \"created_stallholder\",\n NEW_CHAT_MESSAGE = \"new_chat_message\",\n MARKET_INVITE_STALLHOLDER = EnumRelationResource.MARKET_INVITE_STALLHOLDER,\n STALLHOLDER_APPLICATION_TO_MARKET = EnumRelationResource.STALLHOLDER_APPLICATION_TO_MARKET,\n}\n\nexport enum EnumResourceTypeIcon {\n MARKET = \"compass\",\n STALLHOLDER = \"store\",\n}\n\nexport enum EnumRegions {\n Auckland = \"Auckland\",\n BayOfPlenty = \"Bay of Plenty\",\n Canterbury = \"Canterbury\",\n Gisborne = \"Gisborne\",\n HawkesBay = \"Hawke's Bay\",\n ManawatuWanganui = \"Manawatu-Wanganui\",\n Marlborough = \"Marlborough\",\n Nelson = \"Nelson\",\n Northland = \"Northland\",\n Otago = \"Otago\",\n Southland = \"Southland\",\n Taranaki = \"Taranaki\",\n Waikato = \"Waikato\",\n Wellington = \"Wellington\",\n}\n\nexport enum ImageTypeEnum {\n AVATAR = \"avatar\",\n COVER = \"cover\",\n IMAGE = \"image\",\n LOGO = \"logo\",\n}\n\nexport enum EnumUserLicence {\n ENTERPRISE_MARKET = \"enterprise_market\",\n ENTERPRISE_STALLHOLDER = \"enterprise_stallholder\",\n PRO_MARKET = \"pro_market\",\n PRO_STALLHOLDER = \"pro_stallholder\",\n STANDARD_MARKET = \"standard_market\",\n STANDARD_STALLHOLDER = \"standard_stallholder\",\n}\n\nexport enum EnumUserRole {\n ADMIN = \"admin\",\n CUSTOMER = \"customer\",\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA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B,MAAI,CAAC,SAAS,CAAC,MAAM,QAAQ;AAC3B,WAAO,CAAC;AAAA,EACV;AACA,QAAM,gBAAY,aAAAA,SAAM;AACxB,SAAO,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM;AAC/B,UAAM,YAAQ,aAAAA,SAAM,EAAE,WAAW,UAAU;AAC3C,UAAM,YAAQ,aAAAA,SAAM,EAAE,WAAW,UAAU;AAC3C,UAAM,QAAQ,KAAK,IAAI,MAAM,KAAK,SAAS,CAAC;AAC5C,UAAM,QAAQ,KAAK,IAAI,MAAM,KAAK,SAAS,CAAC;AAC5C,WAAO,QAAQ;AAAA,EACjB,CAAC;AACH;AAEO,IAAM,uBAAuB,OAAO,OAAO,WAAW;AACtD,IAAM,yBACX,kBAAkB,oBAAoB;AAEjC,IAAM,uBAAqC;AAAA,EAChD,OAAO,OAAO,iBAAiB;AACjC;","names":["EnumInviteStatus","EnumPaymentMethod","EnumRegions","customParseFormat","utc","timezone","isSameOrAfter","dayjs"]}
@@ -0,0 +1,66 @@
1
+ import { EnumInviteStatus, EnumRegions } from '../enums/index.mjs';
2
+ import { b as Region, O as OptionItem } from '../global-B8kYikwQ.mjs';
3
+ import 'react-hook-form';
4
+
5
+ declare const dateFormat = "DD-MM-YYYY";
6
+ declare const timeFormat = "HH:mm";
7
+ type DateFormat = "date" | "time" | "datetime";
8
+ /**
9
+ * Format a date string to a more readable format.
10
+ * @param dateStr - the date string
11
+ * @param timeStr - optional time string
12
+ * @param display - 'date' | 'time' | 'datetime'
13
+ * @returns formatted string based on display option
14
+ */
15
+ declare const formatDate: (dateStr: string, display?: DateFormat, timeStr?: string) => string;
16
+ declare const getCurrentAndFutureDates: <T extends {
17
+ startDate: string;
18
+ startTime: string;
19
+ }>(dates: T[]) => T[];
20
+ declare const getFutureDatesAfterThreshold: (dates: {
21
+ startDate: string;
22
+ startTime: string;
23
+ }[], minHoursFromNow?: number) => {
24
+ startDate: string;
25
+ startTime: string;
26
+ }[];
27
+ declare const formatTimestamp: (timestamp: string) => string;
28
+ declare const defaultRegion: Region;
29
+ /**
30
+ * Function to remove __typename from an object or array of objects.
31
+ * @param obj - The object or array to clean.
32
+ * @returns - The cleaned object or array.
33
+ */
34
+ declare const removeTypename: (obj: any) => any;
35
+ /**
36
+ * Truncate text to a specified length and append ellipsis if necessary.
37
+ * @param text
38
+ * @param maxLength
39
+ * @returns
40
+ */
41
+ declare const truncateText: (text: string, maxLength?: number) => string;
42
+ /**
43
+ * Convert an array of strings to an array of objects with label and value properties.
44
+ * @param items - The array of strings to convert.
45
+ * @returns - The converted array of objects.
46
+ */
47
+ declare const mapArrayToOptions: (items: string[]) => OptionItem[];
48
+ declare const capitalizeFirstLetter: (str: string) => string;
49
+ declare const statusOptions: {
50
+ label: EnumInviteStatus;
51
+ value: EnumInviteStatus;
52
+ }[];
53
+ /**
54
+ * Sort an array of date strings by their proximity to the current date.
55
+ * @param dates - The array of date strings to sort.
56
+ * @returns - The sorted array of date strings.
57
+ */
58
+ declare function sortDatesByProximity<T extends {
59
+ startDate: string;
60
+ startTime: string;
61
+ }>(dates: T[]): T[];
62
+ declare const availableRegionTypes: EnumRegions[];
63
+ declare const availableRegionOptions: OptionItem[];
64
+ declare const paymentMethodOptions: OptionItem[];
65
+
66
+ export { availableRegionOptions, availableRegionTypes, capitalizeFirstLetter, dateFormat, defaultRegion, formatDate, formatTimestamp, getCurrentAndFutureDates, getFutureDatesAfterThreshold, mapArrayToOptions, paymentMethodOptions, removeTypename, sortDatesByProximity, statusOptions, timeFormat, truncateText };
@@ -0,0 +1,66 @@
1
+ import { EnumInviteStatus, EnumRegions } from '../enums/index.js';
2
+ import { b as Region, O as OptionItem } from '../global-B7gB8cvC.js';
3
+ import 'react-hook-form';
4
+
5
+ declare const dateFormat = "DD-MM-YYYY";
6
+ declare const timeFormat = "HH:mm";
7
+ type DateFormat = "date" | "time" | "datetime";
8
+ /**
9
+ * Format a date string to a more readable format.
10
+ * @param dateStr - the date string
11
+ * @param timeStr - optional time string
12
+ * @param display - 'date' | 'time' | 'datetime'
13
+ * @returns formatted string based on display option
14
+ */
15
+ declare const formatDate: (dateStr: string, display?: DateFormat, timeStr?: string) => string;
16
+ declare const getCurrentAndFutureDates: <T extends {
17
+ startDate: string;
18
+ startTime: string;
19
+ }>(dates: T[]) => T[];
20
+ declare const getFutureDatesAfterThreshold: (dates: {
21
+ startDate: string;
22
+ startTime: string;
23
+ }[], minHoursFromNow?: number) => {
24
+ startDate: string;
25
+ startTime: string;
26
+ }[];
27
+ declare const formatTimestamp: (timestamp: string) => string;
28
+ declare const defaultRegion: Region;
29
+ /**
30
+ * Function to remove __typename from an object or array of objects.
31
+ * @param obj - The object or array to clean.
32
+ * @returns - The cleaned object or array.
33
+ */
34
+ declare const removeTypename: (obj: any) => any;
35
+ /**
36
+ * Truncate text to a specified length and append ellipsis if necessary.
37
+ * @param text
38
+ * @param maxLength
39
+ * @returns
40
+ */
41
+ declare const truncateText: (text: string, maxLength?: number) => string;
42
+ /**
43
+ * Convert an array of strings to an array of objects with label and value properties.
44
+ * @param items - The array of strings to convert.
45
+ * @returns - The converted array of objects.
46
+ */
47
+ declare const mapArrayToOptions: (items: string[]) => OptionItem[];
48
+ declare const capitalizeFirstLetter: (str: string) => string;
49
+ declare const statusOptions: {
50
+ label: EnumInviteStatus;
51
+ value: EnumInviteStatus;
52
+ }[];
53
+ /**
54
+ * Sort an array of date strings by their proximity to the current date.
55
+ * @param dates - The array of date strings to sort.
56
+ * @returns - The sorted array of date strings.
57
+ */
58
+ declare function sortDatesByProximity<T extends {
59
+ startDate: string;
60
+ startTime: string;
61
+ }>(dates: T[]): T[];
62
+ declare const availableRegionTypes: EnumRegions[];
63
+ declare const availableRegionOptions: OptionItem[];
64
+ declare const paymentMethodOptions: OptionItem[];
65
+
66
+ export { availableRegionOptions, availableRegionTypes, capitalizeFirstLetter, dateFormat, defaultRegion, formatDate, formatTimestamp, getCurrentAndFutureDates, getFutureDatesAfterThreshold, mapArrayToOptions, paymentMethodOptions, removeTypename, sortDatesByProximity, statusOptions, timeFormat, truncateText };
@@ -0,0 +1,38 @@
1
+ import {
2
+ availableRegionOptions,
3
+ availableRegionTypes,
4
+ capitalizeFirstLetter,
5
+ dateFormat,
6
+ defaultRegion,
7
+ formatDate,
8
+ formatTimestamp,
9
+ getCurrentAndFutureDates,
10
+ getFutureDatesAfterThreshold,
11
+ mapArrayToOptions,
12
+ paymentMethodOptions,
13
+ removeTypename,
14
+ sortDatesByProximity,
15
+ statusOptions,
16
+ timeFormat,
17
+ truncateText
18
+ } from "../chunk-K5NK2CK5.mjs";
19
+ import "../chunk-L2H5WFGC.mjs";
20
+ export {
21
+ availableRegionOptions,
22
+ availableRegionTypes,
23
+ capitalizeFirstLetter,
24
+ dateFormat,
25
+ defaultRegion,
26
+ formatDate,
27
+ formatTimestamp,
28
+ getCurrentAndFutureDates,
29
+ getFutureDatesAfterThreshold,
30
+ mapArrayToOptions,
31
+ paymentMethodOptions,
32
+ removeTypename,
33
+ sortDatesByProximity,
34
+ statusOptions,
35
+ timeFormat,
36
+ truncateText
37
+ };
38
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,16 +1,49 @@
1
1
  {
2
2
  "name": "@timardex/cluemart-shared",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
8
8
  "exports": {
9
- "import": "./dist/index.mjs",
10
- "require": "./dist/index.cjs"
9
+ ".": {
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.cjs",
12
+ "types": "./dist/index.d.ts"
13
+ },
14
+ "./types": {
15
+ "import": "./dist/types/index.mjs",
16
+ "require": "./dist/types/index.cjs",
17
+ "types": "./dist/types/index.d.ts"
18
+ },
19
+ "./utils": {
20
+ "import": "./dist/utils/index.mjs",
21
+ "require": "./dist/utils/index.cjs",
22
+ "types": "./dist/utils/index.d.ts"
23
+ },
24
+ "./hooks": {
25
+ "import": "./dist/hooks/index.mjs",
26
+ "require": "./dist/hooks/index.cjs",
27
+ "types": "./dist/hooks/index.d.ts"
28
+ },
29
+ "./graphql": {
30
+ "import": "./dist/graphql/index.mjs",
31
+ "require": "./dist/graphql/index.cjs",
32
+ "types": "./dist/graphql/index.d.ts"
33
+ },
34
+ "./formFields": {
35
+ "import": "./dist/formFields/index.mjs",
36
+ "require": "./dist/formFields/index.cjs",
37
+ "types": "./dist/formFields/index.d.ts"
38
+ },
39
+ "./enums": {
40
+ "import": "./dist/enums/index.mjs",
41
+ "require": "./dist/enums/index.cjs",
42
+ "types": "./dist/enums/index.d.ts"
43
+ }
11
44
  },
12
45
  "scripts": {
13
- "build": "rimraf dist && tsup src/index.ts --format esm,cjs --dts --sourcemap && mv dist/index.js dist/index.cjs && npm pack",
46
+ "build": "rimraf dist && tsup && npm pack",
14
47
  "lint": "eslint --ext .ts src",
15
48
  "lint:fix": "eslint --ext .ts --fix src",
16
49
  "typecheck": "tsc --noEmit"