intl-tel-input 19.2.6 → 19.2.8

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.
@@ -10,6 +10,10 @@ const IntlTelInput = ({
10
10
  onChangeValidity,
11
11
  onChangeErrorCode,
12
12
  initOptions,
13
+ className,
14
+ disabled,
15
+ onFocus,
16
+ onBlur,
13
17
  }) => {
14
18
  const inputRef = useRef(null);
15
19
  const itiRef = useRef(null);
@@ -44,54 +48,66 @@ const IntlTelInput = ({
44
48
 
45
49
  return (
46
50
  <input
47
- type="phone"
51
+ type="tel"
48
52
  ref={inputRef}
49
53
  onInput={update}
50
54
  defaultValue={initialValue}
51
- />
55
+ className={className}
56
+ disabled={disabled}
57
+ onFocus={onFocus}
58
+ onBlur={onBlur}
59
+ />
52
60
  );
53
61
  };
54
62
 
55
63
  IntlTelInput.propTypes = {
56
- initialValue: PropTypes.string,
57
- onChangeNumber: PropTypes.func,
58
- onChangeCountry: PropTypes.func,
59
- onChangeValidity: PropTypes.func,
60
- onChangeErrorCode: PropTypes.func,
61
- initOptions: PropTypes.shape({
62
- allowDropdown: PropTypes.bool,
63
- autoInsertDialCode: PropTypes.bool,
64
- autoPlaceholder: PropTypes.string,
65
- containerClass: PropTypes.string,
66
- countrySearch: PropTypes.bool,
67
- customPlaceholder: PropTypes.func,
68
- dropdownContainer: PropTypes.node,
69
- excludeCountries: PropTypes.arrayOf(PropTypes.string),
70
- fixDropdownWidth: PropTypes.bool,
71
- formatAsYouType: PropTypes.bool,
72
- formatOnDisplay: PropTypes.bool,
73
- geoIpLookup: PropTypes.func,
74
- hiddenInput: PropTypes.func,
75
- i18n: PropTypes.objectOf(PropTypes.string),
76
- initialCountry: PropTypes.string,
77
- nationalMode: PropTypes.bool,
78
- onlyCountries: PropTypes.arrayOf(PropTypes.string),
79
- placeholderNumberType: PropTypes.string,
80
- preferredCountries: PropTypes.arrayOf(PropTypes.string),
81
- showFlags: PropTypes.bool,
82
- showSelectedDialCode: PropTypes.bool,
83
- useFullscreenPopup: PropTypes.bool,
84
- utilsScript: PropTypes.string,
85
- }),
64
+ initialValue: PropTypes.string,
65
+ onChangeNumber: PropTypes.func,
66
+ onChangeCountry: PropTypes.func,
67
+ onChangeValidity: PropTypes.func,
68
+ onChangeErrorCode: PropTypes.func,
69
+ initOptions: PropTypes.shape({
70
+ allowDropdown: PropTypes.bool,
71
+ autoInsertDialCode: PropTypes.bool,
72
+ autoPlaceholder: PropTypes.string,
73
+ containerClass: PropTypes.string,
74
+ countrySearch: PropTypes.bool,
75
+ customPlaceholder: PropTypes.func,
76
+ dropdownContainer: PropTypes.node,
77
+ excludeCountries: PropTypes.arrayOf(PropTypes.string),
78
+ fixDropdownWidth: PropTypes.bool,
79
+ formatAsYouType: PropTypes.bool,
80
+ formatOnDisplay: PropTypes.bool,
81
+ geoIpLookup: PropTypes.func,
82
+ hiddenInput: PropTypes.func,
83
+ i18n: PropTypes.objectOf(PropTypes.string),
84
+ initialCountry: PropTypes.string,
85
+ nationalMode: PropTypes.bool,
86
+ onlyCountries: PropTypes.arrayOf(PropTypes.string),
87
+ placeholderNumberType: PropTypes.string,
88
+ preferredCountries: PropTypes.arrayOf(PropTypes.string),
89
+ showFlags: PropTypes.bool,
90
+ showSelectedDialCode: PropTypes.bool,
91
+ useFullscreenPopup: PropTypes.bool,
92
+ utilsScript: PropTypes.string,
93
+ }),
94
+ className: PropTypes.string,
95
+ disabled: PropTypes.bool,
96
+ onFocus: PropTypes.func,
97
+ onBlur: PropTypes.func,
86
98
  };
87
99
 
88
100
  IntlTelInput.defaultProps = {
89
- initialValue: "",
90
- onChangeNumber: () => {},
91
- onChangeCountry: () => {},
92
- onChangeValidity: () => {},
93
- onChangeErrorCode: () => {},
94
- initOptions: {},
101
+ initialValue: "",
102
+ onChangeNumber: () => {},
103
+ onChangeCountry: () => {},
104
+ onChangeValidity: () => {},
105
+ onChangeErrorCode: () => {},
106
+ initOptions: {},
107
+ className: "",
108
+ disabled: false,
109
+ onFocus: () => {},
110
+ onBlur: () => {},
95
111
  };
96
112
 
97
113
  export default IntlTelInput;
@@ -886,7 +886,10 @@ class Iti {
886
886
 
887
887
  if (this.options.countrySearch) {
888
888
  // start by highlighting the first item in the list
889
- this._highlightListItem(this.countryList.firstElementChild, false);
889
+ const { firstElementChild } = this.countryList;
890
+ if (firstElementChild) {
891
+ this._highlightListItem(firstElementChild, false);
892
+ }
890
893
  this.searchInput.focus();
891
894
  } else if (this.activeItem) {
892
895
  // update highlighting and scroll to active list item
@@ -1500,7 +1503,7 @@ class Iti {
1500
1503
 
1501
1504
  // check if an element is visible within it's container, else scroll until it is
1502
1505
  _scrollTo(element, middle) {
1503
- const container = this.dropdownContent;
1506
+ const container = this.countryList;
1504
1507
  // windowTop from https://stackoverflow.com/a/14384091/217866
1505
1508
  const windowTop = document.documentElement.scrollTop;
1506
1509
  const containerHeight = container.offsetHeight;