@aws-amplify/ui-svelte 0.0.0-cifix-d415b87-20251212183747

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 (98) hide show
  1. package/README.md +150 -0
  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 -0
  87. package/dist/index.js +8 -0
  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.d.ts +0 -0
  92. package/dist/styles/index.js +3 -0
  93. package/dist/styles.css +2 -0
  94. package/dist/types/index.d.ts +21 -0
  95. package/dist/types/index.js +1 -0
  96. package/dist/version.d.ts +1 -0
  97. package/dist/version.js +1 -0
  98. package/package.json +72 -0
package/README.md ADDED
@@ -0,0 +1,150 @@
1
+ # @aws-amplify/ui-svelte
2
+
3
+ Svelte components for Amplify UI
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @aws-amplify/ui-svelte aws-amplify
9
+ ```
10
+
11
+ or
12
+
13
+ ```bash
14
+ yarn add @aws-amplify/ui-svelte aws-amplify
15
+ ```
16
+
17
+ ## Usage
18
+
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>
35
+ ```
36
+
37
+ ### Using with TypeScript
38
+
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';
46
+
47
+ Amplify.configure(awsExports);
48
+
49
+ let user: AuthUser;
50
+ let signOut: () => void;
51
+ </script>
52
+
53
+ <Authenticator let:user let:signOut>
54
+ <h1>Hello {user.username}</h1>
55
+ <button on:click={signOut}>Sign out</button>
56
+ </Authenticator>
57
+ ```
58
+
59
+ ### Customization
60
+
61
+ The Authenticator component provides several props for customization:
62
+
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
+ }
129
+ ```
130
+
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;