@webority/mobile-core 0.0.23

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 (211) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +39 -0
  3. package/android/build.gradle +65 -0
  4. package/android/src/newarch/java/com/webority/mobilecore/smsretriever/AppSignatureHelper.kt +57 -0
  5. package/android/src/newarch/java/com/webority/mobilecore/smsretriever/SmsRetrieverModule.kt +20 -0
  6. package/android/src/newarch/java/com/webority/mobilecore/smsretriever/SmsRetrieverModuleImpl.kt +146 -0
  7. package/android/src/newarch/java/com/webority/mobilecore/smsretriever/SmsRetrieverPackage.kt +33 -0
  8. package/lib/commonjs/api/baseUrl.js +34 -0
  9. package/lib/commonjs/api/curl.js +109 -0
  10. package/lib/commonjs/api/publicClient.js +73 -0
  11. package/lib/commonjs/api/retry.js +75 -0
  12. package/lib/commonjs/api/tokenRefresh.js +205 -0
  13. package/lib/commonjs/api/userClient.js +255 -0
  14. package/lib/commonjs/auth/authStore.js +232 -0
  15. package/lib/commonjs/auth/index.js +44 -0
  16. package/lib/commonjs/auth/jwt.js +112 -0
  17. package/lib/commonjs/config/index.js +66 -0
  18. package/lib/commonjs/deepLink/index.js +286 -0
  19. package/lib/commonjs/download/adapters/expoFs.js +69 -0
  20. package/lib/commonjs/download/adapters/shared.js +13 -0
  21. package/lib/commonjs/download/index.js +250 -0
  22. package/lib/commonjs/formatters/currency.js +69 -0
  23. package/lib/commonjs/formatters/date.js +168 -0
  24. package/lib/commonjs/formatters/dateMath.js +310 -0
  25. package/lib/commonjs/formatters/index.js +246 -0
  26. package/lib/commonjs/formatters/initials.js +32 -0
  27. package/lib/commonjs/formatters/number.js +88 -0
  28. package/lib/commonjs/formatters/phone.js +369 -0
  29. package/lib/commonjs/formatters/windowsToIanaTable.js +164 -0
  30. package/lib/commonjs/geolocation/adapters/expoLocation.js +126 -0
  31. package/lib/commonjs/geolocation/index.js +355 -0
  32. package/lib/commonjs/index.js +630 -0
  33. package/lib/commonjs/initSDK.js +66 -0
  34. package/lib/commonjs/initUserAuth.js +37 -0
  35. package/lib/commonjs/logger/index.js +291 -0
  36. package/lib/commonjs/network/index.js +31 -0
  37. package/lib/commonjs/network/networkStatus.js +133 -0
  38. package/lib/commonjs/package.json +1 -0
  39. package/lib/commonjs/permissions/calendar.js +14 -0
  40. package/lib/commonjs/permissions/camera.js +14 -0
  41. package/lib/commonjs/permissions/contacts.js +10 -0
  42. package/lib/commonjs/permissions/index.js +133 -0
  43. package/lib/commonjs/permissions/location.js +14 -0
  44. package/lib/commonjs/permissions/mediaLibrary.js +10 -0
  45. package/lib/commonjs/permissions/notifications.js +10 -0
  46. package/lib/commonjs/permissions/photos.js +14 -0
  47. package/lib/commonjs/phone/countries.js +265 -0
  48. package/lib/commonjs/share/index.js +70 -0
  49. package/lib/commonjs/smsRetriever/index.js +91 -0
  50. package/lib/commonjs/specs/NativeSmsRetriever.js +15 -0
  51. package/lib/commonjs/sqlite/adapters/expo.js +53 -0
  52. package/lib/commonjs/sqlite/index.js +604 -0
  53. package/lib/commonjs/storage/index.js +214 -0
  54. package/lib/commonjs/types/globals.d.js +6 -0
  55. package/lib/commonjs/utils/imageCompression.js +389 -0
  56. package/lib/commonjs/utils/index.js +19 -0
  57. package/lib/commonjs/validators/index.js +227 -0
  58. package/lib/commonjs/versionCheck/index.js +419 -0
  59. package/lib/module/api/baseUrl.js +30 -0
  60. package/lib/module/api/curl.js +104 -0
  61. package/lib/module/api/publicClient.js +69 -0
  62. package/lib/module/api/retry.js +69 -0
  63. package/lib/module/api/tokenRefresh.js +192 -0
  64. package/lib/module/api/userClient.js +233 -0
  65. package/lib/module/auth/authStore.js +224 -0
  66. package/lib/module/auth/index.js +5 -0
  67. package/lib/module/auth/jwt.js +106 -0
  68. package/lib/module/config/index.js +58 -0
  69. package/lib/module/deepLink/index.js +280 -0
  70. package/lib/module/download/adapters/expoFs.js +64 -0
  71. package/lib/module/download/adapters/shared.js +8 -0
  72. package/lib/module/download/index.js +242 -0
  73. package/lib/module/formatters/currency.js +64 -0
  74. package/lib/module/formatters/date.js +160 -0
  75. package/lib/module/formatters/dateMath.js +294 -0
  76. package/lib/module/formatters/index.js +9 -0
  77. package/lib/module/formatters/initials.js +27 -0
  78. package/lib/module/formatters/number.js +81 -0
  79. package/lib/module/formatters/phone.js +302 -0
  80. package/lib/module/formatters/windowsToIanaTable.js +160 -0
  81. package/lib/module/geolocation/adapters/expoLocation.js +121 -0
  82. package/lib/module/geolocation/index.js +347 -0
  83. package/lib/module/index.js +54 -0
  84. package/lib/module/initSDK.js +61 -0
  85. package/lib/module/initUserAuth.js +33 -0
  86. package/lib/module/logger/index.js +285 -0
  87. package/lib/module/network/index.js +4 -0
  88. package/lib/module/network/networkStatus.js +124 -0
  89. package/lib/module/package.json +1 -0
  90. package/lib/module/permissions/calendar.js +15 -0
  91. package/lib/module/permissions/camera.js +15 -0
  92. package/lib/module/permissions/contacts.js +11 -0
  93. package/lib/module/permissions/index.js +128 -0
  94. package/lib/module/permissions/location.js +15 -0
  95. package/lib/module/permissions/mediaLibrary.js +11 -0
  96. package/lib/module/permissions/notifications.js +11 -0
  97. package/lib/module/permissions/photos.js +15 -0
  98. package/lib/module/phone/countries.js +261 -0
  99. package/lib/module/share/index.js +64 -0
  100. package/lib/module/smsRetriever/index.js +86 -0
  101. package/lib/module/specs/NativeSmsRetriever.js +13 -0
  102. package/lib/module/sqlite/adapters/expo.js +48 -0
  103. package/lib/module/sqlite/index.js +594 -0
  104. package/lib/module/storage/index.js +208 -0
  105. package/lib/module/types/globals.d.js +10 -0
  106. package/lib/module/utils/imageCompression.js +383 -0
  107. package/lib/module/utils/index.js +4 -0
  108. package/lib/module/validators/index.js +205 -0
  109. package/lib/module/versionCheck/index.js +413 -0
  110. package/lib/typescript/commonjs/api/baseUrl.d.ts +20 -0
  111. package/lib/typescript/commonjs/api/curl.d.ts +18 -0
  112. package/lib/typescript/commonjs/api/publicClient.d.ts +11 -0
  113. package/lib/typescript/commonjs/api/retry.d.ts +27 -0
  114. package/lib/typescript/commonjs/api/tokenRefresh.d.ts +43 -0
  115. package/lib/typescript/commonjs/api/userClient.d.ts +37 -0
  116. package/lib/typescript/commonjs/auth/authStore.d.ts +79 -0
  117. package/lib/typescript/commonjs/auth/index.d.ts +5 -0
  118. package/lib/typescript/commonjs/auth/jwt.d.ts +31 -0
  119. package/lib/typescript/commonjs/config/index.d.ts +55 -0
  120. package/lib/typescript/commonjs/deepLink/index.d.ts +54 -0
  121. package/lib/typescript/commonjs/download/adapters/expoFs.d.ts +38 -0
  122. package/lib/typescript/commonjs/download/adapters/shared.d.ts +3 -0
  123. package/lib/typescript/commonjs/download/index.d.ts +86 -0
  124. package/lib/typescript/commonjs/formatters/currency.d.ts +24 -0
  125. package/lib/typescript/commonjs/formatters/date.d.ts +22 -0
  126. package/lib/typescript/commonjs/formatters/dateMath.d.ts +88 -0
  127. package/lib/typescript/commonjs/formatters/index.d.ts +10 -0
  128. package/lib/typescript/commonjs/formatters/initials.d.ts +11 -0
  129. package/lib/typescript/commonjs/formatters/number.d.ts +15 -0
  130. package/lib/typescript/commonjs/formatters/phone.d.ts +133 -0
  131. package/lib/typescript/commonjs/formatters/windowsToIanaTable.d.ts +18 -0
  132. package/lib/typescript/commonjs/geolocation/adapters/expoLocation.d.ts +42 -0
  133. package/lib/typescript/commonjs/geolocation/index.d.ts +90 -0
  134. package/lib/typescript/commonjs/index.d.ts +54 -0
  135. package/lib/typescript/commonjs/initSDK.d.ts +72 -0
  136. package/lib/typescript/commonjs/initUserAuth.d.ts +41 -0
  137. package/lib/typescript/commonjs/logger/index.d.ts +81 -0
  138. package/lib/typescript/commonjs/network/index.d.ts +3 -0
  139. package/lib/typescript/commonjs/network/networkStatus.d.ts +43 -0
  140. package/lib/typescript/commonjs/package.json +1 -0
  141. package/lib/typescript/commonjs/permissions/calendar.d.ts +2 -0
  142. package/lib/typescript/commonjs/permissions/camera.d.ts +2 -0
  143. package/lib/typescript/commonjs/permissions/contacts.d.ts +2 -0
  144. package/lib/typescript/commonjs/permissions/index.d.ts +48 -0
  145. package/lib/typescript/commonjs/permissions/location.d.ts +2 -0
  146. package/lib/typescript/commonjs/permissions/mediaLibrary.d.ts +2 -0
  147. package/lib/typescript/commonjs/permissions/notifications.d.ts +2 -0
  148. package/lib/typescript/commonjs/permissions/photos.d.ts +2 -0
  149. package/lib/typescript/commonjs/phone/countries.d.ts +13 -0
  150. package/lib/typescript/commonjs/share/index.d.ts +29 -0
  151. package/lib/typescript/commonjs/smsRetriever/index.d.ts +30 -0
  152. package/lib/typescript/commonjs/specs/NativeSmsRetriever.d.ts +15 -0
  153. package/lib/typescript/commonjs/sqlite/adapters/expo.d.ts +30 -0
  154. package/lib/typescript/commonjs/sqlite/index.d.ts +113 -0
  155. package/lib/typescript/commonjs/storage/index.d.ts +64 -0
  156. package/lib/typescript/commonjs/utils/imageCompression.d.ts +152 -0
  157. package/lib/typescript/commonjs/utils/index.d.ts +3 -0
  158. package/lib/typescript/commonjs/validators/index.d.ts +51 -0
  159. package/lib/typescript/commonjs/versionCheck/index.d.ts +80 -0
  160. package/lib/typescript/module/api/baseUrl.d.ts +20 -0
  161. package/lib/typescript/module/api/curl.d.ts +18 -0
  162. package/lib/typescript/module/api/publicClient.d.ts +11 -0
  163. package/lib/typescript/module/api/retry.d.ts +27 -0
  164. package/lib/typescript/module/api/tokenRefresh.d.ts +43 -0
  165. package/lib/typescript/module/api/userClient.d.ts +37 -0
  166. package/lib/typescript/module/auth/authStore.d.ts +79 -0
  167. package/lib/typescript/module/auth/index.d.ts +5 -0
  168. package/lib/typescript/module/auth/jwt.d.ts +31 -0
  169. package/lib/typescript/module/config/index.d.ts +55 -0
  170. package/lib/typescript/module/deepLink/index.d.ts +54 -0
  171. package/lib/typescript/module/download/adapters/expoFs.d.ts +38 -0
  172. package/lib/typescript/module/download/adapters/shared.d.ts +3 -0
  173. package/lib/typescript/module/download/index.d.ts +86 -0
  174. package/lib/typescript/module/formatters/currency.d.ts +24 -0
  175. package/lib/typescript/module/formatters/date.d.ts +22 -0
  176. package/lib/typescript/module/formatters/dateMath.d.ts +88 -0
  177. package/lib/typescript/module/formatters/index.d.ts +10 -0
  178. package/lib/typescript/module/formatters/initials.d.ts +11 -0
  179. package/lib/typescript/module/formatters/number.d.ts +15 -0
  180. package/lib/typescript/module/formatters/phone.d.ts +133 -0
  181. package/lib/typescript/module/formatters/windowsToIanaTable.d.ts +18 -0
  182. package/lib/typescript/module/geolocation/adapters/expoLocation.d.ts +42 -0
  183. package/lib/typescript/module/geolocation/index.d.ts +90 -0
  184. package/lib/typescript/module/index.d.ts +54 -0
  185. package/lib/typescript/module/initSDK.d.ts +72 -0
  186. package/lib/typescript/module/initUserAuth.d.ts +41 -0
  187. package/lib/typescript/module/logger/index.d.ts +81 -0
  188. package/lib/typescript/module/network/index.d.ts +3 -0
  189. package/lib/typescript/module/network/networkStatus.d.ts +43 -0
  190. package/lib/typescript/module/package.json +1 -0
  191. package/lib/typescript/module/permissions/calendar.d.ts +2 -0
  192. package/lib/typescript/module/permissions/camera.d.ts +2 -0
  193. package/lib/typescript/module/permissions/contacts.d.ts +2 -0
  194. package/lib/typescript/module/permissions/index.d.ts +48 -0
  195. package/lib/typescript/module/permissions/location.d.ts +2 -0
  196. package/lib/typescript/module/permissions/mediaLibrary.d.ts +2 -0
  197. package/lib/typescript/module/permissions/notifications.d.ts +2 -0
  198. package/lib/typescript/module/permissions/photos.d.ts +2 -0
  199. package/lib/typescript/module/phone/countries.d.ts +13 -0
  200. package/lib/typescript/module/share/index.d.ts +29 -0
  201. package/lib/typescript/module/smsRetriever/index.d.ts +30 -0
  202. package/lib/typescript/module/specs/NativeSmsRetriever.d.ts +15 -0
  203. package/lib/typescript/module/sqlite/adapters/expo.d.ts +30 -0
  204. package/lib/typescript/module/sqlite/index.d.ts +113 -0
  205. package/lib/typescript/module/storage/index.d.ts +64 -0
  206. package/lib/typescript/module/utils/imageCompression.d.ts +152 -0
  207. package/lib/typescript/module/utils/index.d.ts +3 -0
  208. package/lib/typescript/module/validators/index.d.ts +51 -0
  209. package/lib/typescript/module/versionCheck/index.d.ts +80 -0
  210. package/package.json +298 -0
  211. package/src/specs/NativeSmsRetriever.ts +16 -0
@@ -0,0 +1,310 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.startOfDay = exports.isSameDay = exports.isDateBefore = exports.isDateAfter = exports.formatTimeInZone = exports.formatTimeInWindowsZone = exports.formatTime12h = exports.formatDatePattern = exports.formatDateISO = exports.formatDateDDMMMYYYY = exports.diffMs = exports.addDays = void 0;
7
+ var _windowsToIanaTable = require("./windowsToIanaTable.js");
8
+ const toDate = value => {
9
+ if (value instanceof Date) {
10
+ return Number.isNaN(value.getTime()) ? null : value;
11
+ }
12
+ const d = new Date(value);
13
+ return Number.isNaN(d.getTime()) ? null : d;
14
+ };
15
+ const PAD = n => n < 10 ? `0${n}` : `${n}`;
16
+
17
+ /**
18
+ * Whether two values fall on the same calendar day in the device's local
19
+ * timezone. Invalid input on either side returns false rather than throwing.
20
+ */
21
+ const isSameDay = (a, b) => {
22
+ const da = toDate(a);
23
+ const db = toDate(b);
24
+ if (!da || !db) {
25
+ return false;
26
+ }
27
+ return da.getFullYear() === db.getFullYear() && da.getMonth() === db.getMonth() && da.getDate() === db.getDate();
28
+ };
29
+
30
+ /** `a` is strictly before `b`. Invalid input on either side returns false. */
31
+ exports.isSameDay = isSameDay;
32
+ const isDateBefore = (a, b) => {
33
+ const da = toDate(a);
34
+ const db = toDate(b);
35
+ return da !== null && db !== null && da.getTime() < db.getTime();
36
+ };
37
+
38
+ /** `a` is strictly after `b`. Invalid input on either side returns false. */
39
+ exports.isDateBefore = isDateBefore;
40
+ const isDateAfter = (a, b) => {
41
+ const da = toDate(a);
42
+ const db = toDate(b);
43
+ return da !== null && db !== null && da.getTime() > db.getTime();
44
+ };
45
+
46
+ /**
47
+ * `a - b` in milliseconds, matching dayjs's `a.diff(b)` sign convention
48
+ * (positive when `a` is later than `b`). Returns `NaN` if either side fails
49
+ * to parse, the same way subtracting two invalid dayjs objects would.
50
+ */
51
+ exports.isDateAfter = isDateAfter;
52
+ const diffMs = (a, b) => {
53
+ const da = toDate(a);
54
+ const db = toDate(b);
55
+ if (!da || !db) {
56
+ return Number.NaN;
57
+ }
58
+ return da.getTime() - db.getTime();
59
+ };
60
+
61
+ /**
62
+ * Midnight of the given date, in the device's local timezone. Returns null
63
+ * for unparseable input.
64
+ */
65
+ exports.diffMs = diffMs;
66
+ const startOfDay = value => {
67
+ const d = toDate(value);
68
+ if (!d) {
69
+ return null;
70
+ }
71
+ const start = new Date(d);
72
+ start.setHours(0, 0, 0, 0);
73
+ return start;
74
+ };
75
+
76
+ /**
77
+ * Adds (or, with a negative count, subtracts) whole calendar days in the
78
+ * device's local timezone. Returns null for unparseable input.
79
+ */
80
+ exports.startOfDay = startOfDay;
81
+ const addDays = (value, count) => {
82
+ const d = toDate(value);
83
+ if (!d) {
84
+ return null;
85
+ }
86
+ const next = new Date(d);
87
+ next.setDate(next.getDate() + count);
88
+ return next;
89
+ };
90
+ exports.addDays = addDays;
91
+ const WEEKDAY_SHORT = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
92
+ const WEEKDAY_LONG = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
93
+ const MONTH_LONG = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
94
+
95
+ // Longest-first so 'YYYY' is tried before 'YY', 'DD' before 'D', etc. — a
96
+ // greedy single pass over the pattern, not a regex, so a literal character
97
+ // (a comma, a colon, a digit) can never accidentally match a token.
98
+ const TOKENS = ['YYYY', 'YY', 'MMMM', 'MMM', 'MM', 'M', 'DD', 'D', 'dddd', 'ddd', 'HH', 'H', 'hh', 'h', 'mm', 'm', 'ss', 's', 'A', 'a'];
99
+ const tokenizePattern = pattern => {
100
+ const result = [];
101
+ let i = 0;
102
+ outer: while (i < pattern.length) {
103
+ for (const token of TOKENS) {
104
+ if (pattern.startsWith(token, i)) {
105
+ result.push(token);
106
+ i += token.length;
107
+ continue outer;
108
+ }
109
+ }
110
+ result.push(pattern[i]);
111
+ i += 1;
112
+ }
113
+ return result;
114
+ };
115
+
116
+ /**
117
+ * Small dayjs/moment-style token formatter — YYYY/YY, MMMM/MMM/MM/M,
118
+ * DD/D, dddd/ddd, HH/H (24h), hh/h (12h), mm/m, ss/s, A/a (upper/lower AM/PM).
119
+ * Everything else in the pattern (spaces, commas, colons) passes through
120
+ * literally. Hand-rolled rather than a dependency because this fleet's date
121
+ * formatting needs are a small, closed token set, not general i18n — for
122
+ * genuinely locale-aware output, `formatDate`/`formatTime` (Intl-backed, in
123
+ * `./date`) are the ones to reach for; this is for matching an exact
124
+ * existing pattern (a legacy display string, an API's expected shape).
125
+ *
126
+ * `utc: true` reads every field from the UTC calendar/clock instead of the
127
+ * device's local one — see `formatDateDDMMMYYYY`'s note on why this isn't
128
+ * cosmetic.
129
+ */
130
+ const formatDatePattern = (value, pattern, options) => {
131
+ const d = toDate(value);
132
+ if (!d) {
133
+ return '';
134
+ }
135
+ const utc = options?.utc ?? false;
136
+ const year = utc ? d.getUTCFullYear() : d.getFullYear();
137
+ const month = utc ? d.getUTCMonth() : d.getMonth();
138
+ const day = utc ? d.getUTCDate() : d.getDate();
139
+ const weekday = utc ? d.getUTCDay() : d.getDay();
140
+ const hours24 = utc ? d.getUTCHours() : d.getHours();
141
+ const minutes = utc ? d.getUTCMinutes() : d.getMinutes();
142
+ const seconds = utc ? d.getUTCSeconds() : d.getSeconds();
143
+ const {
144
+ hour12,
145
+ period
146
+ } = to12Hour(hours24);
147
+ return tokenizePattern(pattern).map(t => {
148
+ switch (t) {
149
+ case 'YYYY':
150
+ return String(year);
151
+ case 'YY':
152
+ return String(year).slice(-2);
153
+ case 'MMMM':
154
+ return MONTH_LONG[month];
155
+ case 'MMM':
156
+ return MONTH_SHORT[month];
157
+ case 'MM':
158
+ return PAD(month + 1);
159
+ case 'M':
160
+ return String(month + 1);
161
+ case 'DD':
162
+ return PAD(day);
163
+ case 'D':
164
+ return String(day);
165
+ case 'dddd':
166
+ return WEEKDAY_LONG[weekday];
167
+ case 'ddd':
168
+ return WEEKDAY_SHORT[weekday];
169
+ case 'HH':
170
+ return PAD(hours24);
171
+ case 'H':
172
+ return String(hours24);
173
+ case 'hh':
174
+ return PAD(hour12);
175
+ case 'h':
176
+ return String(hour12);
177
+ case 'mm':
178
+ return PAD(minutes);
179
+ case 'm':
180
+ return String(minutes);
181
+ case 'ss':
182
+ return PAD(seconds);
183
+ case 's':
184
+ return String(seconds);
185
+ case 'A':
186
+ return period;
187
+ case 'a':
188
+ return period.toLowerCase();
189
+ default:
190
+ return t;
191
+ }
192
+ }).join('');
193
+ };
194
+ exports.formatDatePattern = formatDatePattern;
195
+ const MONTH_SHORT = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
196
+
197
+ /**
198
+ * `DD MMM, YYYY` — zero-padded day, short month, comma, year (e.g.
199
+ * `05 Sep, 2025`). A specific legacy pattern some apps already display,
200
+ * not the fleet's own product convention: `formatDate` (the Intl `style`-based
201
+ * formatter in `./date`) is the one to reach for in new code. This exists so
202
+ * an app already showing this exact pattern can move off a date library
203
+ * without a visible change.
204
+ *
205
+ * `utc: true` reads the calendar day from the UTC fields instead of the
206
+ * device's local ones — matching `dayjs.utc(x).format(...)`, not
207
+ * `dayjs(x).format(...)`. The two disagree whenever local time has crossed a
208
+ * day boundary UTC hasn't yet (or vice versa), so this is not a cosmetic
209
+ * option; pass it only to match a call site that was genuinely UTC-explicit.
210
+ */
211
+ const formatDateDDMMMYYYY = (value, options) => {
212
+ const d = toDate(value);
213
+ if (!d) {
214
+ return '';
215
+ }
216
+ if (options?.utc) {
217
+ return `${PAD(d.getUTCDate())} ${MONTH_SHORT[d.getUTCMonth()]}, ${d.getUTCFullYear()}`;
218
+ }
219
+ return `${PAD(d.getDate())} ${MONTH_SHORT[d.getMonth()]}, ${d.getFullYear()}`;
220
+ };
221
+
222
+ /** `YYYY-MM-DD`, in the device's local timezone. */
223
+ exports.formatDateDDMMMYYYY = formatDateDDMMMYYYY;
224
+ const formatDateISO = value => {
225
+ const d = toDate(value);
226
+ if (!d) {
227
+ return '';
228
+ }
229
+ return `${d.getFullYear()}-${PAD(d.getMonth() + 1)}-${PAD(d.getDate())}`;
230
+ };
231
+ exports.formatDateISO = formatDateISO;
232
+ const to12Hour = hours => {
233
+ const period = hours >= 12 ? 'PM' : 'AM';
234
+ const hour12 = hours % 12 || 12;
235
+ return {
236
+ hour12,
237
+ period
238
+ };
239
+ };
240
+
241
+ /**
242
+ * `hh:mm A` in the device's local timezone — zero-padded 12-hour clock,
243
+ * uppercase AM/PM (e.g. `09:30 PM`).
244
+ */
245
+ const formatTime12h = value => {
246
+ const d = toDate(value);
247
+ if (!d) {
248
+ return '';
249
+ }
250
+ const {
251
+ hour12,
252
+ period
253
+ } = to12Hour(d.getHours());
254
+ return `${PAD(hour12)}:${PAD(d.getMinutes())} ${period}`;
255
+ };
256
+ exports.formatTime12h = formatTime12h;
257
+ const hasIntl = () => typeof Intl !== 'undefined' && typeof Intl.DateTimeFormat === 'function';
258
+
259
+ /**
260
+ * `hh:mm a` (zero-padded 12-hour, lowercase am/pm) of the given instant as
261
+ * seen in `ianaTimeZone` (e.g. `Asia/Kolkata`) — not the device's own
262
+ * timezone. Reads the hour/minute/period through `Intl.DateTimeFormat`'s
263
+ * `formatToParts` rather than its assembled string, because the assembled
264
+ * string's spacing before AM/PM varies by JS engine (some insert a narrow
265
+ * no-break space, U+202F, instead of a plain space) and isn't reliably
266
+ * zero-padded either. Throws if `ianaTimeZone` isn't a timezone Intl
267
+ * recognises — the same failure mode as handing dayjs.tz() a bad zone name.
268
+ */
269
+ const formatTimeInZone = (value, ianaTimeZone) => {
270
+ const d = toDate(value);
271
+ if (!d) {
272
+ return '';
273
+ }
274
+ if (!hasIntl()) {
275
+ // No Intl.DateTimeFormat means no reliable IANA timezone database to
276
+ // convert against; the device-local fallback below is the least-wrong
277
+ // answer available, not a genuine timezone conversion.
278
+ return formatTime12h(d);
279
+ }
280
+ const parts = new Intl.DateTimeFormat('en-US', {
281
+ timeZone: ianaTimeZone,
282
+ hour: 'numeric',
283
+ minute: '2-digit',
284
+ hour12: true
285
+ }).formatToParts(d);
286
+ const get = type => parts.find(p => p.type === type)?.value ?? '';
287
+ const hour = Number.parseInt(get('hour'), 10);
288
+ const minute = get('minute');
289
+ const period = get('dayPeriod').toLowerCase();
290
+ return `${PAD(hour)}:${minute} ${period}`;
291
+ };
292
+
293
+ /**
294
+ * Same as {@link formatTimeInZone}, but for a .NET-style Windows timezone ID
295
+ * (e.g. `"India Standard Time"`) rather than an IANA one. .NET's own
296
+ * `TimeZoneInfo` API only knows Windows IDs, so a backend built on it hands
297
+ * these to clients directly — `Intl`, by contrast, only recognises IANA
298
+ * names, so the ID has to be translated before it can be used here. Throws
299
+ * if `windowsTimeZoneId` has no known IANA mapping.
300
+ */
301
+ exports.formatTimeInZone = formatTimeInZone;
302
+ const formatTimeInWindowsZone = (value, windowsTimeZoneId) => {
303
+ const ianaTimeZone = _windowsToIanaTable.WINDOWS_TO_IANA[windowsTimeZoneId];
304
+ if (!ianaTimeZone) {
305
+ throw new Error(`Mapping for Windows time zone '${windowsTimeZoneId}' not found.`);
306
+ }
307
+ return formatTimeInZone(value, ianaTimeZone);
308
+ };
309
+ exports.formatTimeInWindowsZone = formatTimeInWindowsZone;
310
+ //# sourceMappingURL=dateMath.js.map
@@ -0,0 +1,246 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "AsYouType", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _phone.AsYouType;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "addDays", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _dateMath.addDays;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "clampNationalNumber", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _phone.clampNationalNumber;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "countryFlagEmoji", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _phone.countryFlagEmoji;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "detectPhoneCountry", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _phone.detectPhoneCountry;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "diffMs", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _dateMath.diffMs;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "formatCompactNumber", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _number.formatCompactNumber;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "formatCurrency", {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _currency.formatCurrency;
52
+ }
53
+ });
54
+ Object.defineProperty(exports, "formatDate", {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _date.formatDate;
58
+ }
59
+ });
60
+ Object.defineProperty(exports, "formatDateDDMMMYYYY", {
61
+ enumerable: true,
62
+ get: function () {
63
+ return _dateMath.formatDateDDMMMYYYY;
64
+ }
65
+ });
66
+ Object.defineProperty(exports, "formatDateISO", {
67
+ enumerable: true,
68
+ get: function () {
69
+ return _dateMath.formatDateISO;
70
+ }
71
+ });
72
+ Object.defineProperty(exports, "formatDatePattern", {
73
+ enumerable: true,
74
+ get: function () {
75
+ return _dateMath.formatDatePattern;
76
+ }
77
+ });
78
+ Object.defineProperty(exports, "formatDateTime", {
79
+ enumerable: true,
80
+ get: function () {
81
+ return _date.formatDateTime;
82
+ }
83
+ });
84
+ Object.defineProperty(exports, "formatNumber", {
85
+ enumerable: true,
86
+ get: function () {
87
+ return _number.formatNumber;
88
+ }
89
+ });
90
+ Object.defineProperty(exports, "formatPercent", {
91
+ enumerable: true,
92
+ get: function () {
93
+ return _number.formatPercent;
94
+ }
95
+ });
96
+ Object.defineProperty(exports, "formatPhone", {
97
+ enumerable: true,
98
+ get: function () {
99
+ return _phone.formatPhone;
100
+ }
101
+ });
102
+ Object.defineProperty(exports, "formatPhoneAsTyped", {
103
+ enumerable: true,
104
+ get: function () {
105
+ return _phone.formatPhoneAsTyped;
106
+ }
107
+ });
108
+ Object.defineProperty(exports, "formatRelativeTime", {
109
+ enumerable: true,
110
+ get: function () {
111
+ return _date.formatRelativeTime;
112
+ }
113
+ });
114
+ Object.defineProperty(exports, "formatTime", {
115
+ enumerable: true,
116
+ get: function () {
117
+ return _date.formatTime;
118
+ }
119
+ });
120
+ Object.defineProperty(exports, "formatTime12h", {
121
+ enumerable: true,
122
+ get: function () {
123
+ return _dateMath.formatTime12h;
124
+ }
125
+ });
126
+ Object.defineProperty(exports, "formatTimeInWindowsZone", {
127
+ enumerable: true,
128
+ get: function () {
129
+ return _dateMath.formatTimeInWindowsZone;
130
+ }
131
+ });
132
+ Object.defineProperty(exports, "formatTimeInZone", {
133
+ enumerable: true,
134
+ get: function () {
135
+ return _dateMath.formatTimeInZone;
136
+ }
137
+ });
138
+ Object.defineProperty(exports, "getCountries", {
139
+ enumerable: true,
140
+ get: function () {
141
+ return _phone.getCountries;
142
+ }
143
+ });
144
+ Object.defineProperty(exports, "getCountryCallingCode", {
145
+ enumerable: true,
146
+ get: function () {
147
+ return _phone.getCountryCallingCode;
148
+ }
149
+ });
150
+ Object.defineProperty(exports, "getInitials", {
151
+ enumerable: true,
152
+ get: function () {
153
+ return _initials.getInitials;
154
+ }
155
+ });
156
+ Object.defineProperty(exports, "getPhoneCountries", {
157
+ enumerable: true,
158
+ get: function () {
159
+ return _phone.getPhoneCountries;
160
+ }
161
+ });
162
+ Object.defineProperty(exports, "isDateAfter", {
163
+ enumerable: true,
164
+ get: function () {
165
+ return _dateMath.isDateAfter;
166
+ }
167
+ });
168
+ Object.defineProperty(exports, "isDateBefore", {
169
+ enumerable: true,
170
+ get: function () {
171
+ return _dateMath.isDateBefore;
172
+ }
173
+ });
174
+ Object.defineProperty(exports, "isSameDay", {
175
+ enumerable: true,
176
+ get: function () {
177
+ return _dateMath.isSameDay;
178
+ }
179
+ });
180
+ Object.defineProperty(exports, "isSupportedCountry", {
181
+ enumerable: true,
182
+ get: function () {
183
+ return _phone.isSupportedCountry;
184
+ }
185
+ });
186
+ Object.defineProperty(exports, "isValidNationalNumber", {
187
+ enumerable: true,
188
+ get: function () {
189
+ return _phone.isValidNationalNumber;
190
+ }
191
+ });
192
+ Object.defineProperty(exports, "isValidPhoneNumber", {
193
+ enumerable: true,
194
+ get: function () {
195
+ return _phone.isValidPhoneNumber;
196
+ }
197
+ });
198
+ Object.defineProperty(exports, "maxNationalNumberLength", {
199
+ enumerable: true,
200
+ get: function () {
201
+ return _phone.maxNationalNumberLength;
202
+ }
203
+ });
204
+ Object.defineProperty(exports, "normalizePhone", {
205
+ enumerable: true,
206
+ get: function () {
207
+ return _phone.normalizePhone;
208
+ }
209
+ });
210
+ Object.defineProperty(exports, "parsePhoneNumber", {
211
+ enumerable: true,
212
+ get: function () {
213
+ return _phone.parsePhoneNumber;
214
+ }
215
+ });
216
+ Object.defineProperty(exports, "parsePhoneNumberFromString", {
217
+ enumerable: true,
218
+ get: function () {
219
+ return _phone.parsePhoneNumberFromString;
220
+ }
221
+ });
222
+ Object.defineProperty(exports, "splitPhoneNumber", {
223
+ enumerable: true,
224
+ get: function () {
225
+ return _phone.splitPhoneNumber;
226
+ }
227
+ });
228
+ Object.defineProperty(exports, "startOfDay", {
229
+ enumerable: true,
230
+ get: function () {
231
+ return _dateMath.startOfDay;
232
+ }
233
+ });
234
+ Object.defineProperty(exports, "validatePhoneNumberLength", {
235
+ enumerable: true,
236
+ get: function () {
237
+ return _phone.validatePhoneNumberLength;
238
+ }
239
+ });
240
+ var _currency = require("./currency.js");
241
+ var _date = require("./date.js");
242
+ var _dateMath = require("./dateMath.js");
243
+ var _initials = require("./initials.js");
244
+ var _number = require("./number.js");
245
+ var _phone = require("./phone.js");
246
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getInitials = void 0;
7
+ /**
8
+ * Returns up to `maxChars` uppercase initials from a name.
9
+ *
10
+ * @example
11
+ * getInitials('Navneet Singh') // 'NS'
12
+ * getInitials('mary anne lee', 3) // 'MAL'
13
+ * getInitials('navneet') // 'NA'
14
+ * getInitials(' ') // ''
15
+ */
16
+ const getInitials = (name, maxChars = 2) => {
17
+ if (!name) {
18
+ return '';
19
+ }
20
+ const trimmed = name.trim();
21
+ if (!trimmed) {
22
+ return '';
23
+ }
24
+ const parts = trimmed.split(/\s+/);
25
+ if (parts.length === 1) {
26
+ const single = parts[0] ?? '';
27
+ return single.slice(0, maxChars).toUpperCase();
28
+ }
29
+ return parts.slice(0, maxChars).map(p => (p[0] ?? '').toUpperCase()).join('');
30
+ };
31
+ exports.getInitials = getInitials;
32
+ //# sourceMappingURL=initials.js.map
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.formatPercent = exports.formatNumber = exports.formatCompactNumber = void 0;
7
+ const hasIntlNumber = () => typeof Intl !== 'undefined' && typeof Intl.NumberFormat === 'function';
8
+
9
+ /**
10
+ * Locale-aware number formatter. Defaults to `'en-IN'` (Indian grouping).
11
+ */
12
+ const formatNumber = (value, fractionDigits, locale = 'en-IN') => {
13
+ if (value == null || Number.isNaN(value)) {
14
+ return '';
15
+ }
16
+ if (hasIntlNumber()) {
17
+ try {
18
+ const opts = {};
19
+ if (fractionDigits != null) {
20
+ opts.minimumFractionDigits = fractionDigits;
21
+ opts.maximumFractionDigits = fractionDigits;
22
+ }
23
+ return new Intl.NumberFormat(locale, opts).format(value);
24
+ } catch {
25
+ /* fall through */
26
+ }
27
+ }
28
+ return fractionDigits != null ? value.toFixed(fractionDigits) : String(value);
29
+ };
30
+
31
+ /**
32
+ * Format a 0–1 ratio (or 0–100 percent) as a percent string.
33
+ * Pass `asRatio: false` if your input is already on the 0–100 scale.
34
+ */
35
+ exports.formatNumber = formatNumber;
36
+ const formatPercent = (value, fractionDigits = 0, asRatio = true, locale = 'en-IN') => {
37
+ if (value == null || Number.isNaN(value)) {
38
+ return '';
39
+ }
40
+ const ratio = asRatio ? value : value / 100;
41
+ if (hasIntlNumber()) {
42
+ try {
43
+ return new Intl.NumberFormat(locale, {
44
+ style: 'percent',
45
+ minimumFractionDigits: fractionDigits,
46
+ maximumFractionDigits: fractionDigits
47
+ }).format(ratio);
48
+ } catch {
49
+ /* fall through */
50
+ }
51
+ }
52
+ return `${(ratio * 100).toFixed(fractionDigits)}%`;
53
+ };
54
+
55
+ /**
56
+ * Format a number compactly (1.2K, 3.4M, 1.5L, 2.3Cr).
57
+ * Defaults to Indian compact notation via `'en-IN'` locale (lakh / crore).
58
+ */
59
+ exports.formatPercent = formatPercent;
60
+ const formatCompactNumber = (value, locale = 'en-IN') => {
61
+ if (value == null || Number.isNaN(value)) {
62
+ return '';
63
+ }
64
+ if (hasIntlNumber()) {
65
+ try {
66
+ return new Intl.NumberFormat(locale, {
67
+ notation: 'compact',
68
+ maximumFractionDigits: 1
69
+ }).format(value);
70
+ } catch {
71
+ /* fall through */
72
+ }
73
+ }
74
+ const abs = Math.abs(value);
75
+ const sign = value < 0 ? '-' : '';
76
+ if (abs >= 1e7) {
77
+ return `${sign}${(abs / 1e7).toFixed(1)}Cr`;
78
+ }
79
+ if (abs >= 1e5) {
80
+ return `${sign}${(abs / 1e5).toFixed(1)}L`;
81
+ }
82
+ if (abs >= 1e3) {
83
+ return `${sign}${(abs / 1e3).toFixed(1)}K`;
84
+ }
85
+ return `${value}`;
86
+ };
87
+ exports.formatCompactNumber = formatCompactNumber;
88
+ //# sourceMappingURL=number.js.map