@aws-amplify/ui-svelte 0.0.0-next-5fb24a8-20220106211328 → 0.0.0-next-9a4f1cf-20220113211745

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.
@@ -0,0 +1,41 @@
1
+ <script >import { onMount } from 'svelte';
2
+ import { authState } from './authStore';
3
+ import { authInputAttributes, } from '@aws-amplify/ui';
4
+ import AmplifyFormField from '../components/primitives/AmplifyFormField.svelte';
5
+ import UserNameAlias from './UserNameAlias.svelte';
6
+ let fieldNames = [];
7
+ let loginMechanism;
8
+ onMount(() => {
9
+ const context = $authState.context;
10
+ const { loginMechanisms, signUpAttributes } = context.config;
11
+ fieldNames = Array.from(new Set([...loginMechanisms, ...signUpAttributes]));
12
+ fieldNames = fieldNames.filter((fieldName) => {
13
+ const hasDefaultField = !!authInputAttributes[fieldName];
14
+ if (!hasDefaultField) {
15
+ console.debug(`Authenticator does not have a default implementation for ${fieldName}. Customize Authenticator.SignUp.FormFields to add your own.`);
16
+ }
17
+ return hasDefaultField;
18
+ });
19
+ // Only 1 is supported, so `['email', 'phone_number']` will only show `email`
20
+ loginMechanism = fieldNames.shift();
21
+ });
22
+ </script>
23
+
24
+ <div class="amplify-flex" style="flex-direction: column" data-amplify-fieldset>
25
+ <UserNameAlias name={loginMechanism} />
26
+ <AmplifyFormField
27
+ name="password"
28
+ type="password"
29
+ autocomplete="new-password"
30
+ />
31
+ <AmplifyFormField
32
+ name="confirm_password"
33
+ label="Confirm Password"
34
+ type="password"
35
+ autocomplete="new-password"
36
+ />
37
+
38
+ {#each fieldNames as field}
39
+ <AmplifyFormField name={field} type="text" labelHidden={false} />
40
+ {/each}
41
+ </div>
@@ -0,0 +1,14 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {};
4
+ events: {
5
+ [evt: string]: CustomEvent<any>;
6
+ };
7
+ slots: {};
8
+ };
9
+ export declare type AmplifySignUpFormFieldsProps = typeof __propDef.props;
10
+ export declare type AmplifySignUpFormFieldsEvents = typeof __propDef.events;
11
+ export declare type AmplifySignUpFormFieldsSlots = typeof __propDef.slots;
12
+ export default class AmplifySignUpFormFields extends SvelteComponentTyped<AmplifySignUpFormFieldsProps, AmplifySignUpFormFieldsEvents, AmplifySignUpFormFieldsSlots> {
13
+ }
14
+ export {};
@@ -1,7 +1,8 @@
1
1
  <script >import { onDestroy } from 'svelte';
2
2
  import { setupMachine, route, toSignIn } from './authStore';
3
- import SignIn from './SignIn.svelte';
4
3
  import AmplifyTabs from './primitives/AmplifyTabs.svelte';
4
+ import AmplifyTabItem from './primitives/AmplifyTabItem.svelte';
5
+ import ConfirmSignUp from './ConfirmSignUp.svelte';
5
6
  export let initialState = undefined;
6
7
  export let loginMechanisms = undefined;
7
8
  export let services = undefined;
@@ -20,20 +21,26 @@ onDestroy(() => {
20
21
  <!--Slot header goes here-->
21
22
  <div data-amplify-router>
22
23
  {#if $route === 'signIn' || $route === 'signUp'}
23
- <AmplifyTabs />
24
- {/if}
25
-
26
- {#if $route === 'signIn'}
27
- <SignIn />
28
- {/if}
29
- {#if $route === 'signUp'}
30
- <p>Sign Up</p>
31
- <button on:click={toSignIn}>To Sign In</button>
24
+ <AmplifyTabs let:tabs>
25
+ {#each tabs as tab}
26
+ <AmplifyTabItem
27
+ active={tab.active}
28
+ id={tab.id}
29
+ labelledById={tab.labelledById}
30
+ tabIndex={tab.tabIndex}
31
+ >
32
+ <svelte:component this={tab.component} />
33
+ </AmplifyTabItem>
34
+ {/each}
35
+ </AmplifyTabs>
32
36
  {/if}
33
37
  {#if $route === 'resetPassword'}
34
38
  <p>reset password</p>
35
39
  <button on:click={toSignIn}>To Sign In</button>
36
40
  {/if}
41
+ {#if $route === 'confirmSignUp'}
42
+ <ConfirmSignUp />
43
+ {/if}
37
44
  </div>
38
45
  </div>
39
46
  </div>
@@ -0,0 +1,87 @@
1
+ <script >import { codeDeliveryDetails, updateForm, submitForm, resendCode, error, isPending, } from './authStore';
2
+ import { translate } from '@aws-amplify/ui';
3
+ import AmplifyFormField from './primitives/AmplifyFormField.svelte';
4
+ import AmplifyButton from './primitives/AmplifyButton.svelte';
5
+ import AmplifyError from './primitives/AmplifyError.svelte';
6
+ // translated texts
7
+ const resendCodeText = translate('Resend Code');
8
+ const confirmText = translate('Confirm');
9
+ let confirmSignUpHeading = '';
10
+ let subtitleText = '';
11
+ $: {
12
+ const { DeliveryMedium = {} } = $codeDeliveryDetails;
13
+ confirmSignUpHeading =
14
+ DeliveryMedium === 'EMAIL'
15
+ ? translate('We Emailed You')
16
+ : DeliveryMedium === 'SMS'
17
+ ? translate('We Texted You')
18
+ : translate('We Sent A Code');
19
+ }
20
+ $: {
21
+ const { DeliveryMedium, Destination } = $codeDeliveryDetails;
22
+ subtitleText =
23
+ DeliveryMedium === 'EMAIL'
24
+ ? `Your code is on the way. To log in, enter the code we emailed to ${Destination}. It may take a minute to arrive.`
25
+ : DeliveryMedium === 'SMS'
26
+ ? `Your code is on the way. To log in, enter the code we texted to ${Destination}. It may take a minute to arrive.`
27
+ : translate(`Your code is on the way. To log in, enter the code we sent you. It may take a minute to arrive.`);
28
+ }
29
+ function onInput(event) {
30
+ event.preventDefault();
31
+ const { name, value } = event.target;
32
+ updateForm({ name, value });
33
+ }
34
+ function onSubmit(event) {
35
+ event.preventDefault();
36
+ submitForm();
37
+ }
38
+ </script>
39
+
40
+ <div data-amplify-container>
41
+ <form
42
+ data-amplify-form
43
+ on:submit|preventDefault={onSubmit}
44
+ on:input={onInput}
45
+ >
46
+ <fieldset
47
+ class="amplify-flex"
48
+ style="flex-direction: column"
49
+ data-amplify-fieldset
50
+ disabled={$isPending}
51
+ >
52
+ <h3 class="amplify-heading" style="font-size: 1.5rem">
53
+ {confirmSignUpHeading}
54
+ </h3>
55
+ <span style="margin-bottom: 1rem">
56
+ {subtitleText}
57
+ </span>
58
+ <AmplifyFormField
59
+ name="confirmation_code"
60
+ type="text"
61
+ autocomplete="one-time-code"
62
+ />
63
+
64
+ {#if $error}
65
+ <AmplifyError>
66
+ {$error}
67
+ </AmplifyError>
68
+ {/if}
69
+
70
+ <AmplifyButton
71
+ amplify-AmplifyButton
72
+ variation="primary"
73
+ fullWidth="true"
74
+ type="submit"
75
+ >
76
+ {confirmText}
77
+ </AmplifyButton>
78
+ <AmplifyButton
79
+ amplify-button
80
+ fontWeight="normal"
81
+ on:click={() => resendCode()}
82
+ >
83
+ {resendCodeText}
84
+ </AmplifyButton>
85
+ </fieldset>
86
+ </form>
87
+ </div>
@@ -0,0 +1,14 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {};
4
+ events: {
5
+ [evt: string]: CustomEvent<any>;
6
+ };
7
+ slots: {};
8
+ };
9
+ export declare type ConfirmSignUpProps = typeof __propDef.props;
10
+ export declare type ConfirmSignUpEvents = typeof __propDef.events;
11
+ export declare type ConfirmSignUpSlots = typeof __propDef.slots;
12
+ export default class ConfirmSignUp extends SvelteComponentTyped<ConfirmSignUpProps, ConfirmSignUpEvents, ConfirmSignUpSlots> {
13
+ }
14
+ export {};
File without changes
@@ -0,0 +1,19 @@
1
+ /** @typedef {typeof __propDef.props} FederatedSignInProps */
2
+ /** @typedef {typeof __propDef.events} FederatedSignInEvents */
3
+ /** @typedef {typeof __propDef.slots} FederatedSignInSlots */
4
+ export default class FederatedSignIn extends SvelteComponentTyped<{}, {
5
+ [evt: string]: CustomEvent<any>;
6
+ }, {}> {
7
+ }
8
+ export type FederatedSignInProps = typeof __propDef.props;
9
+ export type FederatedSignInEvents = typeof __propDef.events;
10
+ export type FederatedSignInSlots = typeof __propDef.slots;
11
+ import { SvelteComponentTyped } from "svelte";
12
+ declare const __propDef: {
13
+ props: {};
14
+ events: {
15
+ [evt: string]: CustomEvent<any>;
16
+ };
17
+ slots: {};
18
+ };
19
+ export {};
@@ -0,0 +1,45 @@
1
+ <script >import { updateForm, submitForm, error, isPending, hasValidationErrors, } from './authStore';
2
+ import AmplifyError from './primitives/AmplifyError.svelte';
3
+ import AmplifyButton from './primitives/AmplifyButton.svelte';
4
+ import AmplifySignUpFormFields from './AmplifySignUpFormFields.svelte';
5
+ import { translate } from '@aws-amplify/ui';
6
+ const createAccountText = translate('Create Account');
7
+ function onInput(event) {
8
+ let { checked, name, type, value } = event.target;
9
+ if (type === 'checkbox' && !checked)
10
+ value = undefined;
11
+ updateForm({ name, value });
12
+ }
13
+ function onSubmit(event) {
14
+ submitForm();
15
+ }
16
+ </script>
17
+
18
+ <form data-amplify-form on:submit|preventDefault={onSubmit} on:input={onInput}>
19
+ <div class="amplify-flex" style="flex-direction: column">
20
+ <div class="amplify-flex" style="flex-direction: column">
21
+ <fieldset
22
+ class="amplify-flex"
23
+ style="flex-direction: column"
24
+ disabled={$isPending}
25
+ >
26
+ <AmplifySignUpFormFields />
27
+ </fieldset>
28
+ {#if $error}
29
+ <AmplifyError>
30
+ {$error}
31
+ </AmplifyError>
32
+ {/if}
33
+ </div>
34
+
35
+ <AmplifyButton
36
+ disabled={$isPending || $hasValidationErrors}
37
+ amplify-button
38
+ variation="primary"
39
+ fullWidth="true"
40
+ type="submit"
41
+ >
42
+ {createAccountText}
43
+ </AmplifyButton>
44
+ </div>
45
+ </form>
@@ -0,0 +1,14 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ declare const __propDef: {
3
+ props: {};
4
+ events: {
5
+ [evt: string]: CustomEvent<any>;
6
+ };
7
+ slots: {};
8
+ };
9
+ export declare type SignUpProps = typeof __propDef.props;
10
+ export declare type SignUpEvents = typeof __propDef.events;
11
+ export declare type SignUpSlots = typeof __propDef.slots;
12
+ export default class SignUp extends SvelteComponentTyped<SignUpProps, SignUpEvents, SignUpSlots> {
13
+ }
14
+ export {};
@@ -1,4 +1,4 @@
1
- import { createAuthenticatorMachine, getServiceContextFacade, getSendEventAliases, translate, } from '@aws-amplify/ui';
1
+ import { createAuthenticatorMachine, getSendEventAliases, translate, getServiceContextFacade, } from '@aws-amplify/ui';
2
2
  import { interpret } from 'xstate';
3
3
  import { writable, get } from 'svelte/store';
4
4
  let _facade = writable(null);
@@ -10,6 +10,7 @@ export const user = writable(null);
10
10
  export const validationErrors = writable(null);
11
11
  export const codeDeliveryDetails = writable(null);
12
12
  const _sendEventAliases = writable(null);
13
+ const contextFacade = getServiceContextFacade;
13
14
  /** @deprecated For internal use only */
14
15
  export const authState = writable(null);
15
16
  export function setupMachine(initialState, loginMechanisms, services, signUpAttributes, socialProviders) {
@@ -25,7 +26,7 @@ export function setupMachine(initialState, loginMechanisms, services, signUpAttr
25
26
  }).start();
26
27
  const subscription = authService.subscribe((state) => {
27
28
  authState.update(() => state);
28
- _facade.update(() => getServiceContextFacade(state));
29
+ _facade.update(() => contextFacade(state));
29
30
  setError();
30
31
  setRoute();
31
32
  setHasValidationErrors();
@@ -0,0 +1,19 @@
1
+ <script >import 'svelte';
2
+ export let active = false;
3
+ export let id;
4
+ export let labelledById;
5
+ export let tabIndex;
6
+ </script>
7
+
8
+ <div
9
+ data-orientation="horizontal"
10
+ role="tabpanel"
11
+ {id}
12
+ aria-labelledby={labelledById}
13
+ data-state={active ? 'active' : 'inactive'}
14
+ tabindex={tabIndex}
15
+ >
16
+ {#if active}
17
+ <slot />
18
+ {/if}
19
+ </div>
@@ -1,19 +1,21 @@
1
- /** @typedef {typeof __propDef.props} AmplifyTabItemProps */
2
- /** @typedef {typeof __propDef.events} AmplifyTabItemEvents */
3
- /** @typedef {typeof __propDef.slots} AmplifyTabItemSlots */
4
- export default class AmplifyTabItem extends SvelteComponentTyped<{}, {
5
- [evt: string]: CustomEvent<any>;
6
- }, {}> {
7
- }
8
- export type AmplifyTabItemProps = typeof __propDef.props;
9
- export type AmplifyTabItemEvents = typeof __propDef.events;
10
- export type AmplifyTabItemSlots = typeof __propDef.slots;
11
1
  import { SvelteComponentTyped } from "svelte";
12
2
  declare const __propDef: {
13
- props: {};
3
+ props: {
4
+ active?: boolean;
5
+ id: string;
6
+ labelledById: string;
7
+ tabIndex: number;
8
+ };
14
9
  events: {
15
10
  [evt: string]: CustomEvent<any>;
16
11
  };
17
- slots: {};
12
+ slots: {
13
+ default: {};
14
+ };
18
15
  };
16
+ export declare type AmplifyTabItemProps = typeof __propDef.props;
17
+ export declare type AmplifyTabItemEvents = typeof __propDef.events;
18
+ export declare type AmplifyTabItemSlots = typeof __propDef.slots;
19
+ export default class AmplifyTabItem extends SvelteComponentTyped<AmplifyTabItemProps, AmplifyTabItemEvents, AmplifyTabItemSlots> {
20
+ }
19
21
  export {};
@@ -1,50 +1,72 @@
1
- <script >//tab list
2
- const tabs = [
1
+ <script >import SignIn from '../SignIn.svelte';
2
+ import SignUp from '../SignUp.svelte';
3
+ import { toSignIn, toSignUp } from '../authStore';
4
+ //tab list
5
+ let tabs = [
3
6
  {
4
7
  active: true,
5
8
  labelledById: '1',
6
9
  id: '1',
7
- title: 'Sign In'
10
+ title: 'Sign In',
11
+ tabIndex: 0,
12
+ component: SignIn,
8
13
  },
9
14
  {
10
15
  active: false,
11
16
  labelledById: '2',
12
17
  id: '2',
13
- title: 'Sign Up'
14
- }
18
+ title: 'Sign Up',
19
+ tabIndex: -1,
20
+ component: SignUp,
21
+ },
15
22
  ];
16
23
  function handleTabClick(e) {
17
- // future
24
+ if (e.id === '1') {
25
+ toSignIn();
26
+ }
27
+ else {
28
+ toSignUp();
29
+ }
30
+ tabs = tabs.map((tab) => {
31
+ if (tab.id === e.id) {
32
+ return { ...tab, active: true };
33
+ }
34
+ else {
35
+ return { ...tab, active: false };
36
+ }
37
+ });
18
38
  }
19
39
  </script>
20
40
 
21
41
  <div
22
- tabindex="0"
23
- aria-orientation="horizontal"
24
- data-orientation="horizontal"
25
- role="tablist"
26
- style="outline: none"
42
+ tabindex="0"
43
+ aria-orientation="horizontal"
44
+ data-orientation="horizontal"
45
+ role="tablist"
46
+ style="outline: none"
27
47
  >
28
- <div
29
- class="amplify-flex amplify-tabs"
30
- data-indicator-position="top"
31
- style="gap: 0px; justify-content: center"
32
- >
33
- {#each tabs as tab}
34
- <div
35
- class="amplify-tabs-item"
36
- data-spacing="equal"
37
- data-orientation="horizontal"
38
- role="tab"
39
- id={tab.labelledById}
40
- tabindex={tab.active ? 0 : 1}
41
- aria-selected={tab.active}
42
- aria-controls={tab.id}
43
- data-state={tab.active ? 'active' : 'inactive'}
44
- on:click={() => handleTabClick(tab)}
45
- >
46
- {tab.title}
47
- </div>
48
- {/each}
49
- </div>
48
+ <div
49
+ class="amplify-flex amplify-tabs"
50
+ data-indicator-position="top"
51
+ style="gap: 0px; justify-content: center"
52
+ >
53
+ {#each tabs as tab}
54
+ <div
55
+ class="amplify-tabs-item"
56
+ data-spacing="equal"
57
+ data-orientation="horizontal"
58
+ role="tab"
59
+ id={tab.labelledById}
60
+ tabindex={tab.active ? 0 : 1}
61
+ aria-selected={tab.active}
62
+ aria-controls={tab.id}
63
+ data-state={tab.active ? 'active' : 'inactive'}
64
+ on:click={() => handleTabClick(tab)}
65
+ >
66
+ {tab.title}
67
+ </div>
68
+ {/each}
69
+ </div>
50
70
  </div>
71
+
72
+ <slot {tabs} />
@@ -1,10 +1,22 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
+ import SignIn from '../SignIn.svelte';
2
3
  declare const __propDef: {
3
4
  props: {};
4
5
  events: {
5
6
  [evt: string]: CustomEvent<any>;
6
7
  };
7
- slots: {};
8
+ slots: {
9
+ default: {
10
+ tabs: {
11
+ active: boolean;
12
+ labelledById: string;
13
+ id: string;
14
+ title: string;
15
+ tabIndex: number;
16
+ component: typeof SignIn;
17
+ }[];
18
+ };
19
+ };
8
20
  };
9
21
  export declare type AmplifyTabsProps = typeof __propDef.props;
10
22
  export declare type AmplifyTabsEvents = typeof __propDef.events;
package/dist/package.json CHANGED
@@ -6,8 +6,12 @@
6
6
  "svelte": "dist/index.js",
7
7
  "exports": {
8
8
  "./package.json": "./package.json",
9
+ "./components/AmplifySignUpFormFields.svelte": "./components/AmplifySignUpFormFields.svelte",
9
10
  "./components/Authenticator.svelte": "./components/Authenticator.svelte",
11
+ "./components/ConfirmSignUp.svelte": "./components/ConfirmSignUp.svelte",
12
+ "./components/FederatedSignIn.svelte": "./components/FederatedSignIn.svelte",
10
13
  "./components/SignIn.svelte": "./components/SignIn.svelte",
14
+ "./components/SignUp.svelte": "./components/SignUp.svelte",
11
15
  "./components/UserNameAlias.svelte": "./components/UserNameAlias.svelte",
12
16
  "./components/authStore": "./components/authStore.js",
13
17
  "./components/primitives/AmplifyButton.svelte": "./components/primitives/AmplifyButton.svelte",
@@ -55,7 +59,7 @@
55
59
  "aws-amplify": "^4.2.2"
56
60
  },
57
61
  "dependencies": {
58
- "@aws-amplify/ui": "^3.0.5",
62
+ "@aws-amplify/ui": "3.0.6",
59
63
  "@rollup/plugin-replace": "^3.0.0",
60
64
  "nanoid": "^3.1.30",
61
65
  "qrcode": "^1.5.0",
package/dist/styles.css CHANGED
@@ -3,7 +3,7 @@
3
3
  */
4
4
  /**
5
5
  * Do not edit directly
6
- * Generated on Thu, 06 Jan 2022 21:11:37 GMT
6
+ * Generated on Thu, 13 Jan 2022 21:15:54 GMT
7
7
  */
8
8
  :root, [data-amplify-theme] {
9
9
  --amplify-transforms-slide-x-large: translateX(2em);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/ui-svelte",
3
- "version": "0.0.0-next-5fb24a8-20220106211328",
3
+ "version": "0.0.0-next-9a4f1cf-20220113211745",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "svelte": "dist/index.js",
@@ -53,7 +53,7 @@
53
53
  "aws-amplify": "^4.2.2"
54
54
  },
55
55
  "dependencies": {
56
- "@aws-amplify/ui": "^0.0.0-next-5fb24a8-20220106211328",
56
+ "@aws-amplify/ui": "0.0.0-next-9a4f1cf-20220113211745",
57
57
  "@rollup/plugin-replace": "^3.0.0",
58
58
  "nanoid": "^3.1.30",
59
59
  "qrcode": "^1.5.0",