@aws-amplify/ui-svelte 0.0.0-next-c8114c5-20220105200613 → 0.0.0-next-3785286-20220106221746

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.
@@ -1,25 +0,0 @@
1
- <script lang="ts">
2
- import { createEventDispatcher } from 'svelte';
3
- export let type: 'submit' | 'button' = 'button';
4
- export let fullWidth: boolean | string = false;
5
- export let size: 'small' | 'medium' | 'large' = 'medium';
6
- export let variation: 'primary' | 'default' | 'link' = 'default';
7
- export let fontWeight: 'normal' | 'bold' | 'lighter' = 'normal';
8
-
9
- const dispatch = createEventDispatcher();
10
- </script>
11
-
12
- <button
13
- {...$$restProps}
14
- on:click={() => dispatch('click')}
15
- class={`amplify-button ${$$props.class ?? ''}`}
16
- {type}
17
- style="font-weight: {fontWeight} "
18
- data-fullwidth={fullWidth}
19
- data-size={size}
20
- data-fontWeight={fontWeight}
21
- data-variation={variation}
22
- data-amplify-button=""
23
- >
24
- <slot />
25
- </button>
@@ -1,48 +0,0 @@
1
- <script lang="ts">
2
- import AmplifyButton from './AmplifyButton.svelte';
3
- let isVisible = true;
4
-
5
- function close() {
6
- isVisible = false;
7
- }
8
- </script>
9
-
10
- {#if isVisible}
11
- <div
12
- class="amplify-flex amplify-alert"
13
- data-variation="error"
14
- style="align-items: center; justify-content: space-between"
15
- role="alert"
16
- >
17
- <div class="amplify-flex" style="align-items: center">
18
- <svg
19
- xmlns="http://www.w3.org/2000/svg"
20
- class="amplify-icon"
21
- viewBox="0 0 24 24"
22
- fill="currentColor"
23
- >
24
- <path
25
- d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"
26
- />
27
- </svg>
28
- <div><slot /></div>
29
- </div>
30
- <AmplifyButton
31
- class="amplify-field-group__control"
32
- variation="link"
33
- fullWidth={false}
34
- on:click={close}
35
- >
36
- <svg
37
- xmlns="http://www.w3.org/2000/svg"
38
- class="amplify-icon"
39
- viewBox="0 0 24 24"
40
- fill="currentColor"
41
- >
42
- <path
43
- d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
44
- />
45
- </svg>
46
- </AmplifyButton>
47
- </div>
48
- {/if}
@@ -1,146 +0,0 @@
1
- <script lang="ts">
2
- import AmplifyPhoneNumberField from './AmplifyPhoneNumberField.svelte';
3
- import AmplifyPasswordField from './AmplifyPasswordField.svelte';
4
- import AmplifyTextField from './AmplifyTextField.svelte';
5
- import AmplifyError from './AmplifyError.svelte';
6
-
7
- import { authState, updateForm, updateBlur } from '$lib/components/authStore';
8
- import {
9
- ActorContextWithForms,
10
- authInputAttributes,
11
- AuthInputAttributes,
12
- getActorContext,
13
- translate,
14
- } from '@aws-amplify/ui';
15
-
16
- import { onMount } from 'svelte';
17
-
18
- export let name: string;
19
- export let type: string;
20
- export let required = true;
21
- export let placeholder = '';
22
- export let label = '';
23
- export let initialValue = '';
24
- export let disabled = false;
25
- export let autocomplete = '';
26
- export let labelHidden = true;
27
-
28
- const getAttributeMap: AttributeInfoProvider = () => authInputAttributes;
29
- type AttributeInfoProvider = () => AuthInputAttributes;
30
-
31
- let defaultCountryCode: string;
32
- onMount(() => {
33
- if (isPhoneField) {
34
- const state = $authState;
35
- const { country_code }: ActorContextWithForms = getActorContext(state);
36
- defaultCountryCode = country_code;
37
-
38
- // TODO: remove this side-effect
39
- updateForm({
40
- name: 'country_code',
41
- value: country_code,
42
- });
43
- }
44
- });
45
-
46
- const attributeMap = getAttributeMap();
47
-
48
- let error: string;
49
- $: {
50
- const formContext: ActorContextWithForms = getActorContext($authState);
51
- const { validationError } = formContext;
52
- error = translate(validationError[name]);
53
- }
54
-
55
- function onBlur($event) {
56
- let { name } = <HTMLInputElement>$event?.detail?.target;
57
-
58
- updateBlur({ name });
59
- }
60
-
61
- let inferLabel: string;
62
- $: {
63
- const myLabel = label || attributeMap[name]?.label;
64
- inferLabel = translate<string>(myLabel);
65
- }
66
-
67
- let inferPlaceholder: string;
68
- $: {
69
- const myPlaceholder =
70
- placeholder || attributeMap[name]?.placeholder || inferLabel;
71
- inferPlaceholder = translate<string>(myPlaceholder);
72
- }
73
-
74
- // infers what the `type` of underlying input element should be.
75
- let inferType: string;
76
- $: {
77
- inferType = type ?? attributeMap[name]?.type ?? 'text';
78
- }
79
-
80
- let inferAutocomplete: string;
81
- $: {
82
- inferAutocomplete = autocomplete || attributeMap[name]?.autocomplete;
83
- }
84
-
85
- // TODO(enhancement): use enum to differentiate special field types
86
- let isPasswordField: boolean;
87
- $: {
88
- isPasswordField = inferType === 'password';
89
- }
90
-
91
- let isPhoneField: boolean;
92
- isPhoneField = inferType === 'tel';
93
- </script>
94
-
95
- <div class="amplify-flex amplify-field" style="flex-direction: column">
96
- <!-- Country code field -->
97
- {#if isPhoneField}
98
- <AmplifyPhoneNumberField
99
- {defaultCountryCode}
100
- type={inferType}
101
- {name}
102
- label={inferLabel}
103
- placeholder={inferPlaceholder}
104
- {required}
105
- {initialValue}
106
- {disabled}
107
- {labelHidden}
108
- autocomplete={inferAutocomplete}
109
- />
110
- {/if}
111
-
112
- {#if isPasswordField}
113
- <AmplifyPasswordField
114
- {...$$restProps}
115
- {name}
116
- label={inferLabel}
117
- placeholder={inferPlaceholder}
118
- {required}
119
- {initialValue}
120
- {disabled}
121
- {labelHidden}
122
- autocomplete={inferAutocomplete}
123
- />
124
- {/if}
125
-
126
- {#if !isPasswordField && !isPhoneField}
127
- <AmplifyTextField
128
- on:blur={onBlur}
129
- type={inferType}
130
- {name}
131
- label={inferLabel}
132
- placeholder={inferPlaceholder}
133
- {required}
134
- {initialValue}
135
- {disabled}
136
- {labelHidden}
137
- autocomplete={inferAutocomplete}
138
- />
139
- {/if}
140
-
141
- {#if error}
142
- <AmplifyError>
143
- {error}
144
- </AmplifyError>
145
- {/if}
146
- </div>
@@ -1,39 +0,0 @@
1
- <script lang="ts">
2
- export let items: string[];
3
- export let name: string;
4
- export let label: string;
5
- export let id: string;
6
- export let defaultValue: string;
7
- </script>
8
-
9
- <label class="amplify-label sr-only" for={id}>
10
- {label}
11
- </label>
12
- <div class="amplify-select__wrapper">
13
- <select
14
- class="amplify-select amplify-field-group__control"
15
- autocomplete="tel-country-code"
16
- {id}
17
- {name}
18
- >
19
- {#each items as item}
20
- <option value={item} selected={item === defaultValue}>
21
- {item}
22
- </option>
23
- {/each}
24
- </select>
25
- <div
26
- class="amplify-flex amplify-select__icon-wrapper"
27
- style="align-items: center; justify-content: center"
28
- >
29
- <svg
30
- xmlns="http://www.w3.org/2000/svg"
31
- class="amplify-icon"
32
- viewBox="0 0 24 24"
33
- data-size="large"
34
- fill="currentColor"
35
- >
36
- <path d="M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z" />
37
- </svg>
38
- </div>
39
- </div>
@@ -1,78 +0,0 @@
1
- <script lang="ts">
2
- import AmplifyButton from './AmplifyButton.svelte';
3
- import { nanoid } from 'nanoid';
4
- import { translate } from '@aws-amplify/ui';
5
- export let autocomplete = 'new-password';
6
- export let disabled = false;
7
- export let fieldId: string = `amplify-field-${nanoid(12)}`;
8
- export let initialValue = '';
9
- export let label = '';
10
- export let name: string;
11
- export let placeholder = '';
12
- export let required = true;
13
- export let labelHidden = false;
14
-
15
- export let type: 'text' | 'password' = 'password';
16
-
17
- let showPassword = false;
18
- let showPasswordButtonlabel = translate('Show password');
19
- function togglePasswordText() {
20
- showPassword = !showPassword;
21
- showPasswordButtonlabel = showPassword
22
- ? translate('Show password')
23
- : translate('Hide password');
24
- type = showPassword ? 'text' : 'password';
25
- }
26
- </script>
27
-
28
- <label class="amplify-label {labelHidden ? 'sr-only' : ''}" for={fieldId}>
29
- {label}
30
- </label>
31
- <div class="amplify-flex amplify-field-group">
32
- <input
33
- {...$$restProps}
34
- class={`amplify-input amplify-field-group__control ${$$props.class ?? ''}`}
35
- id={fieldId}
36
- {type}
37
- {name}
38
- {placeholder}
39
- {required}
40
- value={initialValue}
41
- {disabled}
42
- {autocomplete}
43
- />
44
- <div class="amplify-field-group__outer-end">
45
- <AmplifyButton
46
- amplify-button
47
- aria-label={showPasswordButtonlabel}
48
- class="amplify-field-group__control amplify-field__show-password"
49
- on:click={togglePasswordText}
50
- >
51
- {#if !showPassword}
52
- <svg
53
- xmlns="http://www.w3.org/2000/svg"
54
- fill="currentColor"
55
- viewBox="0 0 24 24"
56
- class="amplify-icon"
57
- >
58
- <path
59
- d="M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"
60
- />
61
- </svg>
62
- {/if}
63
- {#if showPassword}
64
- <svg
65
- xmlns="http://www.w3.org/2000/svg"
66
- fill="currentColor"
67
- viewBox="0 0 24 24"
68
- class="amplify-icon"
69
- >
70
- <path d="M0 0h24v24H0zm0 0h24v24H0zm0 0h24v24H0zm0 0h24v24H0z" fill="none" />
71
- <path
72
- d="M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78l3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z"
73
- />
74
- </svg>
75
- {/if}
76
- </AmplifyButton>
77
- </div>
78
- </div>
@@ -1,52 +0,0 @@
1
- <script lang="ts">
2
- import AmplifyFormSelect from './AmplifyFormSelect.svelte';
3
- import { nanoid } from 'nanoid';
4
- import { countryDialCodes } from '@aws-amplify/ui';
5
-
6
- export let autocomplete = 'new-password';
7
- export let disabled = false;
8
- export let defaultCountryCode: string;
9
- export let selectFieldId: string = `amplify-field-${nanoid(12)}`;
10
- export let textFieldId: string = `amplify-field-${nanoid(12)}`;
11
- export let initialValue = '';
12
- export let label = '';
13
- export let name: string;
14
- export let placeholder = '';
15
- export let required = true;
16
- export let type: string;
17
- export let labelHidden = false;
18
- </script>
19
-
20
- <label class="amplify-label {labelHidden ? 'sr-only' : ''}" for={textFieldId}>
21
- {label}
22
- </label>
23
- <div class="amplify-flex amplify-phonenumberfield" amplify-field-group style="gap: 0px">
24
- <div class="amplify-field-group__outer-start">
25
- <div
26
- class="
27
- amplify-flex amplify-field amplify-selectfield amplify-countrycodeselect
28
- "
29
- style="flex-direction: column"
30
- >
31
- <AmplifyFormSelect
32
- name="country_code"
33
- label="Country Code"
34
- id={selectFieldId}
35
- items={countryDialCodes}
36
- defaultValue={defaultCountryCode}
37
- />
38
- </div>
39
- </div>
40
-
41
- <input
42
- class="amplify-input"
43
- id={textFieldId}
44
- {type}
45
- {name}
46
- {placeholder}
47
- {required}
48
- value={initialValue}
49
- {disabled}
50
- {autocomplete}
51
- />
52
- </div>
@@ -1,52 +0,0 @@
1
- <script lang="ts">
2
- //tab list
3
- const tabs = [
4
- {
5
- active: true,
6
- labelledById: '1',
7
- id: '1',
8
- title: 'Sign In'
9
- },
10
- {
11
- active: false,
12
- labelledById: '2',
13
- id: '2',
14
- title: 'Sign Up'
15
- }
16
- ];
17
-
18
- function handleTabClick(e) {
19
- // future
20
- }
21
- </script>
22
-
23
- <div
24
- tabindex="0"
25
- aria-orientation="horizontal"
26
- data-orientation="horizontal"
27
- role="tablist"
28
- style="outline: none"
29
- >
30
- <div
31
- class="amplify-flex amplify-tabs"
32
- data-indicator-position="top"
33
- style="gap: 0px; justify-content: center"
34
- >
35
- {#each tabs as tab}
36
- <div
37
- class="amplify-tabs-item"
38
- data-spacing="equal"
39
- data-orientation="horizontal"
40
- role="tab"
41
- id={tab.labelledById}
42
- tabindex={tab.active ? 0 : 1}
43
- aria-selected={tab.active}
44
- aria-controls={tab.id}
45
- data-state={tab.active ? 'active' : 'inactive'}
46
- on:click={() => handleTabClick(tab)}
47
- >
48
- {tab.title}
49
- </div>
50
- {/each}
51
- </div>
52
- </div>
@@ -1,33 +0,0 @@
1
- <script lang="ts">
2
- import { createEventDispatcher } from 'svelte';
3
- import { nanoid } from 'nanoid';
4
- export let autocomplete = 'new-password';
5
- export let disabled = false;
6
- export let fieldId: string = `amplify-field-${nanoid(12)}`;
7
- export let initialValue = '';
8
- export let label = '';
9
- export let name: string;
10
- export let placeholder = '';
11
- export let required = true;
12
- export let type: string;
13
- export let labelHidden = false;
14
-
15
- const dispatch = createEventDispatcher();
16
- </script>
17
-
18
- <label class="amplify-label {labelHidden ? 'sr-only' : ''}" for={fieldId}>
19
- {label}
20
- </label>
21
- <input
22
- {...$$restProps}
23
- on:blur={($event) => dispatch('blur', $event)}
24
- class={`amplify-input ${$$props.class ?? ''}`}
25
- id={fieldId}
26
- {type}
27
- {name}
28
- {placeholder}
29
- {required}
30
- value={initialValue}
31
- {disabled}
32
- {autocomplete}
33
- />
package/src/lib/index.ts DELETED
@@ -1,4 +0,0 @@
1
- import Authenticator from './components/Authenticator.svelte';
2
- import * as authStore from '$lib/components/authStore';
3
-
4
- export { Authenticator, authStore };
@@ -1 +0,0 @@
1
- @import '@aws-amplify/ui/styles.css';
@@ -1,8 +0,0 @@
1
- <script>
2
- import Authenticator from '$lib/components/Authenticator.svelte';
3
- import '$lib/styles.css';
4
- </script>
5
-
6
- <h1>Welcome to SvelteKit</h1>
7
- <p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
8
- <Authenticator loginMechanisms={['email']} />
Binary file
package/svelte.config.js DELETED
@@ -1,41 +0,0 @@
1
- import adapter from '@sveltejs/adapter-static';
2
- import preprocess from 'svelte-preprocess';
3
- import path from 'path';
4
- import { fileURLToPath } from 'url';
5
- import { dirname } from 'path';
6
-
7
- const __filename = fileURLToPath(import.meta.url);
8
- const __dirname = dirname(__filename);
9
-
10
- /** @type {import('@sveltejs/kit').Config} */
11
- const config = {
12
- // Consult https://github.com/sveltejs/svelte-preprocess
13
- // for more information about preprocessors
14
- preprocess: preprocess(),
15
-
16
- kit: {
17
- adapter: adapter(),
18
- package: {
19
- dir: 'dist'
20
- },
21
-
22
- // hydrate the <div id="svelte"> element in src/app.html
23
- target: '#svelte',
24
- vite: {
25
- ssr: {
26
- noExternal:
27
- process.env.NODE_ENV !== 'development' ? ['lodash', 'xstate', 'style-dictionary'] : []
28
- },
29
- resolve: {
30
- alias: {
31
- './runtimeConfig': './runtimeConfig.browser',
32
- entries: {
33
- svelte: path.join(__dirname, '../../node_modules/svelte')
34
- }
35
- }
36
- }
37
- }
38
- }
39
- };
40
-
41
- export default config;
package/tsconfig.json DELETED
@@ -1,31 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "moduleResolution": "node",
4
- "module": "es2020",
5
- "lib": ["es2020", "DOM"],
6
- "target": "es2020",
7
- /**
8
- svelte-preprocess cannot figure out whether you have a value or a type, so tell TypeScript
9
- to enforce using \`import type\` instead of \`import\` for Types.
10
- */
11
- "importsNotUsedAsValues": "error",
12
- "isolatedModules": true,
13
- "resolveJsonModule": true,
14
- /**
15
- To have warnings/errors of the Svelte compiler at the correct position,
16
- enable source maps by default.
17
- */
18
- "sourceMap": true,
19
- "esModuleInterop": true,
20
- "skipLibCheck": true,
21
- "forceConsistentCasingInFileNames": true,
22
- "baseUrl": ".",
23
- "allowJs": true,
24
- "checkJs": true,
25
- "paths": {
26
- "$lib": ["src/lib"],
27
- "$lib/*": ["src/lib/*"]
28
- }
29
- },
30
- "include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.ts", "src/**/*.svelte"]
31
- }