mui-tel-input 7.0.0 → 8.0.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.
Files changed (36) hide show
  1. package/dist/components/Flag/Flag.d.ts +9 -0
  2. package/dist/components/Flag/Flag.styled.d.ts +4 -0
  3. package/dist/components/FlagButton/FlagButton.d.ts +16 -0
  4. package/dist/components/FlagButton/FlagButton.styled.d.ts +4 -0
  5. package/dist/components/FlagMenuItem/FlagMenuItem.d.ts +16 -0
  6. package/dist/components/FlagMenuItem/FlagsMenuItem.styled.d.ts +5 -0
  7. package/dist/components/FlagsMenu/FlagsMenu.d.ts +17 -0
  8. package/dist/index.types.d.ts +47 -0
  9. package/dist/mui-tel-input.es.js +764 -742
  10. package/dist/shared/constants/continents.d.ts +7 -0
  11. package/dist/shared/constants/countries.d.ts +5 -0
  12. package/dist/shared/constants/flags.d.ts +6 -0
  13. package/dist/shared/constants/lang.d.ts +1 -0
  14. package/dist/shared/helpers/__tests__/array.test.d.ts +1 -0
  15. package/dist/shared/helpers/__tests__/country.test.d.ts +1 -0
  16. package/dist/shared/helpers/__tests__/intl.test.d.ts +0 -0
  17. package/dist/shared/helpers/__tests__/string.test.d.ts +0 -0
  18. package/dist/shared/helpers/__tests__/valid-phone-number.test.d.ts +0 -0
  19. package/dist/shared/helpers/array.d.ts +2 -0
  20. package/dist/shared/helpers/country.d.ts +18 -0
  21. package/dist/shared/helpers/dom.d.ts +1 -0
  22. package/dist/shared/helpers/flag.d.ts +14 -0
  23. package/dist/shared/helpers/intl.d.ts +1 -0
  24. package/dist/shared/helpers/log.d.ts +1 -0
  25. package/dist/shared/helpers/object.d.ts +2 -0
  26. package/dist/shared/helpers/ref.d.ts +2 -0
  27. package/dist/shared/helpers/string.d.ts +1 -0
  28. package/dist/shared/helpers/valid-phone-number.d.ts +7 -0
  29. package/dist/shared/hooks/__tests__/useMissmatch.test.d.ts +1 -0
  30. package/dist/shared/hooks/useAnchor.d.ts +10 -0
  31. package/dist/shared/hooks/useEvents.d.ts +10 -0
  32. package/dist/shared/hooks/useMissmatchProps.d.ts +2 -0
  33. package/dist/shared/hooks/usePhoneDigits.d.ts +34 -0
  34. package/dist/testUtils/index.d.ts +11 -0
  35. package/package.json +34 -34
  36. package/dist/index.d.ts +0 -770
@@ -0,0 +1,7 @@
1
+ import { MuiTelInputCountry } from './countries';
2
+ export type MuiTelInputContinent = 'EU' | 'AS' | 'NA' | 'SA' | 'OC' | 'AF';
3
+ type Continents = {
4
+ [key in MuiTelInputContinent]: MuiTelInputCountry[];
5
+ };
6
+ export declare const CONTINENTS: Continents;
7
+ export {};
@@ -0,0 +1,5 @@
1
+ import { MetadataJson } from 'libphonenumber-js';
2
+ export declare const COUNTRIES: MetadataJson['countries'];
3
+ export declare const ISO_CODES: import('libphonenumber-js').CountryCode[];
4
+ export type MuiTelInputCountry = (typeof ISO_CODES)[number];
5
+ export declare const DEFAULT_ISO_CODE: MuiTelInputCountry;
@@ -0,0 +1,6 @@
1
+ type Flags = {
2
+ AC: string;
3
+ TA: string;
4
+ };
5
+ export declare const FLAGS_SVG: Flags;
6
+ export {};
@@ -0,0 +1 @@
1
+ export declare const DEFAULT_LANG = "en";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ export declare function matchIsArray(value: unknown, filled?: boolean): value is unknown[];
2
+ export declare function getFirstIntersection<T extends unknown[]>(arrayA: T, arrayB: T): T[number] | null;
@@ -0,0 +1,18 @@
1
+ import { MuiTelInputContinent } from '../constants/continents';
2
+ import { MuiTelInputCountry } from '../constants/countries';
3
+ type FilterCountriesOptions = {
4
+ onlyCountries?: readonly MuiTelInputCountry[];
5
+ excludedCountries?: readonly MuiTelInputCountry[];
6
+ preferredCountries?: readonly MuiTelInputCountry[];
7
+ continents?: readonly MuiTelInputContinent[];
8
+ };
9
+ export declare function getCallingCodeOfCountry(isoCode: MuiTelInputCountry): string;
10
+ export declare function getValidCountry(country?: MuiTelInputCountry): MuiTelInputCountry;
11
+ export declare function sortPreferredCountries(countries: readonly MuiTelInputCountry[], preferredCountries: readonly MuiTelInputCountry[]): readonly MuiTelInputCountry[];
12
+ export declare function getCountriesOfContinents(continents: readonly MuiTelInputContinent[]): readonly MuiTelInputCountry[];
13
+ export declare function getOnlyCountries(countries: readonly MuiTelInputCountry[], onlyCountries: readonly MuiTelInputCountry[]): readonly MuiTelInputCountry[];
14
+ export declare function excludeCountries(countries: readonly MuiTelInputCountry[], excludedCountries?: readonly MuiTelInputCountry[]): readonly MuiTelInputCountry[];
15
+ export declare function sortAlphabeticallyCountryCodes(countryCodes: readonly MuiTelInputCountry[], displayNames: Intl.DisplayNames): readonly MuiTelInputCountry[];
16
+ export declare function filterCountries(countries: readonly MuiTelInputCountry[], displayNames: Intl.DisplayNames, options: FilterCountriesOptions): readonly MuiTelInputCountry[];
17
+ export declare function matchContinentsIncludeCountry(continents: MuiTelInputContinent[], isoCode: MuiTelInputCountry): boolean;
18
+ export {};
@@ -0,0 +1 @@
1
+ export declare function putCursorAtEndOfInput(inputElement: HTMLInputElement): void;
@@ -0,0 +1,14 @@
1
+ import { GetFlagElement, MuiTelInputCountry } from '../../index.types';
2
+ export declare const flagImgClass = "MuiTelInput-FlagImg";
3
+ export declare const getDefaultImgProps: ({ isoCode, countryName }: {
4
+ isoCode: MuiTelInputCountry;
5
+ countryName: string;
6
+ }) => {
7
+ src: string;
8
+ loading: "lazy";
9
+ width: number;
10
+ alt: string;
11
+ className: string;
12
+ };
13
+ export declare const getDefaultFlagElement: GetFlagElement;
14
+ export declare const defaultUnknownFlagElement: import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare function getDisplayNames(lang?: string): Intl.DisplayNames;
@@ -0,0 +1 @@
1
+ export declare function log(...args: Parameters<Console['error']>): void;
@@ -0,0 +1,2 @@
1
+ export declare function matchIsObject(value: unknown): value is object;
2
+ export declare const getKeys: <T>(object: T) => (keyof T)[];
@@ -0,0 +1,2 @@
1
+ import { default as React } from 'react';
2
+ export declare function refToRefs(refs: (React.Ref<unknown> | undefined)[]): (refInstance: unknown) => void;
@@ -0,0 +1 @@
1
+ export declare function removeOccurrence(text: string, part: string | RegExp): string;
@@ -0,0 +1,7 @@
1
+ import { MuiTelInputContinent } from 'index.types';
2
+ import { MuiTelInputCountry } from '../constants/countries';
3
+ export declare function matchIsValidTel(text: string, options?: {
4
+ excludedCountries?: MuiTelInputCountry[];
5
+ onlyCountries?: MuiTelInputCountry[];
6
+ continents?: MuiTelInputContinent[];
7
+ }): boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import { default as React } from 'react';
2
+ import { MuiTelInputProps } from '../../index.types';
3
+ type Options = Pick<MuiTelInputProps, 'disableDropdown' | 'disabled'>;
4
+ export declare function useAnchor({ disabled, disableDropdown }: Options): {
5
+ anchorRef: React.RefObject<HTMLDivElement | null>;
6
+ anchorEl: HTMLDivElement | null;
7
+ openMenu: () => void;
8
+ closeMenu: () => void;
9
+ };
10
+ export {};
@@ -0,0 +1,10 @@
1
+ import { TextFieldProps } from '@mui/material';
2
+ type Options = Pick<TextFieldProps, 'onDoubleClick' | 'onCopy' | 'onFocus'> & {
3
+ inputRef: React.MutableRefObject<HTMLInputElement | null>;
4
+ };
5
+ export declare function useEvents({ onDoubleClick, onCopy, onFocus, inputRef }: Options): {
6
+ handleDoubleClick: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
7
+ handleCopy: (event: React.ClipboardEvent<HTMLInputElement>) => void;
8
+ handleFocus: (event: React.FocusEvent<HTMLInputElement, Element>) => void;
9
+ };
10
+ export {};
@@ -0,0 +1,2 @@
1
+ import { MuiTelInputProps } from '../../index.types';
2
+ export declare function useMismatchProps(props: MuiTelInputProps): void;
@@ -0,0 +1,34 @@
1
+ import { default as React } from 'react';
2
+ import { MuiTelInputContinent } from '../constants/continents';
3
+ import { MuiTelInputCountry } from '../constants/countries';
4
+ import { MuiTelInputInfo, MuiTelInputReason } from '../../index.types';
5
+ type UsePhoneDigitsParams = {
6
+ value: string;
7
+ onChange?: (value: string, info: MuiTelInputInfo) => void;
8
+ defaultCountry?: MuiTelInputCountry;
9
+ forceCallingCode: boolean;
10
+ disableFormatting: boolean;
11
+ excludedCountries?: MuiTelInputCountry[];
12
+ onlyCountries?: MuiTelInputCountry[];
13
+ continents?: MuiTelInputContinent[];
14
+ };
15
+ type State = {
16
+ inputValue: string;
17
+ isoCode: MuiTelInputCountry | null;
18
+ };
19
+ type GetInitialStateParams = {
20
+ defaultCountry?: MuiTelInputCountry;
21
+ initialValue: string;
22
+ forceCallingCode: boolean;
23
+ disableFormatting: boolean;
24
+ };
25
+ export declare function getInitialState(params: GetInitialStateParams): State;
26
+ export default function usePhoneDigits({ value, onChange, defaultCountry, onlyCountries, excludedCountries, continents, disableFormatting, forceCallingCode }: UsePhoneDigitsParams): {
27
+ inputValue: string;
28
+ isoCode: import('libphonenumber-js').CountryCode | null;
29
+ onInputChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
30
+ onCountryChange: (newCountry: MuiTelInputCountry) => void;
31
+ inputRef: React.RefObject<HTMLInputElement | null>;
32
+ buildInputInfo: (reason: MuiTelInputReason) => MuiTelInputInfo;
33
+ };
34
+ export {};
@@ -0,0 +1,11 @@
1
+ import { MuiTelInputCountry } from '../shared/constants/countries';
2
+ export declare function getInputElement(): HTMLInputElement;
3
+ export declare function getButtonElement(): HTMLButtonElement;
4
+ export declare function expectButtonIsFlagOf(isoCode: MuiTelInputCountry): void;
5
+ export declare function expectButtonNotIsFlagOf(isoCode: MuiTelInputCountry): void;
6
+ export declare function expectButtonContainsCallingCode(callingCode: string): void;
7
+ export declare function typeInInputElement(value: string): Promise<{
8
+ result: string;
9
+ }>;
10
+ export declare function selectCountry(isoCode: MuiTelInputCountry): void;
11
+ export declare function closeFlagsMenu(): Promise<void>;
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "url": "https://github.com/viclafouch/mui-tel-input/issues"
8
8
  },
9
9
  "homepage": "https://viclafouch.github.io/mui-tel-input",
10
- "version": "7.0.0",
10
+ "version": "8.0.0",
11
11
  "files": [
12
12
  "dist"
13
13
  ],
@@ -61,9 +61,9 @@
61
61
  "@emotion/react": "^11.13.0",
62
62
  "@emotion/styled": "^11.13.0",
63
63
  "@mui/material": "^6.0.0",
64
- "@types/react": "^18.0.0",
65
- "react": "^18.0.0",
66
- "react-dom": "^18.0.0"
64
+ "@types/react": "^18.0.0 || ^19.0.0",
65
+ "react": "^18.0.0 || ^19.0.0",
66
+ "react-dom": "^18.0.0 || ^19.0.0"
67
67
  },
68
68
  "peerDependenciesMeta": {
69
69
  "@types/react": {
@@ -71,43 +71,43 @@
71
71
  }
72
72
  },
73
73
  "dependencies": {
74
- "@types/node": "^22.9.0",
75
- "libphonenumber-js": "^1.11.14"
74
+ "@types/node": "^22.13.7",
75
+ "libphonenumber-js": "^1.11.19"
76
76
  },
77
77
  "devDependencies": {
78
- "@babel/core": "^7.26.0",
79
- "@emotion/react": "^11.13.3",
80
- "@emotion/styled": "^11.13.0",
81
- "@mui/material": "^6.1.6",
82
- "@storybook/addon-actions": "^8.4.2",
83
- "@storybook/addon-essentials": "^8.4.2",
84
- "@storybook/addon-interactions": "^8.4.2",
85
- "@storybook/addon-links": "^8.4.2",
86
- "@storybook/react": "^8.4.2",
87
- "@storybook/react-vite": "^8.4.2",
88
- "@storybook/test": "^8.4.2",
78
+ "@babel/core": "^7.26.9",
79
+ "@emotion/react": "^11.14.0",
80
+ "@emotion/styled": "^11.14.0",
81
+ "@mui/material": "^6.4.6",
82
+ "@storybook/addon-actions": "^8.6.2",
83
+ "@storybook/addon-essentials": "^8.6.2",
84
+ "@storybook/addon-interactions": "^8.6.2",
85
+ "@storybook/addon-links": "^8.6.2",
86
+ "@storybook/react": "^8.6.2",
87
+ "@storybook/react-vite": "^8.6.2",
88
+ "@storybook/test": "^8.6.2",
89
89
  "@testing-library/dom": "^10.4.0",
90
90
  "@testing-library/jest-dom": "^6.6.3",
91
- "@testing-library/react": "^16.0.1",
92
- "@testing-library/user-event": "^14.5.2",
93
- "@types/react": "^18.3.12",
94
- "@types/react-dom": "^18.3.1",
95
- "@viclafouch/eslint-config-viclafouch": "^4.16.0",
96
- "@vitejs/plugin-react": "^4.3.3",
91
+ "@testing-library/react": "^16.2.0",
92
+ "@testing-library/user-event": "^14.6.1",
93
+ "@types/react": "^19.0.10",
94
+ "@types/react-dom": "^19.0.4",
95
+ "@viclafouch/eslint-config-viclafouch": "4.16.0",
96
+ "@vitejs/plugin-react": "^4.3.4",
97
97
  "babel-loader": "^9.2.1",
98
98
  "eslint": "^8.56.0",
99
- "husky": "^9.1.6",
100
- "jsdom": "^25.0.1",
101
- "prettier": "^3.3.3",
102
- "react": "^18.3.1",
103
- "react-dom": "^18.3.1",
99
+ "husky": "^9.1.7",
100
+ "jsdom": "^26.0.0",
101
+ "prettier": "^3.4.2",
102
+ "react": "^19.0.0",
103
+ "react-dom": "^19.0.0",
104
104
  "rollup-plugin-peer-deps-external": "^2.2.4",
105
105
  "standard-version": "^9.5.0",
106
- "storybook": "^8.4.2",
107
- "typescript": "^5.6.3",
108
- "vite": "^5.4.11",
109
- "vite-aliases": "^0.11.7",
110
- "vite-plugin-dts": "^4.3.0",
111
- "vitest": "^2.1.4"
106
+ "storybook": "^8.6.2",
107
+ "typescript": "^5.8.2",
108
+ "vite": "6.2.0",
109
+ "vite-aliases": "^0.11.8",
110
+ "vite-plugin-dts": "^4.5.1",
111
+ "vitest": "^3.0.7"
112
112
  }
113
113
  }