svelte-tel-input 4.0.1 → 4.0.2
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.
- package/dist/components/input/TelInput.svelte +5 -3
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/types/index.d.ts +5 -5
- package/dist/utils/{directives/countryHelpers.d.ts → countryHelpers.d.ts} +1 -1
- package/dist/utils/{directives/countryHelpers.js → countryHelpers.js} +1 -1
- package/dist/utils/directives/telInputAction.js +2 -2
- package/dist/utils/helpers.js +1 -1
- package/dist/utils/index.d.ts +1 -3
- package/dist/utils/index.js +1 -3
- package/package.json +2 -2
- package/dist/utils/directives/clickOutsideAction.d.ts +0 -3
- package/dist/utils/directives/clickOutsideAction.js +0 -18
- /package/dist/utils/{directives/cursorPosition.d.ts → cursorPosition.d.ts} +0 -0
- /package/dist/utils/{directives/cursorPosition.js → cursorPosition.js} +0 -0
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { onMount, untrack } from 'svelte';
|
|
3
3
|
import { ParseError } from 'libphonenumber-js/max';
|
|
4
|
-
import { generatePlaceholder
|
|
4
|
+
import { generatePlaceholder } from '../../utils/index.js';
|
|
5
|
+
import { parsePhoneInput } from '../../utils/helpers.js';
|
|
6
|
+
import { telInputAction } from '../../utils/directives/telInputAction.js';
|
|
7
|
+
import { getCountry, guessCountryByPartialNumber } from '../../utils/countryHelpers.js';
|
|
5
8
|
import type { CountryCode, TelInputOptions, Props, ValidationError } from '../../types';
|
|
6
|
-
import { getCountry, guessCountryByPartialNumber } from '../../utils/directives/countryHelpers';
|
|
7
9
|
|
|
8
10
|
const defaultOptions = {
|
|
9
11
|
autoPlaceholder: true,
|
|
@@ -31,7 +33,7 @@
|
|
|
31
33
|
defaultCountry = null,
|
|
32
34
|
detailedValue = $bindable(null),
|
|
33
35
|
valid = $bindable(true),
|
|
34
|
-
validationError = $bindable<ValidationError
|
|
36
|
+
validationError = $bindable<Readonly<ValidationError>>(null),
|
|
35
37
|
options = defaultOptions,
|
|
36
38
|
el = $bindable(undefined),
|
|
37
39
|
'aria-invalid': ariaInvalidProp = undefined,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { default as TelInput } from './components/input/TelInput.svelte';
|
|
2
|
-
export {
|
|
3
|
-
export { parsePhoneNumberWithError, ParseError } from 'libphonenumber-js/max';
|
|
2
|
+
export { parse, normalizeToE164, pickCountries } from './utils/index.js';
|
|
4
3
|
export { countries } from './assets/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { default as TelInput } from './components/input/TelInput.svelte';
|
|
2
|
-
export {
|
|
3
|
-
export { parsePhoneNumberWithError, ParseError } from 'libphonenumber-js/max';
|
|
2
|
+
export { parse, normalizeToE164, pickCountries } from './utils/index.js';
|
|
4
3
|
export { countries } from './assets/index.js';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CountryCode } from 'libphonenumber-js';
|
|
2
2
|
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
3
3
|
|
|
4
4
|
export interface Country {
|
|
@@ -38,7 +38,7 @@ export interface DetailedValue {
|
|
|
38
38
|
uri: string | null;
|
|
39
39
|
e164: string | null;
|
|
40
40
|
/** Granular validation error when `isValid` is `false`. */
|
|
41
|
-
validationError
|
|
41
|
+
validationError: ValidationError;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
@@ -133,7 +133,7 @@ export interface Props extends HTMLInputAttributes {
|
|
|
133
133
|
/** Validity of the input based on the config settings. */
|
|
134
134
|
valid?: boolean;
|
|
135
135
|
/** The reason the current value is invalid, or `null` when valid. */
|
|
136
|
-
validationError?: ValidationError
|
|
136
|
+
validationError?: Readonly<ValidationError>;
|
|
137
137
|
/** You can turn on and off certain features by this object */
|
|
138
138
|
options?: TelInputOptions;
|
|
139
139
|
/** Binding to the underlying `<input>` element */
|
|
@@ -148,7 +148,7 @@ export interface Props extends HTMLInputAttributes {
|
|
|
148
148
|
* @param newValidity The new validity state.
|
|
149
149
|
* @param error The validation error type.
|
|
150
150
|
*/
|
|
151
|
-
onValidityChange?: (newValidity: boolean, error: ValidationError) => void;
|
|
151
|
+
onValidityChange?: (newValidity: boolean, error: Readonly<ValidationError>) => void;
|
|
152
152
|
/**
|
|
153
153
|
* Callback fired when the value or details change.
|
|
154
154
|
* @param newValue The new E164 value.
|
|
@@ -166,4 +166,4 @@ export interface Props extends HTMLInputAttributes {
|
|
|
166
166
|
onLoad?: () => void;
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
export type {
|
|
169
|
+
export type { CountryCode };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { countries as normalizedCountries } from '
|
|
1
|
+
import { countries as normalizedCountries } from '../assets/index.js';
|
|
2
2
|
export const getCountry = ({ field, value, countries = normalizedCountries }) => {
|
|
3
3
|
if (['priority'].includes(field)) {
|
|
4
4
|
throw new Error(`Field "${field}" is not supported`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getCountry } from '
|
|
1
|
+
import { getCountry } from '../countryHelpers.js';
|
|
2
2
|
import { parsePhoneInput } from '../helpers.js';
|
|
3
|
-
import { calculateCursorPosition } from '
|
|
3
|
+
import { calculateCursorPosition } from '../cursorPosition.js';
|
|
4
4
|
let inputState = null;
|
|
5
5
|
const normalizeUserInput = (input) => {
|
|
6
6
|
let value = '';
|
package/dist/utils/helpers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AsYouType, getExampleNumber, formatIncompletePhoneNumber, validatePhoneNumberLength } from 'libphonenumber-js/max';
|
|
2
2
|
import { examplePhoneNumbers, countries } from '../assets/index.js';
|
|
3
|
-
import { getCountry } from './
|
|
3
|
+
import { getCountry } from './countryHelpers.js';
|
|
4
4
|
const whiteSpaceRegex = new RegExp('[\\t\\n\\v\\f\\r \\u00a0\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u200b\\u2028\\u2029\\u3000]', 'g');
|
|
5
5
|
const plusSignRegex = new RegExp('\\+', 'g');
|
|
6
6
|
export const generatePlaceholder = (country, { spaces } = {
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
export { generatePlaceholder,
|
|
2
|
-
export * from './directives/clickOutsideAction.js';
|
|
3
|
-
export * from './directives/telInputAction.js';
|
|
1
|
+
export { generatePlaceholder, parse, normalizeToE164, pickCountries } from './helpers.js';
|
package/dist/utils/index.js
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
export { generatePlaceholder,
|
|
2
|
-
export * from './directives/clickOutsideAction.js';
|
|
3
|
-
export * from './directives/telInputAction.js';
|
|
1
|
+
export { generatePlaceholder, parse, normalizeToE164, pickCountries } from './helpers.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-tel-input",
|
|
3
3
|
"description": "svelte-tel-input",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.2",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/gyurielf/svelte-tel-input.git"
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"micromatch": "^4.0.8",
|
|
48
48
|
"postcss": "^8.5.8",
|
|
49
49
|
"publint": "^0.3.18",
|
|
50
|
-
"svelte": "^5.
|
|
50
|
+
"svelte": "^5.55.0",
|
|
51
51
|
"svelte-check": "^4.4.5",
|
|
52
52
|
"svelte2tsx": "^0.7.52",
|
|
53
53
|
"tailwindcss": "^4.2.2",
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export const clickOutsideAction = (node, handler, skipPrevented = true) => {
|
|
2
|
-
const handleClick = async (event) => {
|
|
3
|
-
if (skipPrevented) {
|
|
4
|
-
if (!node.contains(event.target) && !event.defaultPrevented)
|
|
5
|
-
handler();
|
|
6
|
-
}
|
|
7
|
-
else {
|
|
8
|
-
if (!node.contains(event.target))
|
|
9
|
-
handler();
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
document.addEventListener('click', handleClick, true);
|
|
13
|
-
return {
|
|
14
|
-
destroy() {
|
|
15
|
-
document.removeEventListener('click', handleClick, true);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
};
|
|
File without changes
|
|
File without changes
|