` HTML element of the `FlagDropDown` React component.
269 | */
270 | flagDropDown: HTMLDivElement | null
271 |
272 | /**
273 | * `
` HTML element of the `TelInput` React component.
274 | */
275 | tel: HTMLInputElement | null
276 |
277 | // NOTE:
278 | // The underscore.deferred package doesn't have known type definitions.
279 | // The closest counterpart is jquery's Deferred object, which it claims to derive itself from.
280 | // These two are equivalent if you log it in console:
281 | //
282 | // underscore.deferred
283 | // var deferred = new _.Deferred()
284 | //
285 | // jquery
286 | // var deferred = $.Deferred()
287 | deferreds: JQuery.Deferred
[]
288 |
289 | autoCountryDeferred: JQuery.Deferred
290 |
291 | utilsScriptDeferred: JQuery.Deferred
292 | //#endregion
293 |
294 | //#region Methods
295 | /**
296 | * Updates flag when value of defaultCountry props change
297 | */
298 | updateFlagOnDefaultCountryChange(countryCode?: string): void
299 |
300 | getTempCountry(countryCode?: string): CountryData['iso2'] | 'auto'
301 |
302 | /**
303 | * set the input value and update the flag
304 | */
305 | setNumber(number: string, preventFocus?: boolean): void
306 |
307 | setFlagDropdownRef(ref: HTMLDivElement | null): void
308 |
309 | setTelRef(ref: HTMLInputElement | null): void
310 |
311 | /**
312 | * select the given flag, update the placeholder and the active list item
313 | *
314 | * Note: called from setInitialState, updateFlagFromNumber, selectListItem, setCountry, updateFlagOnDefaultCountryChange
315 | */
316 | setFlag(countryCode?: string, isInit?: boolean): void
317 |
318 | /**
319 | * get the extension from the current number
320 | */
321 | getExtension(number?: string): string
322 |
323 | /**
324 | * format the number to the given format
325 | */
326 | getNumber(number?: string, format?: string): string
327 |
328 | /**
329 | * get the input val, adding the dial code if separateDialCode is enabled
330 | */
331 | getFullNumber(number?: string): string
332 |
333 | /**
334 | * try and extract a valid international dial code from a full telephone number
335 | */
336 | getDialCode(number: string): string
337 |
338 | /**
339 | * check if the given number contains an unknown area code from
340 | */
341 | isUnknownNanp(number?: string, dialCode?: string): boolean
342 |
343 | /**
344 | * add a country code to countryCodes
345 | */
346 | addCountryCode(
347 | countryCodes: {
348 | [key: string]: string[]
349 | },
350 | iso2: string,
351 | dialCode: string,
352 | priority?: number,
353 | ): {
354 | [key: string]: string[]
355 | }
356 |
357 | processAllCountries(): void
358 |
359 | /**
360 | * process the countryCodes map
361 | */
362 | processCountryCodes(): void
363 |
364 | /**
365 | * process preferred countries - iterate through the preferences,
366 | * fetching the country data for each one
367 | */
368 | processPreferredCountries(): void
369 |
370 | /**
371 | * set the initial state of the input value and the selected flag
372 | */
373 | setInitialState(): void
374 |
375 | initRequests(): void
376 |
377 | loadCountryFromLocalStorage(): string
378 |
379 | loadAutoCountry(): void
380 |
381 | cap(number?: string): string | undefined
382 |
383 | removeEmptyDialCode(): void
384 |
385 | /**
386 | * highlight the next/prev item in the list (and ensure it is visible)
387 | */
388 | handleUpDownKey(key?: number): void
389 |
390 | /**
391 | * select the currently highlighted item
392 | */
393 | handleEnterKey(): void
394 |
395 | /**
396 | * find the first list item whose name starts with the query string
397 | */
398 | searchForCountry(query: string): void
399 |
400 | formatNumber(number?: string): string
401 |
402 | /**
403 | * update the input's value to the given val (format first if possible)
404 | */
405 | updateValFromNumber(
406 | number?: string,
407 | doFormat?: boolean,
408 | doNotify?: boolean,
409 | ): void
410 |
411 | /**
412 | * check if need to select a new flag based on the given number
413 | */
414 | updateFlagFromNumber(number?: string, isInit?: boolean): void
415 |
416 | /**
417 | * filter the given countries using the process function
418 | */
419 | filterCountries(
420 | countryArray: string[],
421 | processFunc: (iso2: string) => void,
422 | ): void
423 |
424 | /**
425 | * prepare all of the country data, including onlyCountries and preferredCountries options
426 | */
427 | processCountryData(): void
428 |
429 | handleOnBlur(event: React.FocusEvent): void
430 |
431 | handleOnFocus(event: React.FocusEvent): void
432 |
433 | bindDocumentClick(): void
434 |
435 | unbindDocumentClick(): void
436 |
437 | clickSelectedFlag(event: React.MouseEvent): void
438 |
439 | /**
440 | * update the input placeholder to an
441 | * example number from the currently selected country
442 | */
443 | updatePlaceholder(props?: IntlTelInputProps): void
444 |
445 | toggleDropdown(status?: boolean): void
446 |
447 | /**
448 | * check if an element is visible within it's container, else scroll until it is
449 | */
450 | scrollTo(element: Element, middle?: boolean): void
451 |
452 | /**
453 | * replace any existing dial code with the new one
454 | *
455 | * Note: called from _setFlag
456 | */
457 | updateDialCode(newDialCode?: string, hasSelectedListItem?: boolean): string
458 |
459 | generateMarkup(): void
460 |
461 | handleSelectedFlagKeydown(event: React.KeyboardEvent): void
462 |
463 | /**
464 | * validate the input val - assumes the global function isValidNumber (from libphonenumber)
465 | */
466 | isValidNumber(number?: string): boolean
467 |
468 | formatFullNumber(number?: string): string
469 |
470 | notifyPhoneNumberChange(number?: string): void
471 |
472 | /**
473 | * remove the dial code if separateDialCode is enabled
474 | */
475 | beforeSetNumber(
476 | number?: string,
477 | props?: IntlTelInputProps,
478 | ): string | undefined
479 |
480 | handleWindowScroll(): void
481 |
482 | handleDocumentKeyDown(event: KeyboardEvent): void
483 |
484 | handleDocumentClick(event: MouseEvent): void
485 |
486 | /**
487 | * Either notify phoneNumber changed if component is controlled
488 | */
489 | handleInputChange(event: React.FocusEvent): void
490 |
491 | changeHighlightCountry(showDropdown: boolean, selectedIndex: number): void
492 |
493 | loadUtils(): void
494 |
495 | /**
496 | * this is called when the geoip call returns
497 | */
498 | autoCountryLoaded(): void
499 | //#endregion
500 | }
501 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## [v7.1.0](https://github.com/patw0929/react-intl-tel-input/releases/tag/v7.1.0)
4 |
5 | ### New features
6 |
7 | - [#308](https://github.com/patw0929/react-intl-tel-input/pull/308): Add optional onPhoneNumberFocus function (by [@johannessjoberg](https://github.com/johannessjoberg))
8 |
9 | ## [v7.0.3](https://github.com/patw0929/react-intl-tel-input/releases/tag/v7.0.2)
10 |
11 | ### Bug fixes
12 |
13 | - [#285](https://github.com/patw0929/react-intl-tel-input/pull/285): Update flag when defaultCountry value is changed (by [@dhanesh-kapadiya](https://github.com/dhanesh-kapadiya))
14 |
15 | ## [v7.0.2](https://github.com/patw0929/react-intl-tel-input/releases/tag/v7.0.2)
16 |
17 | ### Bug fixes:
18 |
19 | - [#302](https://github.com/patw0929/react-intl-tel-input/pull/302): Remove package-lock.json (by [@patw0929](https://github.com/patw0929))
20 | - [#283](https://github.com/patw0929/react-intl-tel-input/pull/283): Fix: invoke onPhoneNumberChange callback with formatted value on init instead of unformatted value from previous state (by [@coox](https://github.com/coox))
21 | - [#300](https://github.com/patw0929/react-intl-tel-input/pull/300): fixed bug with pasting number over another number (by [@flagoon](https://github.com/flagoon))
22 | - [#299](https://github.com/patw0929/react-intl-tel-input/pull/299): Use cross-env to solve cross platforms issue (scripts with node env variables) (by [@patw0929](https://github.com/patw0929))
23 |
24 | ### Docs:
25 |
26 | - [#298](https://github.com/patw0929/react-intl-tel-input/pull/298): Update LICENSE (by [@Parikshit-Hooda](https://github.com/Parikshit-Hooda))
27 | - [#297](https://github.com/patw0929/react-intl-tel-input/pull/297): Update README.md Update LICENSE (by [@Parikshit-Hooda](https://github.com/Parikshit-Hooda))
28 | - [#294](https://github.com/patw0929/react-intl-tel-input/pull/294): Removed bash highlighting for npm/yarn commands in README (by [@bhumijgupta](https://github.com/bhumijgupta))
29 |
30 | ## [v7.0.1](https://github.com/patw0929/react-intl-tel-input/releases/tag/v7.0.1)
31 |
32 | ### Bug fixes
33 |
34 | - [#277](https://github.com/patw0929/react-intl-tel-input/pull/277): Fix([#272](https://github.com/patw0929/react-intl-tel-input/pull/272)): Updating Allowdropdown after mount (by [@nutboltu](https://github.com/nutboltu))
35 |
36 | ### Docs
37 |
38 | - [#273](https://github.com/patw0929/react-intl-tel-input/pull/273): Feature: Introducing storybook for documentation and playground (by [@nutboltu](https://github.com/nutboltu))
39 | - [#274](https://github.com/patw0929/react-intl-tel-input/pull/274): fix(storybook-deploy): Fixed the storybook deployment script in travis (by [@nutboltu](https://github.com/nutboltu))
40 | - [#275](https://github.com/patw0929/react-intl-tel-input/pull/275): Fix: storybook's public path (by [@patw0929](https://github.com/patw0929))
41 | - [#276](https://github.com/patw0929/react-intl-tel-input/pull/276): Refactor: Removing all unused files and codes for example (by [@nutboltu](https://github.com/nutboltu))
42 |
43 | ## [v7.0.0](https://github.com/patw0929/react-intl-tel-input/releases/tag/v7.0.0)
44 |
45 | ### Bug fixes
46 |
47 | - [#270](https://github.com/patw0929/react-intl-tel-input/pull/270): Fixed the issue of pasting number to text input cannot update flag in international mode (by [@patw0929](https://github.com/patw0929))
48 | - [#271](https://github.com/patw0929/react-intl-tel-input/pull/271): Fixed the CSS prop name issue of styled-component (by [@patw0929](https://github.com/patw0929))
49 |
50 | ## [v6.1.1](https://github.com/patw0929/react-intl-tel-input/releases/tag/v6.1.1)
51 |
52 | ### Bug fixes
53 |
54 | - [#269](https://github.com/patw0929/react-intl-tel-input/pull/269): Fixed issue [#268](https://github.com/patw0929/react-intl-tel-input/issues/268) - disabled state doesn't update an input field (by [@patw0929](https://github.com/patw0929))
55 | - [#265](https://github.com/patw0929/react-intl-tel-input/pull/265): update cursor position after focused (by [@Loongwoo](https://github.com/Loongwoo))
56 |
57 | ### Chores
58 |
59 | - [#267](https://github.com/patw0929/react-intl-tel-input/pull/267) - Use createPortal API to implement RootModal (by [@patw0929](https://github.com/patw0929))
60 | - Added `ISSUE_TEMPLATE.md` & `PULL_REQUEST_TEMPLATE.md`
61 |
62 | ## [v6.1.0](https://github.com/patw0929/react-intl-tel-input/releases/tag/v6.1.0)
63 |
64 | ### New features
65 |
66 | - [#249](https://github.com/patw0929/react-intl-tel-input/pull/249): Add support for onFlagClick (by [@tomegz](https://github.com/tomegz))
67 | - [#254](https://github.com/patw0929/react-intl-tel-input/pull/254): Updated libphonenumber to 8.10.2 (by [@superhit0](https://github.com/superhit0))
68 | - [#256](https://github.com/patw0929/react-intl-tel-input/pull/256): Added event object to onPhoneNumberBlur callback's parameter (by [@superhit0](https://github.com/superhit0))
69 |
70 | ### Bug fixes
71 |
72 | - [#254](https://github.com/patw0929/react-intl-tel-input/pull/254): Fixed issue [#253](https://github.com/patw0929/react-intl-tel-input/issues/253) - Can not import from Node.js since module build upgrade to webpack 4 (by [@superhit0](https://github.com/superhit0))
73 | - [#256](https://github.com/patw0929/react-intl-tel-input/pull/256): Defined `.npmrc` to avoid overriding the default npm registry server (by [@superhit0](https://github.com/superhit0))
74 | - [#259](https://github.com/patw0929/react-intl-tel-input/pull/259): Fixed not update value issue when value is empty string (by [@patw0929](https://github.com/patw0929))
75 |
76 | ## [v6.0.0](https://github.com/patw0929/react-intl-tel-input/releases/tag/v6.0.0)
77 |
78 | ### Breaking changes
79 |
80 | - [#235](https://github.com/patw0929/react-intl-tel-input/pull/245): Remove utilsScript prop (by [@patw0929](https://github.com/patw0929))
81 | - [#247](https://github.com/patw0929/react-intl-tel-input/pull/247): Removed libphonenumber.js (by [@patw0929](https://github.com/patw0929))
82 |
83 | ### New features
84 |
85 | - [#248](https://github.com/patw0929/react-intl-tel-input/pull/248): Analyze bundle size & decrease the size of main.js (by [@patw0929](https://github.com/patw0929))
86 | - [#227](https://github.com/patw0929/react-intl-tel-input/pull/227): Bumping React version to 16.4.1 & removing deprecated lifecycle events (by [@superhit0](https://github.com/superhit0))
87 | - [#214](https://github.com/patw0929/react-intl-tel-input/pull/214): Provide fullNumber and isValid when onSelectFlag (by [@adrienharnay](https://github.com/adrienharnay))
88 | - [#232](https://github.com/patw0929/react-intl-tel-input/pull/232): npmignore updated with file list (fixed [#231](https://github.com/patw0929/react-intl-tel-input/issues/231)) (by [@nutboltu](https://github.com/nutboltu))
89 | - [#242](https://github.com/patw0929/react-intl-tel-input/pull/242): Upgrade webpack, eslint, babel and refine coding style (by [@patw0929](https://github.com/patw0929))
90 | - [#243](https://github.com/patw0929/react-intl-tel-input/pull/243): Improvement: Utilize @babel/plugin-proposal-class-properties by using class properties in class components (by [@tomegz](https://github.com/tomegz))
91 |
92 | ### Bug fixes
93 |
94 | - [#246](https://github.com/patw0929/react-intl-tel-input/pull/246): Refactor FlagDropDown: Avoid creating functions every time render() is invoked, use class properties instead (by [@tomegz](https://github.com/tomegz))
95 | - [#221](https://github.com/patw0929/react-intl-tel-input/pull/221): Fix cursor Issue ([#205](https://github.com/patw0929/react-intl-tel-input/issues/205)) (by [@superhit0](https://github.com/superhit0))
96 | - [#223](https://github.com/patw0929/react-intl-tel-input/pull/223): Removed second argument of parseFloat (by [@patw0929](https://github.com/patw0929))
97 | - [#234](https://github.com/patw0929/react-intl-tel-input/pull/234): Hide country list when click on flag button (by [@ilagnev](https://github.com/ilagnev))
98 | - [#241](https://github.com/patw0929/react-intl-tel-input/pull/241): Fixes [#235](https://github.com/patw0929/react-intl-tel-input/issues/235): Show countrylist when allowDropdown flag is set to true (by [@tomegz](https://github.com/tomegz))
99 |
100 | ## [v5.1.0-rc.0](https://github.com/patw0929/react-intl-tel-input/releases/tag/v5.1.0-rc.0)
101 |
102 | ### New features
103 |
104 | - [#227](https://github.com/patw0929/react-intl-tel-input/pull/227): Bumping React version to 16.4.1 & removing deprecated lifecycle events (by [@superhit0](https://github.com/superhit0))
105 | - [#214](https://github.com/patw0929/react-intl-tel-input/pull/214): Provide fullNumber and isValid when onSelectFlag (by [@adrienharnay](https://github.com/adrienharnay))
106 | - [#232](https://github.com/patw0929/react-intl-tel-input/pull/232): npmignore updated with file list (fixed [#231](https://github.com/patw0929/react-intl-tel-input/issues/231)) (by [@nutboltu](https://github.com/nutboltu))
107 | - [#242](https://github.com/patw0929/react-intl-tel-input/pull/242): Upgrade webpack, eslint, babel and refine coding style (by [@patw0929](https://github.com/patw0929))
108 | - [#243](https://github.com/patw0929/react-intl-tel-input/pull/243): Improvement: Utilize @babel/plugin-proposal-class-properties by using class properties in class components (by [@tomegz](https://github.com/tomegz))
109 |
110 | ### Bug fixes
111 |
112 | - [#221](https://github.com/patw0929/react-intl-tel-input/pull/221): Fix cursor Issue ([#205](https://github.com/patw0929/react-intl-tel-input/issues/205)) (by [@superhit0](https://github.com/superhit0))
113 | - [#223](https://github.com/patw0929/react-intl-tel-input/pull/223): Removed second argument of parseFloat (by [@patw0929](https://github.com/patw0929))
114 | - [#234](https://github.com/patw0929/react-intl-tel-input/pull/234): Hide country list when click on flag button (by [@ilagnev](https://github.com/ilagnev))
115 | - [#241](https://github.com/patw0929/react-intl-tel-input/pull/241): Fixes [#235](https://github.com/patw0929/react-intl-tel-input/issues/235): Show countrylist when allowDropdown flag is set to true (by [@tomegz](https://github.com/tomegz))
116 |
117 | ## [v5.0.7](https://github.com/patw0929/react-intl-tel-input/releases/tag/v5.0.7)
118 |
119 | ### Bug fixes
120 |
121 | - [#220](https://github.com/patw0929/react-intl-tel-input/pull/220): Upgrade Libphonenumber to v8.9.9 (by [@superhit0](https://github.com/superhit0))
122 |
123 |
124 | ## [v5.0.6](https://github.com/patw0929/react-intl-tel-input/releases/tag/v5.0.6)
125 |
126 | ### Bug fixes
127 |
128 | - [#217](https://github.com/patw0929/react-intl-tel-input/pull/217): Add findIndex implementation for IE 11 (by [@ostap0207](https://github.com/ostap0207))
129 | - [#219](https://github.com/patw0929/react-intl-tel-input/pull/219): Fixed [#218](https://github.com/patw0929/react-intl-tel-input/issues/218): Fix expanded class not being removed from wrapper (by [@MilosMosovsky](https://github.com/MilosMosovsky))
130 |
131 |
132 | ## [v5.0.5](https://github.com/patw0929/react-intl-tel-input/releases/tag/v5.0.5)
133 |
134 | ### Bug fixes
135 |
136 | - Fixed [#208](https://github.com/patw0929/react-intl-tel-input/issues/208): issue of dial code shows twice in input ([#209](https://github.com/patw0929/react-intl-tel-input/pull/209) & [#210](https://github.com/patw0929/react-intl-tel-input/pull/210))
137 |
138 |
139 | ## [v5.0.4](https://github.com/patw0929/react-intl-tel-input/releases/tag/v5.0.4)
140 |
141 | ### Bug fixes
142 |
143 | - [#207](https://github.com/patw0929/react-intl-tel-input/pull/207): Move Prop-types out of peer dependency. remove proptypes in dist ([57a6956](https://github.com/patw0929/react-intl-tel-input/commit/57a695617582a7662e1af4a66d326a9ff7d61ba7) by [@dphrag](https://github.com/dphrag))
144 |
145 |
146 | ## [v5.0.3](https://github.com/patw0929/react-intl-tel-input/releases/tag/v5.0.3)
147 |
148 | ### Bug fixes
149 |
150 | - [#204](https://github.com/patw0929/react-intl-tel-input/pull/204): Handle placeholder and customPlaceholder change (by [@adrienharnay](https://github.com/adrienharnay))
151 |
152 |
153 | ## [v5.0.2](https://github.com/patw0929/react-intl-tel-input/releases/tag/v5.0.2)
154 |
155 | ### Bug fixes
156 |
157 | - [#202](https://github.com/patw0929/react-intl-tel-input/pull/202): Fix runtime error when this.tel is null ([e021526](https://github.com/patw0929/react-intl-tel-input/commit/e02152686a39ae76dc801aa5a31df5f5b00e74ea) by[@adrienharnay](https://github.com/adrienharnay))
158 | - [#201](https://github.com/patw0929/react-intl-tel-input/pull/201): Update placeholder when receiving new placeholder prop (4e9bcaf by @patw0929)
159 |
160 | ## [v5.0.1](https://github.com/patw0929/react-intl-tel-input/releases/tag/v5.0.1)
161 |
162 | ### Bug fixes
163 |
164 | - [#199](https://github.com/patw0929/react-intl-tel-input/pull/199): reconfigure packages to bring back compatibility to both react 15 & 16 ([ea2d593](https://github.com/patw0929/react-intl-tel-input/commit/ea2d593df075d59446d58f11df2d191afb813c6b) by [@ignatiusreza](https://github.com/ignatiusreza))
165 |
166 |
167 | ## [v5.0.0](https://github.com/patw0929/react-intl-tel-input/releases/tag/v5.0.0)
168 |
169 | ### Breaking change
170 |
171 | - [#196](https://github.com/patw0929/react-intl-tel-input/pull/196) Upgrade to React 16 (by [@puffo](https://github.com/puffo) & [@ignatiusreza](https://github.com/ignatiusreza))
172 |
173 |
174 | ## [v4.3.4](https://github.com/patw0929/react-intl-tel-input/releases/tag/v4.3.4)
175 |
176 | ### Bug fixes
177 |
178 | - [#198](https://github.com/patw0929/react-intl-tel-input/pull/198) Allow country code to be deleted (Fixed [#197](https://github.com/patw0929/react-intl-tel-input/issues/197)) ([c731a6b](https://github.com/patw0929/react-intl-tel-input/commit/c731a6b913b5d8852d886c4b0e35ae7cbc7c37b7) by [@MatthewAnstey](https://github.com/MatthewAnstey))
179 |
180 |
181 | ## [v4.3.3](https://github.com/patw0929/react-intl-tel-input/releases/tag/v4.3.3)
182 |
183 | ### Bug fixes
184 |
185 | - [#195](https://github.com/patw0929/react-intl-tel-input/pull/195): Add flag update when phones changes through props ([9d58356](https://github.com/patw0929/react-intl-tel-input/commit/9d583560a80c0ff30ff5bf390d6ebcb31cea1130) by [@MatthewAnstey](https://github.com/MatthewAnstey))
186 |
187 |
188 | ## [v4.3.2](https://github.com/patw0929/react-intl-tel-input/releases/tag/v4.3.2)
189 |
190 | ### Bug fixes
191 |
192 | - [#192](https://github.com/patw0929/react-intl-tel-input/pull/192): highlight country from preferred list ([b37cc3d](https://github.com/patw0929/react-intl-tel-input/commit/b37cc3d6c1f7d9f2b94dc912b4698b0143c5d4ee), [7f2b90e](https://github.com/patw0929/react-intl-tel-input/commit/7f2b90ecd74768e0a729327bd4af7e8ee4deeba3), [5bdbb79](https://github.com/patw0929/react-intl-tel-input/commit/5bdbb798bfec46c0df2237c2c52ceb72ef8b8ec0) by [@denis-k](https://github.com/denis-k))
193 |
194 |
195 | ## [v4.3.1](https://github.com/patw0929/react-intl-tel-input/releases/tag/v4.3.1)
196 |
197 | ### Bug fixes
198 |
199 | - Changed line that sets countryCode. Now, when CC is invalid, it is set to null and therefor not changed ([34b5517](https://github.com/patw0929/react-intl-tel-input/commit/34b551772d3a21d823e42864f99d5f925ff9273a) by [@darkenvy](https://github.com/darkenvy))
200 |
201 |
202 | ## [v4.0.1](https://github.com/patw0929/react-intl-tel-input/releases/tag/v4.0.1)
203 |
204 | ### Bug fixes
205 |
206 | - Make isMobile isomorphic-friendly ([690f25b](https://github.com/patw0929/react-intl-tel-input/commit/690f25b954fde8e810d029e70515229849722ff2) by [@mariusandra](https://github.com/mariusandra))
207 |
208 |
209 | ## [v3.7.0](https://github.com/patw0929/react-intl-tel-input/releases/tag/v3.7.0)
210 |
211 | ### New features
212 |
213 | - [#162](https://github.com/patw0929/react-intl-tel-input/pull/162): Pass arbitrary props to the tel input element (Also fixed [#158](https://github.com/patw0929/react-intl-tel-input/issues/158)) ([5e2d4f9](https://github.com/patw0929/react-intl-tel-input/commit/5e2d4f999942b6cb33beb518ff317de76d6fafac) by [@Arkq](https://github.com/Arkq))
214 |
215 |
216 | ## [v3.2.0](https://github.com/patw0929/react-intl-tel-input/releases/tag/v3.2.0)
217 |
218 | ### New features
219 |
220 | - [#140](https://github.com/patw0929/react-intl-tel-input/pull/140): Pass down status to onSelectFlag by using isValidNumberForRegion ([fd39e98](https://github.com/patw0929/react-intl-tel-input/commit/fd39e98607b833aec297a2dcfd23b7149a267677), [ed781ed](https://github.com/patw0929/react-intl-tel-input/commit/ed781edcc8bb686e43cb75998f2cf9a04e387349) by [@viqh](https://github.com/viqh))
221 | - [#141](https://github.com/patw0929/react-intl-tel-input/pull/141): Added on blur callback handler ([5aaef6e](https://github.com/patw0929/react-intl-tel-input/commit/5aaef6edb0a0a3f27b28e9bb1fd4e31e7142d020) by [@matteoantoci](https://github.com/matteoantoci))
222 |
223 | ### Bug fixes
224 |
225 | - [#142](https://github.com/patw0929/react-intl-tel-input/pull/142): implement state.value change in componentWillReceiveProps ([09eae7e](https://github.com/patw0929/react-intl-tel-input/commit/09eae7ec7132ab70fb34ffc1a2ff26becfe6424a) by [@pwlmaciejewski](https://github.com/pwlmaciejewski))
226 |
227 |
--------------------------------------------------------------------------------
/src/components/__tests__/FlagDropDown.test.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable react/no-find-dom-node, no-eval */
2 | import React from 'react'
3 | import ReactDOM from 'react-dom'
4 | import ReactTestUtils from 'react-dom/test-utils'
5 | import { mount } from 'enzyme'
6 | import IntlTelInput from '../IntlTelInput'
7 | import FlagDropDown from '../FlagDropDown'
8 | import CountryList from '../CountryList'
9 | import TelInput from '../TelInput'
10 |
11 | // eslint-disable-next-line func-names
12 | describe('FlagDropDown', function() {
13 | beforeEach(() => {
14 | jest.resetModules()
15 |
16 | this.params = {
17 | containerClassName: 'intl-tel-input',
18 | inputClassName: 'form-control phoneNumber',
19 | fieldName: 'telephone',
20 | defaultCountry: 'tw',
21 | }
22 |
23 | this.makeSubject = () => {
24 | return mount()
25 | }
26 | })
27 |
28 | it('should be rendered', () => {
29 | const subject = this.makeSubject()
30 | const flagComponent = subject.find(FlagDropDown)
31 | const countryListComponent = subject.find(CountryList)
32 |
33 | expect(flagComponent.length).toBeTruthy()
34 | expect(countryListComponent.length).toBeTruthy()
35 | })
36 |
37 | it('should load country "jp" from localStorage', async () => {
38 | window.localStorage.setItem('itiAutoCountry', 'jp')
39 | this.params = {
40 | ...this.params,
41 | defaultCountry: 'auto',
42 | }
43 | const subject = await this.makeSubject()
44 |
45 | subject.instance().utilsScriptDeferred.then(() => {
46 | expect(subject.state().countryCode).toBe('jp')
47 | window.localStorage.clear()
48 | })
49 | })
50 |
51 | it('should fallback to US when localStorage is not available', async () => {
52 | const mockedLocalStorage = window.localStorage
53 | // This will cause calls to localStorage.getItem() to throw
54 | window.localStorage = {}
55 |
56 | this.params = {
57 | ...this.params,
58 | defaultCountry: 'auto',
59 | }
60 | const subject = await this.makeSubject()
61 |
62 | subject.instance().utilsScriptDeferred.then(() => {
63 | expect(subject.state().countryCode).toBe('us')
64 | window.localStorage.clear()
65 | })
66 |
67 | window.localStorage = mockedLocalStorage
68 | })
69 |
70 | it('should has .separate-dial-code class when with separateDialCode = true', () => {
71 | this.params = {
72 | ...this.params,
73 | separateDialCode: true,
74 | }
75 | const subject = this.makeSubject()
76 |
77 | expect(subject.find('.separate-dial-code').length).toBeTruthy()
78 | })
79 |
80 | it('should has "tw" in class name', () => {
81 | const subject = this.makeSubject()
82 | const flagComponent = subject.find(FlagDropDown)
83 |
84 | expect(flagComponent.find('.iti-flag.tw').first().length).toBeTruthy()
85 | })
86 |
87 | it('should not has .hide class after clicking flag component', () => {
88 | const subject = this.makeSubject()
89 | const flagComponent = subject.find(FlagDropDown)
90 |
91 | expect(
92 | subject.find(CountryList).find('.country-list.hide').length,
93 | ).toBeTruthy()
94 | flagComponent
95 | .find('.selected-flag')
96 | .last()
97 | .simulate('click')
98 |
99 | subject.update()
100 | expect(
101 | subject.find(CountryList).find('.country-list.hide').length,
102 | ).toBeFalsy()
103 | })
104 |
105 | it('Simulate change to Japan flag in dropdown before & after', () => {
106 | const subject = this.makeSubject()
107 | const flagComponent = subject.find(FlagDropDown)
108 |
109 | expect(subject.state().showDropdown).toBeFalsy()
110 | expect(flagComponent.find('.iti-flag.tw').length).toBeTruthy()
111 | flagComponent.simulate('click')
112 | const japanOption = flagComponent.find('[data-country-code="jp"]')
113 |
114 | japanOption.simulate('click')
115 | expect(flagComponent.find('.iti-flag.jp').length).toBeTruthy()
116 | expect(subject.state().showDropdown).toBeFalsy()
117 | })
118 |
119 | it('Set onlyCountries', () => {
120 | this.params.onlyCountries = ['tw', 'us', 'kr']
121 | const subject = this.makeSubject()
122 | const flagComponent = subject.find(FlagDropDown)
123 |
124 | const result = [
125 | {
126 | name: 'South Korea (대한민국)',
127 | iso2: 'kr',
128 | dialCode: '82',
129 | priority: 0,
130 | areaCodes: null,
131 | },
132 | {
133 | name: 'Taiwan (台灣)',
134 | iso2: 'tw',
135 | dialCode: '886',
136 | priority: 0,
137 | areaCodes: null,
138 | },
139 | {
140 | name: 'United States',
141 | iso2: 'us',
142 | dialCode: '1',
143 | priority: 0,
144 | areaCodes: null,
145 | },
146 | ]
147 |
148 | expect(flagComponent.props().countries).toEqual(result)
149 | })
150 |
151 | it('Set excludeCountries', () => {
152 | this.params.excludeCountries = ['us', 'kr']
153 | const subject = this.makeSubject()
154 | const flagComponent = subject.find(FlagDropDown)
155 |
156 | expect(flagComponent.props().countries.length).toBe(241)
157 | })
158 |
159 | it('Set defaultCountry as "auto"', async () => {
160 | const lookup = callback => {
161 | callback('jp')
162 | }
163 |
164 | this.params = {
165 | ...this.params,
166 | defaultCountry: 'auto',
167 | geoIpLookup: lookup,
168 | }
169 | const subject = await this.makeSubject()
170 |
171 | subject.instance().utilsScriptDeferred.then(() => {
172 | expect(subject.state().countryCode).toBe('jp')
173 | })
174 | })
175 |
176 | describe('with original ReactTestUtils', () => {
177 | it('Mouse over on country', () => {
178 | const renderedComponent = ReactTestUtils.renderIntoDocument(
179 | ,
184 | )
185 |
186 | const flagComponent = ReactTestUtils.findRenderedDOMComponentWithClass(
187 | renderedComponent,
188 | 'selected-flag',
189 | )
190 |
191 | const dropDownComponent = ReactTestUtils.findRenderedDOMComponentWithClass(
192 | renderedComponent,
193 | 'country-list',
194 | )
195 |
196 | ReactTestUtils.Simulate.click(ReactDOM.findDOMNode(flagComponent))
197 | const options = ReactDOM.findDOMNode(dropDownComponent).querySelectorAll(
198 | '.country:not([class="preferred"])',
199 | )
200 | const koreaOption = ReactDOM.findDOMNode(dropDownComponent).querySelector(
201 | '[data-country-code="kr"]',
202 | )
203 |
204 | let index = -1
205 |
206 | for (let i = 0, max = options.length; i < max; ++i) {
207 | if (options[i] === koreaOption) {
208 | index = i
209 | }
210 | }
211 |
212 | ReactTestUtils.Simulate.mouseOver(koreaOption)
213 | expect(renderedComponent.state.highlightedCountry).toBe(index)
214 | })
215 |
216 | it('Simulate change to flag in dropdown by up and down key', () => {
217 | const renderedComponent = ReactTestUtils.renderIntoDocument(
218 | ,
223 | )
224 |
225 | const flagComponent = ReactTestUtils.findRenderedDOMComponentWithClass(
226 | renderedComponent,
227 | 'selected-flag',
228 | )
229 |
230 | expect(
231 | ReactDOM.findDOMNode(flagComponent).querySelector('.iti-flag')
232 | .className,
233 | ).toBe('iti-flag tw')
234 |
235 | ReactTestUtils.Simulate.keyDown(ReactDOM.findDOMNode(flagComponent), {
236 | key: 'Enter',
237 | keyCode: 13,
238 | which: 13,
239 | })
240 | expect(renderedComponent.state.showDropdown).toBeTruthy()
241 |
242 | ReactTestUtils.Simulate.keyDown(ReactDOM.findDOMNode(flagComponent), {
243 | key: 'Tab',
244 | keyCode: 9,
245 | which: 9,
246 | })
247 | expect(renderedComponent.state.showDropdown).toBeFalsy()
248 |
249 | ReactTestUtils.Simulate.keyDown(ReactDOM.findDOMNode(flagComponent), {
250 | key: 'Enter',
251 | keyCode: 13,
252 | which: 13,
253 | })
254 |
255 | const pressUpEvent = new window.KeyboardEvent('keydown', {
256 | bubbles: true,
257 | cancelable: true,
258 | shiftKey: true,
259 | keyCode: 38,
260 | key: 'Up',
261 | which: 38,
262 | })
263 |
264 | document.dispatchEvent(pressUpEvent)
265 | expect(renderedComponent.state.highlightedCountry).toBe(212)
266 |
267 | const pressEnterEvent = new window.KeyboardEvent('keydown', {
268 | bubbles: true,
269 | cancelable: true,
270 | shiftKey: true,
271 | keyCode: 13,
272 | key: 'Enter',
273 | which: 13,
274 | })
275 |
276 | document.dispatchEvent(pressEnterEvent)
277 | expect(renderedComponent.state.showDropdown).toBeFalsy()
278 | expect(
279 | ReactDOM.findDOMNode(flagComponent).querySelector('.iti-flag')
280 | .className === 'iti-flag sy',
281 | )
282 | })
283 |
284 | it('Simulate close the dropdown menu by ESC key', () => {
285 | const renderedComponent = ReactTestUtils.renderIntoDocument(
286 | ,
291 | )
292 |
293 | const flagComponent = ReactTestUtils.findRenderedDOMComponentWithClass(
294 | renderedComponent,
295 | 'selected-flag',
296 | )
297 |
298 | ReactTestUtils.Simulate.keyDown(ReactDOM.findDOMNode(flagComponent), {
299 | key: 'Enter',
300 | keyCode: 13,
301 | which: 13,
302 | })
303 | expect(renderedComponent.state.showDropdown).toBeTruthy()
304 |
305 | const pressEscEvent = new window.KeyboardEvent('keydown', {
306 | bubbles: true,
307 | cancelable: true,
308 | shiftKey: true,
309 | keyCode: 27,
310 | key: 'Esc',
311 | which: 27,
312 | })
313 |
314 | document.dispatchEvent(pressEscEvent)
315 | expect(renderedComponent.state.showDropdown).toBeFalsy()
316 | })
317 |
318 | it('Simulate close the dropdown menu by clicking on document', () => {
319 | const renderedComponent = ReactTestUtils.renderIntoDocument(
320 | ,
325 | )
326 |
327 | const flagComponent = ReactTestUtils.findRenderedDOMComponentWithClass(
328 | renderedComponent,
329 | 'selected-flag',
330 | )
331 |
332 | ReactTestUtils.Simulate.keyDown(ReactDOM.findDOMNode(flagComponent), {
333 | key: 'Enter',
334 | keyCode: 13,
335 | which: 13,
336 | })
337 | expect(renderedComponent.state.showDropdown).toBeTruthy()
338 |
339 | const clickEvent = new window.MouseEvent('click', {
340 | view: window,
341 | bubbles: true,
342 | cancelable: true,
343 | })
344 |
345 | document.querySelector('html').dispatchEvent(clickEvent)
346 | expect(renderedComponent.state.showDropdown).toBeFalsy()
347 | })
348 |
349 | it('componentWillUnmount', () => {
350 | const renderedComponent = ReactTestUtils.renderIntoDocument(
351 | ,
356 | )
357 |
358 | const flagComponent = ReactTestUtils.findRenderedDOMComponentWithClass(
359 | renderedComponent,
360 | 'selected-flag',
361 | )
362 |
363 | ReactTestUtils.Simulate.keyDown(ReactDOM.findDOMNode(flagComponent), {
364 | key: 'Enter',
365 | keyCode: 13,
366 | which: 13,
367 | })
368 | expect(renderedComponent.state.showDropdown).toBeTruthy()
369 |
370 | renderedComponent.componentWillUnmount()
371 |
372 | const clickEvent = new window.MouseEvent('click', {
373 | view: window,
374 | bubbles: true,
375 | cancelable: true,
376 | })
377 |
378 | document.querySelector('html').dispatchEvent(clickEvent)
379 | expect(renderedComponent.state.showDropdown).toBeTruthy()
380 | })
381 |
382 | it('Simulate search country name in dropdown menu', () => {
383 | const renderedComponent = ReactTestUtils.renderIntoDocument(
384 | ,
389 | )
390 |
391 | const flagComponent = ReactTestUtils.findRenderedDOMComponentWithClass(
392 | renderedComponent,
393 | 'selected-flag',
394 | )
395 |
396 | ReactTestUtils.Simulate.keyDown(ReactDOM.findDOMNode(flagComponent), {
397 | key: 'Enter',
398 | keyCode: 13,
399 | which: 13,
400 | })
401 | expect(renderedComponent.state.showDropdown).toBe(true)
402 |
403 | const pressJEvent = new window.KeyboardEvent('keydown', {
404 | bubbles: true,
405 | cancelable: true,
406 | shiftKey: true,
407 | keyCode: 74,
408 | key: 'J',
409 | which: 74,
410 | })
411 | const pressAEvent = new window.KeyboardEvent('keydown', {
412 | bubbles: true,
413 | cancelable: true,
414 | shiftKey: true,
415 | keyCode: 65,
416 | key: 'A',
417 | which: 65,
418 | })
419 | const pressPEvent = new window.KeyboardEvent('keydown', {
420 | bubbles: true,
421 | cancelable: true,
422 | shiftKey: true,
423 | keyCode: 80,
424 | key: 'P',
425 | which: 80,
426 | })
427 |
428 | document.dispatchEvent(pressJEvent)
429 | document.dispatchEvent(pressAEvent)
430 | document.dispatchEvent(pressPEvent)
431 | const pressEnterEvent = new window.KeyboardEvent('keydown', {
432 | bubbles: true,
433 | cancelable: true,
434 | shiftKey: true,
435 | keyCode: 13,
436 | key: 'Enter',
437 | which: 13,
438 | })
439 |
440 | document.dispatchEvent(pressEnterEvent)
441 |
442 | expect(renderedComponent.state.showDropdown).toBeFalsy()
443 | expect(renderedComponent.state.highlightedCountry).toBe(108)
444 | expect(renderedComponent.state.countryCode).toBe('jp')
445 | })
446 | })
447 |
448 | it('customPlaceholder', () => {
449 | let expected = ''
450 | const customPlaceholder = (placeholder, countryData) => {
451 | expected = `${placeholder},${countryData.iso2}`
452 | }
453 |
454 | this.params.customPlaceholder = customPlaceholder
455 | const subject = this.makeSubject()
456 | const flagComponent = subject.find(FlagDropDown)
457 | const countryListComponent = subject.find(CountryList)
458 |
459 | expect(expected).toBe('0912 345 678,tw')
460 | flagComponent.simulate('click')
461 | const japanOption = countryListComponent.find('[data-country-code="jp"]')
462 |
463 | japanOption.simulate('click')
464 | expect(expected).toBe('090-1234-5678,jp')
465 | })
466 |
467 | it('onSelectFlag', () => {
468 | let expected = ''
469 | const onSelectFlag = (currentNumber, countryData, fullNumber, isValid) => {
470 | expected = Object.assign(
471 | {},
472 | { currentNumber, fullNumber, isValid, ...countryData },
473 | )
474 | }
475 |
476 | this.params.onSelectFlag = onSelectFlag
477 | const subject = this.makeSubject()
478 | const flagComponent = subject.find(FlagDropDown)
479 | const inputComponent = subject.find(TelInput)
480 | const countryListComponent = subject.find(CountryList)
481 |
482 | inputComponent.simulate('change', { target: { value: '+8109012345678' } })
483 | flagComponent.simulate('click')
484 | const japanOption = countryListComponent.find('[data-country-code="jp"]')
485 |
486 | japanOption.simulate('click')
487 |
488 | expect(expected).toEqual({
489 | currentNumber: '+8109012345678',
490 | fullNumber: '+81 90-1234-5678',
491 | isValid: true,
492 | name: 'Japan (日本)',
493 | iso2: 'jp',
494 | dialCode: '81',
495 | priority: 0,
496 | areaCodes: null,
497 | })
498 | })
499 |
500 | it('should output formatted number with formatNumber function', () => {
501 | this.params.format = true
502 | this.params.nationalMode = true
503 | const subject = this.makeSubject()
504 |
505 | expect(subject.instance().formatNumber('+886 912 345 678')).toBe(
506 | '0912 345 678',
507 | )
508 | })
509 |
510 | it('should highlight country from preferred list', async () => {
511 | const { defaultCountry } = this.params
512 |
513 | this.params = {
514 | ...this.params,
515 | preferredCountries: ['us', 'gb', defaultCountry],
516 | }
517 | const subject = await this.makeSubject()
518 |
519 | expect(defaultCountry).toBeTruthy()
520 | expect(subject.state().highlightedCountry).toBe(2)
521 | })
522 | })
523 |
--------------------------------------------------------------------------------
/src/components/__tests__/TelInput.test.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-eval, no-restricted-properties */
2 | import React from 'react'
3 | import { mount } from 'enzyme'
4 | import IntlTelInput from '../IntlTelInput'
5 | import TelInput from '../TelInput'
6 | import FlagDropDown from '../FlagDropDown'
7 |
8 | // eslint-disable-next-line func-names
9 | describe('TelInput', function() {
10 | beforeEach(() => {
11 | jest.resetModules()
12 |
13 | document.body.innerHTML = ''
14 |
15 | this.params = {
16 | containerClassName: 'intl-tel-input',
17 | inputClassName: 'form-control phoneNumber',
18 | fieldName: 'telephone',
19 | fieldId: 'telephone-id',
20 | defaultCountry: 'tw',
21 | defaultValue: '0999 123 456',
22 | }
23 | this.makeSubject = () => {
24 | return mount(, {
25 | attachTo: document.querySelector('#root'),
26 | })
27 | }
28 | })
29 |
30 | it('should set fieldName as "telephone"', () => {
31 | const subject = this.makeSubject()
32 | const inputComponent = subject.find(TelInput)
33 |
34 | expect(inputComponent.props().fieldName).toBe('telephone')
35 | })
36 |
37 | it('should set fieldId as "telephone-id"', () => {
38 | const subject = this.makeSubject()
39 | const inputComponent = subject.find(TelInput)
40 |
41 | expect(inputComponent.props().fieldId).toBe('telephone-id')
42 | })
43 |
44 | it('onPhoneNumberChange without libphonenumber', () => {
45 | let expected = ''
46 | const onPhoneNumberChange = (
47 | isValid,
48 | newNumber,
49 | countryData,
50 | fullNumber,
51 | ext,
52 | ) => {
53 | expected = `${isValid},${newNumber},${countryData.iso2},${fullNumber},${ext}`
54 | }
55 |
56 | window.intlTelInputUtils = undefined
57 |
58 | this.params.onPhoneNumberChange = onPhoneNumberChange
59 | const subject = this.makeSubject()
60 | const inputComponent = subject.find(TelInput)
61 |
62 | inputComponent.simulate('change', { target: { value: '+886911222333' } })
63 | expect(expected).toBe('false,+886911222333,tw,+886911222333,')
64 | })
65 |
66 | it('should set value as "0999 123 456"', async () => {
67 | const subject = await this.makeSubject()
68 | const inputComponent = subject.find(TelInput)
69 |
70 | expect(inputComponent.props().value).toBe('0999 123 456')
71 | })
72 |
73 | it('should set className', () => {
74 | const subject = this.makeSubject()
75 | const inputComponent = subject.find(TelInput)
76 |
77 | expect(inputComponent.find('.form-control.phoneNumber').length).toBeTruthy()
78 | })
79 |
80 | it('should not focused on render', () => {
81 | const initialSelectFlag = IntlTelInput.prototype.selectFlag
82 |
83 | let focused = false
84 |
85 | IntlTelInput.prototype.selectFlag = function selectFlag(
86 | countryCode,
87 | setFocus = true,
88 | ) {
89 | focused = focused || setFocus
90 | initialSelectFlag.call(this, countryCode, setFocus)
91 | }
92 |
93 | this.params = {
94 | ...this.params,
95 | value: '+886901234567',
96 | preferredCountries: ['kr', 'jp', 'tw'],
97 | }
98 | this.makeSubject()
99 |
100 | IntlTelInput.prototype.selectFlag = initialSelectFlag
101 | expect(focused).toBeFalsy()
102 | })
103 |
104 | it('should has "kr" in preferred countries state', () => {
105 | this.params = {
106 | ...this.params,
107 | defaultCountry: 'zz',
108 | preferredCountries: ['kr', 'jp', 'tw'],
109 | }
110 | const subject = this.makeSubject()
111 |
112 | expect(subject.state().countryCode).toBe('kr')
113 | })
114 |
115 | it('should set countryCode as "af" in state, when giving an invalid default country', () => {
116 | this.params = {
117 | ...this.params,
118 | preferredCountries: [],
119 | defaultValue: '',
120 | defaultCountry: 'zz',
121 | }
122 | const subject = this.makeSubject()
123 |
124 | expect(subject.state().countryCode).toBe('af')
125 | })
126 |
127 | it('getNumber without libphonenumber', () => {
128 | window.intlTelInputUtils = undefined
129 |
130 | this.params = {
131 | ...this.params,
132 | }
133 | const subject = this.makeSubject()
134 |
135 | expect(subject.instance().getNumber(1)).toBe('')
136 | })
137 |
138 | it('setNumber', () => {
139 | const subject = this.makeSubject()
140 |
141 | subject.instance().setNumber('+810258310015')
142 | expect(subject.state().countryCode).toBe('jp')
143 | })
144 |
145 | it('handleKeyUp', () => {
146 | const subject = this.makeSubject()
147 | const inputComponent = subject.find(TelInput)
148 |
149 | inputComponent.simulate('focus')
150 | inputComponent.simulate('keyDown', { keyCode: 35 })
151 | inputComponent.simulate('keyUp', {
152 | key: 'Backspace',
153 | keyCode: 8,
154 | which: 8,
155 | })
156 | inputComponent.simulate('change', {
157 | target: { value: '0999 123 45' },
158 | })
159 |
160 | const changedInputComponent = subject.find(TelInput)
161 |
162 | expect(changedInputComponent.props().value).toBe('0999 123 45')
163 | })
164 |
165 | it('ensurePlus', () => {
166 | this.params = {
167 | ...this.params,
168 | nationalMode: false,
169 | defaultValue: '+886999111222345',
170 | }
171 | const subject = this.makeSubject()
172 | const inputComponent = subject.find(TelInput)
173 |
174 | inputComponent.simulate('focus')
175 | inputComponent.simulate('keyDown', { keyCode: 35 })
176 | const bspaceKey = {
177 | key: 'Backspace',
178 | keyCode: 8,
179 | which: 8,
180 | }
181 |
182 | inputComponent.simulate('keyUp', bspaceKey)
183 | inputComponent.simulate('keyUp', bspaceKey)
184 | inputComponent.simulate('keyUp', bspaceKey)
185 | inputComponent.simulate('change', {
186 | target: { value: '+886 999 111 222' },
187 | })
188 | expect(subject.state().value).toBe('+886 999 111 222')
189 | })
190 |
191 | it('Disabled nationalMode and input phone number', () => {
192 | this.params.nationalMode = false
193 | const subject = this.makeSubject()
194 | const inputComponent = subject.find(TelInput)
195 |
196 | inputComponent.simulate('change', { target: { value: '+886901234567' } })
197 |
198 | const changedInputComponent = subject.find(TelInput)
199 |
200 | expect(changedInputComponent.props().value).toBe('+886901234567')
201 | })
202 |
203 | it('utils loaded', () => {
204 | this.makeSubject()
205 |
206 | expect(typeof window.intlTelInputUtils === 'object')
207 | expect(typeof window.intlTelInputUtils.isValidNumber === 'function')
208 | })
209 |
210 | it('onPhoneNumberChange', () => {
211 | let expected = ''
212 | const onPhoneNumberChange = (
213 | isValid,
214 | newNumber,
215 | countryData,
216 | fullNumber,
217 | ext,
218 | ) => {
219 | expected = `${isValid},${newNumber},${countryData.iso2},${fullNumber},${ext}`
220 | }
221 |
222 | this.params.onPhoneNumberChange = onPhoneNumberChange
223 | const subject = this.makeSubject()
224 | const inputComponent = subject.find(TelInput)
225 |
226 | inputComponent.simulate('change', { target: { value: '+886911222333' } })
227 | expect(expected).toBe('true,+886911222333,tw,+886 911 222 333,null')
228 | })
229 |
230 | it('Blur and cleaning the empty dialcode', () => {
231 | const subject = this.makeSubject()
232 | const inputComponent = subject.find(TelInput)
233 |
234 | inputComponent.simulate('change', { target: { value: '+886' } })
235 | subject.instance().handleOnBlur()
236 | expect(subject.state().value).toBe('')
237 | })
238 |
239 | const testOnPhoneNumberEvent = ({ property, eventType }) =>
240 | it(`${property}`, () => {
241 | let expected = ''
242 | const onPhoneNumberEvent = (
243 | isValid,
244 | newNumber,
245 | countryData,
246 | fullNumber,
247 | ext,
248 | event,
249 | ) => {
250 | const { type } = event
251 |
252 | expected = `${isValid},${newNumber},${countryData.iso2},${fullNumber},${ext},${type}`
253 | }
254 |
255 | this.params[property] = onPhoneNumberEvent
256 | const subject = this.makeSubject()
257 | const inputComponent = subject.find(TelInput)
258 |
259 | inputComponent.simulate('change', { target: { value: '+886911222333' } })
260 | inputComponent.simulate(eventType)
261 | expect(expected).toBe(
262 | `true,+886911222333,tw,+886 911 222 333,null,${eventType}`,
263 | )
264 | })
265 |
266 | ;[
267 | { property: 'onPhoneNumberBlur', eventType: 'blur' },
268 | { property: 'onPhoneNumberFocus', eventType: 'focus' },
269 | ].forEach(testOnPhoneNumberEvent)
270 |
271 | it('should has empty value with false nationalMode, false autoHideDialCode and false separateDialCode', () => {
272 | this.params = {
273 | ...this.params,
274 | defaultValue: '',
275 | nationalMode: false,
276 | autoHideDialCode: false,
277 | separateDialCode: false,
278 | }
279 | const subject = this.makeSubject()
280 |
281 | expect(subject.state().value).toBe('+886')
282 | })
283 |
284 | it('updateFlagFromNumber', () => {
285 | this.params = {
286 | defaultCountry: 'us',
287 | nationalMode: true,
288 | }
289 | const subject = this.makeSubject()
290 | const inputComponent = subject.find(TelInput)
291 |
292 | inputComponent.simulate('change', { target: { value: '9183319436' } })
293 | expect(subject.state().countryCode).toBe('us')
294 |
295 | inputComponent.simulate('change', { target: { value: '+' } })
296 | expect(subject.state().countryCode).toBe('us')
297 | })
298 |
299 | it('isValidNumber', () => {
300 | const subject = this.makeSubject()
301 |
302 | expect(subject.instance().isValidNumber('0910123456')).toBeTruthy()
303 | expect(subject.instance().isValidNumber('091012345')).toBeFalsy()
304 | })
305 |
306 | it('getFullNumber', () => {
307 | this.params = {
308 | ...this.params,
309 | separateDialCode: true,
310 | }
311 | const subject = this.makeSubject()
312 | const inputComponent = subject.find(TelInput)
313 |
314 | inputComponent.simulate('change', { target: { value: '910123456' } })
315 | expect(subject.instance().getFullNumber(910123456)).toBe('+886910123456')
316 | })
317 |
318 | it('should render custom placeholder', () => {
319 | this.params.placeholder = 'foo'
320 | const subject = this.makeSubject()
321 | const inputComponent = subject.find(TelInput)
322 |
323 | expect(inputComponent.props().placeholder).toBe('foo')
324 | })
325 |
326 | // FIXME: Enzyme not support :focus in current time
327 | xit('should focus input when autoFocus set to true', () => {
328 | this.params.autoFocus = true
329 | const subject = this.makeSubject()
330 | const inputComponent = subject.find(TelInput)
331 |
332 | expect(inputComponent.is(':focus')).toBeTruthy()
333 | })
334 |
335 | it('should not focus input when autoFocus set to false', () => {
336 | this.params.autoFocus = false
337 | const subject = this.makeSubject()
338 | const inputComponent = subject.find(TelInput)
339 |
340 | expect(document.activeElement).not.toBe(inputComponent)
341 | })
342 |
343 | describe('when mobile useragent', () => {
344 | let defaultUserAgent
345 |
346 | beforeEach(() => {
347 | defaultUserAgent = navigator.userAgent
348 | window.navigator.__defineGetter__('userAgent', () => 'iPhone')
349 | })
350 |
351 | afterEach(() => {
352 | window.navigator.__defineGetter__('userAgent', () => defaultUserAgent)
353 | })
354 |
355 | it('sets FlagDropDown "dropdowncontainer" prop to "body"', () => {
356 | const subject = this.makeSubject()
357 | const flagDropdownComponent = subject.find(FlagDropDown)
358 |
359 | expect(flagDropdownComponent.props().dropdownContainer).toBe('body')
360 | })
361 |
362 | it('sets FlagDropDown "isMobile" prop to true', () => {
363 | const subject = this.makeSubject()
364 | const flagDropdownComponent = subject.find(FlagDropDown)
365 |
366 | expect(flagDropdownComponent.props().isMobile).toBeTruthy()
367 | })
368 |
369 | it('sets "iti-mobile" class to "body"', () => {
370 | expect(document.body.className).toBe('iti-mobile')
371 | })
372 |
373 | it(`does not set FlagDropDown "dropdowncontainer" to "body"
374 | when "useMobileFullscreenDropdown" set to false`, () => {
375 | this.params.useMobileFullscreenDropdown = false
376 | const subject = this.makeSubject()
377 | const flagDropdownComponent = subject.find(FlagDropDown)
378 |
379 | expect(flagDropdownComponent.props().dropdownContainer).toBe('')
380 | })
381 | })
382 |
383 | describe('controlled', () => {
384 | it('should set the value', () => {
385 | const subject = this.makeSubject()
386 |
387 | expect(subject.state().value).toBe('0999 123 456')
388 | })
389 |
390 | it('should not change input value if value is constrained by parent', () => {
391 | this.params.value = '0999 123 456'
392 | const subject = this.makeSubject()
393 | const inputComponent = subject.find(TelInput)
394 |
395 | inputComponent.simulate('change', { target: { value: '12345' } })
396 | expect(subject.state().value).toBe('0999 123 456')
397 | })
398 |
399 | it('should change input value on value prop change', () => {
400 | const subject = this.makeSubject()
401 |
402 | subject.setProps({ value: '+447598455159' })
403 | subject.update()
404 |
405 | expect(subject.find(FlagDropDown).props().highlightedCountry).toBe(1)
406 |
407 | subject.setProps({ value: '+1(201) 555-0129' })
408 | subject.update()
409 |
410 | expect(subject.find(FlagDropDown).props().highlightedCountry).toBe(0)
411 | })
412 |
413 | it('should update country flag when value updates', () => {
414 | const subject = this.makeSubject()
415 |
416 | subject.setProps({ value: 'foo bar' })
417 | subject.update()
418 |
419 | expect(subject.find(TelInput).props().value).toBe('foo bar')
420 | })
421 |
422 | it('should be able to delete country code after input field has been populated with number', () => {
423 | const subject = this.makeSubject()
424 |
425 | subject.setProps({ value: '+447598455159' })
426 |
427 | subject.setProps({ value: '+' })
428 |
429 | expect(subject.state().value).toBe('+')
430 | })
431 |
432 | it('should change input placeholder on placeholder prop change', () => {
433 | const subject = this.makeSubject()
434 |
435 | subject.setProps({ placeholder: 'Phone number' })
436 | subject.update()
437 |
438 | expect(subject.find(TelInput).props().placeholder).toBe('Phone number')
439 |
440 | subject.setProps({ placeholder: 'Your phone' })
441 | subject.update()
442 |
443 | expect(subject.find(TelInput).props().placeholder).toBe('Your phone')
444 | })
445 |
446 | it('should change input placeholder on customPlaceholder prop change', () => {
447 | const subject = this.makeSubject()
448 |
449 | subject.setProps({ customPlaceholder: () => 'Phone number' })
450 | subject.update()
451 |
452 | expect(subject.find(TelInput).props().placeholder).toBe('Phone number')
453 |
454 | subject.setProps({ customPlaceholder: () => 'Your phone' })
455 | subject.update()
456 |
457 | expect(subject.find(TelInput).props().placeholder).toBe('Your phone')
458 | })
459 |
460 | it('should set "expanded" class to wrapper only when flags are open', () => {
461 | const subject = this.makeSubject()
462 | const flagComponent = subject
463 | .find(FlagDropDown)
464 | .find('.selected-flag')
465 | .last()
466 |
467 | flagComponent.simulate('click')
468 | expect(subject.instance().wrapperClass.expanded).toBe(true)
469 |
470 | const taiwanOption = subject
471 | .find(FlagDropDown)
472 | .find('[data-country-code="tw"]')
473 |
474 | taiwanOption.simulate('click')
475 | expect(subject.instance().wrapperClass.expanded).toBe(false)
476 | })
477 | })
478 |
479 | describe('uncontrolled', () => {
480 | it('should initialize state with defaultValue', () => {
481 | this.params.defaultValue = '54321'
482 | const subject = this.makeSubject()
483 | const inputComponent = subject.find(TelInput)
484 |
485 | expect(inputComponent.props().value).toBe('54321')
486 | expect(subject.state().value).toBe('54321')
487 | })
488 |
489 | it('should change value', () => {
490 | this.params.defaultValue = ''
491 | const subject = this.makeSubject()
492 | const inputComponent = subject.find(TelInput)
493 |
494 | inputComponent.simulate('change', { target: { value: '12345' } })
495 |
496 | const changedInputComponent = subject.find(TelInput)
497 |
498 | expect(changedInputComponent.props().value).toBe('12345')
499 | expect(subject.state().value).toBe('12345')
500 | })
501 |
502 | it('should change props value', () => {
503 | const subject = this.makeSubject()
504 |
505 | subject.setState({
506 | value: '+886912345678',
507 | })
508 |
509 | const changedInputComponent = subject.find(TelInput)
510 |
511 | expect(changedInputComponent.props().value).toBe('+886912345678')
512 | })
513 | })
514 | })
515 |
--------------------------------------------------------------------------------
/src/sprite.scss:
--------------------------------------------------------------------------------
1 | @function retina-size($value) {
2 | @return floor($value / 2);
3 | }
4 |
5 | @mixin retina-bg-size($spriteWidth, $spriteHeight) {
6 | background-size: floor($spriteWidth / 2) floor($spriteHeight / 2);
7 | }
8 |
9 | .iti-flag {
10 | $item-width-maps: (ac: 20px, ad: 20px, ae: 20px, af: 20px, ag: 20px, ai: 20px, al: 20px, am: 20px, ao: 20px, aq: 20px, ar: 20px, as: 20px, at: 20px, au: 20px, aw: 20px, ax: 20px, az: 20px, ba: 20px, bb: 20px, bd: 20px, be: 18px, bf: 20px, bg: 20px, bh: 20px, bi: 20px, bj: 20px, bl: 20px, bm: 20px, bn: 20px, bo: 20px, bq: 20px, br: 20px, bs: 20px, bt: 20px, bv: 20px, bw: 20px, by: 20px, bz: 20px, ca: 20px, cc: 20px, cd: 20px, cf: 20px, cg: 20px, ch: 15px, ci: 20px, ck: 20px, cl: 20px, cm: 20px, cn: 20px, co: 20px, cp: 20px, cr: 20px, cu: 20px, cv: 20px, cw: 20px, cx: 20px, cy: 20px, cz: 20px, de: 20px, dg: 20px, dj: 20px, dk: 20px, dm: 20px, do: 20px, dz: 20px, ea: 20px, ec: 20px, ee: 20px, eg: 20px, eh: 20px, er: 20px, es: 20px, et: 20px, eu: 20px, fi: 20px, fj: 20px, fk: 20px, fm: 20px, fo: 20px, fr: 20px, ga: 20px, gb: 20px, gd: 20px, ge: 20px, gf: 20px, gg: 20px, gh: 20px, gi: 20px, gl: 20px, gm: 20px, gn: 20px, gp: 20px, gq: 20px, gr: 20px, gs: 20px, gt: 20px, gu: 20px, gw: 20px, gy: 20px, hk: 20px, hm: 20px, hn: 20px, hr: 20px, ht: 20px, hu: 20px, ic: 20px, id: 20px, ie: 20px, il: 20px, im: 20px, in: 20px, io: 20px, iq: 20px, ir: 20px, is: 20px, it: 20px, je: 20px, jm: 20px, jo: 20px, jp: 20px, ke: 20px, kg: 20px, kh: 20px, ki: 20px, km: 20px, kn: 20px, kp: 20px, kr: 20px, kw: 20px, ky: 20px, kz: 20px, la: 20px, lb: 20px, lc: 20px, li: 20px, lk: 20px, lr: 20px, ls: 20px, lt: 20px, lu: 20px, lv: 20px, ly: 20px, ma: 20px, mc: 19px, md: 20px, me: 20px, mf: 20px, mg: 20px, mh: 20px, mk: 20px, ml: 20px, mm: 20px, mn: 20px, mo: 20px, mp: 20px, mq: 20px, mr: 20px, ms: 20px, mt: 20px, mu: 20px, mv: 20px, mw: 20px, mx: 20px, my: 20px, mz: 20px, na: 20px, nc: 20px, ne: 18px, nf: 20px, ng: 20px, ni: 20px, nl: 20px, no: 20px, np: 13px, nr: 20px, nu: 20px, nz: 20px, om: 20px, pa: 20px, pe: 20px, pf: 20px, pg: 20px, ph: 20px, pk: 20px, pl: 20px, pm: 20px, pn: 20px, pr: 20px, ps: 20px, pt: 20px, pw: 20px, py: 20px, qa: 20px, re: 20px, ro: 20px, rs: 20px, ru: 20px, rw: 20px, sa: 20px, sb: 20px, sc: 20px, sd: 20px, se: 20px, sg: 20px, sh: 20px, si: 20px, sj: 20px, sk: 20px, sl: 20px, sm: 20px, sn: 20px, so: 20px, sr: 20px, ss: 20px, st: 20px, sv: 20px, sx: 20px, sy: 20px, sz: 20px, ta: 20px, tc: 20px, td: 20px, tf: 20px, tg: 20px, th: 20px, tj: 20px, tk: 20px, tl: 20px, tm: 20px, tn: 20px, to: 20px, tr: 20px, tt: 20px, tv: 20px, tw: 20px, tz: 20px, ua: 20px, ug: 20px, um: 20px, us: 20px, uy: 20px, uz: 20px, va: 15px, vc: 20px, ve: 20px, vg: 20px, vi: 20px, vn: 20px, vu: 20px, wf: 20px, ws: 20px, xk: 20px, ye: 20px, yt: 20px, za: 20px, zm: 20px, zw: 20px, );
11 | $standard-country: 'ac';
12 | width: map-get($item-width-maps, $standard-country);
13 |
14 | @each $key, $width in $item-width-maps {
15 | @if $width != map-get($item-width-maps, $standard-country) {
16 | &.#{$key} {
17 | width: $width;
18 | }
19 | }
20 | }
21 |
22 | @media
23 | only screen and (-webkit-min-device-pixel-ratio: 2),
24 | only screen and ( min--moz-device-pixel-ratio: 2),
25 | only screen and ( -o-min-device-pixel-ratio: 2/1),
26 | only screen and ( min-device-pixel-ratio: 2),
27 | only screen and ( min-resolution: 192dpi),
28 | only screen and ( min-resolution: 2dppx) {
29 | background-size: 5630px 15px;
30 | }
31 |
32 | &.ac {
33 | height: 10px;
34 | background-position: 0px 0px;
35 | }
36 | &.ad {
37 | height: 14px;
38 | background-position: -22px 0px;
39 | }
40 | &.ae {
41 | height: 10px;
42 | background-position: -44px 0px;
43 | }
44 | &.af {
45 | height: 14px;
46 | background-position: -66px 0px;
47 | }
48 | &.ag {
49 | height: 14px;
50 | background-position: -88px 0px;
51 | }
52 | &.ai {
53 | height: 10px;
54 | background-position: -110px 0px;
55 | }
56 | &.al {
57 | height: 15px;
58 | background-position: -132px 0px;
59 | }
60 | &.am {
61 | height: 10px;
62 | background-position: -154px 0px;
63 | }
64 | &.ao {
65 | height: 14px;
66 | background-position: -176px 0px;
67 | }
68 | &.aq {
69 | height: 14px;
70 | background-position: -198px 0px;
71 | }
72 | &.ar {
73 | height: 13px;
74 | background-position: -220px 0px;
75 | }
76 | &.as {
77 | height: 10px;
78 | background-position: -242px 0px;
79 | }
80 | &.at {
81 | height: 14px;
82 | background-position: -264px 0px;
83 | }
84 | &.au {
85 | height: 10px;
86 | background-position: -286px 0px;
87 | }
88 | &.aw {
89 | height: 14px;
90 | background-position: -308px 0px;
91 | }
92 | &.ax {
93 | height: 13px;
94 | background-position: -330px 0px;
95 | }
96 | &.az {
97 | height: 10px;
98 | background-position: -352px 0px;
99 | }
100 | &.ba {
101 | height: 10px;
102 | background-position: -374px 0px;
103 | }
104 | &.bb {
105 | height: 14px;
106 | background-position: -396px 0px;
107 | }
108 | &.bd {
109 | height: 12px;
110 | background-position: -418px 0px;
111 | }
112 | &.be {
113 | height: 15px;
114 | background-position: -440px 0px;
115 | }
116 | &.bf {
117 | height: 14px;
118 | background-position: -460px 0px;
119 | }
120 | &.bg {
121 | height: 12px;
122 | background-position: -482px 0px;
123 | }
124 | &.bh {
125 | height: 12px;
126 | background-position: -504px 0px;
127 | }
128 | &.bi {
129 | height: 12px;
130 | background-position: -526px 0px;
131 | }
132 | &.bj {
133 | height: 14px;
134 | background-position: -548px 0px;
135 | }
136 | &.bl {
137 | height: 14px;
138 | background-position: -570px 0px;
139 | }
140 | &.bm {
141 | height: 10px;
142 | background-position: -592px 0px;
143 | }
144 | &.bn {
145 | height: 10px;
146 | background-position: -614px 0px;
147 | }
148 | &.bo {
149 | height: 14px;
150 | background-position: -636px 0px;
151 | }
152 | &.bq {
153 | height: 14px;
154 | background-position: -658px 0px;
155 | }
156 | &.br {
157 | height: 14px;
158 | background-position: -680px 0px;
159 | }
160 | &.bs {
161 | height: 10px;
162 | background-position: -702px 0px;
163 | }
164 | &.bt {
165 | height: 14px;
166 | background-position: -724px 0px;
167 | }
168 | &.bv {
169 | height: 15px;
170 | background-position: -746px 0px;
171 | }
172 | &.bw {
173 | height: 14px;
174 | background-position: -768px 0px;
175 | }
176 | &.by {
177 | height: 10px;
178 | background-position: -790px 0px;
179 | }
180 | &.bz {
181 | height: 14px;
182 | background-position: -812px 0px;
183 | }
184 | &.ca {
185 | height: 10px;
186 | background-position: -834px 0px;
187 | }
188 | &.cc {
189 | height: 10px;
190 | background-position: -856px 0px;
191 | }
192 | &.cd {
193 | height: 15px;
194 | background-position: -878px 0px;
195 | }
196 | &.cf {
197 | height: 14px;
198 | background-position: -900px 0px;
199 | }
200 | &.cg {
201 | height: 14px;
202 | background-position: -922px 0px;
203 | }
204 | &.ch {
205 | height: 15px;
206 | background-position: -944px 0px;
207 | }
208 | &.ci {
209 | height: 14px;
210 | background-position: -961px 0px;
211 | }
212 | &.ck {
213 | height: 10px;
214 | background-position: -983px 0px;
215 | }
216 | &.cl {
217 | height: 14px;
218 | background-position: -1005px 0px;
219 | }
220 | &.cm {
221 | height: 14px;
222 | background-position: -1027px 0px;
223 | }
224 | &.cn {
225 | height: 14px;
226 | background-position: -1049px 0px;
227 | }
228 | &.co {
229 | height: 14px;
230 | background-position: -1071px 0px;
231 | }
232 | &.cp {
233 | height: 14px;
234 | background-position: -1093px 0px;
235 | }
236 | &.cr {
237 | height: 12px;
238 | background-position: -1115px 0px;
239 | }
240 | &.cu {
241 | height: 10px;
242 | background-position: -1137px 0px;
243 | }
244 | &.cv {
245 | height: 12px;
246 | background-position: -1159px 0px;
247 | }
248 | &.cw {
249 | height: 14px;
250 | background-position: -1181px 0px;
251 | }
252 | &.cx {
253 | height: 10px;
254 | background-position: -1203px 0px;
255 | }
256 | &.cy {
257 | height: 14px;
258 | background-position: -1225px 0px;
259 | }
260 | &.cz {
261 | height: 14px;
262 | background-position: -1247px 0px;
263 | }
264 | &.de {
265 | height: 12px;
266 | background-position: -1269px 0px;
267 | }
268 | &.dg {
269 | height: 10px;
270 | background-position: -1291px 0px;
271 | }
272 | &.dj {
273 | height: 14px;
274 | background-position: -1313px 0px;
275 | }
276 | &.dk {
277 | height: 15px;
278 | background-position: -1335px 0px;
279 | }
280 | &.dm {
281 | height: 10px;
282 | background-position: -1357px 0px;
283 | }
284 | &.do {
285 | height: 13px;
286 | background-position: -1379px 0px;
287 | }
288 | &.dz {
289 | height: 14px;
290 | background-position: -1401px 0px;
291 | }
292 | &.ea {
293 | height: 14px;
294 | background-position: -1423px 0px;
295 | }
296 | &.ec {
297 | height: 14px;
298 | background-position: -1445px 0px;
299 | }
300 | &.ee {
301 | height: 13px;
302 | background-position: -1467px 0px;
303 | }
304 | &.eg {
305 | height: 14px;
306 | background-position: -1489px 0px;
307 | }
308 | &.eh {
309 | height: 10px;
310 | background-position: -1511px 0px;
311 | }
312 | &.er {
313 | height: 10px;
314 | background-position: -1533px 0px;
315 | }
316 | &.es {
317 | height: 14px;
318 | background-position: -1555px 0px;
319 | }
320 | &.et {
321 | height: 10px;
322 | background-position: -1577px 0px;
323 | }
324 | &.eu {
325 | height: 14px;
326 | background-position: -1599px 0px;
327 | }
328 | &.fi {
329 | height: 12px;
330 | background-position: -1621px 0px;
331 | }
332 | &.fj {
333 | height: 10px;
334 | background-position: -1643px 0px;
335 | }
336 | &.fk {
337 | height: 10px;
338 | background-position: -1665px 0px;
339 | }
340 | &.fm {
341 | height: 11px;
342 | background-position: -1687px 0px;
343 | }
344 | &.fo {
345 | height: 15px;
346 | background-position: -1709px 0px;
347 | }
348 | &.fr {
349 | height: 14px;
350 | background-position: -1731px 0px;
351 | }
352 | &.ga {
353 | height: 15px;
354 | background-position: -1753px 0px;
355 | }
356 | &.gb {
357 | height: 10px;
358 | background-position: -1775px 0px;
359 | }
360 | &.gd {
361 | height: 12px;
362 | background-position: -1797px 0px;
363 | }
364 | &.ge {
365 | height: 14px;
366 | background-position: -1819px 0px;
367 | }
368 | &.gf {
369 | height: 14px;
370 | background-position: -1841px 0px;
371 | }
372 | &.gg {
373 | height: 14px;
374 | background-position: -1863px 0px;
375 | }
376 | &.gh {
377 | height: 14px;
378 | background-position: -1885px 0px;
379 | }
380 | &.gi {
381 | height: 10px;
382 | background-position: -1907px 0px;
383 | }
384 | &.gl {
385 | height: 14px;
386 | background-position: -1929px 0px;
387 | }
388 | &.gm {
389 | height: 14px;
390 | background-position: -1951px 0px;
391 | }
392 | &.gn {
393 | height: 14px;
394 | background-position: -1973px 0px;
395 | }
396 | &.gp {
397 | height: 14px;
398 | background-position: -1995px 0px;
399 | }
400 | &.gq {
401 | height: 14px;
402 | background-position: -2017px 0px;
403 | }
404 | &.gr {
405 | height: 14px;
406 | background-position: -2039px 0px;
407 | }
408 | &.gs {
409 | height: 10px;
410 | background-position: -2061px 0px;
411 | }
412 | &.gt {
413 | height: 13px;
414 | background-position: -2083px 0px;
415 | }
416 | &.gu {
417 | height: 11px;
418 | background-position: -2105px 0px;
419 | }
420 | &.gw {
421 | height: 10px;
422 | background-position: -2127px 0px;
423 | }
424 | &.gy {
425 | height: 12px;
426 | background-position: -2149px 0px;
427 | }
428 | &.hk {
429 | height: 14px;
430 | background-position: -2171px 0px;
431 | }
432 | &.hm {
433 | height: 10px;
434 | background-position: -2193px 0px;
435 | }
436 | &.hn {
437 | height: 10px;
438 | background-position: -2215px 0px;
439 | }
440 | &.hr {
441 | height: 10px;
442 | background-position: -2237px 0px;
443 | }
444 | &.ht {
445 | height: 12px;
446 | background-position: -2259px 0px;
447 | }
448 | &.hu {
449 | height: 10px;
450 | background-position: -2281px 0px;
451 | }
452 | &.ic {
453 | height: 14px;
454 | background-position: -2303px 0px;
455 | }
456 | &.id {
457 | height: 14px;
458 | background-position: -2325px 0px;
459 | }
460 | &.ie {
461 | height: 10px;
462 | background-position: -2347px 0px;
463 | }
464 | &.il {
465 | height: 15px;
466 | background-position: -2369px 0px;
467 | }
468 | &.im {
469 | height: 10px;
470 | background-position: -2391px 0px;
471 | }
472 | &.in {
473 | height: 14px;
474 | background-position: -2413px 0px;
475 | }
476 | &.io {
477 | height: 10px;
478 | background-position: -2435px 0px;
479 | }
480 | &.iq {
481 | height: 14px;
482 | background-position: -2457px 0px;
483 | }
484 | &.ir {
485 | height: 12px;
486 | background-position: -2479px 0px;
487 | }
488 | &.is {
489 | height: 15px;
490 | background-position: -2501px 0px;
491 | }
492 | &.it {
493 | height: 14px;
494 | background-position: -2523px 0px;
495 | }
496 | &.je {
497 | height: 12px;
498 | background-position: -2545px 0px;
499 | }
500 | &.jm {
501 | height: 10px;
502 | background-position: -2567px 0px;
503 | }
504 | &.jo {
505 | height: 10px;
506 | background-position: -2589px 0px;
507 | }
508 | &.jp {
509 | height: 14px;
510 | background-position: -2611px 0px;
511 | }
512 | &.ke {
513 | height: 14px;
514 | background-position: -2633px 0px;
515 | }
516 | &.kg {
517 | height: 12px;
518 | background-position: -2655px 0px;
519 | }
520 | &.kh {
521 | height: 13px;
522 | background-position: -2677px 0px;
523 | }
524 | &.ki {
525 | height: 10px;
526 | background-position: -2699px 0px;
527 | }
528 | &.km {
529 | height: 12px;
530 | background-position: -2721px 0px;
531 | }
532 | &.kn {
533 | height: 14px;
534 | background-position: -2743px 0px;
535 | }
536 | &.kp {
537 | height: 10px;
538 | background-position: -2765px 0px;
539 | }
540 | &.kr {
541 | height: 14px;
542 | background-position: -2787px 0px;
543 | }
544 | &.kw {
545 | height: 10px;
546 | background-position: -2809px 0px;
547 | }
548 | &.ky {
549 | height: 10px;
550 | background-position: -2831px 0px;
551 | }
552 | &.kz {
553 | height: 10px;
554 | background-position: -2853px 0px;
555 | }
556 | &.la {
557 | height: 14px;
558 | background-position: -2875px 0px;
559 | }
560 | &.lb {
561 | height: 14px;
562 | background-position: -2897px 0px;
563 | }
564 | &.lc {
565 | height: 10px;
566 | background-position: -2919px 0px;
567 | }
568 | &.li {
569 | height: 12px;
570 | background-position: -2941px 0px;
571 | }
572 | &.lk {
573 | height: 10px;
574 | background-position: -2963px 0px;
575 | }
576 | &.lr {
577 | height: 11px;
578 | background-position: -2985px 0px;
579 | }
580 | &.ls {
581 | height: 14px;
582 | background-position: -3007px 0px;
583 | }
584 | &.lt {
585 | height: 12px;
586 | background-position: -3029px 0px;
587 | }
588 | &.lu {
589 | height: 12px;
590 | background-position: -3051px 0px;
591 | }
592 | &.lv {
593 | height: 10px;
594 | background-position: -3073px 0px;
595 | }
596 | &.ly {
597 | height: 10px;
598 | background-position: -3095px 0px;
599 | }
600 | &.ma {
601 | height: 14px;
602 | background-position: -3117px 0px;
603 | }
604 | &.mc {
605 | height: 15px;
606 | background-position: -3139px 0px;
607 | }
608 | &.md {
609 | height: 10px;
610 | background-position: -3160px 0px;
611 | }
612 | &.me {
613 | height: 10px;
614 | background-position: -3182px 0px;
615 | }
616 | &.mf {
617 | height: 14px;
618 | background-position: -3204px 0px;
619 | }
620 | &.mg {
621 | height: 14px;
622 | background-position: -3226px 0px;
623 | }
624 | &.mh {
625 | height: 11px;
626 | background-position: -3248px 0px;
627 | }
628 | &.mk {
629 | height: 10px;
630 | background-position: -3270px 0px;
631 | }
632 | &.ml {
633 | height: 14px;
634 | background-position: -3292px 0px;
635 | }
636 | &.mm {
637 | height: 14px;
638 | background-position: -3314px 0px;
639 | }
640 | &.mn {
641 | height: 10px;
642 | background-position: -3336px 0px;
643 | }
644 | &.mo {
645 | height: 14px;
646 | background-position: -3358px 0px;
647 | }
648 | &.mp {
649 | height: 10px;
650 | background-position: -3380px 0px;
651 | }
652 | &.mq {
653 | height: 14px;
654 | background-position: -3402px 0px;
655 | }
656 | &.mr {
657 | height: 14px;
658 | background-position: -3424px 0px;
659 | }
660 | &.ms {
661 | height: 10px;
662 | background-position: -3446px 0px;
663 | }
664 | &.mt {
665 | height: 14px;
666 | background-position: -3468px 0px;
667 | }
668 | &.mu {
669 | height: 14px;
670 | background-position: -3490px 0px;
671 | }
672 | &.mv {
673 | height: 14px;
674 | background-position: -3512px 0px;
675 | }
676 | &.mw {
677 | height: 14px;
678 | background-position: -3534px 0px;
679 | }
680 | &.mx {
681 | height: 12px;
682 | background-position: -3556px 0px;
683 | }
684 | &.my {
685 | height: 10px;
686 | background-position: -3578px 0px;
687 | }
688 | &.mz {
689 | height: 14px;
690 | background-position: -3600px 0px;
691 | }
692 | &.na {
693 | height: 14px;
694 | background-position: -3622px 0px;
695 | }
696 | &.nc {
697 | height: 10px;
698 | background-position: -3644px 0px;
699 | }
700 | &.ne {
701 | height: 15px;
702 | background-position: -3666px 0px;
703 | }
704 | &.nf {
705 | height: 10px;
706 | background-position: -3686px 0px;
707 | }
708 | &.ng {
709 | height: 10px;
710 | background-position: -3708px 0px;
711 | }
712 | &.ni {
713 | height: 12px;
714 | background-position: -3730px 0px;
715 | }
716 | &.nl {
717 | height: 14px;
718 | background-position: -3752px 0px;
719 | }
720 | &.no {
721 | height: 15px;
722 | background-position: -3774px 0px;
723 | }
724 | &.np {
725 | height: 15px;
726 | background-position: -3796px 0px;
727 | }
728 | &.nr {
729 | height: 10px;
730 | background-position: -3811px 0px;
731 | }
732 | &.nu {
733 | height: 10px;
734 | background-position: -3833px 0px;
735 | }
736 | &.nz {
737 | height: 10px;
738 | background-position: -3855px 0px;
739 | }
740 | &.om {
741 | height: 10px;
742 | background-position: -3877px 0px;
743 | }
744 | &.pa {
745 | height: 14px;
746 | background-position: -3899px 0px;
747 | }
748 | &.pe {
749 | height: 14px;
750 | background-position: -3921px 0px;
751 | }
752 | &.pf {
753 | height: 14px;
754 | background-position: -3943px 0px;
755 | }
756 | &.pg {
757 | height: 15px;
758 | background-position: -3965px 0px;
759 | }
760 | &.ph {
761 | height: 10px;
762 | background-position: -3987px 0px;
763 | }
764 | &.pk {
765 | height: 14px;
766 | background-position: -4009px 0px;
767 | }
768 | &.pl {
769 | height: 13px;
770 | background-position: -4031px 0px;
771 | }
772 | &.pm {
773 | height: 14px;
774 | background-position: -4053px 0px;
775 | }
776 | &.pn {
777 | height: 10px;
778 | background-position: -4075px 0px;
779 | }
780 | &.pr {
781 | height: 14px;
782 | background-position: -4097px 0px;
783 | }
784 | &.ps {
785 | height: 10px;
786 | background-position: -4119px 0px;
787 | }
788 | &.pt {
789 | height: 14px;
790 | background-position: -4141px 0px;
791 | }
792 | &.pw {
793 | height: 13px;
794 | background-position: -4163px 0px;
795 | }
796 | &.py {
797 | height: 11px;
798 | background-position: -4185px 0px;
799 | }
800 | &.qa {
801 | height: 8px;
802 | background-position: -4207px 0px;
803 | }
804 | &.re {
805 | height: 14px;
806 | background-position: -4229px 0px;
807 | }
808 | &.ro {
809 | height: 14px;
810 | background-position: -4251px 0px;
811 | }
812 | &.rs {
813 | height: 14px;
814 | background-position: -4273px 0px;
815 | }
816 | &.ru {
817 | height: 14px;
818 | background-position: -4295px 0px;
819 | }
820 | &.rw {
821 | height: 14px;
822 | background-position: -4317px 0px;
823 | }
824 | &.sa {
825 | height: 14px;
826 | background-position: -4339px 0px;
827 | }
828 | &.sb {
829 | height: 10px;
830 | background-position: -4361px 0px;
831 | }
832 | &.sc {
833 | height: 10px;
834 | background-position: -4383px 0px;
835 | }
836 | &.sd {
837 | height: 10px;
838 | background-position: -4405px 0px;
839 | }
840 | &.se {
841 | height: 13px;
842 | background-position: -4427px 0px;
843 | }
844 | &.sg {
845 | height: 14px;
846 | background-position: -4449px 0px;
847 | }
848 | &.sh {
849 | height: 10px;
850 | background-position: -4471px 0px;
851 | }
852 | &.si {
853 | height: 10px;
854 | background-position: -4493px 0px;
855 | }
856 | &.sj {
857 | height: 15px;
858 | background-position: -4515px 0px;
859 | }
860 | &.sk {
861 | height: 14px;
862 | background-position: -4537px 0px;
863 | }
864 | &.sl {
865 | height: 14px;
866 | background-position: -4559px 0px;
867 | }
868 | &.sm {
869 | height: 15px;
870 | background-position: -4581px 0px;
871 | }
872 | &.sn {
873 | height: 14px;
874 | background-position: -4603px 0px;
875 | }
876 | &.so {
877 | height: 14px;
878 | background-position: -4625px 0px;
879 | }
880 | &.sr {
881 | height: 14px;
882 | background-position: -4647px 0px;
883 | }
884 | &.ss {
885 | height: 10px;
886 | background-position: -4669px 0px;
887 | }
888 | &.st {
889 | height: 10px;
890 | background-position: -4691px 0px;
891 | }
892 | &.sv {
893 | height: 12px;
894 | background-position: -4713px 0px;
895 | }
896 | &.sx {
897 | height: 14px;
898 | background-position: -4735px 0px;
899 | }
900 | &.sy {
901 | height: 14px;
902 | background-position: -4757px 0px;
903 | }
904 | &.sz {
905 | height: 14px;
906 | background-position: -4779px 0px;
907 | }
908 | &.ta {
909 | height: 10px;
910 | background-position: -4801px 0px;
911 | }
912 | &.tc {
913 | height: 10px;
914 | background-position: -4823px 0px;
915 | }
916 | &.td {
917 | height: 14px;
918 | background-position: -4845px 0px;
919 | }
920 | &.tf {
921 | height: 14px;
922 | background-position: -4867px 0px;
923 | }
924 | &.tg {
925 | height: 13px;
926 | background-position: -4889px 0px;
927 | }
928 | &.th {
929 | height: 14px;
930 | background-position: -4911px 0px;
931 | }
932 | &.tj {
933 | height: 10px;
934 | background-position: -4933px 0px;
935 | }
936 | &.tk {
937 | height: 10px;
938 | background-position: -4955px 0px;
939 | }
940 | &.tl {
941 | height: 10px;
942 | background-position: -4977px 0px;
943 | }
944 | &.tm {
945 | height: 14px;
946 | background-position: -4999px 0px;
947 | }
948 | &.tn {
949 | height: 14px;
950 | background-position: -5021px 0px;
951 | }
952 | &.to {
953 | height: 10px;
954 | background-position: -5043px 0px;
955 | }
956 | &.tr {
957 | height: 14px;
958 | background-position: -5065px 0px;
959 | }
960 | &.tt {
961 | height: 12px;
962 | background-position: -5087px 0px;
963 | }
964 | &.tv {
965 | height: 10px;
966 | background-position: -5109px 0px;
967 | }
968 | &.tw {
969 | height: 14px;
970 | background-position: -5131px 0px;
971 | }
972 | &.tz {
973 | height: 14px;
974 | background-position: -5153px 0px;
975 | }
976 | &.ua {
977 | height: 14px;
978 | background-position: -5175px 0px;
979 | }
980 | &.ug {
981 | height: 14px;
982 | background-position: -5197px 0px;
983 | }
984 | &.um {
985 | height: 11px;
986 | background-position: -5219px 0px;
987 | }
988 | &.us {
989 | height: 11px;
990 | background-position: -5241px 0px;
991 | }
992 | &.uy {
993 | height: 14px;
994 | background-position: -5263px 0px;
995 | }
996 | &.uz {
997 | height: 10px;
998 | background-position: -5285px 0px;
999 | }
1000 | &.va {
1001 | height: 15px;
1002 | background-position: -5307px 0px;
1003 | }
1004 | &.vc {
1005 | height: 14px;
1006 | background-position: -5324px 0px;
1007 | }
1008 | &.ve {
1009 | height: 14px;
1010 | background-position: -5346px 0px;
1011 | }
1012 | &.vg {
1013 | height: 10px;
1014 | background-position: -5368px 0px;
1015 | }
1016 | &.vi {
1017 | height: 14px;
1018 | background-position: -5390px 0px;
1019 | }
1020 | &.vn {
1021 | height: 14px;
1022 | background-position: -5412px 0px;
1023 | }
1024 | &.vu {
1025 | height: 12px;
1026 | background-position: -5434px 0px;
1027 | }
1028 | &.wf {
1029 | height: 14px;
1030 | background-position: -5456px 0px;
1031 | }
1032 | &.ws {
1033 | height: 10px;
1034 | background-position: -5478px 0px;
1035 | }
1036 | &.xk {
1037 | height: 15px;
1038 | background-position: -5500px 0px;
1039 | }
1040 | &.ye {
1041 | height: 14px;
1042 | background-position: -5522px 0px;
1043 | }
1044 | &.yt {
1045 | height: 14px;
1046 | background-position: -5544px 0px;
1047 | }
1048 | &.za {
1049 | height: 14px;
1050 | background-position: -5566px 0px;
1051 | }
1052 | &.zm {
1053 | height: 14px;
1054 | background-position: -5588px 0px;
1055 | }
1056 | &.zw {
1057 | height: 10px;
1058 | background-position: -5610px 0px;
1059 | }
1060 | }
1061 |
--------------------------------------------------------------------------------