svelte-tel-input 0.1.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.
- package/.changeset/config.json +9 -0
- package/.editorconfig +13 -0
- package/.eslintignore +11 -0
- package/.eslintrc.cjs +30 -0
- package/.github/workflows/lint.yml +12 -0
- package/.github/workflows/release.yml +50 -0
- package/.husky/pre-commit +4 -0
- package/.prettierignore +10 -0
- package/.prettierrc.cjs +6 -0
- package/.storybook/main.cjs +38 -0
- package/.storybook/preview-head.html +1 -0
- package/.storybook/preview.cjs +39 -0
- package/CHANGELOG.md +23 -0
- package/README.md +19 -0
- package/babel.config.cjs +12 -0
- package/docker-compose.yml +18 -0
- package/docs/_index.md +1 -0
- package/jest.config.cjs +21 -0
- package/package.json +164 -0
- package/postcss.config.cjs +21 -0
- package/scripts/changelog-github-custom.cjs +110 -0
- package/scripts/changelog-github-custom.test.ts +136 -0
- package/scripts/changelog-github-custom.ts +127 -0
- package/src/app.css +4 -0
- package/src/app.html +13 -0
- package/src/global.d.ts +1 -0
- package/src/hooks.ts +9 -0
- package/src/lib/assets/countries.ts +605 -0
- package/src/lib/assets/regions.ts +46 -0
- package/src/lib/components/Input/SvelteTelInput.svelte +29 -0
- package/src/lib/components/LazyLoad/LazyLoad.svelte +23 -0
- package/src/lib/components/Select/CountrySelect.svelte +15 -0
- package/src/lib/components/Select/RegionSelect.svelte +15 -0
- package/src/lib/index.ts +2 -0
- package/src/lib/models/enums/PhoneType.enum.ts +4 -0
- package/src/lib/models/enums/index.ts +1 -0
- package/src/lib/models/index.ts +1 -0
- package/src/lib/models/interfaces/Select.interface.ts +5 -0
- package/src/lib/models/types/DynamicSvelteComponent.type.ts +9 -0
- package/src/lib/models/types/Select.type.ts +3 -0
- package/src/lib/stores/index.ts +35 -0
- package/src/lib/utils/directives/clickOutsideAction.ts +13 -0
- package/src/lib/utils/simulator.ts +5 -0
- package/src/lib/utils/typeCheck.ts +17 -0
- package/src/routes/__layout.svelte +11 -0
- package/src/routes/index.svelte +22 -0
- package/static/favicon.ico +0 -0
- package/static/robots.txt +3 -0
- package/svelte.config.js +34 -0
- package/tailwind.config.cjs +10 -0
- package/tsconfig.json +32 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import changelogFunctions from './changelog-github-custom';
|
|
2
|
+
import parse from '@changesets/parse';
|
|
3
|
+
|
|
4
|
+
const getReleaseLine = changelogFunctions.getReleaseLine;
|
|
5
|
+
|
|
6
|
+
describe('Changeset test suite', () => {
|
|
7
|
+
test('Should test changeset commit..', () => {
|
|
8
|
+
jest.mock(
|
|
9
|
+
'@changesets/get-github-info',
|
|
10
|
+
(): typeof import('@changesets/get-github-info') => {
|
|
11
|
+
// this is duplicated because jest.mock reordering things
|
|
12
|
+
const data = {
|
|
13
|
+
commit: 'a085003',
|
|
14
|
+
user: 'Andarist',
|
|
15
|
+
pull: 1613,
|
|
16
|
+
repo: 'emotion-js/emotion'
|
|
17
|
+
};
|
|
18
|
+
const links = {
|
|
19
|
+
user: `[@${data.user}](https://github.com/${data.user})`,
|
|
20
|
+
pull: `[#${data.pull}](https://github.com/${data.repo}/pull/${data.pull})`,
|
|
21
|
+
commit: `[\`${data.commit}\`](https://github.com/${data.repo}/commit/${data.commit})`
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
async getInfo({ commit, repo }) {
|
|
25
|
+
expect(commit).toBe(data.commit);
|
|
26
|
+
expect(repo).toBe(data.repo);
|
|
27
|
+
return {
|
|
28
|
+
pull: data.pull,
|
|
29
|
+
user: data.user,
|
|
30
|
+
links
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
async getInfoFromPullRequest({ pull, repo }) {
|
|
34
|
+
expect(pull).toBe(data.pull);
|
|
35
|
+
expect(repo).toBe(data.repo);
|
|
36
|
+
return {
|
|
37
|
+
commit: data.commit,
|
|
38
|
+
user: data.user,
|
|
39
|
+
links
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const getChangeset = (content: string, commit: string | undefined) => {
|
|
47
|
+
return [
|
|
48
|
+
{
|
|
49
|
+
...parse(
|
|
50
|
+
`---
|
|
51
|
+
pkg: "minor"
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
something
|
|
55
|
+
${content}
|
|
56
|
+
`
|
|
57
|
+
),
|
|
58
|
+
id: 'some-id',
|
|
59
|
+
commit
|
|
60
|
+
},
|
|
61
|
+
'minor',
|
|
62
|
+
{ repo: data.repo }
|
|
63
|
+
] as const;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const data = {
|
|
67
|
+
commit: 'a085003',
|
|
68
|
+
user: 'Andarist',
|
|
69
|
+
pull: 1613,
|
|
70
|
+
repo: 'emotion-js/emotion'
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
describe.each([data.commit, 'wrongcommit', undefined])(
|
|
74
|
+
'with commit from changeset of %s',
|
|
75
|
+
(commitFromChangeset) => {
|
|
76
|
+
describe.each(['pr', 'pull request', 'pull'])(
|
|
77
|
+
'override pr with %s keyword',
|
|
78
|
+
(keyword) => {
|
|
79
|
+
test.each(['with #', 'without #'] as const)('%s', async (kind) => {
|
|
80
|
+
expect(
|
|
81
|
+
await getReleaseLine(
|
|
82
|
+
...getChangeset(
|
|
83
|
+
`${keyword}: ${kind === 'with #' ? '#' : ''}${data.pull}`,
|
|
84
|
+
commitFromChangeset
|
|
85
|
+
)
|
|
86
|
+
)
|
|
87
|
+
).toEqual(
|
|
88
|
+
`\n\n- [#1613](https://github.com/emotion-js/emotion/pull/1613) [\`a085003\`](https://github.com/emotion-js/emotion/commit/a085003) Thanks [@Andarist](https://github.com/Andarist)! - something\n`
|
|
89
|
+
);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
test('override commit with commit keyword', async () => {
|
|
94
|
+
expect(
|
|
95
|
+
await getReleaseLine(
|
|
96
|
+
...getChangeset(`commit: ${data.commit}`, commitFromChangeset)
|
|
97
|
+
)
|
|
98
|
+
).toEqual(
|
|
99
|
+
`\n\n- [#1613](https://github.com/emotion-js/emotion/pull/1613) [\`a085003\`](https://github.com/emotion-js/emotion/commit/a085003) Thanks [@Andarist](https://github.com/Andarist)! - something\n`
|
|
100
|
+
);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
describe.each(['author', 'user'])('override author with %s keyword', (keyword) => {
|
|
106
|
+
test.each(['with @', 'without @'] as const)('%s', async (kind) => {
|
|
107
|
+
expect(
|
|
108
|
+
await getReleaseLine(
|
|
109
|
+
...getChangeset(
|
|
110
|
+
`${keyword}: ${kind === 'with @' ? '@' : ''}other`,
|
|
111
|
+
data.commit
|
|
112
|
+
)
|
|
113
|
+
)
|
|
114
|
+
).toEqual(
|
|
115
|
+
`\n\n- [#1613](https://github.com/emotion-js/emotion/pull/1613) [\`a085003\`](https://github.com/emotion-js/emotion/commit/a085003) Thanks [@other](https://github.com/other)! - something\n`
|
|
116
|
+
);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('with multiple authors', async () => {
|
|
121
|
+
expect(
|
|
122
|
+
await getReleaseLine(
|
|
123
|
+
...getChangeset(
|
|
124
|
+
['author: @Andarist', 'author: @mitchellhamilton'].join('\n'),
|
|
125
|
+
data.commit
|
|
126
|
+
)
|
|
127
|
+
)
|
|
128
|
+
).toMatchInlineSnapshot(`
|
|
129
|
+
"
|
|
130
|
+
|
|
131
|
+
- [#1613](https://github.com/emotion-js/emotion/pull/1613) [\`a085003\`](https://github.com/emotion-js/emotion/commit/a085003) Thanks [@Andarist](https://github.com/Andarist), [@mitchellhamilton](https://github.com/mitchellhamilton)! - something
|
|
132
|
+
"
|
|
133
|
+
`);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
});
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { ChangelogFunctions } from '@changesets/types';
|
|
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
ADDED
package/src/app.html
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
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
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="@sveltejs/kit" />
|