@ews-admin/global-design-system 1.21.0 → 1.23.0
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/index.d.ts +17 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +38 -9
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +38 -8
- package/dist/index.js.map +1 -1
- package/dist/utils/index.d.ts +16 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/locations.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/utils/index.ts +36 -2
- package/src/utils/locations.ts +16 -14
package/dist/index.js
CHANGED
|
@@ -88,17 +88,19 @@ exports.SupportedCountry = void 0;
|
|
|
88
88
|
const REGIONS_BY_COUNTRY = {
|
|
89
89
|
[exports.SupportedCountry.SENEGAL]: [
|
|
90
90
|
"Dakar",
|
|
91
|
-
"
|
|
92
|
-
"Saint-Louis",
|
|
93
|
-
"Louga",
|
|
91
|
+
"Diourbel",
|
|
94
92
|
"Fatick",
|
|
95
|
-
"
|
|
93
|
+
"Kaffrine", // missing in your list
|
|
94
|
+
"Kaolack", // missing in your list (spelling variant of Kaolac)
|
|
95
|
+
"Kédougou",
|
|
96
96
|
"Kolda",
|
|
97
|
-
"
|
|
97
|
+
"Louga",
|
|
98
98
|
"Matam",
|
|
99
|
-
"
|
|
99
|
+
"Saint-Louis",
|
|
100
100
|
"Sédhiou",
|
|
101
|
-
"
|
|
101
|
+
"Tambacounda",
|
|
102
|
+
"Thiès",
|
|
103
|
+
"Ziguinchor",
|
|
102
104
|
],
|
|
103
105
|
[exports.SupportedCountry.CHAD]: [
|
|
104
106
|
"N'Djamena",
|
|
@@ -224,9 +226,36 @@ function formatCurrency(amount, currency = CURRENCY) {
|
|
|
224
226
|
currency,
|
|
225
227
|
}).format(amount);
|
|
226
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* Parses a date value the way every date coming from these platforms'
|
|
231
|
+
* Java/Kotlin backends actually shows up, without the classic off-by-one
|
|
232
|
+
* timezone bug.
|
|
233
|
+
*
|
|
234
|
+
* A bare "YYYY-MM-DD" string is parsed by `new Date(...)` as UTC midnight
|
|
235
|
+
* (per the ECMAScript spec), which then shifts a day earlier once formatted
|
|
236
|
+
* in any timezone behind UTC. This function parses date-only strings (and
|
|
237
|
+
* Jackson's `[year, month, day, ...]` LocalDate/LocalDateTime array
|
|
238
|
+
* serialization) as local calendar components instead. Full ISO datetime
|
|
239
|
+
* strings (with a time and/or timezone), Date objects, and numeric
|
|
240
|
+
* timestamps are unaffected and still go through the normal `new Date(...)`
|
|
241
|
+
* parse.
|
|
242
|
+
*/
|
|
243
|
+
function parseDateSafe(date) {
|
|
244
|
+
if (Array.isArray(date)) {
|
|
245
|
+
const [y, m, d, h = 0, min = 0, s = 0] = date;
|
|
246
|
+
return new Date(y, m - 1, d, h, min, s);
|
|
247
|
+
}
|
|
248
|
+
if (typeof date === "string") {
|
|
249
|
+
const dateOnlyMatch = /^(\d{4})-(\d{2})-(\d{2})$/.exec(date);
|
|
250
|
+
if (dateOnlyMatch) {
|
|
251
|
+
return new Date(Number(dateOnlyMatch[1]), Number(dateOnlyMatch[2]) - 1, Number(dateOnlyMatch[3]));
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return new Date(date);
|
|
255
|
+
}
|
|
227
256
|
function formatDate(date, options) {
|
|
228
257
|
const { locale = "en-US", ...intlOptions } = options ?? {};
|
|
229
|
-
const dateObj =
|
|
258
|
+
const dateObj = parseDateSafe(date);
|
|
230
259
|
return new Intl.DateTimeFormat(locale, {
|
|
231
260
|
year: "numeric",
|
|
232
261
|
month: "long",
|
|
@@ -40818,6 +40847,7 @@ exports.getRegionOptions = getRegionOptions;
|
|
|
40818
40847
|
exports.getRegionsByCountry = getRegionsByCountry;
|
|
40819
40848
|
exports.icons = index;
|
|
40820
40849
|
exports.isValidPhoneNumber = isValidPhoneNumber;
|
|
40850
|
+
exports.parseDateSafe = parseDateSafe;
|
|
40821
40851
|
exports.useDebounce = useDebounce;
|
|
40822
40852
|
exports.useDebouncedCallback = useDebouncedCallback;
|
|
40823
40853
|
exports.useSelectField = useSelectField;
|