@aws-amplify/ui 6.0.2 → 6.0.4

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.
package/dist/index.js CHANGED
@@ -3287,6 +3287,7 @@ const runFieldValidators = ({ value, validators, eventType, hasBlurred, }) => {
3287
3287
 
3288
3288
  // default `autoSignIn` flag is `true`
3289
3289
  const DEFAULT_AUTO_SIGN_IN = true;
3290
+ const EMPTY_STRING = '';
3290
3291
  const sanitizePhoneNumber = (dialCode, phoneNumber) => `${dialCode}${phoneNumber}`.replace(/[^A-Z0-9+]/gi, '');
3291
3292
  const selectUserAttributes = (_, key) => {
3292
3293
  // Allowlist of Cognito User Pool Attributes (from OpenID Connect specification)
@@ -3318,7 +3319,7 @@ const selectUserAttributes = (_, key) => {
3318
3319
  const getUserAttributes = (formValues) => {
3319
3320
  const { phone_number, ...userAttributes } = pickBy__default["default"](formValues, selectUserAttributes);
3320
3321
  // only include `phone_number` attribute in `userAttributes` if it has a value
3321
- if (isString(phone_number)) {
3322
+ if (isString(phone_number) && phone_number !== EMPTY_STRING) {
3322
3323
  const { country_code } = formValues;
3323
3324
  return {
3324
3325
  ...userAttributes,
@@ -4461,13 +4462,13 @@ function signUpActor({ services }) {
4461
4462
  async federatedSignIn(_, { data }) {
4462
4463
  return auth.signInWithRedirect(data);
4463
4464
  },
4464
- async handleSignUp(context, _event) {
4465
+ async handleSignUp(context) {
4465
4466
  const { formValues, loginMechanisms, username } = context;
4466
4467
  const loginMechanism = loginMechanisms[0];
4467
4468
  const input = getSignUpInput(username, formValues, loginMechanism);
4468
4469
  return services.handleSignUp(input);
4469
4470
  },
4470
- async validateSignUp(context, _event) {
4471
+ async validateSignUp(context) {
4471
4472
  // This needs to exist in the machine to reference new `services`
4472
4473
  return runValidators(context.formValues, context.touched, context.passwordSettings, [
4473
4474
  // Validation of password
@@ -4629,6 +4630,7 @@ const LEGACY_WAIT_CONFIG = {
4629
4630
  actions: ['configure'],
4630
4631
  target: 'getConfig',
4631
4632
  },
4633
+ SIGN_OUT: '#authenticator.signOut',
4632
4634
  },
4633
4635
  };
4634
4636
  // setup step proceeds directly to configure
@@ -4654,7 +4656,7 @@ function createAuthenticatorMachine(options) {
4654
4656
  idle: {
4655
4657
  invoke: {
4656
4658
  src: 'handleGetCurrentUser',
4657
- onDone: { actions: 'setUser', target: 'authenticated' },
4659
+ onDone: { actions: 'setUser', target: 'setup' },
4658
4660
  onError: { target: 'setup' },
4659
4661
  },
4660
4662
  },
@@ -4665,10 +4667,17 @@ function createAuthenticatorMachine(options) {
4665
4667
  getConfig: {
4666
4668
  invoke: {
4667
4669
  src: 'getAmplifyConfig',
4668
- onDone: {
4669
- actions: ['applyAmplifyConfig', 'setHasSetup'],
4670
- target: 'goToInitialState',
4671
- },
4670
+ onDone: [
4671
+ {
4672
+ actions: ['applyAmplifyConfig', 'setHasSetup'],
4673
+ cond: 'hasUser',
4674
+ target: '#authenticator.authenticated',
4675
+ },
4676
+ {
4677
+ actions: ['applyAmplifyConfig', 'setHasSetup'],
4678
+ target: 'goToInitialState',
4679
+ },
4680
+ ],
4672
4681
  },
4673
4682
  },
4674
4683
  goToInitialState: {
@@ -4927,7 +4936,7 @@ function createAuthenticatorMachine(options) {
4927
4936
  configure: xstate.assign((_, event) => {
4928
4937
  const { services: customServices, ...config } = !isEmptyObject(overrideConfigServices)
4929
4938
  ? overrideConfigServices
4930
- : event.data;
4939
+ : event.data ?? {};
4931
4940
  return {
4932
4941
  services: { ...defaultServices, ...customServices },
4933
4942
  config,
@@ -4941,6 +4950,9 @@ function createAuthenticatorMachine(options) {
4941
4950
  isInitialStateSignUp: ({ config }) => config.initialState === 'signUp',
4942
4951
  isInitialStateResetPassword: ({ config }) => config.initialState === 'forgotPassword',
4943
4952
  shouldSetup: ({ hasSetup }) => !hasSetup,
4953
+ hasUser: ({ user }) => {
4954
+ return !!user;
4955
+ },
4944
4956
  },
4945
4957
  services: {
4946
4958
  getAmplifyConfig: ({ services }) => services.getAmplifyConfig(),
@@ -5388,13 +5400,7 @@ const button = {
5388
5400
  backgroundColor: { value: '{colors.blue.10.value}' },
5389
5401
  color: { value: '{colors.blue.100.value}' },
5390
5402
  boxShadow: {
5391
- value: {
5392
- offsetX: '0px',
5393
- offsetY: '0px',
5394
- blurRadius: '0px',
5395
- spreadRadius: '1px',
5396
- color: '{colors.blue.100.value}',
5397
- },
5403
+ value: '{components.fieldcontrol.info._focus.boxShadow.value}',
5398
5404
  },
5399
5405
  },
5400
5406
  _active: {
@@ -5417,13 +5423,7 @@ const button = {
5417
5423
  backgroundColor: { value: '{colors.orange.10.value}' },
5418
5424
  color: { value: '{colors.orange.100.value}' },
5419
5425
  boxShadow: {
5420
- value: {
5421
- offsetX: '0px',
5422
- offsetY: '0px',
5423
- blurRadius: '0px',
5424
- spreadRadius: '1px',
5425
- color: '{colors.orange.100.value}',
5426
- },
5426
+ value: '{components.fieldcontrol.warning._focus.boxShadow.value}',
5427
5427
  },
5428
5428
  },
5429
5429
  _active: {
@@ -5446,13 +5446,7 @@ const button = {
5446
5446
  backgroundColor: { value: '{colors.green.10.value}' },
5447
5447
  color: { value: '{colors.green.100.value}' },
5448
5448
  boxShadow: {
5449
- value: {
5450
- offsetX: '0px',
5451
- offsetY: '0px',
5452
- blurRadius: '0px',
5453
- spreadRadius: '1px',
5454
- color: '{colors.green.100.value}',
5455
- },
5449
+ value: '{components.fieldcontrol.success._focus.boxShadow.value}',
5456
5450
  },
5457
5451
  },
5458
5452
  _active: {
@@ -5475,13 +5469,7 @@ const button = {
5475
5469
  backgroundColor: { value: '{colors.red.10.value}' },
5476
5470
  color: { value: '{colors.red.100.value}' },
5477
5471
  boxShadow: {
5478
- value: {
5479
- offsetX: '0px',
5480
- offsetY: '0px',
5481
- blurRadius: '0px',
5482
- spreadRadius: '1px',
5483
- color: '{colors.red.100.value}',
5484
- },
5472
+ value: '{components.fieldcontrol._error._focus.boxShadow.value}',
5485
5473
  },
5486
5474
  },
5487
5475
  _active: {
@@ -5504,13 +5492,7 @@ const button = {
5504
5492
  backgroundColor: { value: '{colors.overlay.5.value}' },
5505
5493
  color: { value: '{colors.neutral.90.value}' },
5506
5494
  boxShadow: {
5507
- value: {
5508
- offsetX: '0px',
5509
- offsetY: '0px',
5510
- blurRadius: '0px',
5511
- spreadRadius: '1px',
5512
- color: '{colors.overlay.90.value}',
5513
- },
5495
+ value: '{components.fieldcontrol.overlay._focus.boxShadow.value}',
5514
5496
  },
5515
5497
  },
5516
5498
  _active: {
@@ -5566,13 +5548,7 @@ const button = {
5566
5548
  backgroundColor: { value: '{colors.blue.90.value}' },
5567
5549
  color: { value: '{colors.font.inverse.value}' },
5568
5550
  boxShadow: {
5569
- value: {
5570
- offsetX: '0px',
5571
- offsetY: '0px',
5572
- blurRadius: '0px',
5573
- spreadRadius: '1px',
5574
- color: '{colors.blue.100.value}',
5575
- },
5551
+ value: '{components.fieldcontrol.info._focus.boxShadow.value}',
5576
5552
  },
5577
5553
  },
5578
5554
  _active: {
@@ -5595,13 +5571,7 @@ const button = {
5595
5571
  backgroundColor: { value: '{colors.orange.90.value}' },
5596
5572
  color: { value: '{colors.font.inverse.value}' },
5597
5573
  boxShadow: {
5598
- value: {
5599
- offsetX: '0px',
5600
- offsetY: '0px',
5601
- blurRadius: '0px',
5602
- spreadRadius: '1px',
5603
- color: '{colors.orange.100.value}',
5604
- },
5574
+ value: '{components.fieldcontrol.overlay._focus.boxShadow.value}',
5605
5575
  },
5606
5576
  },
5607
5577
  _active: {
@@ -5624,13 +5594,7 @@ const button = {
5624
5594
  backgroundColor: { value: '{colors.red.90.value}' },
5625
5595
  color: { value: '{colors.font.inverse.value}' },
5626
5596
  boxShadow: {
5627
- value: {
5628
- offsetX: '0px',
5629
- offsetY: '0px',
5630
- blurRadius: '0px',
5631
- spreadRadius: '1px',
5632
- color: '{colors.red.100.value}',
5633
- },
5597
+ value: '{components.fieldcontrol._error._focus.boxShadow.value}',
5634
5598
  },
5635
5599
  },
5636
5600
  _active: {
@@ -5653,13 +5617,7 @@ const button = {
5653
5617
  backgroundColor: { value: '{colors.green.90.value}' },
5654
5618
  color: { value: '{colors.font.inverse.value}' },
5655
5619
  boxShadow: {
5656
- value: {
5657
- offsetX: '0px',
5658
- offsetY: '0px',
5659
- blurRadius: '0px',
5660
- spreadRadius: '1px',
5661
- color: '{colors.green.100.value}',
5662
- },
5620
+ value: '{components.fieldcontrol.success._focus.boxShadow.value}',
5663
5621
  },
5664
5622
  },
5665
5623
  _active: {
@@ -5682,13 +5640,7 @@ const button = {
5682
5640
  backgroundColor: { value: '{colors.overlay.90.value}' },
5683
5641
  color: { value: '{colors.font.inverse.value}' },
5684
5642
  boxShadow: {
5685
- value: {
5686
- offsetX: '0px',
5687
- offsetY: '0px',
5688
- blurRadius: '0px',
5689
- spreadRadius: '1px',
5690
- color: '{colors.overlay.90.value}',
5691
- },
5643
+ value: '{components.fieldcontrol.overlay._focus.boxShadow.value}',
5692
5644
  },
5693
5645
  },
5694
5646
  _active: {
@@ -5766,13 +5718,7 @@ const button = {
5766
5718
  backgroundColor: { value: '{colors.blue.10.value}' },
5767
5719
  color: { value: '{colors.blue.100.value}' },
5768
5720
  boxShadow: {
5769
- value: {
5770
- offsetX: '0px',
5771
- offsetY: '0px',
5772
- blurRadius: '0px',
5773
- spreadRadius: '1px',
5774
- color: '{colors.blue.100.value}',
5775
- },
5721
+ value: '{components.fieldcontrol.info._focus.boxShadow.value}',
5776
5722
  },
5777
5723
  },
5778
5724
  _active: {
@@ -5795,13 +5741,7 @@ const button = {
5795
5741
  backgroundColor: { value: '{colors.orange.10.value}' },
5796
5742
  color: { value: '{colors.orange.100.value}' },
5797
5743
  boxShadow: {
5798
- value: {
5799
- offsetX: '0px',
5800
- offsetY: '0px',
5801
- blurRadius: '0px',
5802
- spreadRadius: '1px',
5803
- color: '{colors.orange.100.value}',
5804
- },
5744
+ value: '{components.fieldcontrol.warning._focus.boxShadow.value}',
5805
5745
  },
5806
5746
  },
5807
5747
  _active: {
@@ -5824,13 +5764,7 @@ const button = {
5824
5764
  backgroundColor: { value: '{colors.green.10.value}' },
5825
5765
  color: { value: '{colors.green.100.value}' },
5826
5766
  boxShadow: {
5827
- value: {
5828
- offsetX: '0px',
5829
- offsetY: '0px',
5830
- blurRadius: '0px',
5831
- spreadRadius: '1px',
5832
- color: '{colors.green.100.value}',
5833
- },
5767
+ value: '{components.fieldcontrol.success._focus.boxShadow.value}',
5834
5768
  },
5835
5769
  },
5836
5770
  _active: {
@@ -5853,13 +5787,7 @@ const button = {
5853
5787
  backgroundColor: { value: '{colors.red.10.value}' },
5854
5788
  color: { value: '{colors.red.100.value}' },
5855
5789
  boxShadow: {
5856
- value: {
5857
- offsetX: '0px',
5858
- offsetY: '0px',
5859
- blurRadius: '0px',
5860
- spreadRadius: '1px',
5861
- color: '{colors.red.100.value}',
5862
- },
5790
+ value: '{components.fieldcontrol._error._focus.boxShadow.value}',
5863
5791
  },
5864
5792
  },
5865
5793
  _active: {
@@ -5882,13 +5810,7 @@ const button = {
5882
5810
  backgroundColor: { value: '{colors.overlay.5.value}' },
5883
5811
  color: { value: '{colors.overlay.90.value}' },
5884
5812
  boxShadow: {
5885
- value: {
5886
- offsetX: '0px',
5887
- offsetY: '0px',
5888
- blurRadius: '0px',
5889
- spreadRadius: '1px',
5890
- color: '{colors.overlay.90.value}',
5891
- },
5813
+ value: '{components.fieldcontrol.overlay._focus.boxShadow.value}',
5892
5814
  },
5893
5815
  },
5894
5816
  _active: {
@@ -6056,16 +5978,8 @@ const checkbox = {
6056
5978
  outlineStyle: { value: 'solid' },
6057
5979
  outlineWidth: { value: '{outlineWidths.medium.value}' },
6058
5980
  outlineOffset: { value: '{outlineOffsets.medium.value}' },
6059
- borderColor: { value: '{colors.transparent.value}' },
6060
- boxShadow: {
6061
- value: {
6062
- offsetX: '0px',
6063
- offsetY: '0px',
6064
- blurRadius: '0px',
6065
- spreadRadius: '2px',
6066
- color: '{colors.border.focus.value}',
6067
- },
6068
- },
5981
+ borderColor: { value: '{colors.border.focus.value}' },
5982
+ boxShadow: { value: '{components.fieldcontrol._focus.boxShadow.value}' },
6069
5983
  },
6070
5984
  _disabled: {
6071
5985
  borderColor: { value: '{colors.border.disabled.value}' },
@@ -6073,15 +5987,9 @@ const checkbox = {
6073
5987
  _error: {
6074
5988
  borderColor: { value: '{colors.border.error.value}' },
6075
5989
  _focus: {
6076
- borderColor: { value: '{colors.transparent.value}' },
5990
+ borderColor: { value: '{colors.border.error.value}' },
6077
5991
  boxShadow: {
6078
- value: {
6079
- offsetX: '0px',
6080
- offsetY: '0px',
6081
- blurRadius: '0px',
6082
- spreadRadius: '2px',
6083
- color: '{colors.border.error.value}',
6084
- },
5992
+ value: '{components.fieldcontrol._error._focus.boxShadow.value}',
6085
5993
  },
6086
5994
  },
6087
5995
  },
@@ -6410,47 +6318,38 @@ const fieldcontrol = {
6410
6318
  borderBlockStart: { value: 'none' },
6411
6319
  borderRadius: { value: '0' },
6412
6320
  _focus: {
6413
- borderBlockEndColor: { value: '{colors.border.focus.value}' },
6321
+ borderBlockEndColor: { value: 'transparent' },
6414
6322
  boxShadow: {
6415
- value: {
6416
- offsetX: '0px',
6417
- offsetY: '1px',
6418
- color: '{colors.border.focus.value}',
6419
- blurRadius: '0px',
6420
- },
6323
+ value: '{components.fieldcontrol._focus.boxShadow.value}',
6421
6324
  },
6422
6325
  },
6423
6326
  _error: {
6424
6327
  borderBlockEndColor: { value: '{colors.border.error.value}' },
6425
6328
  _focus: {
6329
+ borderBlockEndColor: { value: 'transparent' },
6426
6330
  boxShadow: {
6427
- value: {
6428
- offsetX: '0px',
6429
- offsetY: '1px',
6430
- color: '{colors.border.error.value}',
6431
- blurRadius: '0px',
6432
- },
6331
+ value: '{components.fieldcontrol._error._focus.boxShadow.value}',
6433
6332
  },
6434
6333
  },
6435
6334
  },
6436
6335
  },
6437
6336
  _focus: {
6438
6337
  // These focus styles have been calibrated to create
6439
- // a highly visible focus indicator per WCAG 2.1 guidliness:
6440
- // See: https://www.w3.org/WAI/WCAG21/Techniques/general/G195.html
6338
+ // a highly visible focus indicator per WCAG 2.2 guidlines:
6339
+ // See: https://www.w3.org/TR/WCAG22/#focus-appearance
6441
6340
  //
6442
6341
  // Key features:
6443
- // * Focus indicator area is at least the 1 CSS px border around the component.
6444
- // * Contrast between focused and unfocused states has a ratio of 3:1
6342
+ // * Focus indicator area is at least the 2 CSS px perimeter around the component.
6343
+ // * Contrast between focused and unfocused area of contrast has a ratio of 3:1
6445
6344
  //
6446
- // IMPORTANT: Must recalibrate if `colors.border.primary` or `colors.focus` are changed
6345
+ // IMPORTANT: Must recalibrate if `colors.border.focus` are changed
6447
6346
  borderColor: { value: '{colors.border.focus.value}' },
6448
6347
  boxShadow: {
6449
6348
  value: {
6450
6349
  offsetX: '0px',
6451
6350
  offsetY: '0px',
6452
6351
  blurRadius: '0px',
6453
- spreadRadius: '1px',
6352
+ spreadRadius: '2px',
6454
6353
  color: '{colors.border.focus.value}',
6455
6354
  },
6456
6355
  },
@@ -6470,12 +6369,64 @@ const fieldcontrol = {
6470
6369
  offsetX: '0px',
6471
6370
  offsetY: '0px',
6472
6371
  blurRadius: '0px',
6473
- spreadRadius: '1px',
6372
+ spreadRadius: '2px',
6474
6373
  color: '{colors.border.error.value}',
6475
6374
  },
6476
6375
  },
6477
6376
  },
6478
6377
  },
6378
+ info: {
6379
+ _focus: {
6380
+ boxShadow: {
6381
+ value: {
6382
+ offsetX: '0px',
6383
+ offsetY: '0px',
6384
+ blurRadius: '0px',
6385
+ spreadRadius: '2px',
6386
+ color: '{colors.blue.100.value}',
6387
+ },
6388
+ },
6389
+ },
6390
+ },
6391
+ warning: {
6392
+ _focus: {
6393
+ boxShadow: {
6394
+ value: {
6395
+ offsetX: '0px',
6396
+ offsetY: '0px',
6397
+ blurRadius: '0px',
6398
+ spreadRadius: '2px',
6399
+ color: '{colors.orange.100.value}',
6400
+ },
6401
+ },
6402
+ },
6403
+ },
6404
+ success: {
6405
+ _focus: {
6406
+ boxShadow: {
6407
+ value: {
6408
+ offsetX: '0px',
6409
+ offsetY: '0px',
6410
+ blurRadius: '0px',
6411
+ spreadRadius: '2px',
6412
+ color: '{colors.green.100.value}',
6413
+ },
6414
+ },
6415
+ },
6416
+ },
6417
+ overlay: {
6418
+ _focus: {
6419
+ boxShadow: {
6420
+ value: {
6421
+ offsetX: '0px',
6422
+ offsetY: '0px',
6423
+ blurRadius: '0px',
6424
+ spreadRadius: '2px',
6425
+ color: '{colors.overlay.90.value}',
6426
+ },
6427
+ },
6428
+ },
6429
+ },
6479
6430
  };
6480
6431
 
6481
6432
  const fieldgroup = {
@@ -7156,15 +7107,7 @@ const sliderfield = {
7156
7107
  },
7157
7108
  _focus: {
7158
7109
  borderColor: { value: '{colors.border.focus.value}' },
7159
- boxShadow: {
7160
- value: {
7161
- offsetX: '0',
7162
- offsetY: '0',
7163
- blurRadius: '0',
7164
- spreadRadius: '2px',
7165
- color: '{colors.border.focus.value}',
7166
- },
7167
- },
7110
+ boxShadow: { value: '{components.fieldcontrol._focus.boxShadow.value}' },
7168
7111
  },
7169
7112
  },
7170
7113
  small: {
@@ -7322,13 +7265,7 @@ const switchfield = {
7322
7265
  },
7323
7266
  _focused: {
7324
7267
  shadow: {
7325
- value: {
7326
- offsetX: '0px',
7327
- offsetY: '0px',
7328
- blurRadius: '0px',
7329
- spreadRadius: '2px',
7330
- color: '{colors.border.focus.value}',
7331
- },
7268
+ value: '{components.fieldcontrol._focus.boxShadow.value}',
7332
7269
  },
7333
7270
  },
7334
7271
  // Sizes