@descope/web-components-ui 3.1.3 → 3.1.5
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/cjs/index.cjs.js +34 -12
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.esm.js +34 -12
- package/dist/index.esm.js.map +1 -1
- package/dist/umd/DescopeDev.js +1 -1
- package/dist/umd/DescopeDev.js.map +1 -1
- package/dist/umd/descope-country-subdivision-city-field.js +1 -1
- package/dist/umd/descope-country-subdivision-city-field.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/package.json +31 -31
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -8965,10 +8965,14 @@ const subdivisionItem = ({ name, state_code, translations, lang }) => {
|
|
|
8965
8965
|
return `<div data-id="${escapedStateCode}" data-name="${escapedSearchTerms}" data-label="${escapedLabel}">${escapedLabel}</div>`;
|
|
8966
8966
|
};
|
|
8967
8967
|
|
|
8968
|
-
const cityItem = ({ name }) => {
|
|
8968
|
+
const cityItem = ({ name, translations, lang }) => {
|
|
8969
|
+
const displayName = resolveTranslation({ name, translations }, lang);
|
|
8970
|
+
const searchTerms = [displayName];
|
|
8971
|
+
if (displayName !== name) searchTerms.push(name);
|
|
8969
8972
|
const escapedId = escapeHtml(name);
|
|
8970
|
-
const
|
|
8971
|
-
|
|
8973
|
+
const escapedSearchTerms = escapeHtml(searchTerms.join(' '));
|
|
8974
|
+
const escapedLabel = escapeHtml(displayName);
|
|
8975
|
+
return `<div data-id="${escapedId}" data-name="${escapedSearchTerms}" data-label="${escapedLabel}">${escapedLabel}</div>`;
|
|
8972
8976
|
};
|
|
8973
8977
|
|
|
8974
8978
|
const comboBoxHTML = (id) =>
|
|
@@ -9028,6 +9032,7 @@ class RawCountrySubdivisionCityFieldInternal extends BaseInputClass$4 {
|
|
|
9028
9032
|
#countriesMap = new Map();
|
|
9029
9033
|
#cachedCountries = null;
|
|
9030
9034
|
#cachedSubdivisions = null;
|
|
9035
|
+
#cachedCities = null;
|
|
9031
9036
|
#labels = null;
|
|
9032
9037
|
|
|
9033
9038
|
// Value requested programmatically before data has loaded.
|
|
@@ -9074,8 +9079,8 @@ class RawCountrySubdivisionCityFieldInternal extends BaseInputClass$4 {
|
|
|
9074
9079
|
const lang = this.getAttribute('lang') || undefined;
|
|
9075
9080
|
if (!lang) return undefined;
|
|
9076
9081
|
try {
|
|
9077
|
-
Intl.getCanonicalLocales(lang);
|
|
9078
|
-
return
|
|
9082
|
+
const [canonical] = Intl.getCanonicalLocales(lang);
|
|
9083
|
+
return canonical;
|
|
9079
9084
|
} catch {
|
|
9080
9085
|
return undefined; // invalid BCP47 tag — fall back to English
|
|
9081
9086
|
}
|
|
@@ -9258,8 +9263,11 @@ class RawCountrySubdivisionCityFieldInternal extends BaseInputClass$4 {
|
|
|
9258
9263
|
|
|
9259
9264
|
#setupValueTransform() {
|
|
9260
9265
|
// Display only the item name in the input, while data-name includes ISO codes for search
|
|
9261
|
-
[
|
|
9262
|
-
|
|
9266
|
+
[
|
|
9267
|
+
this.#countryComboBox,
|
|
9268
|
+
this.#subdivisionComboBox,
|
|
9269
|
+
this.#cityComboBox,
|
|
9270
|
+
].forEach((combo) => {
|
|
9263
9271
|
combo.customValueTransformFn = (val) => {
|
|
9264
9272
|
const item = combo.baseElement?.items?.find(
|
|
9265
9273
|
(i) => i['data-name'] === val,
|
|
@@ -9404,7 +9412,11 @@ class RawCountrySubdivisionCityFieldInternal extends BaseInputClass$4 {
|
|
|
9404
9412
|
if (cities) {
|
|
9405
9413
|
this.#cityVisible = cities.length > 0;
|
|
9406
9414
|
if (cities.length > 0) {
|
|
9407
|
-
this.#
|
|
9415
|
+
this.#cachedCities = cities;
|
|
9416
|
+
this.#cityComboBox.data = cities.map((c) => ({
|
|
9417
|
+
...c,
|
|
9418
|
+
lang: this.#lang,
|
|
9419
|
+
}));
|
|
9408
9420
|
if (pendingCity) toSelect.push([this.#cityComboBox, pendingCity]);
|
|
9409
9421
|
}
|
|
9410
9422
|
}
|
|
@@ -9515,7 +9527,6 @@ class RawCountrySubdivisionCityFieldInternal extends BaseInputClass$4 {
|
|
|
9515
9527
|
if (!this.#pendingValue && this.#defaultCountry)
|
|
9516
9528
|
this.#onCountrySelected(this.#defaultCountry);
|
|
9517
9529
|
} catch (e) {
|
|
9518
|
-
|
|
9519
9530
|
console.error(`[${componentName$V}] Failed to load countries`, e);
|
|
9520
9531
|
} finally {
|
|
9521
9532
|
this.#countryComboBox.removeAttribute('loading');
|
|
@@ -9540,7 +9551,6 @@ class RawCountrySubdivisionCityFieldInternal extends BaseInputClass$4 {
|
|
|
9540
9551
|
this.#loadCities(countryIso2);
|
|
9541
9552
|
}
|
|
9542
9553
|
} catch (e) {
|
|
9543
|
-
|
|
9544
9554
|
console.error(
|
|
9545
9555
|
`[${componentName$V}] Failed to load subdivisions for ${countryIso2}`,
|
|
9546
9556
|
e,
|
|
@@ -9562,10 +9572,13 @@ class RawCountrySubdivisionCityFieldInternal extends BaseInputClass$4 {
|
|
|
9562
9572
|
this.#cityVisible = cities.length > 0;
|
|
9563
9573
|
this.#refreshState();
|
|
9564
9574
|
if (cities.length > 0) {
|
|
9565
|
-
this.#
|
|
9575
|
+
this.#cachedCities = cities;
|
|
9576
|
+
this.#cityComboBox.data = cities.map((c) => ({
|
|
9577
|
+
...c,
|
|
9578
|
+
lang: this.#lang,
|
|
9579
|
+
}));
|
|
9566
9580
|
}
|
|
9567
9581
|
} catch (e) {
|
|
9568
|
-
|
|
9569
9582
|
console.error(
|
|
9570
9583
|
`[${componentName$V}] Failed to load cities for ${countryIso2}${stateCode ? `/${stateCode}` : ''}`,
|
|
9571
9584
|
e,
|
|
@@ -9590,6 +9603,14 @@ class RawCountrySubdivisionCityFieldInternal extends BaseInputClass$4 {
|
|
|
9590
9603
|
if (prevSubdivision)
|
|
9591
9604
|
this.#selectItemById(this.#subdivisionComboBox, prevSubdivision);
|
|
9592
9605
|
}
|
|
9606
|
+
if (this.#cachedCities && this.#cityVisible) {
|
|
9607
|
+
const prevCity = this.#cityComboBox.value;
|
|
9608
|
+
this.#cityComboBox.data = this.#cachedCities.map((c) => ({
|
|
9609
|
+
...c,
|
|
9610
|
+
lang: this.#lang,
|
|
9611
|
+
}));
|
|
9612
|
+
if (prevCity) this.#selectItemById(this.#cityComboBox, prevCity);
|
|
9613
|
+
}
|
|
9593
9614
|
// Re-apply translated subdivision type label for the new lang
|
|
9594
9615
|
const currentIso2 = this.#countryComboBox.value;
|
|
9595
9616
|
if (currentIso2) {
|
|
@@ -9703,6 +9724,7 @@ class RawCountrySubdivisionCityFieldInternal extends BaseInputClass$4 {
|
|
|
9703
9724
|
#resetCity() {
|
|
9704
9725
|
this.#cityComboBox.value = '';
|
|
9705
9726
|
this.#cityComboBox.data = [];
|
|
9727
|
+
this.#cachedCities = null;
|
|
9706
9728
|
this.#cityVisible = false;
|
|
9707
9729
|
this.#refreshState();
|
|
9708
9730
|
}
|