@descope/web-components-ui 3.1.4 → 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/index.esm.js
CHANGED
|
@@ -24167,10 +24167,14 @@ const subdivisionItem = ({ name, state_code, translations, lang }) => {
|
|
|
24167
24167
|
return `<div data-id="${escapedStateCode}" data-name="${escapedSearchTerms}" data-label="${escapedLabel}">${escapedLabel}</div>`;
|
|
24168
24168
|
};
|
|
24169
24169
|
|
|
24170
|
-
const cityItem = ({ name }) => {
|
|
24170
|
+
const cityItem = ({ name, translations, lang }) => {
|
|
24171
|
+
const displayName = resolveTranslation({ name, translations }, lang);
|
|
24172
|
+
const searchTerms = [displayName];
|
|
24173
|
+
if (displayName !== name) searchTerms.push(name);
|
|
24171
24174
|
const escapedId = escapeHtml(name);
|
|
24172
|
-
const
|
|
24173
|
-
|
|
24175
|
+
const escapedSearchTerms = escapeHtml(searchTerms.join(' '));
|
|
24176
|
+
const escapedLabel = escapeHtml(displayName);
|
|
24177
|
+
return `<div data-id="${escapedId}" data-name="${escapedSearchTerms}" data-label="${escapedLabel}">${escapedLabel}</div>`;
|
|
24174
24178
|
};
|
|
24175
24179
|
|
|
24176
24180
|
const comboBoxHTML = (id) =>
|
|
@@ -24230,6 +24234,7 @@ class RawCountrySubdivisionCityFieldInternal extends BaseInputClass {
|
|
|
24230
24234
|
#countriesMap = new Map();
|
|
24231
24235
|
#cachedCountries = null;
|
|
24232
24236
|
#cachedSubdivisions = null;
|
|
24237
|
+
#cachedCities = null;
|
|
24233
24238
|
#labels = null;
|
|
24234
24239
|
|
|
24235
24240
|
// Value requested programmatically before data has loaded.
|
|
@@ -24276,8 +24281,8 @@ class RawCountrySubdivisionCityFieldInternal extends BaseInputClass {
|
|
|
24276
24281
|
const lang = this.getAttribute('lang') || undefined;
|
|
24277
24282
|
if (!lang) return undefined;
|
|
24278
24283
|
try {
|
|
24279
|
-
Intl.getCanonicalLocales(lang);
|
|
24280
|
-
return
|
|
24284
|
+
const [canonical] = Intl.getCanonicalLocales(lang);
|
|
24285
|
+
return canonical;
|
|
24281
24286
|
} catch {
|
|
24282
24287
|
return undefined; // invalid BCP47 tag — fall back to English
|
|
24283
24288
|
}
|
|
@@ -24460,8 +24465,11 @@ class RawCountrySubdivisionCityFieldInternal extends BaseInputClass {
|
|
|
24460
24465
|
|
|
24461
24466
|
#setupValueTransform() {
|
|
24462
24467
|
// Display only the item name in the input, while data-name includes ISO codes for search
|
|
24463
|
-
[
|
|
24464
|
-
|
|
24468
|
+
[
|
|
24469
|
+
this.#countryComboBox,
|
|
24470
|
+
this.#subdivisionComboBox,
|
|
24471
|
+
this.#cityComboBox,
|
|
24472
|
+
].forEach((combo) => {
|
|
24465
24473
|
combo.customValueTransformFn = (val) => {
|
|
24466
24474
|
const item = combo.baseElement?.items?.find(
|
|
24467
24475
|
(i) => i['data-name'] === val,
|
|
@@ -24606,7 +24614,11 @@ class RawCountrySubdivisionCityFieldInternal extends BaseInputClass {
|
|
|
24606
24614
|
if (cities) {
|
|
24607
24615
|
this.#cityVisible = cities.length > 0;
|
|
24608
24616
|
if (cities.length > 0) {
|
|
24609
|
-
this.#
|
|
24617
|
+
this.#cachedCities = cities;
|
|
24618
|
+
this.#cityComboBox.data = cities.map((c) => ({
|
|
24619
|
+
...c,
|
|
24620
|
+
lang: this.#lang,
|
|
24621
|
+
}));
|
|
24610
24622
|
if (pendingCity) toSelect.push([this.#cityComboBox, pendingCity]);
|
|
24611
24623
|
}
|
|
24612
24624
|
}
|
|
@@ -24717,7 +24729,6 @@ class RawCountrySubdivisionCityFieldInternal extends BaseInputClass {
|
|
|
24717
24729
|
if (!this.#pendingValue && this.#defaultCountry)
|
|
24718
24730
|
this.#onCountrySelected(this.#defaultCountry);
|
|
24719
24731
|
} catch (e) {
|
|
24720
|
-
|
|
24721
24732
|
console.error(`[${componentName$3}] Failed to load countries`, e);
|
|
24722
24733
|
} finally {
|
|
24723
24734
|
this.#countryComboBox.removeAttribute('loading');
|
|
@@ -24742,7 +24753,6 @@ class RawCountrySubdivisionCityFieldInternal extends BaseInputClass {
|
|
|
24742
24753
|
this.#loadCities(countryIso2);
|
|
24743
24754
|
}
|
|
24744
24755
|
} catch (e) {
|
|
24745
|
-
|
|
24746
24756
|
console.error(
|
|
24747
24757
|
`[${componentName$3}] Failed to load subdivisions for ${countryIso2}`,
|
|
24748
24758
|
e,
|
|
@@ -24764,10 +24774,13 @@ class RawCountrySubdivisionCityFieldInternal extends BaseInputClass {
|
|
|
24764
24774
|
this.#cityVisible = cities.length > 0;
|
|
24765
24775
|
this.#refreshState();
|
|
24766
24776
|
if (cities.length > 0) {
|
|
24767
|
-
this.#
|
|
24777
|
+
this.#cachedCities = cities;
|
|
24778
|
+
this.#cityComboBox.data = cities.map((c) => ({
|
|
24779
|
+
...c,
|
|
24780
|
+
lang: this.#lang,
|
|
24781
|
+
}));
|
|
24768
24782
|
}
|
|
24769
24783
|
} catch (e) {
|
|
24770
|
-
|
|
24771
24784
|
console.error(
|
|
24772
24785
|
`[${componentName$3}] Failed to load cities for ${countryIso2}${stateCode ? `/${stateCode}` : ''}`,
|
|
24773
24786
|
e,
|
|
@@ -24792,6 +24805,14 @@ class RawCountrySubdivisionCityFieldInternal extends BaseInputClass {
|
|
|
24792
24805
|
if (prevSubdivision)
|
|
24793
24806
|
this.#selectItemById(this.#subdivisionComboBox, prevSubdivision);
|
|
24794
24807
|
}
|
|
24808
|
+
if (this.#cachedCities && this.#cityVisible) {
|
|
24809
|
+
const prevCity = this.#cityComboBox.value;
|
|
24810
|
+
this.#cityComboBox.data = this.#cachedCities.map((c) => ({
|
|
24811
|
+
...c,
|
|
24812
|
+
lang: this.#lang,
|
|
24813
|
+
}));
|
|
24814
|
+
if (prevCity) this.#selectItemById(this.#cityComboBox, prevCity);
|
|
24815
|
+
}
|
|
24795
24816
|
// Re-apply translated subdivision type label for the new lang
|
|
24796
24817
|
const currentIso2 = this.#countryComboBox.value;
|
|
24797
24818
|
if (currentIso2) {
|
|
@@ -24905,6 +24926,7 @@ class RawCountrySubdivisionCityFieldInternal extends BaseInputClass {
|
|
|
24905
24926
|
#resetCity() {
|
|
24906
24927
|
this.#cityComboBox.value = '';
|
|
24907
24928
|
this.#cityComboBox.data = [];
|
|
24929
|
+
this.#cachedCities = null;
|
|
24908
24930
|
this.#cityVisible = false;
|
|
24909
24931
|
this.#refreshState();
|
|
24910
24932
|
}
|