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.
Files changed (71) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/LICENSE.md +21 -0
  3. package/README.md +14 -8
  4. package/assets/countries.d.ts +2 -0
  5. package/{src/lib/assets/countries.ts → assets/countries.js} +0 -2
  6. package/assets/regions.d.ts +2 -0
  7. package/{src/lib/assets/regions.ts → assets/regions.js} +0 -2
  8. package/components/Input/SvelteTelInput.svelte +23 -0
  9. package/components/Input/SvelteTelInput.svelte.d.ts +14 -0
  10. package/{src/lib/components → components}/Select/CountrySelect.svelte +2 -3
  11. package/components/Select/CountrySelect.svelte.d.ts +14 -0
  12. package/{src/lib/components → components}/Select/RegionSelect.svelte +2 -3
  13. package/components/Select/RegionSelect.svelte.d.ts +14 -0
  14. package/{src/lib/index.ts → index.d.ts} +0 -0
  15. package/index.js +2 -0
  16. package/models/enums/PhoneType.enum.d.ts +4 -0
  17. package/models/enums/PhoneType.enum.js +5 -0
  18. package/{src/lib/models/enums/index.ts → models/enums/index.d.ts} +0 -0
  19. package/models/enums/index.js +1 -0
  20. package/{src/lib/models/index.ts → models/index.d.ts} +0 -0
  21. package/models/index.js +1 -0
  22. package/{src/lib/models/interfaces/Select.interface.ts → models/interfaces/Select.interface.d.ts} +0 -0
  23. package/models/interfaces/Select.interface.js +1 -0
  24. package/models/types/DynamicSvelteComponent.type.d.ts +8 -0
  25. package/models/types/DynamicSvelteComponent.type.js +16 -0
  26. package/{src/lib/models/types/Select.type.ts → models/types/Select.type.d.ts} +1 -2
  27. package/models/types/Select.type.js +1 -0
  28. package/package.json +159 -152
  29. package/stores/index.d.ts +11 -0
  30. package/{src/lib/stores/index.ts → stores/index.js} +6 -10
  31. package/utils/directives/clickOutsideAction.d.ts +3 -0
  32. package/utils/directives/clickOutsideAction.js +9 -0
  33. package/utils/simulator.d.ts +1 -0
  34. package/utils/simulator.js +5 -0
  35. package/utils/typeCheck.d.ts +4 -0
  36. package/utils/typeCheck.js +11 -0
  37. package/.changeset/config.json +0 -9
  38. package/.editorconfig +0 -13
  39. package/.eslintignore +0 -10
  40. package/.eslintrc.cjs +0 -30
  41. package/.github/workflows/lint.yml +0 -12
  42. package/.github/workflows/release.yml +0 -49
  43. package/.husky/pre-commit +0 -4
  44. package/.prettierignore +0 -10
  45. package/.prettierrc.cjs +0 -6
  46. package/babel.config.cjs +0 -12
  47. package/docker-compose.yml +0 -16
  48. package/docs/_index.md +0 -1
  49. package/jest.config.cjs +0 -21
  50. package/postcss.config.cjs +0 -21
  51. package/scripts/changelog-github-custom.cjs +0 -104
  52. package/scripts/changelog-github-custom.test.ts +0 -136
  53. package/scripts/changelog-github-custom.ts +0 -127
  54. package/src/app.css +0 -4
  55. package/src/app.html +0 -13
  56. package/src/global.d.ts +0 -1
  57. package/src/hooks.ts +0 -9
  58. package/src/lib/components/Input/SvelteTelInput.svelte +0 -29
  59. package/src/lib/components/LazyLoad/LazyLoad.svelte +0 -23
  60. package/src/lib/models/enums/PhoneType.enum.ts +0 -4
  61. package/src/lib/models/types/DynamicSvelteComponent.type.ts +0 -9
  62. package/src/lib/utils/directives/clickOutsideAction.ts +0 -13
  63. package/src/lib/utils/simulator.ts +0 -5
  64. package/src/lib/utils/typeCheck.ts +0 -17
  65. package/src/routes/__layout.svelte +0 -11
  66. package/src/routes/index.svelte +0 -22
  67. package/static/favicon.ico +0 -0
  68. package/static/robots.txt +0 -3
  69. package/svelte.config.js +0 -28
  70. package/tailwind.config.cjs +0 -10
  71. package/tsconfig.json +0 -32
@@ -1,8 +1,7 @@
1
1
  import { writable } from 'svelte/store';
2
-
3
2
  // Modal
4
- export const booleanStore = (initial: boolean) => {
5
- const isOpen = writable<boolean>(initial);
3
+ export const booleanStore = (initial) => {
4
+ const isOpen = writable(initial);
6
5
  const { set, update } = isOpen;
7
6
  return {
8
7
  isOpen,
@@ -11,22 +10,19 @@ export const booleanStore = (initial: boolean) => {
11
10
  toggle: () => update((n) => !n)
12
11
  };
13
12
  };
14
-
15
13
  // StatefulSwap (transition)
16
- export const statefulSwap = (initialState: any) => {
14
+ export const statefulSwap = (initialState) => {
17
15
  const transitionState = writable(initialState);
18
16
  let nextState = initialState;
19
-
20
- const transitionTo = (newState: any) => {
21
- if (nextState === newState) return;
17
+ const transitionTo = (newState) => {
18
+ if (nextState === newState)
19
+ return;
22
20
  nextState = newState;
23
21
  transitionState.set(null);
24
22
  };
25
-
26
23
  const onOutro = () => {
27
24
  transitionState.set(nextState);
28
25
  };
29
-
30
26
  return {
31
27
  transitionState,
32
28
  transitionTo,
@@ -0,0 +1,3 @@
1
+ export declare const clickOutsideAction: (node: HTMLElement, handler: () => void) => {
2
+ destroy: () => void;
3
+ };
@@ -0,0 +1,9 @@
1
+ export const clickOutsideAction = (node, handler) => {
2
+ const onClick = (event) => node && !node.contains(event.target) && !event.defaultPrevented && handler();
3
+ document.addEventListener('click', onClick, true);
4
+ return {
5
+ destroy() {
6
+ document.removeEventListener('click', onClick, true);
7
+ }
8
+ };
9
+ };
@@ -0,0 +1 @@
1
+ export declare const delaySimulator: (delay: number | undefined, callback: () => void) => Promise<void>;
@@ -0,0 +1,5 @@
1
+ export const delaySimulator = async (delay = 1000, callback) => {
2
+ const delayPromise = (ms) => new Promise((res) => setTimeout(res, ms));
3
+ await delayPromise(delay);
4
+ callback();
5
+ };
@@ -0,0 +1,4 @@
1
+ import type { DynamicSvelteComponent } from '../models/types/DynamicSvelteComponent.type';
2
+ export declare const isDynamicComponent: (item: unknown) => item is DynamicSvelteComponent;
3
+ export declare const isStringArray: (items: unknown) => items is string[];
4
+ export declare const isDynamicComponentArray: (items: unknown) => items is DynamicSvelteComponent[];
@@ -0,0 +1,11 @@
1
+ export const isDynamicComponent = (item) => {
2
+ return (typeof item === 'object' &&
3
+ item !== null &&
4
+ Object.prototype.hasOwnProperty.call(item, 'component'));
5
+ };
6
+ export const isStringArray = (items) => {
7
+ return Array.isArray(items) && items.length > 0 && typeof items[0] === 'string';
8
+ };
9
+ export const isDynamicComponentArray = (items) => {
10
+ return Array.isArray(items) && items.length > 0 && isDynamicComponent(items[0]);
11
+ };
@@ -1,9 +0,0 @@
1
- {
2
- "$schema": "https://unpkg.com/@changesets/config@1.6.3/schema.json",
3
- "changelog": ["../scripts/changelog-github-custom.cjs", { "repo": "gyurielf/svelte-tel-input" }],
4
- "commit": false,
5
- "linked": [],
6
- "access": "public",
7
- "baseBranch": "main",
8
- "updateInternalDependencies": "patch"
9
- }
package/.editorconfig DELETED
@@ -1,13 +0,0 @@
1
- # EditorConfig is awesome:
2
- # This file is for unifying the coding style for different editors and IDEs.
3
- # More information at http://editorconfig.org
4
-
5
- root = true
6
-
7
- [*]
8
- charset = utf-8
9
- indent_size = 4
10
- indent_style = space
11
- end_of_line = lf
12
- insert_final_newline = true
13
- trim_trailing_whitespace = true
package/.eslintignore DELETED
@@ -1,10 +0,0 @@
1
- # don't ever lint node_modules
2
- node_modules
3
- # don't lint build output (make sure it's set to your correct build folder name)
4
- dist
5
- # don't lint nyc coverage output
6
- coverage
7
- .svelte-kit
8
- static
9
- build
10
- /package
package/.eslintrc.cjs DELETED
@@ -1,30 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- parser: '@typescript-eslint/parser',
4
- extends: [
5
- 'eslint:recommended',
6
- 'plugin:@typescript-eslint/recommended',
7
- 'plugin:jest/recommended',
8
- 'prettier'
9
- ],
10
- plugins: ['svelte3', '@typescript-eslint', 'jest'],
11
- ignorePatterns: ['*.cjs', 'node_modules'],
12
- overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }],
13
- settings: {
14
- 'svelte3/typescript': () => require('typescript'),
15
- 'svelte3/ignore-styles': () => true
16
- },
17
- parserOptions: {
18
- sourceType: 'module',
19
- ecmaVersion: 2020
20
- },
21
- env: {
22
- browser: true,
23
- es2020: true,
24
- node: true
25
- },
26
- rules: {
27
- '@typescript-eslint/consistent-type-assertions': ['error', { assertionStyle: 'as' }],
28
- '@typescript-eslint/array-type': ['error', { default: 'array' }]
29
- }
30
- };
@@ -1,12 +0,0 @@
1
- name: Lint
2
- on: [push, pull_request]
3
- jobs:
4
- run-linter:
5
- runs-on: ubuntu-latest
6
- steps:
7
- - uses: actions/checkout@v2
8
- - uses: actions/setup-node@v2
9
- with:
10
- node-version: '16.x'
11
- - run: npm install
12
- - run: npm run lint
@@ -1,49 +0,0 @@
1
- name: Release
2
-
3
- on:
4
- push:
5
- branches:
6
- - 'main'
7
-
8
- jobs:
9
- release:
10
- name: Release
11
- runs-on: ubuntu-latest
12
- steps:
13
- - name: Checkout Repo
14
- uses: actions/checkout@v2
15
- with:
16
- # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
17
- fetch-depth: 0
18
-
19
- - name: Setup Node.js 16.x
20
- uses: actions/setup-node@v2
21
- with:
22
- node-version: 16.x
23
-
24
- - name: Install dependencies
25
- run: npm install --frozen-lockfile
26
-
27
- - name: Packaging
28
- run: |
29
- npm run package
30
-
31
- - name: Creating .npmrc
32
- run: |
33
- ls -l package
34
- cd package
35
- cat << EOF > ".npmrc"
36
- //registry.npmjs.org/:_authToken=$NPM_TOKEN
37
- EOF
38
- env:
39
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
40
-
41
- - name: Create Release Pull Request or Publish to npm
42
- id: changesets
43
- uses: changesets/action@v1
44
- with:
45
- # This expects you to have a script called release which does a build for your packages and calls changeset publish
46
- publish: npm run release
47
- env:
48
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
package/.husky/pre-commit DELETED
@@ -1,4 +0,0 @@
1
- #!/bin/sh
2
- . "$(dirname "$0")/_/husky.sh"
3
-
4
- docker-compose run --rm node sh -c '[ ! -d ./node_modules ] && npm install ; npm run lint'
package/.prettierignore DELETED
@@ -1,10 +0,0 @@
1
- .svelte-kit
2
- static
3
- build
4
- dist
5
- node_modules
6
- coverage
7
- package
8
- CHANGELOG.md
9
- .changeset
10
- # .github
package/.prettierrc.cjs DELETED
@@ -1,6 +0,0 @@
1
- module.exports = {
2
- singleQuote: true,
3
- trailingComma: 'none',
4
- printWidth: 100,
5
- tabWidth: 4
6
- };
package/babel.config.cjs DELETED
@@ -1,12 +0,0 @@
1
- module.exports = {
2
- presets: [
3
- [
4
- '@babel/preset-env',
5
- {
6
- targets: {
7
- node: 'current'
8
- }
9
- }
10
- ]
11
- ]
12
- };
@@ -1,16 +0,0 @@
1
- version: '3.9'
2
- services:
3
- node:
4
- image: 'node:16.13.1'
5
- container_name: ui-kit
6
- working_dir: /home/node/app
7
- command: 'sh -c "npm i && npm run prepare && npm run dev -- --host"'
8
- user: node
9
- tty: true
10
- ports:
11
- # Server
12
- - '3000:3000'
13
- # Vite
14
- - '24678:24678'
15
- volumes:
16
- - ./:/home/node/app
package/docs/_index.md DELETED
@@ -1 +0,0 @@
1
- # TODO
package/jest.config.cjs DELETED
@@ -1,21 +0,0 @@
1
- module.exports = {
2
- verbose: true,
3
- collectCoverage: true,
4
- coverageDirectory: './coverage',
5
- coverageReporters: ['cobertura', 'html', 'text', 'text-summary'],
6
- transform: {
7
- '^.+\\.svelte$': [
8
- 'svelte-jester',
9
- {
10
- preprocess: true
11
- }
12
- ],
13
- '^.+\\.ts$': 'ts-jest',
14
- '^.+\\.js$': 'babel-jest'
15
- },
16
- moduleFileExtensions: ['js', 'ts', 'svelte'],
17
- moduleNameMapper: {
18
- '\\$lib/(.*)': '<rootDir>/src/lib/$1'
19
- },
20
- transformIgnorePatterns: ['node_modules/(?!(focus-svelte)/)']
21
- };
@@ -1,21 +0,0 @@
1
- const tailwindcss = require('tailwindcss');
2
- const autoprefixer = require('autoprefixer');
3
- const cssnano = require('cssnano');
4
-
5
- const mode = process.env.NODE_ENV;
6
- const dev = mode === 'development';
7
-
8
- const config = {
9
- plugins: [
10
- //Some plugins, like tailwindcss/nesting, need to run before Tailwind,
11
- tailwindcss(),
12
- //But others, like autoprefixer, need to run after,
13
- autoprefixer(),
14
- !dev &&
15
- cssnano({
16
- preset: 'default'
17
- })
18
- ]
19
- };
20
-
21
- module.exports = config;
@@ -1,104 +0,0 @@
1
- const { config } = require('dotenv');
2
- const { getInfo, getInfoFromPullRequest } = require('@changesets/get-github-info');
3
-
4
- config();
5
-
6
- const changelogFunctions = {
7
- getDependencyReleaseLine: async (changesets, dependenciesUpdated, options) => {
8
- if (!options.repo) {
9
- throw new Error(
10
- 'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]'
11
- );
12
- }
13
- if (dependenciesUpdated.length === 0) return '';
14
-
15
- const changesetLink = `- Updated dependencies [${(
16
- await Promise.all(
17
- changesets.map(async (cs) => {
18
- if (cs.commit) {
19
- let { links } = await getInfo({
20
- repo: options.repo,
21
- commit: cs.commit
22
- });
23
- return links.commit;
24
- }
25
- })
26
- )
27
- )
28
- .filter((_) => _)
29
- .join(', ')}]:`;
30
-
31
- const updatedDepenenciesList = dependenciesUpdated.map(
32
- (dependency) => ` - ${dependency.name}@${dependency.newVersion}`
33
- );
34
-
35
- return [changesetLink, ...updatedDepenenciesList].join('\n');
36
- },
37
- getReleaseLine: async (changeset, type, options) => {
38
- if (!options || !options.repo) {
39
- throw new Error(
40
- 'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]'
41
- );
42
- }
43
-
44
- let prFromSummary;
45
- let commitFromSummary;
46
- let usersFromSummary;
47
-
48
- const replacedChangelog = changeset.summary
49
- .replace(/^\s*(?:pr|pull|pull\s+request):\s*#?(\d+)/im, (_, pr) => {
50
- let num = Number(pr);
51
- if (!isNaN(num)) prFromSummary = num;
52
- return '';
53
- })
54
- .replace(/^\s*commit:\s*([^\s]+)/im, (_, commit) => {
55
- commitFromSummary = commit;
56
- return '';
57
- })
58
- .replace(/^\s*(?:author|user):\s*@?([^\s]+)/gim, (_, user) => {
59
- usersFromSummary.push(user);
60
- return '';
61
- })
62
- .trim();
63
-
64
- const [firstLine, ...futureLines] = replacedChangelog.split('\n').map((l) => l.trimRight());
65
-
66
- const links = await (async () => {
67
- if (prFromSummary !== undefined) {
68
- let { links } = await getInfoFromPullRequest({
69
- repo: options.repo,
70
- pull: prFromSummary
71
- });
72
- if (commitFromSummary) {
73
- links = {
74
- ...links,
75
- commit: `[\`${commitFromSummary}\`](https://github.com/${options.repo}/commit/${commitFromSummary})`
76
- };
77
- }
78
- return links;
79
- }
80
- const commitToFetchFrom = commitFromSummary || changeset.commit;
81
- if (commitToFetchFrom) {
82
- let { links } = await getInfo({
83
- repo: options.repo,
84
- commit: commitToFetchFrom
85
- });
86
- return links;
87
- }
88
- return {
89
- commit: null,
90
- pull: null,
91
- user: null
92
- };
93
- })();
94
-
95
- const suffix = [
96
- links.pull === null ? '' : ` (${links.pull})`
97
- //links.commit === null ? '' : ` (${links.commit})`
98
- ].join('');
99
-
100
- return `\n\n- ${firstLine}${suffix}\n${futureLines.map((l) => ` ${l}`).join('\n')}`;
101
- }
102
- };
103
-
104
- module.exports = changelogFunctions;
@@ -1,136 +0,0 @@
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
- });