@brightspace-ui/intl 3.34.2 → 3.34.4
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/lib/_timeZones/mapper.js +0 -17
- package/lib/localize.js +5 -4
- package/lib/timeZones.js +1 -21
- package/package.json +1 -1
package/lib/_timeZones/mapper.js
CHANGED
|
@@ -139,23 +139,6 @@ export class TimeZoneMapper {
|
|
|
139
139
|
return result;
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
|
-
* Get all timeZones for a specific region
|
|
143
|
-
* @param {string} regionCode - ISO 3166-1 alpha-2 region code
|
|
144
|
-
* @returns {string[]} Array of timeZone identifiers
|
|
145
|
-
*/
|
|
146
|
-
getTimeZonesForRegion(regionCode) {
|
|
147
|
-
this._ensureLoaded();
|
|
148
|
-
const timeZones = [];
|
|
149
|
-
|
|
150
|
-
for (const [timeZone, info] of this.mappings.entries()) {
|
|
151
|
-
if (info.regionCode === regionCode.toUpperCase()) {
|
|
152
|
-
timeZones.push(timeZone);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return timeZones.sort();
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
142
|
* Load timeZone mappings from a single combined object
|
|
160
143
|
* @param {Object} timeZoneData - Combined timeZone data object
|
|
161
144
|
*/
|
package/lib/localize.js
CHANGED
|
@@ -238,15 +238,16 @@ export const getLocalizeClass = (superclass = class {}) => class LocalizeClass e
|
|
|
238
238
|
if (osloCollection) {
|
|
239
239
|
const oslo = this.documentLocaleSettings.oslo;
|
|
240
240
|
let languageId = 0;
|
|
241
|
-
if (oslo) {
|
|
242
|
-
const batch = new URL(oslo.batch, document.location.origin);
|
|
243
|
-
const collection = new URL(oslo.collection, document.location.origin);
|
|
241
|
+
if (oslo.collection) {
|
|
244
242
|
languageId = supportedLocalesDetails.find(l => l.code === osloLang || l.pack === osloLang)?.id;
|
|
245
243
|
if (languageId) {
|
|
246
|
-
|
|
244
|
+
const batch = oslo.batch && new URL(oslo.batch, document.location.origin);
|
|
245
|
+
if (batch && languageId !== batch.searchParams.get('languageId')) {
|
|
247
246
|
batch.searchParams.set('languageId', languageId);
|
|
248
247
|
oslo.batch = batch.toString();
|
|
249
248
|
}
|
|
249
|
+
|
|
250
|
+
const collection = new URL(oslo.collection, document.location.origin);
|
|
250
251
|
if (languageId !== collection.searchParams.get('languageId')) {
|
|
251
252
|
collection.searchParams.set('languageId', languageId);
|
|
252
253
|
oslo.collection = collection.toString();
|
package/lib/timeZones.js
CHANGED
|
@@ -1,38 +1,18 @@
|
|
|
1
1
|
import { getDocumentLocaleSettings } from './common.js';
|
|
2
2
|
import { TimeZoneMapper } from './_timeZones/mapper.js';
|
|
3
3
|
|
|
4
|
-
let timeZoneData;
|
|
5
|
-
getDocumentLocaleSettings().addChangeListener(() => timeZoneData = null);
|
|
6
|
-
|
|
7
4
|
const tzMap = {
|
|
8
5
|
'Asia/Calcutta': 'Asia/Kolkata',
|
|
9
6
|
};
|
|
10
7
|
|
|
11
8
|
let timeZoneIdentifiers = null;
|
|
12
|
-
|
|
9
|
+
function getTimeZoneIdentifiers() {
|
|
13
10
|
if (timeZoneIdentifiers === null) {
|
|
14
11
|
timeZoneIdentifiers = Intl.supportedValuesOf?.('timeZone').map(t => tzMap[t] || t) || [];
|
|
15
12
|
}
|
|
16
13
|
return timeZoneIdentifiers;
|
|
17
14
|
}
|
|
18
15
|
|
|
19
|
-
export async function getTimeZonesData(region, modules) {
|
|
20
|
-
let timeZones;
|
|
21
|
-
const mapper = new TimeZoneMapper(modules);
|
|
22
|
-
await mapper.loadMappings();
|
|
23
|
-
|
|
24
|
-
if (region) {
|
|
25
|
-
timeZones = new Intl.Locale(`en-${region}`).getTimeZones?.();
|
|
26
|
-
if (!timeZones?.length) {
|
|
27
|
-
timeZones = mapper.getTimeZonesForRegion(region);
|
|
28
|
-
}
|
|
29
|
-
} else {
|
|
30
|
-
if (timeZoneData) return timeZoneData;
|
|
31
|
-
timeZones = getTimeZoneIdentifiers();
|
|
32
|
-
}
|
|
33
|
-
return await Promise.all(timeZones.map(l => getTimeZoneData(l, { mapper })));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
16
|
export async function getTimeZoneData(
|
|
37
17
|
identifier = getDocumentLocaleSettings().timezone.identifier,
|
|
38
18
|
{
|
package/package.json
CHANGED