@aws-amplify/ui-angular 2.3.0 → 2.3.1

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 (42) hide show
  1. package/aws-amplify-ui-angular.d.ts +24 -24
  2. package/aws-amplify-ui-angular.metadata.json +1 -1
  3. package/bundles/aws-amplify-ui-angular.umd.js +110 -324
  4. package/bundles/aws-amplify-ui-angular.umd.js.map +1 -1
  5. package/bundles/aws-amplify-ui-angular.umd.min.js +1 -1
  6. package/bundles/aws-amplify-ui-angular.umd.min.js.map +1 -1
  7. package/esm2015/aws-amplify-ui-angular.js +25 -25
  8. package/esm2015/lib/common/helpers.js +3 -3
  9. package/esm2015/lib/common/types/auth-types.js +1 -1
  10. package/esm2015/lib/components/authenticator/authenticator.module.js +3 -3
  11. package/esm2015/lib/components/authenticator/components/base-form-fields/base-form-fields.component.js +54 -0
  12. package/esm2015/lib/components/authenticator/components/confirm-reset-password/amplify-confirm-reset-password.component.js +3 -15
  13. package/esm2015/lib/components/authenticator/components/confirm-sign-in/confirm-sign-in.component.js +3 -13
  14. package/esm2015/lib/components/authenticator/components/confirm-sign-up/confirm-sign-up.component.js +3 -15
  15. package/esm2015/lib/components/authenticator/components/confirm-verify-user/amplify-confirm-verify-user.component.js +3 -15
  16. package/esm2015/lib/components/authenticator/components/force-new-password/force-new-password-form-fields/force-new-password-form-fields.component.js +2 -22
  17. package/esm2015/lib/components/authenticator/components/force-new-password/force-new-password.component.js +3 -15
  18. package/esm2015/lib/components/authenticator/components/form-field/form-field.component.js +12 -67
  19. package/esm2015/lib/components/authenticator/components/index.js +2 -2
  20. package/esm2015/lib/components/authenticator/components/reset-password/reset-password.component.js +3 -19
  21. package/esm2015/lib/components/authenticator/components/setup-totp/setup-totp.component.js +3 -13
  22. package/esm2015/lib/components/authenticator/components/sign-in/sign-in.component.js +3 -21
  23. package/esm2015/lib/components/authenticator/components/sign-up/sign-up-form-fields/sign-up-form-fields.component.js +2 -50
  24. package/fesm2015/aws-amplify-ui-angular.js +75 -283
  25. package/fesm2015/aws-amplify-ui-angular.js.map +1 -1
  26. package/lib/common/types/auth-types.d.ts +2 -2
  27. package/lib/components/authenticator/components/base-form-fields/base-form-fields.component.d.ts +15 -0
  28. package/lib/components/authenticator/components/confirm-reset-password/amplify-confirm-reset-password.component.d.ts +3 -7
  29. package/lib/components/authenticator/components/confirm-sign-in/confirm-sign-in.component.d.ts +2 -4
  30. package/lib/components/authenticator/components/confirm-sign-up/confirm-sign-up.component.d.ts +3 -7
  31. package/lib/components/authenticator/components/confirm-verify-user/amplify-confirm-verify-user.component.d.ts +3 -7
  32. package/lib/components/authenticator/components/force-new-password/force-new-password-form-fields/force-new-password-form-fields.component.d.ts +1 -7
  33. package/lib/components/authenticator/components/force-new-password/force-new-password.component.d.ts +1 -7
  34. package/lib/components/authenticator/components/form-field/form-field.component.d.ts +5 -29
  35. package/lib/components/authenticator/components/index.d.ts +1 -1
  36. package/lib/components/authenticator/components/reset-password/reset-password.component.d.ts +3 -8
  37. package/lib/components/authenticator/components/setup-totp/setup-totp.component.d.ts +3 -4
  38. package/lib/components/authenticator/components/sign-in/sign-in.component.d.ts +3 -10
  39. package/lib/components/authenticator/components/sign-up/sign-up-form-fields/sign-up-form-fields.component.d.ts +1 -19
  40. package/package.json +7 -2
  41. package/esm2015/lib/components/authenticator/components/user-name-alias/user-name-alias.component.js +0 -42
  42. package/lib/components/authenticator/components/user-name-alias/user-name-alias.component.d.ts +0 -21
@@ -1,7 +1,7 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Directive, TemplateRef, Input, Injectable, Component, ViewEncapsulation, ContentChildren, HostBinding, EventEmitter, Output, NgModule } from '@angular/core';
3
3
  import { CommonModule } from '@angular/common';
4
- import { createAuthenticatorMachine, getServiceContextFacade, listenToAuthHub, getSendEventAliases, translate, getActorState, getFormDataFromEvent, getActorContext, AuthChallengeNames, FederatedIdentityProviders, authInputAttributes, countryDialCodes, getAliasInfoFromContext, hasTranslation, setFormOrder } from '@aws-amplify/ui';
4
+ import { createAuthenticatorMachine, getServiceContextFacade, listenToAuthHub, getSendEventAliases, translate, getFormDataFromEvent, getActorContext, AuthChallengeNames, FederatedIdentityProviders, countryDialCodes, getErrors, hasTranslation, defaultFormFieldOptions, getActorState, getSortedFormFields, getDefaultFormFields, applyDefaults, sortFormFields } from '@aws-amplify/ui';
5
5
  export { translations } from '@aws-amplify/ui';
6
6
  import { Logger } from '@aws-amplify/core';
7
7
  import { interpret } from 'xstate';
@@ -291,18 +291,6 @@ class ConfirmResetPasswordComponent {
291
291
  this.backToSignInText = translate('Back to Sign In');
292
292
  this.resendCodeText = translate('Resend Code');
293
293
  }
294
- ngOnInit() {
295
- this.setFormFields();
296
- }
297
- setFormFields() {
298
- var _a, _b;
299
- const _state = this.authenticator.authState;
300
- this.formOverrides = (_b = (_a = getActorState(_state).context) === null || _a === void 0 ? void 0 : _a.formFields) === null || _b === void 0 ? void 0 : _b.confirmResetPassword;
301
- }
302
- grabField(name, field, defaultV) {
303
- var _a, _b, _c;
304
- return (_c = (_b = (_a = this.formOverrides) === null || _a === void 0 ? void 0 : _a[name]) === null || _b === void 0 ? void 0 : _b[field]) !== null && _c !== void 0 ? _c : defaultV;
305
- }
306
294
  get context() {
307
295
  return this.authenticator.slotContext;
308
296
  }
@@ -319,7 +307,7 @@ class ConfirmResetPasswordComponent {
319
307
  ConfirmResetPasswordComponent.decorators = [
320
308
  { type: Component, args: [{
321
309
  selector: 'amplify-confirm-reset-password',
322
- template: "<form data-amplify-form (submit)=\"onSubmit($event)\" (input)=\"onInput($event)\">\n <fieldset\n class=\"amplify-flex\"\n style=\"flex-direction: column\"\n data-amplify-fieldset\n [disabled]=\"authenticator.isPending\"\n >\n <amplify-slot name=\"confirm-reset-password-header\" [context]=\"context\">\n <h3 class=\"amplify-heading\">{{ headerText }}</h3>\n </amplify-slot>\n <amplify-form-field\n name=\"confirmation_code\"\n autocomplete=\"one-time-code\"\n [labelHidden]=\"grabField('confirmation_code', 'labelHidden', true)\"\n [placeholder]=\"grabField('confirmation_code', 'placeholder', null)\"\n [required]=\"grabField('confirmation_code', 'required', true)\"\n [label]=\"grabField('confirmation_code', 'label', null)\"\n ></amplify-form-field>\n <amplify-form-field\n name=\"password\"\n label=\"New password\"\n autocomplete=\"new-password\"\n [labelHidden]=\"grabField('password', 'labelHidden', true)\"\n [placeholder]=\"grabField('password', 'placeholder', null)\"\n [required]=\"grabField('password', 'required', true)\"\n [label]=\"grabField('password', 'label', 'New password')\"\n ></amplify-form-field>\n <amplify-form-field\n name=\"confirm_password\"\n type=\"password\"\n autocomplete=\"new-password\"\n [labelHidden]=\"grabField('confirm_password', 'labelHidden', true)\"\n [placeholder]=\"grabField('confirm_password', 'placeholder', null)\"\n [required]=\"grabField('confirm_password', 'required', true)\"\n [label]=\"grabField('confirm_password', 'label', 'Confirm Password')\"\n ></amplify-form-field>\n\n <button amplify-button variation=\"primary\" fullWidth=\"true\" type=\"submit\">\n {{ sendCodeText }}\n </button>\n\n <button\n amplify-button\n size=\"small\"\n variation=\"link\"\n fontWeight=\"normal\"\n fullWidth=\"true\"\n type=\"button\"\n (click)=\"authenticator.resendCode()\"\n >\n {{ resendCodeText }}\n </button>\n\n <amplify-error *ngIf=\"authenticator.error\">\n {{ authenticator.error }}\n </amplify-error>\n </fieldset>\n <amplify-slot name=\"confirm-reset-password-footer\" [context]=\"context\">\n </amplify-slot>\n</form>\n"
310
+ template: "<form data-amplify-form (submit)=\"onSubmit($event)\" (input)=\"onInput($event)\">\n <fieldset\n class=\"amplify-flex\"\n style=\"flex-direction: column\"\n data-amplify-fieldset\n [disabled]=\"authenticator.isPending\"\n >\n <amplify-slot name=\"confirm-reset-password-header\" [context]=\"context\">\n <h3 class=\"amplify-heading\">{{ headerText }}</h3>\n </amplify-slot>\n\n <amplify-base-form-fields\n route=\"confirmResetPassword\"\n ></amplify-base-form-fields>\n\n <button amplify-button variation=\"primary\" fullWidth=\"true\" type=\"submit\">\n {{ sendCodeText }}\n </button>\n\n <button\n amplify-button\n size=\"small\"\n variation=\"link\"\n fontWeight=\"normal\"\n fullWidth=\"true\"\n type=\"button\"\n (click)=\"authenticator.resendCode()\"\n >\n {{ resendCodeText }}\n </button>\n\n <amplify-error *ngIf=\"authenticator.error\">\n {{ authenticator.error }}\n </amplify-error>\n </fieldset>\n <amplify-slot name=\"confirm-reset-password-footer\" [context]=\"context\">\n </amplify-slot>\n</form>\n"
323
311
  },] }
324
312
  ];
325
313
  ConfirmResetPasswordComponent.ctorParameters = () => [
@@ -340,16 +328,6 @@ class ConfirmSignInComponent {
340
328
  }
341
329
  ngOnInit() {
342
330
  this.setHeaderText();
343
- this.setFormFields();
344
- }
345
- setFormFields() {
346
- var _a, _b;
347
- const _state = this.authenticator.authState;
348
- this.formOverrides = (_b = (_a = getActorState(_state).context) === null || _a === void 0 ? void 0 : _a.formFields) === null || _b === void 0 ? void 0 : _b.confirmSignIn;
349
- }
350
- grabField(name, field, defaultV) {
351
- var _a, _b, _c;
352
- return (_c = (_b = (_a = this.formOverrides) === null || _a === void 0 ? void 0 : _a[name]) === null || _b === void 0 ? void 0 : _b[field]) !== null && _c !== void 0 ? _c : defaultV;
353
331
  }
354
332
  get context() {
355
333
  return this.authenticator.slotContext;
@@ -382,7 +360,7 @@ class ConfirmSignInComponent {
382
360
  ConfirmSignInComponent.decorators = [
383
361
  { type: Component, args: [{
384
362
  selector: 'amplify-confirm-sign-in',
385
- template: "<form data-amplify-form (submit)=\"onSubmit($event)\" (input)=\"onInput($event)\">\n <fieldset\n class=\"amplify-flex\"\n style=\"flex-direction: column\"\n data-amplify-fieldset\n [disabled]=\"authenticator.isPending\"\n >\n <amplify-slot name=\"confirm-sign-in-header\" [context]=\"context\">\n <h3 class=\"amplify-heading\">{{ headerText }}</h3>\n </amplify-slot>\n <amplify-form-field\n name=\"confirmation_code\"\n label=\"Code *\"\n autocomplete=\"one-time-code\"\n [labelHidden]=\"grabField('confirmation_code', 'labelHidden', true)\"\n [placeholder]=\"grabField('confirmation_code', 'placeholder', null)\"\n [required]=\"grabField('confirmation_code', 'required', true)\"\n [label]=\"grabField('confirmation_code', 'label', 'Code *')\"\n ></amplify-form-field>\n\n <button amplify-button variation=\"primary\" fullWidth=\"true\" type=\"submit\">\n {{ confirmText }}\n </button>\n <button\n amplify-button\n size=\"small\"\n variation=\"link\"\n fontWeight=\"normal\"\n fullWidth=\"true\"\n (click)=\"authenticator.toSignIn()\"\n >\n {{ backToSignInText }}\n </button>\n <amplify-error *ngIf=\"authenticator.error\">\n {{ authenticator.error }}\n </amplify-error>\n </fieldset>\n <amplify-slot\n name=\"confirm-sign-in-footer\"\n [context]=\"context\"\n ></amplify-slot>\n</form>\n"
363
+ template: "<form data-amplify-form (submit)=\"onSubmit($event)\" (input)=\"onInput($event)\">\n <fieldset\n class=\"amplify-flex\"\n style=\"flex-direction: column\"\n data-amplify-fieldset\n [disabled]=\"authenticator.isPending\"\n >\n <amplify-slot name=\"confirm-sign-in-header\" [context]=\"context\">\n <h3 class=\"amplify-heading\">{{ headerText }}</h3>\n </amplify-slot>\n <amplify-base-form-fields route=\"confirmSignIn\"></amplify-base-form-fields>\n\n <button amplify-button variation=\"primary\" fullWidth=\"true\" type=\"submit\">\n {{ confirmText }}\n </button>\n <button\n amplify-button\n size=\"small\"\n variation=\"link\"\n fontWeight=\"normal\"\n fullWidth=\"true\"\n (click)=\"authenticator.toSignIn()\"\n >\n {{ backToSignInText }}\n </button>\n <amplify-error *ngIf=\"authenticator.error\">\n {{ authenticator.error }}\n </amplify-error>\n </fieldset>\n <amplify-slot\n name=\"confirm-sign-in-footer\"\n [context]=\"context\"\n ></amplify-slot>\n</form>\n"
386
364
  },] }
387
365
  ];
388
366
  ConfirmSignInComponent.ctorParameters = () => [
@@ -405,18 +383,6 @@ class ConfirmSignUpComponent {
405
383
  this.defaultMessage = translate('Your code is on the way. To log in, enter the code we sent you. It may take a minute to arrive.');
406
384
  this.minutesMessage = translate('It may take a minute to arrive.');
407
385
  }
408
- ngOnInit() {
409
- this.setFormFields();
410
- }
411
- setFormFields() {
412
- var _a, _b;
413
- const _state = this.authenticator.authState;
414
- this.formOverrides = (_b = (_a = getActorState(_state).context) === null || _a === void 0 ? void 0 : _a.formFields) === null || _b === void 0 ? void 0 : _b.confirmSignUp;
415
- }
416
- grabField(name, field, defaultV) {
417
- var _a, _b, _c;
418
- return (_c = (_b = (_a = this.formOverrides) === null || _a === void 0 ? void 0 : _a[name]) === null || _b === void 0 ? void 0 : _b[field]) !== null && _c !== void 0 ? _c : defaultV;
419
- }
420
386
  get context() {
421
387
  return this.authenticator.slotContext;
422
388
  }
@@ -449,7 +415,7 @@ class ConfirmSignUpComponent {
449
415
  ConfirmSignUpComponent.decorators = [
450
416
  { type: Component, args: [{
451
417
  selector: 'amplify-confirm-sign-up',
452
- template: "<ng-container>\n <form data-amplify-form (submit)=\"onSubmit($event)\" (input)=\"onInput($event)\">\n <fieldset\n class=\"amplify-flex\"\n style=\"flex-direction: column\"\n data-amplify-fieldset\n [disabled]=\"context.isPending\"\n >\n <amplify-slot name=\"confirm-sign-up-header\" [context]=\"context\">\n <h3 class=\"amplify-heading\" style=\"font-size: 1.5rem\">\n {{ confirmSignUpHeading }}\n </h3>\n </amplify-slot>\n <span style=\"margin-bottom: 1rem\">\n {{ subtitleText }}\n </span>\n <amplify-form-field\n name=\"confirmation_code\"\n autocomplete=\"one-time-code\"\n [labelHidden]=\"grabField('confirmation_code', 'labelHidden', true)\"\n [placeholder]=\"grabField('confirmation_code', 'placeholder', null)\"\n [required]=\"grabField('confirmation_code', 'required', true)\"\n [label]=\"grabField('confirmation_code', 'label', null)\"\n ></amplify-form-field>\n\n <button amplify-button variation=\"primary\" fullWidth=\"true\" type=\"submit\">\n {{ confirmText }}\n </button>\n <button\n amplify-button\n fontWeight=\"normal\"\n (click)=\"authenticator.resendCode()\"\n >\n {{ resendCodeText }}\n </button>\n </fieldset>\n\n <amplify-error *ngIf=\"context.error\">\n {{ authenticator.error }}\n </amplify-error>\n <amplify-slot\n name=\"confirm-sign-up-footer\"\n [context]=\"context\"\n ></amplify-slot>\n </form>\n</ng-container>\n"
418
+ template: "<ng-container>\n <form data-amplify-form (submit)=\"onSubmit($event)\" (input)=\"onInput($event)\">\n <fieldset\n class=\"amplify-flex\"\n style=\"flex-direction: column\"\n data-amplify-fieldset\n [disabled]=\"context.isPending\"\n >\n <amplify-slot name=\"confirm-sign-up-header\" [context]=\"context\">\n <h3 class=\"amplify-heading\" style=\"font-size: 1.5rem\">\n {{ confirmSignUpHeading }}\n </h3>\n </amplify-slot>\n <span style=\"margin-bottom: 1rem\">\n {{ subtitleText }}\n </span>\n <amplify-base-form-fields\n route=\"confirmSignUp\"\n ></amplify-base-form-fields>\n\n <button amplify-button variation=\"primary\" fullWidth=\"true\" type=\"submit\">\n {{ confirmText }}\n </button>\n <button\n amplify-button\n fontWeight=\"normal\"\n (click)=\"authenticator.resendCode()\"\n >\n {{ resendCodeText }}\n </button>\n </fieldset>\n\n <amplify-error *ngIf=\"context.error\">\n {{ authenticator.error }}\n </amplify-error>\n <amplify-slot\n name=\"confirm-sign-up-footer\"\n [context]=\"context\"\n ></amplify-slot>\n </form>\n</ng-container>\n"
453
419
  },] }
454
420
  ];
455
421
  ConfirmSignUpComponent.ctorParameters = () => [
@@ -469,18 +435,6 @@ class ConfirmVerifyUserComponent {
469
435
  this.skipText = translate('Skip');
470
436
  this.submitText = translate('Submit');
471
437
  }
472
- ngOnInit() {
473
- this.setFormFields();
474
- }
475
- setFormFields() {
476
- var _a, _b;
477
- const _state = this.authenticator.authState;
478
- this.formOverrides = (_b = (_a = getActorState(_state).context) === null || _a === void 0 ? void 0 : _a.formFields) === null || _b === void 0 ? void 0 : _b.confirmVerifyUser;
479
- }
480
- grabField(name, field, defaultV) {
481
- var _a, _b, _c;
482
- return (_c = (_b = (_a = this.formOverrides) === null || _a === void 0 ? void 0 : _a[name]) === null || _b === void 0 ? void 0 : _b[field]) !== null && _c !== void 0 ? _c : defaultV;
483
- }
484
438
  get context() {
485
439
  return this.authenticator.slotContext;
486
440
  }
@@ -497,7 +451,7 @@ class ConfirmVerifyUserComponent {
497
451
  ConfirmVerifyUserComponent.decorators = [
498
452
  { type: Component, args: [{
499
453
  selector: 'amplify-confirm-verify-user',
500
- template: "<form data-amplify-form (input)=\"onInput($event)\" (submit)=\"onSubmit($event)\">\n <fieldset\n class=\"amplify-flex\"\n style=\"flex-direction: column\"\n data-amplify-fieldset\n [disabled]=\"authenticator.isPending\"\n >\n <amplify-slot name=\"confirm-verify-user-header\" [context]=\"context\">\n <h3 class=\"amplify-heading\">{{ this.headerText }}</h3>\n </amplify-slot>\n <amplify-form-field\n name=\"confirmation_code\"\n autocomplete=\"one-time-code\"\n [labelHidden]=\"grabField('confirmation_code', 'labelHidden', true)\"\n [placeholder]=\"grabField('confirmation_code', 'placeholder', null)\"\n [required]=\"grabField('confirmation_code', 'required', true)\"\n [label]=\"grabField('confirmation_code', 'label', null)\"\n ></amplify-form-field>\n <button amplify-button variation=\"primary\" fullWidth=\"true\" type=\"submit\">\n {{ submitText }}\n </button>\n\n <button\n amplify-button\n size=\"small\"\n variation=\"link\"\n fontWeight=\"normal\"\n fullWidth=\"true\"\n (click)=\"authenticator.skipVerification()\"\n >\n {{ skipText }}\n </button>\n <amplify-error *ngIf=\"authenticator.error\">\n {{ authenticator.error }}\n </amplify-error>\n </fieldset>\n <amplify-slot name=\"confirm-verify-user-footer\" [context]=\"context\">\n </amplify-slot>\n</form>\n"
454
+ template: "<form data-amplify-form (input)=\"onInput($event)\" (submit)=\"onSubmit($event)\">\n <fieldset\n class=\"amplify-flex\"\n style=\"flex-direction: column\"\n data-amplify-fieldset\n [disabled]=\"authenticator.isPending\"\n >\n <amplify-slot name=\"confirm-verify-user-header\" [context]=\"context\">\n <h3 class=\"amplify-heading\">{{ this.headerText }}</h3>\n </amplify-slot>\n <amplify-base-form-fields\n route=\"confirmVerifyUser\"\n ></amplify-base-form-fields>\n <button amplify-button variation=\"primary\" fullWidth=\"true\" type=\"submit\">\n {{ submitText }}\n </button>\n\n <button\n amplify-button\n size=\"small\"\n variation=\"link\"\n fontWeight=\"normal\"\n fullWidth=\"true\"\n (click)=\"authenticator.skipVerification()\"\n >\n {{ skipText }}\n </button>\n <amplify-error *ngIf=\"authenticator.error\">\n {{ authenticator.error }}\n </amplify-error>\n </fieldset>\n <amplify-slot name=\"confirm-verify-user-footer\" [context]=\"context\">\n </amplify-slot>\n</form>\n"
501
455
  },] }
502
456
  ];
503
457
  ConfirmVerifyUserComponent.ctorParameters = () => [
@@ -585,21 +539,9 @@ class ForceNewPasswordComponent {
585
539
  this.changePasswordText = translate('Change Password');
586
540
  this.backToSignInText = translate('Back to Sign In');
587
541
  }
588
- ngOnInit() {
589
- this.setFormFields();
590
- }
591
542
  get context() {
592
543
  return this.authenticator.slotContext;
593
544
  }
594
- setFormFields() {
595
- var _a, _b;
596
- const _state = this.authenticator.authState;
597
- this.formOverrides = (_b = (_a = getActorState(_state).context) === null || _a === void 0 ? void 0 : _a.formFields) === null || _b === void 0 ? void 0 : _b.forceNewPassword;
598
- }
599
- grabField(name, field, defaultV) {
600
- var _a, _b, _c;
601
- return (_c = (_b = (_a = this.formOverrides) === null || _a === void 0 ? void 0 : _a[name]) === null || _b === void 0 ? void 0 : _b[field]) !== null && _c !== void 0 ? _c : defaultV;
602
- }
603
545
  onInput(event) {
604
546
  event.preventDefault();
605
547
  const { name, value } = event.target;
@@ -613,7 +555,7 @@ class ForceNewPasswordComponent {
613
555
  ForceNewPasswordComponent.decorators = [
614
556
  { type: Component, args: [{
615
557
  selector: 'amplify-force-new-password',
616
- template: "<form data-amplify-form (submit)=\"onSubmit($event)\" (input)=\"onInput($event)\">\n <fieldset\n class=\"amplify-flex\"\n style=\"flex-direction: column\"\n data-amplify-fieldset\n [disabled]=\"authenticator.isPending\"\n >\n <amplify-slot name=\"force-new-password-header\" [context]=\"context\">\n <h3 class=\"amplify-heading\">{{ this.headerText }}</h3>\n </amplify-slot>\n <amplify-form-field\n [labelHidden]=\"grabField('password', 'labelHidden', true)\"\n [placeholder]=\"grabField('password', 'placeholder', null)\"\n [required]=\"grabField('password', 'required', true)\"\n [label]=\"grabField('password', 'label', null)\"\n name=\"password\"\n type=\"password\"\n autocomplete=\"new-password\"\n ></amplify-form-field>\n\n <amplify-form-field\n name=\"confirm_password\"\n type=\"password\"\n autocomplete=\"new-password\"\n [labelHidden]=\"grabField('confirm_password', 'labelHidden', true)\"\n [placeholder]=\"grabField('confirm_password', 'placeholder', null)\"\n [required]=\"grabField('confirm_password', 'required', true)\"\n [label]=\"grabField('confirm_password', 'label', 'Confirm Password')\"\n ></amplify-form-field>\n <amplify-slot name=\"force-new-form-fields\" [context]=\"context\">\n <amplify-force-new-password-form-fields></amplify-force-new-password-form-fields>\n </amplify-slot>\n\n <button amplify-button variation=\"primary\" fullWidth=\"true\" type=\"submit\">\n {{ changePasswordText }}\n </button>\n\n <button\n amplify-button\n size=\"small\"\n variation=\"link\"\n fontWeight=\"normal\"\n fullWidth=\"true\"\n (click)=\"authenticator.toSignIn()\"\n >\n {{ backToSignInText }}\n </button>\n <amplify-error *ngIf=\"authenticator.error\">\n {{ authenticator.error }}\n </amplify-error>\n </fieldset>\n <amplify-slot name=\"force-new-password-footer\" [context]=\"context\">\n </amplify-slot>\n</form>\n"
558
+ template: "<form data-amplify-form (submit)=\"onSubmit($event)\" (input)=\"onInput($event)\">\n <fieldset\n class=\"amplify-flex\"\n style=\"flex-direction: column\"\n data-amplify-fieldset\n [disabled]=\"authenticator.isPending\"\n >\n <amplify-slot name=\"force-new-password-header\" [context]=\"context\">\n <h3 class=\"amplify-heading\">{{ this.headerText }}</h3>\n </amplify-slot>\n\n <amplify-slot name=\"force-new-form-fields\" [context]=\"context\">\n <amplify-force-new-password-form-fields></amplify-force-new-password-form-fields>\n </amplify-slot>\n\n <button amplify-button variation=\"primary\" fullWidth=\"true\" type=\"submit\">\n {{ changePasswordText }}\n </button>\n\n <button\n amplify-button\n size=\"small\"\n variation=\"link\"\n fontWeight=\"normal\"\n fullWidth=\"true\"\n (click)=\"authenticator.toSignIn()\"\n >\n {{ backToSignInText }}\n </button>\n <amplify-error *ngIf=\"authenticator.error\">\n {{ authenticator.error }}\n </amplify-error>\n </fieldset>\n <amplify-slot name=\"force-new-password-footer\" [context]=\"context\">\n </amplify-slot>\n</form>\n"
617
559
  },] }
618
560
  ];
619
561
  ForceNewPasswordComponent.ctorParameters = () => [
@@ -625,106 +567,41 @@ ForceNewPasswordComponent.propDecorators = {
625
567
  };
626
568
 
627
569
  class ForceNewPasswordFormFieldsComponent {
628
- constructor(authenticator) {
629
- this.authenticator = authenticator;
630
- }
631
- ngOnInit() {
632
- const state = this.authenticator.authState;
633
- const actorContext = getActorContext(state);
634
- const { requiredAttributes } = actorContext;
635
- this.fieldNames = requiredAttributes.filter((fieldName) => {
636
- const hasDefaultField = !!authInputAttributes[fieldName];
637
- if (!hasDefaultField) {
638
- console.debug(`Authenticator does not have a default implementation for ${fieldName}. Customize Authenticator.SignUp.FormFields to add your own.`);
639
- }
640
- return hasDefaultField;
641
- });
642
- }
643
570
  }
644
571
  ForceNewPasswordFormFieldsComponent.decorators = [
645
572
  { type: Component, args: [{
646
573
  selector: 'amplify-force-new-password-form-fields',
647
- template: "<div class=\"amplify-flex\" style=\"flex-direction: column\" data-amplify-fieldset>\n <ng-container *ngFor=\"let field of fieldNames\">\n <amplify-form-field\n [name]=\"field\"\n [labelHidden]=\"false\"\n ></amplify-form-field>\n </ng-container>\n</div>\n"
574
+ template: "<div class=\"amplify-flex\" style=\"flex-direction: column\" data-amplify-fieldset>\n <amplify-base-form-fields route=\"forceNewPassword\"></amplify-base-form-fields>\n</div>\n"
648
575
  },] }
649
576
  ];
650
- ForceNewPasswordFormFieldsComponent.ctorParameters = () => [
651
- { type: AuthenticatorService }
652
- ];
653
-
654
- const getAttributeMap = () => authInputAttributes;
655
577
 
656
- /**
657
- * Input interface opinionated for authenticator usage.
658
- *
659
- * TODO: Separate this component out to two parts -- 1) amplify-auth-input that
660
- * contains authenticator opinionated logic and 2) amplify-text-field primitive
661
- * that does not make any auth-related inference.
662
- */
663
578
  class FormFieldComponent {
664
579
  constructor(authenticator) {
665
580
  this.authenticator = authenticator;
666
- this.required = true;
667
- this.placeholder = '';
668
- this.label = '';
669
- this.initialValue = '';
670
- this.disabled = false;
671
- this.autocomplete = '';
672
- this.labelHidden = true;
673
581
  this.countryDialCodesValue = countryDialCodes;
674
582
  }
675
- ngOnInit() {
676
- var _a;
677
- // TODO: consider better default handling mechanisms across frameworks
678
- if (this.isPhoneField()) {
679
- const state = this.authenticator.authState;
680
- const { country_code } = getActorContext(state);
681
- this.defaultCountryCodeValue = (_a = this.defaultCountryCode) !== null && _a !== void 0 ? _a : country_code;
682
- }
683
- }
684
- get attributeMap() {
685
- return getAttributeMap();
686
- }
687
- get error() {
688
- const formContext = getActorContext(this.authenticator.authState);
689
- const { validationError } = formContext;
690
- return translate(validationError[this.name]);
583
+ get errors() {
584
+ const { validationErrors } = this.authenticator;
585
+ return getErrors(validationErrors[this.name]);
691
586
  }
692
587
  onBlur($event) {
693
588
  let { name } = $event.target;
694
589
  this.authenticator.updateBlur({ name });
695
590
  }
696
- inferLabel() {
697
- var _a;
698
- const label = this.label || ((_a = this.attributeMap[this.name]) === null || _a === void 0 ? void 0 : _a.label);
699
- return translate(label);
700
- }
701
- inferPlaceholder() {
702
- var _a;
703
- const placeholder = this.placeholder || ((_a = this.attributeMap[this.name]) === null || _a === void 0 ? void 0 : _a.placeholder) ||
704
- this.inferLabel();
705
- return translate(placeholder);
706
- }
707
- // infers what the `type` of underlying input element should be.
708
- inferType() {
709
- var _a, _b, _c;
710
- return (_c = (_a = this.type) !== null && _a !== void 0 ? _a : (_b = this.attributeMap[this.name]) === null || _b === void 0 ? void 0 : _b.type) !== null && _c !== void 0 ? _c : 'text';
711
- }
712
- inferAutocomplete() {
713
- var _a;
714
- return this.autocomplete || ((_a = this.attributeMap[this.name]) === null || _a === void 0 ? void 0 : _a.autocomplete);
715
- }
716
- // TODO(enhancement): use enum to differentiate special field types
717
591
  isPasswordField() {
718
- return this.inferType() === 'password';
592
+ return this.formField.type === 'password';
719
593
  }
720
594
  isPhoneField() {
721
- return this.inferType() === 'tel';
595
+ return this.formField.type === 'tel';
596
+ }
597
+ translate(phrase) {
598
+ return translate(phrase);
722
599
  }
723
600
  }
724
601
  FormFieldComponent.decorators = [
725
602
  { type: Component, args: [{
726
603
  selector: 'amplify-form-field',
727
- template: "<div class=\"amplify-flex amplify-field\" style=\"flex-direction: column\">\n <!-- Country code field -->\n <amplify-phone-number-field\n *ngIf=\"isPhoneField()\"\n [defaultCountryCode]=\"defaultCountryCodeValue\"\n [dialCodeList]=\"dialCodeList\"\n [type]=\"inferType()\"\n [name]=\"name\"\n [label]=\"inferLabel()\"\n [placeholder]=\"inferPlaceholder()\"\n [required]=\"required\"\n [initialValue]=\"initialValue\"\n [disabled]=\"disabled\"\n [labelHidden]=\"labelHidden\"\n [autocomplete]=\"inferAutocomplete()\"\n ></amplify-phone-number-field>\n\n <amplify-password-field\n *ngIf=\"isPasswordField()\"\n [name]=\"name\"\n [label]=\"inferLabel()\"\n [placeholder]=\"inferPlaceholder()\"\n [required]=\"required\"\n [initialValue]=\"initialValue\"\n [disabled]=\"disabled\"\n [labelHidden]=\"labelHidden\"\n [autocomplete]=\"inferAutocomplete()\"\n (setBlur)=\"onBlur($event)\"\n ></amplify-password-field>\n\n <amplify-text-field\n *ngIf=\"!isPasswordField() && !isPhoneField()\"\n [type]=\"inferType()\"\n [name]=\"name\"\n [label]=\"inferLabel()\"\n [placeholder]=\"inferPlaceholder()\"\n [required]=\"required\"\n [initialValue]=\"initialValue\"\n [disabled]=\"disabled\"\n [labelHidden]=\"labelHidden\"\n [autocomplete]=\"inferAutocomplete()\"\n ></amplify-text-field>\n\n <amplify-error *ngIf=\"error\">\n {{ error }}\n </amplify-error>\n</div>\n"
604
+ template: "<div class=\"amplify-flex amplify-field\" style=\"flex-direction: column\">\n <!-- Country code field -->\n <amplify-phone-number-field\n *ngIf=\"isPhoneField()\"\n [name]=\"name\"\n [label]=\"formField.label\"\n [defaultCountryCode]=\"formField.dialCode\"\n [dialCodeList]=\"formField.dialCodeList\"\n [placeholder]=\"formField.placeholder\"\n [required]=\"formField.isRequired\"\n [labelHidden]=\"formField.labelHidden\"\n [autocomplete]=\"formField.autocomplete\"\n type=\"tel\"\n ></amplify-phone-number-field>\n\n <amplify-password-field\n *ngIf=\"isPasswordField()\"\n [name]=\"name\"\n [label]=\"formField.label\"\n [placeholder]=\"formField.placeholder\"\n [required]=\"formField.isRequired\"\n [labelHidden]=\"formField.labelHidden\"\n [autocomplete]=\"formField.autocomplete\"\n (setBlur)=\"onBlur($event)\"\n ></amplify-password-field>\n\n <amplify-text-field\n *ngIf=\"!isPasswordField() && !isPhoneField()\"\n [name]=\"name\"\n [label]=\"formField.label\"\n [placeholder]=\"formField.placeholder\"\n [required]=\"formField.isRequired\"\n [labelHidden]=\"formField.labelHidden\"\n [autocomplete]=\"formField.autocomplete\"\n [type]=\"formField.type\"\n ></amplify-text-field>\n <div data-amplify-sign-up-errors *ngIf=\"errors?.length > 0\">\n <div\n class=\"amplify-text\"\n data-variation=\"error\"\n *ngFor=\"let error of errors\"\n >\n {{ translate(error) }}\n </div>\n </div>\n</div>\n"
728
605
  },] }
729
606
  ];
730
607
  FormFieldComponent.ctorParameters = () => [
@@ -732,16 +609,7 @@ FormFieldComponent.ctorParameters = () => [
732
609
  ];
733
610
  FormFieldComponent.propDecorators = {
734
611
  name: [{ type: Input }],
735
- type: [{ type: Input }],
736
- required: [{ type: Input }],
737
- placeholder: [{ type: Input }],
738
- label: [{ type: Input }],
739
- initialValue: [{ type: Input }],
740
- disabled: [{ type: Input }],
741
- autocomplete: [{ type: Input }],
742
- labelHidden: [{ type: Input }],
743
- defaultCountryCode: [{ type: Input }],
744
- dialCodeList: [{ type: Input }]
612
+ formField: [{ type: Input }]
745
613
  };
746
614
 
747
615
  class ResetPasswordComponent {
@@ -752,22 +620,6 @@ class ResetPasswordComponent {
752
620
  // translated texts
753
621
  this.sendCodeText = translate('Send Code');
754
622
  this.backToSignInText = translate('Back to Sign In');
755
- this.labelText = translate('Username');
756
- }
757
- ngOnInit() {
758
- const { authState } = this.authenticator;
759
- const { label } = getAliasInfoFromContext(authState.context);
760
- this.labelText = `Enter your ${label.toLowerCase()}`;
761
- this.setFormFields();
762
- }
763
- setFormFields() {
764
- var _a, _b;
765
- const _state = this.authenticator.authState;
766
- this.formOverrides = (_b = (_a = getActorState(_state).context) === null || _a === void 0 ? void 0 : _a.formFields) === null || _b === void 0 ? void 0 : _b.resetPassword;
767
- }
768
- grabField(name, field, defaultV) {
769
- var _a, _b, _c;
770
- return (_c = (_b = (_a = this.formOverrides) === null || _a === void 0 ? void 0 : _a[name]) === null || _b === void 0 ? void 0 : _b[field]) !== null && _c !== void 0 ? _c : defaultV;
771
623
  }
772
624
  get context() {
773
625
  return this.authenticator.slotContext;
@@ -785,7 +637,7 @@ class ResetPasswordComponent {
785
637
  ResetPasswordComponent.decorators = [
786
638
  { type: Component, args: [{
787
639
  selector: 'amplify-reset-password',
788
- template: "<form data-amplify-form (submit)=\"onSubmit($event)\" (input)=\"onInput($event)\">\n <fieldset\n class=\"amplify-flex\"\n style=\"flex-direction: column\"\n data-amplify-fieldset\n [disabled]=\"authenticator.isPending\"\n >\n <amplify-slot\n class=\"amplify-flex\"\n name=\"reset-password-header\"\n [context]=\"context\"\n >\n <h3 class=\"amplify-heading\">{{ this.headerText }}</h3>\n </amplify-slot>\n\n <amplify-form-field\n name=\"username\"\n type=\"username\"\n autocomplete=\"username\"\n [labelHidden]=\"grabField('username', 'labelHidden', true)\"\n [required]=\"grabField('username', 'required', true)\"\n [label]=\"grabField('username', 'label', labelText)\"\n [placeholder]=\"grabField('username', 'placeholder', labelText)\"\n ></amplify-form-field>\n <button amplify-button variation=\"primary\" fullWidth=\"true\" type=\"submit\">\n {{ sendCodeText }}\n </button>\n <button\n amplify-button\n size=\"small\"\n variation=\"link\"\n fontWeight=\"normal\"\n fullWidth=\"true\"\n (click)=\"authenticator.toSignIn()\"\n >\n {{ backToSignInText }}\n </button>\n <amplify-error *ngIf=\"authenticator.error\">\n {{ authenticator.error }}\n </amplify-error>\n </fieldset>\n\n <amplify-slot name=\"reset-password-footer\" [context]=\"context\">\n </amplify-slot>\n</form>\n"
640
+ template: "<form data-amplify-form (submit)=\"onSubmit($event)\" (input)=\"onInput($event)\">\n <fieldset\n class=\"amplify-flex\"\n style=\"flex-direction: column\"\n data-amplify-fieldset\n [disabled]=\"authenticator.isPending\"\n >\n <amplify-slot\n class=\"amplify-flex\"\n name=\"reset-password-header\"\n [context]=\"context\"\n >\n <h3 class=\"amplify-heading\">{{ this.headerText }}</h3>\n </amplify-slot>\n\n <amplify-base-form-fields route=\"resetPassword\"></amplify-base-form-fields>\n <button amplify-button variation=\"primary\" fullWidth=\"true\" type=\"submit\">\n {{ sendCodeText }}\n </button>\n <button\n amplify-button\n size=\"small\"\n variation=\"link\"\n fontWeight=\"normal\"\n fullWidth=\"true\"\n (click)=\"authenticator.toSignIn()\"\n >\n {{ backToSignInText }}\n </button>\n <amplify-error *ngIf=\"authenticator.error\">\n {{ authenticator.error }}\n </amplify-error>\n </fieldset>\n\n <amplify-slot name=\"reset-password-footer\" [context]=\"context\">\n </amplify-slot>\n</form>\n"
789
641
  },] }
790
642
  ];
791
643
  ResetPasswordComponent.ctorParameters = () => [
@@ -811,16 +663,6 @@ class SetupTotpComponent {
811
663
  }
812
664
  ngOnInit() {
813
665
  this.generateQRCode();
814
- this.setFormFields();
815
- }
816
- setFormFields() {
817
- var _a, _b;
818
- const _state = this.authenticator.authState;
819
- this.formOverrides = (_b = (_a = getActorState(_state).context) === null || _a === void 0 ? void 0 : _a.formFields) === null || _b === void 0 ? void 0 : _b.setupTOTP;
820
- }
821
- grabField(name, field, defaultV) {
822
- var _a, _b, _c;
823
- return (_c = (_b = (_a = this.formOverrides) === null || _a === void 0 ? void 0 : _a[name]) === null || _b === void 0 ? void 0 : _b[field]) !== null && _c !== void 0 ? _c : defaultV;
824
666
  }
825
667
  get context() {
826
668
  return this.authenticator.slotContext;
@@ -862,7 +704,7 @@ class SetupTotpComponent {
862
704
  SetupTotpComponent.decorators = [
863
705
  { type: Component, args: [{
864
706
  selector: 'amplify-setup-totp',
865
- template: "<form data-amplify-form (submit)=\"onSubmit($event)\" (input)=\"onInput($event)\">\n <fieldset\n class=\"amplify-flex\"\n style=\"flex-direction: column\"\n data-amplify-fieldset\n [disabled]=\"authenticator.isPending\"\n >\n <amplify-slot name=\"setup-totp-header\" [context]=\"context\">\n <h3 class=\"amplify-heading\">{{ this.headerText }}</h3>\n </amplify-slot>\n <p *ngIf=\"!qrCodeSource\">Loading...</p>\n <img\n *ngIf=\"qrCodeSource\"\n [src]=\"qrCodeSource\"\n alt=\"qr code\"\n data-amplify-qrcode\n width=\"228\"\n height=\"228\"\n />\n <div class=\"amplify-flex\" data-amplify-copy>\n <div>{{ secretKey }}</div>\n <div data-amplify-copy-svg (click)=\"copyText()\">\n <div data-amplify-copy-tooltip>{{ copyTextLabel }}</div>\n <svg\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1ZM15 5H8C6.9 5 6.01 5.9 6.01 7L6 21C6 22.1 6.89 23 7.99 23H19C20.1 23 21 22.1 21 21V11L15 5ZM8 21V7H14V12H19V21H8Z\"\n />\n </svg>\n </div>\n </div>\n\n <amplify-form-field\n name=\"confirmation_code\"\n autocomplete=\"one-time-code\"\n [labelHidden]=\"grabField('confirmation_code', 'labelHidden', true)\"\n [placeholder]=\"grabField('confirmation_code', 'placeholder', null)\"\n [required]=\"grabField('confirmation_code', 'required', true)\"\n [label]=\"grabField('confirmation_code', 'label', 'Code *')\"\n ></amplify-form-field>\n <button amplify-button variation=\"primary\" fullWidth=\"true\" type=\"submit\">\n {{ confirmText }}\n </button>\n <button\n amplify-button\n size=\"small\"\n variation=\"link\"\n fontWeight=\"normal\"\n fullWidth=\"true\"\n (click)=\"authenticator.toSignIn()\"\n >\n {{ backToSignInText }}\n </button>\n <amplify-error *ngIf=\"authenticator.error\">\n {{ authenticator.error }}\n </amplify-error>\n </fieldset>\n <amplify-slot name=\"setup-totp-footer\" [context]=\"context\"> </amplify-slot>\n</form>\n"
707
+ template: "<form data-amplify-form (submit)=\"onSubmit($event)\" (input)=\"onInput($event)\">\n <fieldset\n class=\"amplify-flex\"\n style=\"flex-direction: column\"\n data-amplify-fieldset\n [disabled]=\"authenticator.isPending\"\n >\n <amplify-slot name=\"setup-totp-header\" [context]=\"context\">\n <h3 class=\"amplify-heading\">{{ this.headerText }}</h3>\n </amplify-slot>\n <p *ngIf=\"!qrCodeSource\">Loading...</p>\n <img\n *ngIf=\"qrCodeSource\"\n [src]=\"qrCodeSource\"\n alt=\"qr code\"\n data-amplify-qrcode\n width=\"228\"\n height=\"228\"\n />\n <div class=\"amplify-flex\" data-amplify-copy>\n <div>{{ secretKey }}</div>\n <div data-amplify-copy-svg (click)=\"copyText()\">\n <div data-amplify-copy-tooltip>{{ copyTextLabel }}</div>\n <svg\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M16 1H4C2.9 1 2 1.9 2 3V17H4V3H16V1ZM15 5H8C6.9 5 6.01 5.9 6.01 7L6 21C6 22.1 6.89 23 7.99 23H19C20.1 23 21 22.1 21 21V11L15 5ZM8 21V7H14V12H19V21H8Z\"\n />\n </svg>\n </div>\n </div>\n\n <amplify-base-form-fields route=\"setupTOTP\"></amplify-base-form-fields>\n <button amplify-button variation=\"primary\" fullWidth=\"true\" type=\"submit\">\n {{ confirmText }}\n </button>\n <button\n amplify-button\n size=\"small\"\n variation=\"link\"\n fontWeight=\"normal\"\n fullWidth=\"true\"\n (click)=\"authenticator.toSignIn()\"\n >\n {{ backToSignInText }}\n </button>\n <amplify-error *ngIf=\"authenticator.error\">\n {{ authenticator.error }}\n </amplify-error>\n </fieldset>\n <amplify-slot name=\"setup-totp-footer\" [context]=\"context\"> </amplify-slot>\n</form>\n"
866
708
  },] }
867
709
  ];
868
710
  SetupTotpComponent.ctorParameters = () => [
@@ -883,24 +725,6 @@ class SignInComponent {
883
725
  : translate('Forgot your password? ');
884
726
  this.signInButtonText = translate('Sign in');
885
727
  }
886
- ngOnInit() {
887
- this.setFormFields();
888
- }
889
- setFormFields() {
890
- var _a, _b, _c, _d;
891
- const _state = this.authenticator.authState;
892
- this.formOverrides = (_b = (_a = getActorState(_state).context) === null || _a === void 0 ? void 0 : _a.formFields) === null || _b === void 0 ? void 0 : _b.signIn;
893
- this.userOverrides = (_c = this.formOverrides) === null || _c === void 0 ? void 0 : _c['username'];
894
- this.passwordOR = (_d = this.formOverrides) === null || _d === void 0 ? void 0 : _d['password'];
895
- }
896
- labelHidden(name, defaultV = true) {
897
- var _a, _b, _c;
898
- return (_c = (_b = (_a = this.formOverrides) === null || _a === void 0 ? void 0 : _a[name]) === null || _b === void 0 ? void 0 : _b.labelHidden) !== null && _c !== void 0 ? _c : defaultV;
899
- }
900
- required(name, defaultV = true) {
901
- var _a, _b, _c;
902
- return (_c = (_b = (_a = this.formOverrides) === null || _a === void 0 ? void 0 : _a[name]) === null || _b === void 0 ? void 0 : _b.required) !== null && _c !== void 0 ? _c : defaultV;
903
- }
904
728
  get context() {
905
729
  return this.authenticator.slotContext;
906
730
  }
@@ -917,7 +741,7 @@ class SignInComponent {
917
741
  SignInComponent.decorators = [
918
742
  { type: Component, args: [{
919
743
  selector: 'amplify-sign-in',
920
- template: "<amplify-slot name=\"sign-in-header\" [context]=\"context\"></amplify-slot>\n\n<form data-amplify-form (submit)=\"onSubmit($event)\" (input)=\"onInput($event)\">\n <amplify-federated-sign-in></amplify-federated-sign-in>\n <fieldset\n class=\"amplify-flex\"\n style=\"flex-direction: column\"\n data-amplify-fieldset\n [disabled]=\"authenticator.isPending\"\n >\n <amplify-user-name-alias\n [labelHidden]=\"labelHidden('username')\"\n [placeholder]=\"userOverrides?.placeholder\"\n [required]=\"required('username')\"\n [label]=\"userOverrides?.label\"\n [dialCode]=\"userOverrides?.dialCode\"\n [dialCodeList]=\"userOverrides?.dialCodeList\"\n ></amplify-user-name-alias>\n <amplify-form-field\n [labelHidden]=\"labelHidden('password')\"\n [placeholder]=\"passwordOR?.placeholder\"\n [required]=\"required('password')\"\n [label]=\"passwordOR?.label\"\n data-amplify-password\n name=\"password\"\n type=\"password\"\n autocomplete=\"current-password\"\n ></amplify-form-field>\n <button amplify-button variation=\"primary\" fullWidth=\"true\" type=\"submit\">\n {{ signInButtonText }}\n </button>\n\n <amplify-error *ngIf=\"authenticator.error\">\n {{ authenticator.error }}\n </amplify-error>\n </fieldset>\n</form>\n\n<amplify-slot name=\"sign-in-footer\" [context]=\"context\">\n <div data-amplify-footer>\n <button\n amplify-button\n fontWeight=\"normal\"\n size=\"small\"\n variation=\"link\"\n fullWidth=\"true\"\n (click)=\"authenticator.toResetPassword()\"\n >\n {{ forgotPasswordText }}\n </button>\n </div>\n</amplify-slot>\n",
744
+ template: "<amplify-slot name=\"sign-in-header\" [context]=\"context\"></amplify-slot>\n\n<form data-amplify-form (submit)=\"onSubmit($event)\" (input)=\"onInput($event)\">\n <amplify-federated-sign-in></amplify-federated-sign-in>\n <fieldset class=\"amplify-flex\" style=\"flex-direction: column\" data-amplify-fieldset\n [disabled]=\"authenticator.isPending\">\n <legend class=\"amplify-visually-hidden\">Sign in</legend>\n <amplify-base-form-fields route=\"signIn\"></amplify-base-form-fields>\n <button amplify-button variation=\"primary\" fullWidth=\"true\" type=\"submit\">\n {{ signInButtonText }}\n </button>\n\n <amplify-error *ngIf=\"authenticator.error\">\n {{ authenticator.error }}\n </amplify-error>\n </fieldset>\n</form>\n\n<amplify-slot name=\"sign-in-footer\" [context]=\"context\">\n <div data-amplify-footer>\n <button amplify-button fontWeight=\"normal\" size=\"small\" variation=\"link\" fullWidth=\"true\"\n (click)=\"authenticator.toResetPassword()\">\n {{ forgotPasswordText }}\n </button>\n </div>\n</amplify-slot>\n",
921
745
  encapsulation: ViewEncapsulation.None
922
746
  },] }
923
747
  ];
@@ -963,98 +787,15 @@ SignUpComponent.propDecorators = {
963
787
  };
964
788
 
965
789
  class SignUpFormFieldsComponent {
966
- constructor(authenticator) {
967
- this.authenticator = authenticator;
968
- this.primaryAlias = '';
969
- this.secondaryAliases = [];
970
- this.translate = translate;
971
- }
972
- ngOnInit() {
973
- const context = this.authenticator.context;
974
- const { loginMechanisms, signUpAttributes } = context.config;
975
- this.fieldNames = Array.from(new Set([...loginMechanisms, ...signUpAttributes]));
976
- this.fieldNames = this.fieldNames.filter((fieldName) => {
977
- const hasDefaultField = !!authInputAttributes[fieldName];
978
- if (!hasDefaultField) {
979
- console.debug(`Authenticator does not have a default implementation for ${fieldName}. Customize Authenticator.SignUp.FormFields to add your own.`);
980
- }
981
- return hasDefaultField;
982
- });
983
- // Only 1 is supported, so `['email', 'phone_number']` will only show `email`
984
- this.loginMechanism = this.fieldNames.shift();
985
- const common = [
986
- this.loginMechanism,
987
- 'password',
988
- 'confirm_password',
989
- ];
990
- this.fieldNamesCombined = [...common, ...this.fieldNames];
991
- this.setFormFields();
992
- }
993
- get errors() {
994
- const formContext = getActorContext(this.authenticator.authState);
995
- const { validationError } = formContext;
996
- return validationError['password'];
997
- }
998
- setFormFields() {
999
- var _a, _b, _c;
1000
- const _state = this.authenticator.authState;
1001
- this.formOverrides = (_b = (_a = getActorState(_state).context) === null || _a === void 0 ? void 0 : _a.formFields) === null || _b === void 0 ? void 0 : _b.signUp;
1002
- this.userOverrides = (_c = this.formOverrides) === null || _c === void 0 ? void 0 : _c[this.loginMechanism];
1003
- this.order = setFormOrder(this.formOverrides, this.fieldNamesCombined);
1004
- }
1005
- grabField(name, field, defaultV) {
1006
- var _a, _b, _c;
1007
- return (_c = (_b = (_a = this.formOverrides) === null || _a === void 0 ? void 0 : _a[name]) === null || _b === void 0 ? void 0 : _b[field]) !== null && _c !== void 0 ? _c : defaultV;
1008
- }
1009
790
  }
1010
791
  SignUpFormFieldsComponent.decorators = [
1011
792
  { type: Component, args: [{
1012
793
  selector: 'amplify-sign-up-form-fields',
1013
- template: "<div class=\"amplify-flex\" style=\"flex-direction: column\" data-amplify-fieldset>\n <ng-container *ngFor=\"let field of order\">\n <ng-container [ngSwitch]=\"field\">\n <amplify-user-name-alias\n *ngSwitchCase=\"loginMechanism\"\n [name]=\"loginMechanism\"\n [labelHidden]=\"grabField(loginMechanism, 'labelHidden', true)\"\n [placeholder]=\"userOverrides?.placeholder\"\n [required]=\"grabField(loginMechanism, 'required', true)\"\n [label]=\"userOverrides?.label\"\n [dialCode]=\"userOverrides?.dialCode\"\n [dialCodeList]=\"userOverrides?.dialCodeList\"\n ></amplify-user-name-alias>\n <ng-container *ngSwitchCase=\"'password'\">\n <amplify-form-field\n [labelHidden]=\"grabField('password', 'labelHidden', true)\"\n [placeholder]=\"grabField('password', 'placeholder', null)\"\n [required]=\"grabField('password', 'required', true)\"\n [label]=\"grabField('password', 'label', null)\"\n name=\"password\"\n autocomplete=\"new-password\"\n ></amplify-form-field>\n <div data-amplify-sign-up-errors *ngIf=\"errors\">\n <!-- TODO: add amplify-alert reusable component -->\n <div\n class=\"amplify-text\"\n data-variation=\"error\"\n *ngFor=\"let error of errors\"\n >\n {{ translate(error) }}\n </div>\n </div>\n </ng-container>\n <amplify-form-field\n *ngSwitchCase=\"'confirm_password'\"\n [labelHidden]=\"grabField('confirm_password', 'labelHidden', true)\"\n [placeholder]=\"\n grabField('confirm_password', 'placeholder', 'Confirm Password')\n \"\n [required]=\"grabField('confirm_password', 'required', true)\"\n [label]=\"grabField('confirm_password', 'label', 'Confirm Password')\"\n name=\"confirm_password\"\n type=\"password\"\n autocomplete=\"new-password\"\n ></amplify-form-field>\n\n <amplify-form-field\n *ngSwitchDefault\n [name]=\"field\"\n [labelHidden]=\"grabField(field, 'labelHidden', false)\"\n [placeholder]=\"grabField(field, 'placeholder', null)\"\n [required]=\"grabField(field, 'required', true)\"\n [label]=\"grabField(field, 'label', null)\"\n [defaultCountryCode]=\"grabField(field, 'dialCode', null)\"\n [dialCodeList]=\"grabField(field, 'dialCodeList', null)\"\n ></amplify-form-field>\n </ng-container>\n </ng-container>\n</div>\n"
794
+ template: "<div class=\"amplify-flex\" style=\"flex-direction: column\" data-amplify-fieldset>\n <amplify-base-form-fields route=\"signUp\"></amplify-base-form-fields>\n</div>\n"
1014
795
  },] }
1015
796
  ];
1016
- SignUpFormFieldsComponent.ctorParameters = () => [
1017
- { type: AuthenticatorService }
1018
- ];
1019
797
 
1020
- class UserNameAliasComponent {
1021
- constructor(authenticator) {
1022
- this.authenticator = authenticator;
1023
- this.name = 'username';
1024
- this.disabled = false;
1025
- this.initialValue = '';
1026
- this.required = true;
1027
- }
1028
- ngOnInit() {
1029
- var _a, _b, _c;
1030
- const context = this.authenticator.context;
1031
- const { label: lbl, type } = getAliasInfoFromContext(context);
1032
- this.labelValue = (_a = this.label) !== null && _a !== void 0 ? _a : lbl;
1033
- this.type = type;
1034
- this.placeholderValue = (_b = this.placeholder) !== null && _b !== void 0 ? _b : lbl;
1035
- this.requiredValue = (_c = this.required) !== null && _c !== void 0 ? _c : true;
1036
- }
1037
- }
1038
- UserNameAliasComponent.decorators = [
1039
- { type: Component, args: [{
1040
- selector: 'amplify-user-name-alias',
1041
- template: "<amplify-form-field\n data-amplify-usernamealias\n [name]=\"name\"\n [labelHidden]=\"labelHidden\"\n [label]=\"labelValue\"\n [placeholder]=\"placeholderValue\"\n [required]=\"requiredValue\"\n [defaultCountryCode]=\"dialCode\"\n [dialCodeList]=\"dialCodeList\"\n [type]=\"type\"\n [initialValue]=\"initialValue\"\n [disabled]=\"disabled\"\n autocomplete=\"username\"\n>\n</amplify-form-field>\n"
1042
- },] }
1043
- ];
1044
- UserNameAliasComponent.ctorParameters = () => [
1045
- { type: AuthenticatorService }
1046
- ];
1047
- UserNameAliasComponent.propDecorators = {
1048
- name: [{ type: Input }],
1049
- disabled: [{ type: Input }],
1050
- initialValue: [{ type: Input }],
1051
- required: [{ type: Input }],
1052
- labelHidden: [{ type: Input }],
1053
- label: [{ type: Input }],
1054
- placeholder: [{ type: Input }],
1055
- dialCode: [{ type: Input }],
1056
- dialCodeList: [{ type: Input }]
1057
- };
798
+ const getAttributeMap = () => defaultFormFieldOptions;
1058
799
 
1059
800
  class VerifyUserComponent {
1060
801
  constructor(authenticator) {
@@ -1105,6 +846,57 @@ VerifyUserComponent.propDecorators = {
1105
846
  headerText: [{ type: Input }]
1106
847
  };
1107
848
 
849
+ /**
850
+ * Sorts the given formFields, then renders them in order.
851
+ */
852
+ class BaseFormFieldsComponent {
853
+ constructor(authenticator) {
854
+ this.authenticator = authenticator;
855
+ this.display = 'contents';
856
+ this.formFields = [];
857
+ }
858
+ ngOnInit() {
859
+ const state = this.authenticator.authState;
860
+ this.formFields = getSortedFormFields(this.route, state);
861
+ if (this.route === 'confirmSignUp') {
862
+ this.handleConfirmSignUp();
863
+ }
864
+ }
865
+ handleConfirmSignUp() {
866
+ /**
867
+ * @todo(breaking): Angular `confirmSignUp` has different placholder here from other frameworks.
868
+ *
869
+ * Translating here in a backwards-compatible manner, but should be resolved in next major version.
870
+ */
871
+ var _a;
872
+ const state = this.authenticator.authState;
873
+ // backwards compatible placeholder text
874
+ const placeholder = !hasTranslation('Confirmation Code')
875
+ ? translate('Enter your code') // prioritize new placeholder
876
+ : translate('Confirmation Code'); // legacy placeholder
877
+ let defaultFormFields = getDefaultFormFields(this.route, state);
878
+ if (defaultFormFields.confirmation_code.placeholder) {
879
+ defaultFormFields.confirmation_code.placeholder = placeholder;
880
+ }
881
+ const customFormFields = ((_a = getActorContext(state).formFields) === null || _a === void 0 ? void 0 : _a.confirmSignUp) || {};
882
+ const newFormFields = applyDefaults(defaultFormFields, customFormFields);
883
+ this.formFields = sortFormFields(newFormFields);
884
+ }
885
+ }
886
+ BaseFormFieldsComponent.decorators = [
887
+ { type: Component, args: [{
888
+ selector: 'amplify-base-form-fields',
889
+ template: "<ng-container *ngFor=\"let formField of formFields\">\n <amplify-form-field\n [name]=\"formField[0]\"\n [formField]=\"formField[1]\"\n ></amplify-form-field>\n</ng-container>\n"
890
+ },] }
891
+ ];
892
+ BaseFormFieldsComponent.ctorParameters = () => [
893
+ { type: AuthenticatorService }
894
+ ];
895
+ BaseFormFieldsComponent.propDecorators = {
896
+ route: [{ type: Input }],
897
+ display: [{ type: HostBinding, args: ['style.display',] }]
898
+ };
899
+
1108
900
  class ButtonComponent {
1109
901
  constructor() {
1110
902
  this.type = 'button';
@@ -1420,6 +1212,7 @@ AmplifyAuthenticatorModule.decorators = [
1420
1212
  AmplifySlotComponent,
1421
1213
  AmplifySlotDirective,
1422
1214
  AuthenticatorComponent,
1215
+ BaseFormFieldsComponent,
1423
1216
  ButtonComponent,
1424
1217
  CheckboxComponent,
1425
1218
  ConfirmResetPasswordComponent,
@@ -1443,7 +1236,6 @@ AmplifyAuthenticatorModule.decorators = [
1443
1236
  TabItemComponent,
1444
1237
  TabsComponent,
1445
1238
  TextFieldComponent,
1446
- UserNameAliasComponent,
1447
1239
  VerifyUserComponent,
1448
1240
  ],
1449
1241
  imports: [CommonModule],
@@ -1466,5 +1258,5 @@ AmplifyAuthenticatorModule.decorators = [
1466
1258
  * Generated bundle index. Do not edit.
1467
1259
  */
1468
1260
 
1469
- export { AmplifyAuthenticatorModule, AmplifySlotDirective, AuthenticatorComponent, AuthenticatorService, ButtonComponent, CheckboxComponent, ConfirmResetPasswordComponent, ConfirmSignInComponent, ConfirmSignUpComponent, ConfirmVerifyUserComponent, CustomComponentsService, ErrorComponent, FederatedSignInButtonComponent, FederatedSignInComponent, ForceNewPasswordComponent, ForceNewPasswordFormFieldsComponent, FormFieldComponent, PasswordFieldComponent, PhoneNumberFieldComponent, ResetPasswordComponent, SelectComponent, SetupTotpComponent, SignInComponent, SignUpComponent, SignUpFormFieldsComponent, TabItemComponent, TabsComponent, TextFieldComponent, UserNameAliasComponent, VerifyUserComponent, getAttributeMap, AmplifySlotComponent as ɵa, AuthenticatorComponent as ɵb, VerifyUserComponent as ɵba, ButtonComponent as ɵc, CheckboxComponent as ɵd, ConfirmResetPasswordComponent as ɵe, ConfirmSignInComponent as ɵf, ConfirmSignUpComponent as ɵg, ConfirmVerifyUserComponent as ɵh, ErrorComponent as ɵi, FederatedSignInButtonComponent as ɵj, FederatedSignInComponent as ɵk, ForceNewPasswordComponent as ɵl, ForceNewPasswordFormFieldsComponent as ɵm, FormFieldComponent as ɵn, PasswordFieldComponent as ɵo, PhoneNumberFieldComponent as ɵp, ResetPasswordComponent as ɵq, SelectComponent as ɵr, SetupTotpComponent as ɵs, SignInComponent as ɵt, SignUpComponent as ɵu, SignUpFormFieldsComponent as ɵv, TabItemComponent as ɵw, TabsComponent as ɵx, TextFieldComponent as ɵy, UserNameAliasComponent as ɵz };
1261
+ export { AmplifyAuthenticatorModule, AmplifySlotDirective, AuthenticatorComponent, AuthenticatorService, BaseFormFieldsComponent, ButtonComponent, CheckboxComponent, ConfirmResetPasswordComponent, ConfirmSignInComponent, ConfirmSignUpComponent, ConfirmVerifyUserComponent, CustomComponentsService, ErrorComponent, FederatedSignInButtonComponent, FederatedSignInComponent, ForceNewPasswordComponent, ForceNewPasswordFormFieldsComponent, FormFieldComponent, PasswordFieldComponent, PhoneNumberFieldComponent, ResetPasswordComponent, SelectComponent, SetupTotpComponent, SignInComponent, SignUpComponent, SignUpFormFieldsComponent, TabItemComponent, TabsComponent, TextFieldComponent, VerifyUserComponent, getAttributeMap, AmplifySlotComponent as ɵa, AuthenticatorComponent as ɵb, VerifyUserComponent as ɵba, BaseFormFieldsComponent as ɵc, ButtonComponent as ɵd, CheckboxComponent as ɵe, ConfirmResetPasswordComponent as ɵf, ConfirmSignInComponent as ɵg, ConfirmSignUpComponent as ɵh, ConfirmVerifyUserComponent as ɵi, ErrorComponent as ɵj, FederatedSignInButtonComponent as ɵk, FederatedSignInComponent as ɵl, ForceNewPasswordComponent as ɵm, ForceNewPasswordFormFieldsComponent as ɵn, FormFieldComponent as ɵo, PasswordFieldComponent as ɵp, PhoneNumberFieldComponent as ɵq, ResetPasswordComponent as ɵr, SelectComponent as ɵs, SetupTotpComponent as ɵt, SignInComponent as ɵu, SignUpComponent as ɵv, SignUpFormFieldsComponent as ɵw, TabItemComponent as ɵx, TabsComponent as ɵy, TextFieldComponent as ɵz };
1470
1262
  //# sourceMappingURL=aws-amplify-ui-angular.js.map