intl-tel-input 29.1.1 → 29.1.3

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.
@@ -13,8 +13,8 @@ var rawCountryData = [
13
13
  // Åland Islands (AKA Aland Islands)
14
14
  "358",
15
15
  1,
16
- ["18", "4"],
17
- // (4 is a mobile range shared with FI)
16
+ ["18", "4", "50"],
17
+ // (4 and 50 are mobile ranges shared with FI)
18
18
  // NOTE: https://en.wikipedia.org/wiki/Telephone%20numbers%20in%20%C3%85land says some 4XXX ranges (e.g. 4570) are specific to AX, but LPN doesn't respect this (https://libphonenumber.appspot.com/phonenumberparser?number=%2B3584570123456 says region=FI) so we won't either. Also it's too much of a maintenance burden to keep track of. Keep the 4 area code range here so that if the user selects AX and types this kind of number, we wont change the flag to FI. Whereas if they type a FI-only range then we will.
19
19
  "0"
20
20
  ],
@@ -561,8 +561,8 @@ var rawCountryData = [
561
561
  // Finland
562
562
  "358",
563
563
  0,
564
- ["4"],
565
- // (mobile range shared with AX)
564
+ ["4", "50"],
565
+ // (mobile ranges shared with AX)
566
566
  "0"
567
567
  ],
568
568
  [
@@ -669,7 +669,8 @@ var rawCountryData = [
669
669
  // Guernsey
670
670
  "44",
671
671
  1,
672
- ["1481", "7781", "7839", "7911"],
672
+ //* Only 79111 and 79117 belong to GG - the rest of 7911 is GB (e.g. 79110).
673
+ ["1481", "7781", "7839", "79111", "79117"],
673
674
  "0"
674
675
  ],
675
676
  [
@@ -800,7 +801,8 @@ var rawCountryData = [
800
801
  // Jersey
801
802
  "44",
802
803
  3,
803
- ["1534", "7509", "7700", "7797", "7829", "7937"],
804
+ //* Only 77003/77007/77008 belong to JE - the rest of 7700 is GB (e.g. 77001).
805
+ ["1534", "7509", "77003", "77007", "77008", "7797", "7829", "7937"],
804
806
  "0"
805
807
  ],
806
808
  [
@@ -995,7 +997,7 @@ var rawCountryData = [
995
997
  // Mayotte
996
998
  "262",
997
999
  1,
998
- ["269", "639"],
1000
+ ["2689", "269", "639", "7093"],
999
1001
  "0"
1000
1002
  ],
1001
1003
  [
@@ -2455,7 +2457,7 @@ var Numerals = class _Numerals {
2455
2457
 
2456
2458
  // packages/core/src/js/core/ui.ts
2457
2459
  var supportsCssAnchor = typeof CSS !== "undefined" && typeof CSS.supports === "function" && CSS.supports("anchor-name: --x");
2458
- var UI = class _UI {
2460
+ var UI = class {
2459
2461
  // private
2460
2462
  #options;
2461
2463
  #id;
@@ -2465,6 +2467,7 @@ var UI = class _UI {
2465
2467
  #searchTokens;
2466
2468
  #searchDebounceTimer = null;
2467
2469
  #inlineDropdownHeight;
2470
+ #cssAnchorPositioningDone = false;
2468
2471
  #countryContainerEl;
2469
2472
  #selectedCountryEl;
2470
2473
  #selectedFlagEl;
@@ -2657,16 +2660,6 @@ var UI = class _UI {
2657
2660
  if (countrySearch) {
2658
2661
  this.#updateSearchResultsA11yText();
2659
2662
  }
2660
- if (!isFullscreen) {
2661
- const { height, width } = this.#getHiddenInlineDropdownSize();
2662
- this.#inlineDropdownHeight = height;
2663
- if (countrySearch) {
2664
- this.#countrySelectorEl.style.height = `${height}px`;
2665
- if (!matchDropdownWidth && width > 0) {
2666
- this.#countrySelectorEl.style.width = `${width}px`;
2667
- }
2668
- }
2669
- }
2670
2663
  if (detachedParent) {
2671
2664
  const wrapperClasses = buildClassNames({
2672
2665
  iti: true,
@@ -2677,9 +2670,6 @@ var UI = class _UI {
2677
2670
  });
2678
2671
  this.#detachedCountrySelectorEl = createEl("div", { class: wrapperClasses });
2679
2672
  this.#detachedCountrySelectorEl.appendChild(this.#countrySelectorEl);
2680
- if (!isFullscreen) {
2681
- this.#setupCssAnchorPositioning();
2682
- }
2683
2673
  } else {
2684
2674
  this.#countryContainerEl.appendChild(this.#countrySelectorEl);
2685
2675
  }
@@ -2852,24 +2842,16 @@ var UI = class _UI {
2852
2842
  });
2853
2843
  this.#resizeObserver.observe(this.#selectedCountryEl);
2854
2844
  }
2855
- static #getBody() {
2856
- let body;
2857
- try {
2858
- body = window.top.document.body;
2859
- } catch (e) {
2860
- body = document.body;
2861
- }
2862
- return body;
2863
- }
2864
2845
  //* When input is in a hidden container during init, we cannot calculate the selected country width.
2865
2846
  //* Fix: clone the markup, make it invisible, add it to the end of the DOM, and then measure it's width.
2866
2847
  //* To get the right styling to apply, all we need is a shallow clone of the container,
2867
2848
  //* and then to inject a deep clone of the selectedCountryEl element.
2849
+ //* Measures in the LOCAL document.body: appending to the local body escapes any hidden ancestor container, and the input's own frame is where intl-tel-input's styles live (so the clone lays out correctly). We deliberately do NOT escape to window.top: that only measures correctly in the rare case where the top frame also loads the library's styles, and measures wrong when it doesn't (e.g. a same-origin iframe whose outer frame lacks the styles — cf. #2178). If the local frame itself isn't laid out yet (e.g. an iframe hidden during init), this returns 0 and the caller falls back to a sane constant; the ResizeObserver in #observeSelectedCountryResize then corrects the padding once the input becomes visible.
2868
2850
  #getHiddenSelectedCountryWidth() {
2869
2851
  if (!this.telInputEl.parentNode) {
2870
2852
  return 0;
2871
2853
  }
2872
- const body = _UI.#getBody();
2854
+ const body = document.body;
2873
2855
  const containerClone = this.telInputEl.parentNode.cloneNode(
2874
2856
  false
2875
2857
  );
@@ -2885,21 +2867,43 @@ var UI = class _UI {
2885
2867
  body.removeChild(containerClone);
2886
2868
  return width;
2887
2869
  }
2888
- // Get the dropdown size (before it is added to the DOM)
2870
+ //* Measure the inline dropdown size once, lazily, on first open — see #getHiddenInlineDropdownSize for why measuring forces a reflow. Memoised via #inlineDropdownHeight so subsequent opens are free.
2871
+ //* Captured for two uses: (1) on open, decide whether to position the dropdown above or below the input; (2) when countrySearch is enabled, pin the dropdown height (and, when matchDropdownWidth is disabled, width) so it doesn't jump around as the country list is filtered.
2872
+ #ensureInlineDropdownSizeMeasured() {
2873
+ if (this.#inlineDropdownHeight !== void 0) {
2874
+ return;
2875
+ }
2876
+ const { countrySearch, matchDropdownWidth } = this.#options;
2877
+ const { height, width } = this.#getHiddenInlineDropdownSize();
2878
+ this.#inlineDropdownHeight = height;
2879
+ if (countrySearch) {
2880
+ this.#countrySelectorEl.style.height = `${height}px`;
2881
+ if (!matchDropdownWidth && width > 0) {
2882
+ this.#countrySelectorEl.style.width = `${width}px`;
2883
+ }
2884
+ }
2885
+ }
2886
+ // Measure the dropdown by moving it into a temporary hidden container on the body (it needs the right ancestor classes to lay out correctly). Restores it to its original position afterwards — a no-op during init (when it is still detached) but required when called lazily on first open (when it is already inserted).
2887
+ //* Deliberately measures in the LOCAL document.body (not window.top): this runs on first open, when the input's own frame is visibly rendered and styled. Escaping to the top frame breaks when the input is inside a same-origin iframe whose outer frame lacks intl-tel-input's styles (e.g. Storybook), as the dropdown would then be measured unstyled and come out far too tall (issue #2178).
2889
2888
  #getHiddenInlineDropdownSize() {
2890
- const body = _UI.#getBody();
2891
- this.#countrySelectorEl.classList.remove(CLASSES.HIDE);
2889
+ const body = document.body;
2890
+ const selectorEl = this.#countrySelectorEl;
2891
+ const originalParent = selectorEl.parentNode;
2892
+ const originalNextSibling = selectorEl.nextSibling;
2893
+ selectorEl.classList.remove(CLASSES.HIDE);
2892
2894
  const tempContainer = createEl("div", {
2893
2895
  class: "iti iti--inline-country-selector"
2894
2896
  });
2895
- tempContainer.appendChild(this.#countrySelectorEl);
2897
+ tempContainer.appendChild(selectorEl);
2896
2898
  tempContainer.style.visibility = "hidden";
2897
2899
  body.appendChild(tempContainer);
2898
- const height = this.#countrySelectorEl.offsetHeight;
2899
- const width = this.#countrySelectorEl.offsetWidth;
2900
+ const height = selectorEl.offsetHeight;
2901
+ const width = selectorEl.offsetWidth;
2900
2902
  body.removeChild(tempContainer);
2901
- tempContainer.style.visibility = "";
2902
- this.#countrySelectorEl.classList.add(CLASSES.HIDE);
2903
+ selectorEl.classList.add(CLASSES.HIDE);
2904
+ if (originalParent) {
2905
+ originalParent.insertBefore(selectorEl, originalNextSibling);
2906
+ }
2903
2907
  return {
2904
2908
  height: height > 0 ? height : LAYOUT.FALLBACK_DROPDOWN_HEIGHT,
2905
2909
  width
@@ -3063,6 +3067,9 @@ var UI = class _UI {
3063
3067
  openCountrySelector(onSelect, onClose) {
3064
3068
  const { countrySearch, dropdownAlwaysOpen } = this.#options;
3065
3069
  this.#countrySelectorAbortController = new AbortController();
3070
+ if (this.#options.countrySelectorMode !== COUNTRY_SELECTOR_MODE.FULLSCREEN) {
3071
+ this.#ensureInlineDropdownSizeMeasured();
3072
+ }
3066
3073
  this.ensureDropdownWidthSet();
3067
3074
  if (this.#detachedCountrySelectorEl) {
3068
3075
  this.#injectAndPositionDetachedCountrySelector();
@@ -3335,7 +3342,10 @@ var UI = class _UI {
3335
3342
  this.#detachedCountrySelectorEl.style.paddingLeft = `${inputPos.left}px`;
3336
3343
  this.#detachedCountrySelectorEl.style.paddingRight = `${window.innerWidth - inputPos.right}px`;
3337
3344
  }
3338
- } else if (!supportsCssAnchor) {
3345
+ } else {
3346
+ this.#setupCssAnchorPositioning();
3347
+ }
3348
+ if (!isFullscreen && !supportsCssAnchor) {
3339
3349
  const inputPos = this.telInputEl.getBoundingClientRect();
3340
3350
  this.#detachedCountrySelectorEl.style.left = `${inputPos.left}px`;
3341
3351
  if (this.#shouldPositionDropdownBelowInput()) {
@@ -3348,13 +3358,17 @@ var UI = class _UI {
3348
3358
  detachedParent.appendChild(this.#detachedCountrySelectorEl);
3349
3359
  }
3350
3360
  //* Wire up CSS Anchor Positioning between the input and the detached country selector using a
3351
- //* unique anchor name per instance. Called once at build time — the matching styles in
3361
+ //* unique anchor name per instance. Called lazily on first open (memoised) — the matching styles in
3352
3362
  //* intlTelInput.css only take effect in browsers that support anchor(); elsewhere these
3353
3363
  //* properties are inert. We append our name to any existing anchor-name (read via
3354
3364
  //* getComputedStyle so we pick up CSS-defined values), so consumer-set anchors on the input
3355
3365
  //* are preserved. Caveat: this snapshots the consumer's value once — if they later change
3356
3366
  //* anchor-name via CSS (e.g. a class swap), our inline write will shadow the change.
3357
3367
  #setupCssAnchorPositioning() {
3368
+ if (this.#cssAnchorPositioningDone) {
3369
+ return;
3370
+ }
3371
+ this.#cssAnchorPositioningDone = true;
3358
3372
  const anchorName = `--iti-anchor-${this.#id}`;
3359
3373
  const existing = getComputedStyle(this.telInputEl).anchorName;
3360
3374
  this.telInputEl.style.anchorName = existing && existing !== "none" ? `${existing}, ${anchorName}` : anchorName;
@@ -4829,7 +4843,7 @@ var intlTelInput = Object.assign(
4829
4843
  attachUtils,
4830
4844
  startedLoadingUtils: false,
4831
4845
  startedLoadingAutoCountry: false,
4832
- version: "29.1.1",
4846
+ version: "29.1.3",
4833
4847
  NUMBER_FORMAT,
4834
4848
  NUMBER_TYPE,
4835
4849
  VALIDATION_ERROR,