svelte-tel-input 0.3.0 → 0.4.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/CHANGELOG.md +46 -0
- package/LICENSE.md +21 -0
- package/README.md +14 -8
- package/assets/countries.d.ts +2 -0
- package/{src/lib/assets/countries.ts → assets/countries.js} +0 -2
- package/assets/regions.d.ts +2 -0
- package/{src/lib/assets/regions.ts → assets/regions.js} +0 -2
- package/components/Input/SvelteTelInput.svelte +23 -0
- package/components/Input/SvelteTelInput.svelte.d.ts +14 -0
- package/{src/lib/components → components}/Select/CountrySelect.svelte +2 -3
- package/components/Select/CountrySelect.svelte.d.ts +14 -0
- package/{src/lib/components → components}/Select/RegionSelect.svelte +2 -3
- package/components/Select/RegionSelect.svelte.d.ts +14 -0
- package/{src/lib/index.ts → index.d.ts} +0 -0
- package/index.js +2 -0
- package/models/enums/PhoneType.enum.d.ts +4 -0
- package/models/enums/PhoneType.enum.js +5 -0
- package/{src/lib/models/enums/index.ts → models/enums/index.d.ts} +0 -0
- package/models/enums/index.js +1 -0
- package/{src/lib/models/index.ts → models/index.d.ts} +0 -0
- package/models/index.js +1 -0
- package/{src/lib/models/interfaces/Select.interface.ts → models/interfaces/Select.interface.d.ts} +0 -0
- package/models/interfaces/Select.interface.js +1 -0
- package/models/types/DynamicSvelteComponent.type.d.ts +8 -0
- package/models/types/DynamicSvelteComponent.type.js +16 -0
- package/{src/lib/models/types/Select.type.ts → models/types/Select.type.d.ts} +1 -2
- package/models/types/Select.type.js +1 -0
- package/package.json +159 -152
- package/stores/index.d.ts +11 -0
- package/{src/lib/stores/index.ts → stores/index.js} +6 -10
- package/utils/directives/clickOutsideAction.d.ts +3 -0
- package/utils/directives/clickOutsideAction.js +9 -0
- package/utils/simulator.d.ts +1 -0
- package/utils/simulator.js +5 -0
- package/utils/typeCheck.d.ts +4 -0
- package/utils/typeCheck.js +11 -0
- package/.changeset/config.json +0 -9
- package/.editorconfig +0 -13
- package/.eslintignore +0 -10
- package/.eslintrc.cjs +0 -30
- package/.github/workflows/lint.yml +0 -12
- package/.github/workflows/release.yml +0 -49
- package/.husky/pre-commit +0 -4
- package/.prettierignore +0 -10
- package/.prettierrc.cjs +0 -6
- package/babel.config.cjs +0 -12
- package/docker-compose.yml +0 -16
- package/docs/_index.md +0 -1
- package/jest.config.cjs +0 -21
- package/postcss.config.cjs +0 -21
- package/scripts/changelog-github-custom.cjs +0 -104
- package/scripts/changelog-github-custom.test.ts +0 -136
- package/scripts/changelog-github-custom.ts +0 -127
- package/src/app.css +0 -4
- package/src/app.html +0 -13
- package/src/global.d.ts +0 -1
- package/src/hooks.ts +0 -9
- package/src/lib/components/Input/SvelteTelInput.svelte +0 -29
- package/src/lib/components/LazyLoad/LazyLoad.svelte +0 -23
- package/src/lib/models/enums/PhoneType.enum.ts +0 -4
- package/src/lib/models/types/DynamicSvelteComponent.type.ts +0 -9
- package/src/lib/utils/directives/clickOutsideAction.ts +0 -13
- package/src/lib/utils/simulator.ts +0 -5
- package/src/lib/utils/typeCheck.ts +0 -17
- package/src/routes/__layout.svelte +0 -11
- package/src/routes/index.svelte +0 -22
- package/static/favicon.ico +0 -0
- package/static/robots.txt +0 -3
- package/svelte.config.js +0 -28
- package/tailwind.config.cjs +0 -10
- package/tsconfig.json +0 -32
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import type { ChangelogFunctions } from '@changesets/types/dist/declarations/src/index';
|
|
2
|
-
import { config } from 'dotenv';
|
|
3
|
-
import { getInfo, getInfoFromPullRequest } from '@changesets/get-github-info';
|
|
4
|
-
|
|
5
|
-
config();
|
|
6
|
-
|
|
7
|
-
const changelogFunctions: ChangelogFunctions = {
|
|
8
|
-
getDependencyReleaseLine: async (changesets, dependenciesUpdated, options) => {
|
|
9
|
-
if (!options.repo) {
|
|
10
|
-
throw new Error(
|
|
11
|
-
'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]'
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
if (dependenciesUpdated.length === 0) return '';
|
|
15
|
-
|
|
16
|
-
const changesetLink = `- Updated dependencies [${(
|
|
17
|
-
await Promise.all(
|
|
18
|
-
changesets.map(async (cs) => {
|
|
19
|
-
if (cs.commit) {
|
|
20
|
-
const { links } = await getInfo({
|
|
21
|
-
repo: options.repo,
|
|
22
|
-
commit: cs.commit
|
|
23
|
-
});
|
|
24
|
-
return links.commit;
|
|
25
|
-
}
|
|
26
|
-
})
|
|
27
|
-
)
|
|
28
|
-
)
|
|
29
|
-
.filter((_) => _)
|
|
30
|
-
.join(', ')}]:`;
|
|
31
|
-
|
|
32
|
-
const updatedDepenenciesList = dependenciesUpdated.map(
|
|
33
|
-
(dependency) => ` - ${dependency.name}@${dependency.newVersion}`
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
return [changesetLink, ...updatedDepenenciesList].join('\n');
|
|
37
|
-
},
|
|
38
|
-
getReleaseLine: async (changeset, type, options) => {
|
|
39
|
-
if (!options || !options.repo) {
|
|
40
|
-
throw new Error(
|
|
41
|
-
'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]'
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
let prFromSummary: number | undefined;
|
|
46
|
-
let commitFromSummary: string | undefined;
|
|
47
|
-
const usersFromSummary: string[] = [];
|
|
48
|
-
|
|
49
|
-
const replacedChangelog = changeset.summary
|
|
50
|
-
.replace(/^\s*(?:pr|pull|pull\s+request):\s*#?(\d+)/im, (_, pr) => {
|
|
51
|
-
const num = Number(pr);
|
|
52
|
-
if (!isNaN(num)) prFromSummary = num;
|
|
53
|
-
return '';
|
|
54
|
-
})
|
|
55
|
-
.replace(/^\s*commit:\s*([^\s]+)/im, (_, commit) => {
|
|
56
|
-
commitFromSummary = commit;
|
|
57
|
-
return '';
|
|
58
|
-
})
|
|
59
|
-
.replace(/^\s*(?:author|user):\s*@?([^\s]+)/gim, (_, user) => {
|
|
60
|
-
usersFromSummary.push(user);
|
|
61
|
-
return '';
|
|
62
|
-
})
|
|
63
|
-
.trim();
|
|
64
|
-
|
|
65
|
-
const [firstLine, ...futureLines] = replacedChangelog.split('\n').map((l) => l.trimEnd());
|
|
66
|
-
|
|
67
|
-
const links = await (async () => {
|
|
68
|
-
if (prFromSummary !== undefined) {
|
|
69
|
-
let { links } = await getInfoFromPullRequest({
|
|
70
|
-
repo: options.repo,
|
|
71
|
-
pull: prFromSummary
|
|
72
|
-
});
|
|
73
|
-
if (commitFromSummary) {
|
|
74
|
-
links = {
|
|
75
|
-
...links,
|
|
76
|
-
commit: `[\`${commitFromSummary}\`](https://github.com/${options.repo}/commit/${commitFromSummary})`
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
return links;
|
|
80
|
-
}
|
|
81
|
-
const commitToFetchFrom = commitFromSummary || changeset.commit;
|
|
82
|
-
if (commitToFetchFrom) {
|
|
83
|
-
const { links } = await getInfo({
|
|
84
|
-
repo: options.repo,
|
|
85
|
-
commit: commitToFetchFrom
|
|
86
|
-
});
|
|
87
|
-
return links;
|
|
88
|
-
}
|
|
89
|
-
return {
|
|
90
|
-
commit: null,
|
|
91
|
-
pull: null,
|
|
92
|
-
user: null
|
|
93
|
-
};
|
|
94
|
-
})();
|
|
95
|
-
|
|
96
|
-
// ORIGINAL
|
|
97
|
-
// const users = usersFromSummary.length
|
|
98
|
-
// ? usersFromSummary
|
|
99
|
-
// .map(
|
|
100
|
-
// (userFromSummary) =>
|
|
101
|
-
// `[@${userFromSummary}](https://github.com/${userFromSummary})`
|
|
102
|
-
// )
|
|
103
|
-
// .join(', ')
|
|
104
|
-
// : links.user;
|
|
105
|
-
|
|
106
|
-
// const prefix = [
|
|
107
|
-
// links.pull === null ? '' : ` ${links.pull}`,
|
|
108
|
-
// links.commit === null ? '' : ` ${links.commit}`,
|
|
109
|
-
// users === null ? '' : ` Thanks ${users}!`
|
|
110
|
-
// ].join('');
|
|
111
|
-
|
|
112
|
-
// ORIGINAL
|
|
113
|
-
// return `\n\n-${prefix ? `${prefix} -` : ''} ${firstLine}\n${futureLines
|
|
114
|
-
// .map((l) => ` ${l}`)
|
|
115
|
-
// .join('\n')}`;
|
|
116
|
-
|
|
117
|
-
// OWN
|
|
118
|
-
const suffix = [
|
|
119
|
-
links.pull === null ? '' : ` (${links.pull})`
|
|
120
|
-
//links.commit === null ? '' : ` (${links.commit})`
|
|
121
|
-
].join('');
|
|
122
|
-
|
|
123
|
-
return `\n\n- ${firstLine}${suffix}\n${futureLines.map((l) => ` ${l}`).join('\n')}`;
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
export default changelogFunctions;
|
package/src/app.css
DELETED
package/src/app.html
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en" class="dark">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<link rel="icon" href="/favicon.ico" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
-
%svelte.head%
|
|
8
|
-
</head>
|
|
9
|
-
|
|
10
|
-
<body class="bg-gray-800">
|
|
11
|
-
<div id="svelte">%svelte.body%</div>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|
package/src/global.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="@sveltejs/kit" />
|
package/src/hooks.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { parsePhoneNumberFromString } from 'libphonenumber-js';
|
|
3
|
-
|
|
4
|
-
let telInputNumber: string;
|
|
5
|
-
|
|
6
|
-
// const phoneNumber = parsePhoneNumber(' 8 (800) 555-35-35 ', 'RU');
|
|
7
|
-
// if (phoneNumber) {
|
|
8
|
-
// phoneNumber.country === 'RU';
|
|
9
|
-
// phoneNumber.number === '+78005553535';
|
|
10
|
-
// phoneNumber.isValid() === true;
|
|
11
|
-
// // Note: `.getType()` requires `/max` metadata: see below for an explanation.
|
|
12
|
-
// phoneNumber.getType() === 'TOLL_FREE';
|
|
13
|
-
// }
|
|
14
|
-
|
|
15
|
-
// const parse = parsePhoneNumber(telInputNumber);
|
|
16
|
-
|
|
17
|
-
const handleInput = (event: Event) => {
|
|
18
|
-
let inputVal = (event.target as HTMLInputElement).value;
|
|
19
|
-
console.log(parsePhoneNumberFromString(inputVal));
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
$: console.log(telInputNumber);
|
|
23
|
-
</script>
|
|
24
|
-
|
|
25
|
-
<input
|
|
26
|
-
class="px-4 py-1 text-gray-900 rounded-full focus:outline-none"
|
|
27
|
-
type="tel"
|
|
28
|
-
on:input={handleInput}
|
|
29
|
-
/>
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { inview } from 'svelte-inview';
|
|
3
|
-
|
|
4
|
-
let loadComponent: any;
|
|
5
|
-
export { loadComponent as this };
|
|
6
|
-
|
|
7
|
-
let isShowingComponent = false;
|
|
8
|
-
let componentPromise: any;
|
|
9
|
-
</script>
|
|
10
|
-
|
|
11
|
-
{#if !isShowingComponent}
|
|
12
|
-
<div
|
|
13
|
-
use:inview
|
|
14
|
-
on:enter={() => {
|
|
15
|
-
componentPromise = loadComponent();
|
|
16
|
-
isShowingComponent = true;
|
|
17
|
-
}}
|
|
18
|
-
/>
|
|
19
|
-
{:else}
|
|
20
|
-
{#await componentPromise then { default: Component }}
|
|
21
|
-
<slot name="component" {Component} />
|
|
22
|
-
{/await}
|
|
23
|
-
{/if}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export const clickOutsideAction = (
|
|
2
|
-
node: HTMLElement,
|
|
3
|
-
handler: () => void
|
|
4
|
-
): { destroy: () => void } => {
|
|
5
|
-
const onClick = (event: MouseEvent) =>
|
|
6
|
-
node && !node.contains(event.target as HTMLElement) && !event.defaultPrevented && handler();
|
|
7
|
-
document.addEventListener('click', onClick, true);
|
|
8
|
-
return {
|
|
9
|
-
destroy() {
|
|
10
|
-
document.removeEventListener('click', onClick, true);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { DynamicSvelteComponent } from '../models/types/DynamicSvelteComponent.type';
|
|
2
|
-
|
|
3
|
-
export const isDynamicComponent = (item: unknown): item is DynamicSvelteComponent => {
|
|
4
|
-
return (
|
|
5
|
-
typeof item === 'object' &&
|
|
6
|
-
item !== null &&
|
|
7
|
-
Object.prototype.hasOwnProperty.call(item, 'component')
|
|
8
|
-
);
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const isStringArray = (items: unknown): items is string[] => {
|
|
12
|
-
return Array.isArray(items) && items.length > 0 && typeof items[0] === 'string';
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const isDynamicComponentArray = (items: unknown): items is DynamicSvelteComponent[] => {
|
|
16
|
-
return Array.isArray(items) && items.length > 0 && isDynamicComponent(items[0]);
|
|
17
|
-
};
|
package/src/routes/index.svelte
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<script context="module" lang="ts">
|
|
2
|
-
import SvelteTelInput from '$lib/components/Input/SvelteTelInput.svelte';
|
|
3
|
-
import CountrySelect from '$lib/components/Select/CountrySelect.svelte';
|
|
4
|
-
|
|
5
|
-
export const prerender = true;
|
|
6
|
-
</script>
|
|
7
|
-
|
|
8
|
-
<svelte:head>
|
|
9
|
-
<title>svelte-tel-input</title>
|
|
10
|
-
</svelte:head>
|
|
11
|
-
|
|
12
|
-
<div class="container mx-auto">
|
|
13
|
-
<div class="text-gray-200">
|
|
14
|
-
<div>
|
|
15
|
-
<h1 class="text-2xl my-4">SVELTE-TEL-INPUT</h1>
|
|
16
|
-
<CountrySelect />
|
|
17
|
-
<div>
|
|
18
|
-
<SvelteTelInput />
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
</div>
|
|
22
|
-
</div>
|
package/static/favicon.ico
DELETED
|
Binary file
|
package/static/robots.txt
DELETED
package/svelte.config.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import preprocess from 'svelte-preprocess';
|
|
2
|
-
import staticAdapter from '@sveltejs/adapter-static';
|
|
3
|
-
import mm from 'micromatch';
|
|
4
|
-
|
|
5
|
-
/** @type {import('@sveltejs/kit').Config} */
|
|
6
|
-
export default {
|
|
7
|
-
preprocess: [
|
|
8
|
-
preprocess({
|
|
9
|
-
postcss: true
|
|
10
|
-
})
|
|
11
|
-
],
|
|
12
|
-
kit: {
|
|
13
|
-
target: '#svelte',
|
|
14
|
-
package: {
|
|
15
|
-
// TODO create a single .JS file export.
|
|
16
|
-
exports: (filepath) => {
|
|
17
|
-
if (filepath.endsWith('.d.ts')) return false;
|
|
18
|
-
return mm.all(filepath, ['!**/_*.scss', '!**/*.test.*']);
|
|
19
|
-
},
|
|
20
|
-
files: (filepath) => {
|
|
21
|
-
return mm.all(filepath, ['!**/.*', '!**/*.test.*', '!**/*.sh']);
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
adapter: staticAdapter(),
|
|
25
|
-
amp: false,
|
|
26
|
-
trailingSlash: 'never'
|
|
27
|
-
}
|
|
28
|
-
};
|
package/tailwind.config.cjs
DELETED
package/tsconfig.json
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"outDir": "package",
|
|
4
|
-
"moduleResolution": "node",
|
|
5
|
-
"module": "ES2020",
|
|
6
|
-
"lib": ["ES2020", "DOM"],
|
|
7
|
-
"target": "ES2019",
|
|
8
|
-
"importsNotUsedAsValues": "error",
|
|
9
|
-
"isolatedModules": true,
|
|
10
|
-
"resolveJsonModule": true,
|
|
11
|
-
"sourceMap": true,
|
|
12
|
-
"esModuleInterop": true,
|
|
13
|
-
"skipLibCheck": true,
|
|
14
|
-
"forceConsistentCasingInFileNames": true,
|
|
15
|
-
"baseUrl": ".",
|
|
16
|
-
"allowJs": true,
|
|
17
|
-
"checkJs": true,
|
|
18
|
-
"paths": {
|
|
19
|
-
"$lib/*": ["src/lib/*"]
|
|
20
|
-
},
|
|
21
|
-
"types": ["jest"],
|
|
22
|
-
"strict": true
|
|
23
|
-
},
|
|
24
|
-
"include": [
|
|
25
|
-
"src/**/*.d.ts",
|
|
26
|
-
"src/**/*.js",
|
|
27
|
-
"src/**/*.ts",
|
|
28
|
-
"src/**/*.svelte",
|
|
29
|
-
"scripts/**/*.ts"
|
|
30
|
-
],
|
|
31
|
-
"exclude": ["node_modules/*", "static/*", "src/index.js"]
|
|
32
|
-
}
|