@aws-amplify/ui-svelte 0.0.0-next-9a4f1cf-20220113211745 → 0.0.0-next-23d2233-20251017111356

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 (135) hide show
  1. package/README.md +132 -20
  2. package/dist/components/Authenticator/Authenticator.svelte +230 -0
  3. package/dist/components/Authenticator/Authenticator.svelte.d.ts +41 -0
  4. package/dist/components/Authenticator/ConfirmResetPassword.svelte +119 -0
  5. package/dist/components/Authenticator/ConfirmResetPassword.svelte.d.ts +7 -0
  6. package/dist/components/Authenticator/ConfirmSignIn.svelte +110 -0
  7. package/dist/components/Authenticator/ConfirmSignIn.svelte.d.ts +7 -0
  8. package/dist/components/Authenticator/ConfirmSignUp.svelte +127 -0
  9. package/dist/components/Authenticator/ConfirmSignUp.svelte.d.ts +7 -0
  10. package/dist/components/Authenticator/ConfirmVerifyUser.svelte +106 -0
  11. package/dist/components/Authenticator/ConfirmVerifyUser.svelte.d.ts +7 -0
  12. package/dist/components/Authenticator/ForceNewPassword.svelte +120 -0
  13. package/dist/components/Authenticator/ForceNewPassword.svelte.d.ts +7 -0
  14. package/dist/components/Authenticator/ForgotPassword.svelte +107 -0
  15. package/dist/components/Authenticator/ForgotPassword.svelte.d.ts +7 -0
  16. package/dist/components/Authenticator/SelectMfaType.svelte +145 -0
  17. package/dist/components/Authenticator/SelectMfaType.svelte.d.ts +7 -0
  18. package/dist/components/Authenticator/SetupEmail.svelte +103 -0
  19. package/dist/components/Authenticator/SetupEmail.svelte.d.ts +7 -0
  20. package/dist/components/Authenticator/SetupTotp.svelte +178 -0
  21. package/dist/components/Authenticator/SetupTotp.svelte.d.ts +7 -0
  22. package/dist/components/Authenticator/SignIn.svelte +112 -0
  23. package/dist/components/Authenticator/SignIn.svelte.d.ts +8 -0
  24. package/dist/components/Authenticator/SignUp.svelte +98 -0
  25. package/dist/components/Authenticator/SignUp.svelte.d.ts +8 -0
  26. package/dist/components/Authenticator/VerifyUser.svelte +160 -0
  27. package/dist/components/Authenticator/VerifyUser.svelte.d.ts +7 -0
  28. package/dist/components/Authenticator/index.d.ts +14 -0
  29. package/dist/components/Authenticator/index.js +14 -0
  30. package/dist/components/controls/AliasField.svelte +98 -0
  31. package/dist/components/controls/AliasField.svelte.d.ts +17 -0
  32. package/dist/components/controls/Button.svelte +51 -0
  33. package/dist/components/controls/Button.svelte.d.ts +13 -0
  34. package/dist/components/controls/CheckBox.svelte +57 -0
  35. package/dist/components/controls/CheckBox.svelte.d.ts +6 -0
  36. package/dist/components/controls/FederatedSignIn.svelte +143 -0
  37. package/dist/components/controls/FederatedSignIn.svelte.d.ts +3 -0
  38. package/dist/components/controls/ForceNewPasswordFormFields.svelte +5 -0
  39. package/dist/components/controls/ForceNewPasswordFormFields.svelte.d.ts +18 -0
  40. package/dist/components/controls/PasswordField.svelte +119 -0
  41. package/dist/components/controls/PasswordField.svelte.d.ts +14 -0
  42. package/dist/components/controls/SignUpFormFields.svelte +5 -0
  43. package/dist/components/controls/SignUpFormFields.svelte.d.ts +18 -0
  44. package/dist/components/controls/TextField.svelte +46 -0
  45. package/dist/components/controls/TextField.svelte.d.ts +15 -0
  46. package/dist/components/controls/index.d.ts +8 -0
  47. package/dist/components/controls/index.js +8 -0
  48. package/dist/components/index.d.ts +4 -0
  49. package/dist/components/index.js +4 -0
  50. package/dist/components/primitives/Alert.svelte +61 -0
  51. package/dist/components/primitives/Alert.svelte.d.ts +7 -0
  52. package/dist/components/primitives/Box.svelte +9 -0
  53. package/dist/components/primitives/Box.svelte.d.ts +4 -0
  54. package/dist/components/primitives/FederatedSignInButton.svelte +27 -0
  55. package/dist/components/primitives/FederatedSignInButton.svelte.d.ts +7 -0
  56. package/dist/components/primitives/FieldSet.svelte +9 -0
  57. package/dist/components/primitives/FieldSet.svelte.d.ts +4 -0
  58. package/dist/components/primitives/Footer.svelte +9 -0
  59. package/dist/components/primitives/Footer.svelte.d.ts +4 -0
  60. package/dist/components/primitives/Form.svelte +9 -0
  61. package/dist/components/primitives/Form.svelte.d.ts +4 -0
  62. package/dist/components/primitives/FormField.svelte +72 -0
  63. package/dist/components/primitives/FormField.svelte.d.ts +8 -0
  64. package/dist/components/primitives/FormFields.svelte +29 -0
  65. package/dist/components/primitives/FormFields.svelte.d.ts +7 -0
  66. package/dist/components/primitives/Heading.svelte +13 -0
  67. package/dist/components/primitives/Heading.svelte.d.ts +7 -0
  68. package/dist/components/primitives/Input.svelte +20 -0
  69. package/dist/components/primitives/Input.svelte.d.ts +7 -0
  70. package/dist/components/primitives/Label.svelte +9 -0
  71. package/dist/components/primitives/Label.svelte.d.ts +4 -0
  72. package/dist/components/primitives/Select.svelte +28 -0
  73. package/dist/components/primitives/Select.svelte.d.ts +9 -0
  74. package/dist/components/primitives/Spacer.svelte +7 -0
  75. package/dist/components/primitives/Spacer.svelte.d.ts +5 -0
  76. package/dist/components/primitives/Text.svelte +9 -0
  77. package/dist/components/primitives/Text.svelte.d.ts +4 -0
  78. package/dist/components/primitives/TwoTabItem.svelte +26 -0
  79. package/dist/components/primitives/TwoTabItem.svelte.d.ts +9 -0
  80. package/dist/components/primitives/TwoTabs.svelte +19 -0
  81. package/dist/components/primitives/TwoTabs.svelte.d.ts +5 -0
  82. package/dist/components/primitives/Wrapper.svelte +9 -0
  83. package/dist/components/primitives/Wrapper.svelte.d.ts +4 -0
  84. package/dist/components/primitives/index.d.ts +17 -0
  85. package/dist/components/primitives/index.js +17 -0
  86. package/dist/index.d.ts +7 -3
  87. package/dist/index.js +8 -3
  88. package/dist/stores/authenticator.svelte.d.ts +18 -0
  89. package/dist/stores/authenticator.svelte.js +88 -0
  90. package/dist/styles/authenticator.css +13 -0
  91. package/dist/styles/index.js +3 -0
  92. package/dist/styles.css +2 -2827
  93. package/dist/types/index.d.ts +21 -0
  94. package/dist/types/index.js +1 -0
  95. package/dist/version.d.ts +1 -0
  96. package/dist/version.js +1 -0
  97. package/package.json +59 -50
  98. package/LICENSE +0 -201
  99. package/dist/LICENSE +0 -201
  100. package/dist/README.md +0 -38
  101. package/dist/components/AmplifySignUpFormFields.svelte +0 -41
  102. package/dist/components/AmplifySignUpFormFields.svelte.d.ts +0 -14
  103. package/dist/components/Authenticator.svelte +0 -50
  104. package/dist/components/Authenticator.svelte.d.ts +0 -22
  105. package/dist/components/ConfirmSignUp.svelte +0 -87
  106. package/dist/components/ConfirmSignUp.svelte.d.ts +0 -14
  107. package/dist/components/FederatedSignIn.svelte.d.ts +0 -19
  108. package/dist/components/SignIn.svelte +0 -69
  109. package/dist/components/SignIn.svelte.d.ts +0 -14
  110. package/dist/components/SignUp.svelte +0 -45
  111. package/dist/components/SignUp.svelte.d.ts +0 -14
  112. package/dist/components/UserNameAlias.svelte +0 -29
  113. package/dist/components/UserNameAlias.svelte.d.ts +0 -19
  114. package/dist/components/authStore.d.ts +0 -20
  115. package/dist/components/authStore.js +0 -101
  116. package/dist/components/primitives/AmplifyButton.svelte +0 -23
  117. package/dist/components/primitives/AmplifyButton.svelte.d.ts +0 -25
  118. package/dist/components/primitives/AmplifyError.svelte +0 -46
  119. package/dist/components/primitives/AmplifyError.svelte.d.ts +0 -16
  120. package/dist/components/primitives/AmplifyFormField.svelte +0 -121
  121. package/dist/components/primitives/AmplifyFormField.svelte.d.ts +0 -25
  122. package/dist/components/primitives/AmplifyFormSelect.svelte +0 -38
  123. package/dist/components/primitives/AmplifyFormSelect.svelte.d.ts +0 -20
  124. package/dist/components/primitives/AmplifyPasswordField.svelte +0 -75
  125. package/dist/components/primitives/AmplifyPasswordField.svelte.d.ts +0 -26
  126. package/dist/components/primitives/AmplifyPhoneNumberField.svelte +0 -50
  127. package/dist/components/primitives/AmplifyPhoneNumberField.svelte.d.ts +0 -27
  128. package/dist/components/primitives/AmplifyTabItem.svelte +0 -19
  129. package/dist/components/primitives/AmplifyTabItem.svelte.d.ts +0 -21
  130. package/dist/components/primitives/AmplifyTabs.svelte +0 -72
  131. package/dist/components/primitives/AmplifyTabs.svelte.d.ts +0 -26
  132. package/dist/components/primitives/AmplifyTextField.svelte +0 -31
  133. package/dist/components/primitives/AmplifyTextField.svelte.d.ts +0 -28
  134. package/dist/package.json +0 -69
  135. /package/dist/{components/FederatedSignIn.svelte → styles/index.d.ts} +0 -0
package/README.md CHANGED
@@ -1,38 +1,150 @@
1
- # create-svelte
1
+ # @aws-amplify/ui-svelte
2
2
 
3
- Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte);
3
+ Svelte components for Amplify UI
4
4
 
5
- ## Creating a project
5
+ ## Installation
6
6
 
7
- If you're seeing this, you've probably already done this step. Congrats!
7
+ ```bash
8
+ npm install @aws-amplify/ui-svelte aws-amplify
9
+ ```
10
+
11
+ or
8
12
 
9
13
  ```bash
10
- # create a new project in the current directory
11
- npm init svelte@next
14
+ yarn add @aws-amplify/ui-svelte aws-amplify
15
+ ```
16
+
17
+ ## Usage
12
18
 
13
- # create a new project in my-app
14
- npm init svelte@next my-app
19
+ ### Basic Usage
20
+
21
+ ```svelte
22
+ <script>
23
+ import { Amplify } from 'aws-amplify';
24
+ import { Authenticator } from '@aws-amplify/ui-svelte';
25
+ import '@aws-amplify/ui/styles.css';
26
+ import awsExports from './aws-exports';
27
+
28
+ Amplify.configure(awsExports);
29
+ </script>
30
+
31
+ <Authenticator let:user let:signOut>
32
+ <h1>Hello {user.username}</h1>
33
+ <button on:click={signOut}>Sign out</button>
34
+ </Authenticator>
15
35
  ```
16
36
 
17
- > Note: the `@next` is temporary
37
+ ### Using with TypeScript
18
38
 
19
- ## Developing
39
+ ```svelte
40
+ <script lang="ts">
41
+ import { Amplify } from 'aws-amplify';
42
+ import { Authenticator } from '@aws-amplify/ui-svelte';
43
+ import type { AuthUser } from '@aws-amplify/ui-svelte';
44
+ import '@aws-amplify/ui/styles.css';
45
+ import awsExports from './aws-exports';
20
46
 
21
- Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
47
+ Amplify.configure(awsExports);
22
48
 
23
- ```bash
24
- npm run dev
49
+ let user: AuthUser;
50
+ let signOut: () => void;
51
+ </script>
25
52
 
26
- # or start the server and open the app in a new browser tab
27
- npm run dev -- --open
53
+ <Authenticator let:user let:signOut>
54
+ <h1>Hello {user.username}</h1>
55
+ <button on:click={signOut}>Sign out</button>
56
+ </Authenticator>
28
57
  ```
29
58
 
30
- ## Building
59
+ ### Customization
31
60
 
32
- Before creating a production version of your app, install an [adapter](https://kit.svelte.dev/docs#adapters) for your target environment. Then:
61
+ The Authenticator component provides several props for customization:
33
62
 
34
- ```bash
35
- npm run build
63
+ ```svelte
64
+ <Authenticator
65
+ initialRoute="signIn"
66
+ socialProviders={['google', 'facebook', 'amazon']}
67
+ hideSignUp={false}
68
+ >
69
+ <!-- Your app content -->
70
+ </Authenticator>
71
+ ```
72
+
73
+ ### Using the useAuthenticator Store
74
+
75
+ You can also access the authenticator state directly using the store:
76
+
77
+ ```svelte
78
+ <script>
79
+ import { useAuthenticatorStore } from '@aws-amplify/ui-svelte';
80
+
81
+ const authenticator = useAuthenticatorStore();
82
+
83
+ $: ({ user, authStatus, signOut } = $authenticator);
84
+ </script>
85
+
86
+ {#if authStatus === 'authenticated'}
87
+ <h1>Welcome {user.username}</h1>
88
+ <button on:click={signOut}>Sign out</button>
89
+ {:else}
90
+ <p>Please sign in</p>
91
+ {/if}
92
+ ```
93
+
94
+ ## Components
95
+
96
+ ### Authenticator
97
+
98
+ The main component that provides the complete authentication flow.
99
+
100
+ **Props:**
101
+
102
+ - `initialRoute`: Initial route to display ('signIn' | 'signUp')
103
+ - `socialProviders`: Array of social providers to display
104
+ - `hideSignUp`: Whether to hide the sign up tab
105
+
106
+ **Slot Props:**
107
+
108
+ - `user`: The authenticated user object
109
+ - `authStatus`: Current authentication status
110
+ - `signOut`: Function to sign out the user
111
+
112
+ ### Primitive Components
113
+
114
+ The package also exports primitive components that can be used to build custom UI:
115
+
116
+ - `Button`
117
+ - `TextField`
118
+ - `PasswordField`
119
+
120
+ ## Styling
121
+
122
+ Amplify UI uses CSS variables for theming. You can customize the appearance by overriding these variables:
123
+
124
+ ```css
125
+ :root {
126
+ --amplify-colors-brand-primary: #ff6347;
127
+ --amplify-colors-brand-secondary: #ff7f50;
128
+ }
36
129
  ```
37
130
 
38
- > You can preview the built app with `npm run preview`, regardless of whether you installed an adapter. This should _not_ be used to serve your app in production.
131
+ ## SvelteKit Support
132
+
133
+ When using with SvelteKit, make sure to configure SSR appropriately:
134
+
135
+ ```javascript
136
+ // app.html
137
+ <script>
138
+ if (typeof window !== 'undefined') {
139
+ window.global = window;
140
+ }
141
+ </script>
142
+ ```
143
+
144
+ ## TypeScript Support
145
+
146
+ This package includes TypeScript definitions. No additional setup is required.
147
+
148
+ ## License
149
+
150
+ [Apache-2.0](https://github.com/aws-amplify/amplify-ui/blob/main/LICENSE)
@@ -0,0 +1,230 @@
1
+ <script lang="ts">
2
+ import { onDestroy, onMount, type Snippet } from 'svelte';
3
+ import { get } from 'svelte/store';
4
+ import {
5
+ type AuthenticatorMachineOptions,
6
+ type AuthenticatorRoute,
7
+ authenticatorTextUtil,
8
+ type AuthFormFields,
9
+ type AuthMachineState,
10
+ setUserAgent,
11
+ type SocialProvider,
12
+ } from '@aws-amplify/ui';
13
+ import { type AuthUser } from '@aws-amplify/auth';
14
+
15
+ import { useAuth, useAuthenticator } from '../../stores/authenticator.svelte';
16
+ import { VERSION } from '../../version';
17
+ import { type Components } from '../../types';
18
+
19
+ import { TwoTabItem, TwoTabs } from '../primitives';
20
+ import {
21
+ ConfirmResetPassword,
22
+ ConfirmSignIn,
23
+ ConfirmSignUp,
24
+ ConfirmVerifyUser,
25
+ ForceNewPassword,
26
+ ForgotPassword,
27
+ SelectMfaType,
28
+ SetupEmail,
29
+ SetupTotp,
30
+ SignIn,
31
+ SignUp,
32
+ VerifyUser,
33
+ } from '.';
34
+
35
+ interface ComponentsProvider extends Components {
36
+ ConfirmSignIn?: Components;
37
+ ConfirmSignUp?: Components;
38
+ ConfirmResetPassword?: Components;
39
+ ConfirmVerifyUser?: Components;
40
+ ForceNewPassword?: Components;
41
+ ForgotPassword?: Components;
42
+ SelectMfaType?: Components;
43
+ SetupEmail?: Components;
44
+ SetupTotp?: Components;
45
+ SignIn?: Components;
46
+ SignUp?: Components;
47
+ VerifyUser?: Components;
48
+ }
49
+
50
+ interface AuthenticatorProps {
51
+ components?: ComponentsProvider;
52
+ initialState?: AuthenticatorMachineOptions['initialState'];
53
+ loginMechanisms?: AuthenticatorMachineOptions['loginMechanisms'];
54
+ variation?: 'default' | 'modal';
55
+ services?: AuthenticatorMachineOptions['services'];
56
+ signUpAttributes?: AuthenticatorMachineOptions['signUpAttributes'];
57
+ socialProviders?: SocialProvider[];
58
+ hideSignUp?: boolean;
59
+ formFields?: AuthFormFields;
60
+ children?: Snippet<
61
+ [
62
+ {
63
+ user: AuthUser;
64
+ state: AuthMachineState;
65
+ signOut: () => void;
66
+ send: ReturnType<typeof useAuth>['send'];
67
+ },
68
+ ]
69
+ >;
70
+ }
71
+
72
+ const {
73
+ components,
74
+ initialState,
75
+ loginMechanisms,
76
+ variation = 'default',
77
+ services,
78
+ signUpAttributes,
79
+ socialProviders,
80
+ hideSignUp,
81
+ formFields,
82
+ children,
83
+ }: AuthenticatorProps = $props();
84
+
85
+ let clearUserAgent: () => void;
86
+
87
+ const auth = useAuth();
88
+ const { authenticator } = $derived(useAuthenticator());
89
+ const isSetup = $derived(authenticator.route === 'setup');
90
+
91
+ $effect(() => {
92
+ if (isSetup) {
93
+ auth.send({
94
+ type: 'INIT',
95
+ data: {
96
+ initialState,
97
+ loginMechanisms,
98
+ socialProviders,
99
+ signUpAttributes,
100
+ services,
101
+ formFields,
102
+ },
103
+ });
104
+ }
105
+ });
106
+
107
+ onMount(() => {
108
+ clearUserAgent = setUserAgent({
109
+ componentName: 'Authenticator',
110
+ packageName: 'svelte',
111
+ version: VERSION,
112
+ });
113
+ });
114
+
115
+ onDestroy(() => {
116
+ clearUserAgent?.();
117
+ });
118
+
119
+ // text util
120
+ const { getSignInTabText, getSignUpTabText } = authenticatorTextUtil;
121
+
122
+ // computed
123
+ const signInLabel = $derived(getSignInTabText());
124
+ const createAccountLabel = $derived(getSignUpTabText());
125
+
126
+ // methods
127
+ const hasTabs = $derived(
128
+ authenticator.route === 'signIn' || authenticator.route === 'signUp'
129
+ );
130
+
131
+ const hasRouteComponent = $derived(
132
+ (
133
+ [
134
+ 'confirmResetPassword',
135
+ 'confirmSignIn',
136
+ 'confirmSignUp',
137
+ 'confirmVerifyUser',
138
+ 'forceNewPassword',
139
+ 'forgotPassword',
140
+ 'selectMfaType',
141
+ 'setupEmail',
142
+ 'setupTotp',
143
+ 'signIn',
144
+ 'signUp',
145
+ 'verifyUser',
146
+ ] as AuthenticatorRoute[]
147
+ ).includes(authenticator.route)
148
+ );
149
+ </script>
150
+
151
+ {#if hasRouteComponent}
152
+ <div data-amplify-authenticator data-variation={variation}>
153
+ <div data-amplify-container>
154
+ {@render components?.Header?.()}
155
+ <div
156
+ data-amplify-router
157
+ data-amplify-router-content={hasTabs ? undefined : ''}
158
+ >
159
+ {#if hasTabs && !hideSignUp}
160
+ <TwoTabs>
161
+ <TwoTabItem
162
+ active={authenticator.route === 'signIn'}
163
+ id="signIn"
164
+ label={signInLabel}
165
+ onclick={authenticator.toSignIn}
166
+ />
167
+ <TwoTabItem
168
+ active={authenticator.route === 'signUp'}
169
+ id="signUp"
170
+ label={createAccountLabel}
171
+ onclick={authenticator.toSignUp}
172
+ />
173
+ </TwoTabs>
174
+ {/if}
175
+ {#if hasTabs}
176
+ <div data-amplify-router-content>
177
+ {#if authenticator.route === 'signIn'}
178
+ <SignIn
179
+ id="signIn-panel"
180
+ role="tabpanel"
181
+ class="amplify-tabs__panel amplify-tabs__panel--active"
182
+ aria-labelledby="signIn-tab"
183
+ components={components?.SignIn}
184
+ />
185
+ {/if}
186
+ {#if authenticator.route === 'signUp' && !hideSignUp}
187
+ <SignUp
188
+ id="signUp-panel"
189
+ class="amplify-tabs__panel amplify-tabs__panel--active"
190
+ role="tabpanel"
191
+ aria-labelledby="signUp-tab"
192
+ components={components?.SignUp}
193
+ />
194
+ {/if}
195
+ </div>
196
+ {/if}
197
+ {#if authenticator.route === 'confirmSignUp'}
198
+ <ConfirmSignUp components={components?.ConfirmSignUp} />
199
+ {:else if authenticator.route === 'forgotPassword'}
200
+ <ForgotPassword components={components?.ForgotPassword} />
201
+ {:else if authenticator.route === 'confirmResetPassword'}
202
+ <ConfirmResetPassword components={components?.ConfirmResetPassword} />
203
+ {:else if authenticator.route === 'confirmSignIn'}
204
+ <ConfirmSignIn components={components?.ConfirmSignIn} />
205
+ {:else if authenticator.route === 'setupTotp'}
206
+ <SetupTotp components={components?.SetupTotp} />
207
+ {:else if authenticator.route === 'forceNewPassword'}
208
+ <ForceNewPassword components={components?.ForceNewPassword} />
209
+ {:else if authenticator.route === 'verifyUser'}
210
+ <VerifyUser components={components?.VerifyUser} />
211
+ {:else if authenticator.route === 'confirmVerifyUser'}
212
+ <ConfirmVerifyUser components={components?.ConfirmVerifyUser} />
213
+ {:else if authenticator.route === 'selectMfaType'}
214
+ <SelectMfaType components={components?.SelectMfaType} />
215
+ {:else if authenticator.route === 'setupEmail'}
216
+ <SetupEmail components={components?.SetupEmail} />
217
+ {/if}
218
+ </div>
219
+ {@render components?.Footer?.()}
220
+ </div>
221
+ </div>
222
+ {/if}
223
+ {#if authenticator.route === 'authenticated'}
224
+ {@render children?.({
225
+ user: authenticator.user,
226
+ state: get(auth.state),
227
+ signOut: authenticator.signOut,
228
+ send: auth.send,
229
+ })}
230
+ {/if}
@@ -0,0 +1,41 @@
1
+ import { type Snippet } from 'svelte';
2
+ import { type AuthenticatorMachineOptions, type AuthFormFields, type AuthMachineState, type SocialProvider } from '@aws-amplify/ui';
3
+ import { type AuthUser } from '@aws-amplify/auth';
4
+ import { useAuth } from '../../stores/authenticator.svelte';
5
+ import { type Components } from '../../types';
6
+ interface ComponentsProvider extends Components {
7
+ ConfirmSignIn?: Components;
8
+ ConfirmSignUp?: Components;
9
+ ConfirmResetPassword?: Components;
10
+ ConfirmVerifyUser?: Components;
11
+ ForceNewPassword?: Components;
12
+ ForgotPassword?: Components;
13
+ SelectMfaType?: Components;
14
+ SetupEmail?: Components;
15
+ SetupTotp?: Components;
16
+ SignIn?: Components;
17
+ SignUp?: Components;
18
+ VerifyUser?: Components;
19
+ }
20
+ interface AuthenticatorProps {
21
+ components?: ComponentsProvider;
22
+ initialState?: AuthenticatorMachineOptions['initialState'];
23
+ loginMechanisms?: AuthenticatorMachineOptions['loginMechanisms'];
24
+ variation?: 'default' | 'modal';
25
+ services?: AuthenticatorMachineOptions['services'];
26
+ signUpAttributes?: AuthenticatorMachineOptions['signUpAttributes'];
27
+ socialProviders?: SocialProvider[];
28
+ hideSignUp?: boolean;
29
+ formFields?: AuthFormFields;
30
+ children?: Snippet<[
31
+ {
32
+ user: AuthUser;
33
+ state: AuthMachineState;
34
+ signOut: () => void;
35
+ send: ReturnType<typeof useAuth>['send'];
36
+ }
37
+ ]>;
38
+ }
39
+ declare const Authenticator: import("svelte").Component<AuthenticatorProps, {}, "">;
40
+ type Authenticator = ReturnType<typeof Authenticator>;
41
+ export default Authenticator;
@@ -0,0 +1,119 @@
1
+ <script lang="ts">
2
+ import {
3
+ authenticatorTextUtil,
4
+ getFormDataFromEvent,
5
+ translate,
6
+ } from '@aws-amplify/ui';
7
+
8
+ import { useAuthenticator } from '../../stores/authenticator.svelte';
9
+ import { type Components } from '../../types';
10
+
11
+ import Wrapper from '../primitives/Wrapper.svelte';
12
+ import Form from '../primitives/Form.svelte';
13
+ import Button from '../controls/Button.svelte';
14
+ import FieldSet from '../primitives/FieldSet.svelte';
15
+ import FormFields from '../primitives/FormFields.svelte';
16
+ import Heading from '../primitives/Heading.svelte';
17
+ import Footer from '../primitives/Footer.svelte';
18
+ import Alert from '../primitives/Alert.svelte';
19
+
20
+ interface Props {
21
+ components?: Components;
22
+ }
23
+
24
+ const { components }: Props = $props();
25
+
26
+ const { authenticator } = $derived(useAuthenticator());
27
+
28
+ // Text Util
29
+ const { getResendCodeText, getResetYourPasswordText, getSubmitText } =
30
+ authenticatorTextUtil;
31
+
32
+ // Computed Properties
33
+ const resendCodeText = $derived.by(() => getResendCodeText());
34
+ const confirmResetPasswordHeading = $derived.by(() =>
35
+ getResetYourPasswordText()
36
+ );
37
+ const confirmResetPasswordText = $derived.by(() => getSubmitText());
38
+
39
+ // Methods
40
+ const onConfirmResetPasswordSubmit = (e: Event): void => {
41
+ e.preventDefault();
42
+ submit(e);
43
+ };
44
+
45
+ const submit = (e: Event): void => {
46
+ authenticator.submitForm(getFormDataFromEvent(e));
47
+ };
48
+
49
+ const onLostYourCodeClicked = (e: Event): void => {
50
+ e.preventDefault();
51
+ authenticator.resendCode();
52
+ };
53
+
54
+ const onInput = (e: Event) => {
55
+ const { name, value } = e.target as HTMLInputElement;
56
+ authenticator.updateForm({ name, value });
57
+ };
58
+
59
+ function onBlur(e: Event) {
60
+ const { name } = e.target as HTMLInputElement;
61
+ authenticator.updateBlur({ name });
62
+ }
63
+ </script>
64
+
65
+ <Wrapper>
66
+ <Form
67
+ data-amplify-authenticator-confirmResetpassword
68
+ oninput={onInput}
69
+ onblurcapture={onBlur}
70
+ onsubmit={onConfirmResetPasswordSubmit}
71
+ >
72
+ <FieldSet
73
+ class="amplify-flex amplify-authenticator__column"
74
+ disabled={authenticator.isPending}
75
+ >
76
+ {#if components?.Header}
77
+ {@render components?.Header()}
78
+ {:else}
79
+ <Heading class="amplify-heading" level="h3">
80
+ {confirmResetPasswordHeading}
81
+ </Heading>
82
+ {/if}
83
+ <Wrapper class="amplify-flex amplify-authenticator__column">
84
+ {#if components?.FormFields}
85
+ {@render components?.FormFields()}
86
+ {:else}
87
+ <FormFields route="confirmResetPassword" />
88
+ {/if}
89
+ </Wrapper>
90
+ <Footer class="amplify-flex amplify-authenticator__column">
91
+ {#if authenticator.error}
92
+ <Alert>
93
+ {translate(authenticator.error)}
94
+ </Alert>
95
+ {/if}
96
+ <Button
97
+ class="amplify-field-group__control amplify-authenticator__font"
98
+ variation="primary"
99
+ fullWidth={false}
100
+ type="submit"
101
+ disabled={authenticator.isPending}
102
+ >
103
+ {confirmResetPasswordText}
104
+ </Button>
105
+ <Button
106
+ class="amplify-field-group__control amplify-authenticator__font"
107
+ variation="link"
108
+ fullWidth={false}
109
+ size="small"
110
+ type="button"
111
+ onclick={onLostYourCodeClicked}
112
+ >
113
+ {resendCodeText}
114
+ </Button>
115
+ {@render components?.Footer?.()}
116
+ </Footer>
117
+ </FieldSet>
118
+ </Form>
119
+ </Wrapper>
@@ -0,0 +1,7 @@
1
+ import { type Components } from '../../types';
2
+ interface Props {
3
+ components?: Components;
4
+ }
5
+ declare const ConfirmResetPassword: import("svelte").Component<Props, {}, "">;
6
+ type ConfirmResetPassword = ReturnType<typeof ConfirmResetPassword>;
7
+ export default ConfirmResetPassword;
@@ -0,0 +1,110 @@
1
+ <script lang="ts">
2
+ import {
3
+ authenticatorTextUtil,
4
+ getFormDataFromEvent,
5
+ translate,
6
+ } from '@aws-amplify/ui';
7
+
8
+ import { useAuthenticator } from '../../stores/authenticator.svelte';
9
+ import { type Components } from '../../types';
10
+
11
+ import Wrapper from '../primitives/Wrapper.svelte';
12
+ import Form from '../primitives/Form.svelte';
13
+ import Button from '../controls/Button.svelte';
14
+ import FieldSet from '../primitives/FieldSet.svelte';
15
+ import FormFields from '../primitives/FormFields.svelte';
16
+ import Heading from '../primitives/Heading.svelte';
17
+ import Footer from '../primitives/Footer.svelte';
18
+ import Alert from '../primitives/Alert.svelte';
19
+
20
+ interface Props {
21
+ components?: Components;
22
+ }
23
+
24
+ const { components }: Props = $props();
25
+
26
+ const { authenticator } = $derived(useAuthenticator());
27
+
28
+ // Text Util
29
+ const { getBackToSignInText, getConfirmText, getChallengeText } =
30
+ authenticatorTextUtil;
31
+
32
+ // Computed Properties
33
+ const confirmSignInHeading = $derived.by(() =>
34
+ getChallengeText(authenticator.challengeName)
35
+ );
36
+ const backSignInText = $derived.by(() => getBackToSignInText());
37
+ const confirmText = $derived.by(() => getConfirmText());
38
+
39
+ // Methods
40
+ const onInput = (e: Event): void => {
41
+ const { name, value } = e.target as HTMLInputElement;
42
+ authenticator.updateForm({ name, value });
43
+ };
44
+
45
+ const onConfirmSignInSubmit = (e: Event): void => {
46
+ e.preventDefault();
47
+ authenticator.submitForm(getFormDataFromEvent(e));
48
+ };
49
+
50
+ const onBackToSignInClicked = (e: Event): void => {
51
+ e.preventDefault();
52
+ authenticator.toSignIn();
53
+ };
54
+ </script>
55
+
56
+ <Wrapper>
57
+ <Form
58
+ data-amplify-authenticator-confirmsignin
59
+ oninput={onInput}
60
+ onsubmit={onConfirmSignInSubmit}
61
+ >
62
+ <FieldSet
63
+ class="amplify-flex amplify-authenticator__column"
64
+ disabled={authenticator.isPending}
65
+ >
66
+ {#if components?.Header}
67
+ {@render components?.Header()}
68
+ {:else}
69
+ <Heading level="h3" class="amplify-heading">
70
+ {confirmSignInHeading}
71
+ </Heading>
72
+ {/if}
73
+
74
+ <Wrapper class="amplify-flex amplify-authenticator__column">
75
+ {#if components?.FormFields}
76
+ {@render components?.FormFields()}
77
+ {:else}
78
+ <FormFields route="confirmSignIn" />
79
+ {/if}
80
+ </Wrapper>
81
+ <Footer class="amplify-flex amplify-authenticator__column">
82
+ {#if authenticator.error}
83
+ <Alert>
84
+ {translate(authenticator.error)}
85
+ </Alert>
86
+ {/if}
87
+ <Button
88
+ class="amplify-field-group__control amplify-authenticator__font"
89
+ fullWidth={false}
90
+ loading={false}
91
+ variation="primary"
92
+ disabled={authenticator.isPending}
93
+ >
94
+ {confirmText}
95
+ </Button>
96
+ <Button
97
+ class="amplify-field-group__control amplify-authenticator__font"
98
+ fullWidth={false}
99
+ size="small"
100
+ variation="link"
101
+ type="button"
102
+ onclick={onBackToSignInClicked}
103
+ >
104
+ {backSignInText}
105
+ </Button>
106
+ {@render components?.Footer?.()}
107
+ </Footer>
108
+ </FieldSet>
109
+ </Form>
110
+ </Wrapper>
@@ -0,0 +1,7 @@
1
+ import { type Components } from '../../types';
2
+ interface Props {
3
+ components?: Components;
4
+ }
5
+ declare const ConfirmSignIn: import("svelte").Component<Props, {}, "">;
6
+ type ConfirmSignIn = ReturnType<typeof ConfirmSignIn>;
7
+ export default ConfirmSignIn;