intl-tel-input 25.10.12 → 25.11.0

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.
@@ -123,6 +123,8 @@ declare module "modules/types/public-api" {
123
123
  version: string | undefined;
124
124
  utils?: ItiUtils;
125
125
  }
126
+ type EmptyObject = Record<string, never>;
127
+ export type SelectedCountryData = Country | EmptyObject;
126
128
  }
127
129
  declare module "modules/core/options" {
128
130
  import type { AllOptions } from "modules/types/public-api";
@@ -134,8 +136,59 @@ declare module "modules/utils/string" {
134
136
  export const normaliseString: (s?: string) => string;
135
137
  }
136
138
  declare module "modules/utils/dom" {
139
+ /**
140
+ * Build a space-delimited class string from an object map of className -> truthy/falsey.
141
+ * Only keys with truthy values are included.
142
+ */
143
+ export const buildClassNames: (flags: Record<string, unknown>) => string;
137
144
  export const createEl: (tagName: string, attrs?: object | null, container?: HTMLElement) => HTMLElement;
138
145
  }
146
+ declare module "modules/core/ui" {
147
+ import { Country } from "intl-tel-input/data";
148
+ import { AllOptions } from "modules/types/public-api";
149
+ export default class UI {
150
+ private readonly options;
151
+ private readonly id;
152
+ private readonly isRTL;
153
+ private readonly originalPaddingLeft;
154
+ private countries;
155
+ telInput: HTMLInputElement;
156
+ countryContainer: HTMLElement;
157
+ selectedCountry: HTMLElement;
158
+ selectedCountryInner: HTMLElement;
159
+ selectedDialCode: HTMLElement;
160
+ dropdownArrow: HTMLElement;
161
+ dropdownContent: HTMLElement;
162
+ searchInput: HTMLInputElement;
163
+ searchIcon: HTMLElement;
164
+ searchClearButton: HTMLButtonElement;
165
+ searchNoResults: HTMLElement;
166
+ searchResultsA11yText: HTMLElement;
167
+ countryList: HTMLElement;
168
+ dropdown: HTMLElement;
169
+ hiddenInput: HTMLInputElement;
170
+ hiddenInputCountry: HTMLInputElement;
171
+ highlightedItem: HTMLElement | null;
172
+ readonly hadInitialPlaceholder: boolean;
173
+ constructor(input: HTMLInputElement, options: AllOptions, id: number);
174
+ generateMarkup(countries: Country[]): void;
175
+ private _prepareTelInput;
176
+ private _createWrapperAndInsert;
177
+ private _maybeBuildCountryContainer;
178
+ private _buildDropdownContent;
179
+ private _buildSearchUI;
180
+ private _maybeUpdateInputPaddingAndReveal;
181
+ private _maybeBuildHiddenInputs;
182
+ private _appendListItems;
183
+ updateInputPadding(): void;
184
+ private _getHiddenSelectedCountryWidth;
185
+ updateSearchResultsA11yText(): void;
186
+ scrollTo(element: HTMLElement): void;
187
+ highlightListItem(listItem: HTMLElement | null, shouldFocus: boolean): void;
188
+ filterCountries(matchedCountries: Country[]): void;
189
+ destroy(): void;
190
+ }
191
+ }
139
192
  declare module "modules/data/country-data" {
140
193
  import { Country, Iso2 } from "intl-tel-input/data";
141
194
  import type { AllOptions } from "modules/types/public-api";
@@ -151,9 +204,9 @@ declare module "modules/data/country-data" {
151
204
  export function cacheSearchTokens(countries: Country[]): void;
152
205
  }
153
206
  declare module "modules/format/formatting" {
154
- import { Country } from "intl-tel-input/data";
155
- export function beforeSetNumber(fullNumber: string, dialCode: string, separateDialCode: boolean, selectedCountryData: Partial<Country>): string;
156
- export function formatNumberAsYouType(fullNumber: string, telInputValue: string, utils: any, selectedCountryData: Partial<Country>, separateDialCode: boolean): string;
207
+ import { SelectedCountryData } from "modules/types/public-api";
208
+ export function beforeSetNumber(fullNumber: string, dialCode: string, separateDialCode: boolean, selectedCountryData: SelectedCountryData): string;
209
+ export function formatNumberAsYouType(fullNumber: string, telInputValue: string, utils: any, selectedCountryData: SelectedCountryData, separateDialCode: boolean): string;
157
210
  }
158
211
  declare module "modules/format/caret" {
159
212
  export function translateCursorPosition(relevantChars: number, formattedValue: string, prevCaretPos: number, isDeleteForwards: boolean): number;
@@ -162,86 +215,49 @@ declare module "modules/data/nanp-regionless" {
162
215
  export const regionlessNanpNumbers: string[];
163
216
  export const isRegionlessNanp: (number: string) => boolean;
164
217
  }
218
+ declare module "modules/types/events" {
219
+ export type ItiEventMap = {
220
+ "countrychange": Record<string, never>;
221
+ "open:countrydropdown": Record<string, never>;
222
+ "close:countrydropdown": Record<string, never>;
223
+ "input": {
224
+ isSetNumber?: boolean;
225
+ };
226
+ };
227
+ }
165
228
  declare module "intl-tel-input" {
166
- import { Country, Iso2 } from "intl-tel-input/data";
167
- import type { NumberType, SomeOptions, IntlTelInputInterface } from "modules/types/public-api";
229
+ import { Iso2 } from "intl-tel-input/data";
230
+ import type { NumberType, SomeOptions, IntlTelInputInterface, SelectedCountryData } from "modules/types/public-api";
168
231
  global {
169
232
  interface HTMLInputElement {
170
233
  iti?: Iti;
171
234
  }
172
235
  }
173
236
  export class Iti {
174
- id: number;
175
- promise: Promise<[unknown, unknown]>;
176
- private telInput;
177
- private highlightedItem;
178
- private options;
179
- private hadInitialPlaceholder;
180
- private isRTL;
181
- private isAndroid;
237
+ readonly id: number;
238
+ readonly promise: Promise<[unknown, unknown]>;
239
+ private readonly ui;
240
+ private readonly options;
241
+ private readonly isAndroid;
242
+ private readonly countries;
243
+ private readonly dialCodeMaxLen;
244
+ private readonly dialCodeToIso2Map;
245
+ private readonly dialCodes;
246
+ private readonly countryByIso2;
182
247
  private selectedCountryData;
183
- private countries;
184
- private dialCodeMaxLen;
185
- private dialCodeToIso2Map;
186
- private dialCodes;
187
- private countryByIso2;
188
- private countryContainer;
189
- private selectedCountry;
190
- private selectedCountryInner;
191
- private selectedDialCode;
192
- private dropdownArrow;
193
- private dropdownContent;
194
- private searchInput;
195
- private searchIcon;
196
- private searchClearButton;
197
- private searchNoResults;
198
- private searchResultsA11yText;
199
- private countryList;
200
- private dropdown;
201
- private hiddenInput;
202
- private hiddenInputCountry;
203
248
  private maxCoreNumberLength;
204
249
  private defaultCountry;
205
- private originalPaddingLeft;
206
- private _handleHiddenInputSubmit;
207
- private _handleLabelClick;
208
- private _handleClickSelectedCountry;
209
- private _handleCountryContainerKeydown;
210
- private _handleInputEvent;
211
- private _handleKeydownEvent;
212
- private _handlePasteEvent;
213
- private _handleWindowScroll;
214
- private _handleMouseoverCountryList;
215
- private _handleClickCountryList;
216
- private _handleClickOffToClose;
217
- private _handleKeydownOnDropdown;
218
- private _handleSearchChange;
219
- private _handleSearchClear;
220
- private _handlePageLoad;
221
- private _doAttachUtils;
250
+ private abortController;
251
+ private dropdownAbortController;
222
252
  private resolveAutoCountryPromise;
223
253
  private rejectAutoCountryPromise;
224
254
  private resolveUtilsScriptPromise;
225
255
  private rejectUtilsScriptPromise;
226
- /**
227
- * Build a space-delimited class string from an object map of className -> truthy/falsey.
228
- * Only keys with truthy values are included.
229
- */
230
- private static _buildClassNames;
231
256
  constructor(input: HTMLInputElement, customOptions?: SomeOptions);
232
- private _detectEnvironmentAndLayout;
257
+ private static _getIsAndroid;
233
258
  private _createInitPromises;
234
259
  _init(): void;
235
260
  private _processCountryData;
236
- private _generateMarkup;
237
- private _prepareTelInput;
238
- private _createWrapperAndInsert;
239
- private _maybeBuildCountryContainer;
240
- private _buildDropdownContent;
241
- private _buildSearchUI;
242
- private _maybeUpdateInputPaddingAndReveal;
243
- private _maybeBuildHiddenInputs;
244
- private _appendListItems;
245
261
  private _setInitialState;
246
262
  private _initListeners;
247
263
  private _initHiddenInputListener;
@@ -259,24 +275,19 @@ declare module "intl-tel-input" {
259
275
  private _setDropdownPosition;
260
276
  private _bindDropdownListeners;
261
277
  private _searchForCountry;
262
- private _filterCountries;
278
+ private _filterCountriesByQuery;
263
279
  private _getMatchedCountries;
264
- private _updateSearchResultsA11yText;
265
280
  private _handleUpDownKey;
266
281
  private _handleEnterKey;
267
282
  private _updateValFromNumber;
268
283
  private _updateCountryFromNumber;
269
284
  private _ensureHasDialCode;
270
285
  private _getNewCountryFromNumber;
271
- private _highlightListItem;
272
286
  private _setCountry;
273
- private _updateInputPadding;
274
287
  private _updateMaxLength;
275
- private _getHiddenSelectedCountryWidth;
276
288
  private _updatePlaceholder;
277
289
  private _selectListItem;
278
290
  private _closeDropdown;
279
- private _scrollTo;
280
291
  private _updateDialCode;
281
292
  private _getDialCode;
282
293
  private _getFullNumber;
@@ -288,7 +299,7 @@ declare module "intl-tel-input" {
288
299
  getExtension(): string;
289
300
  getNumber(format?: number): string;
290
301
  getNumberType(): number;
291
- getSelectedCountryData(): Partial<Country>;
302
+ getSelectedCountryData(): SelectedCountryData;
292
303
  getValidationError(): number;
293
304
  isValidNumber(): boolean | null;
294
305
  isValidNumberPrecise(): boolean | null;