@aws-amplify/ui 6.0.5 → 6.0.7

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.
@@ -7,7 +7,7 @@ import { isFunction } from '../../utils/utils.mjs';
7
7
  * Handles Amplify JS Auth hub events, by forwarding hub events as appropriate
8
8
  * xstate events.
9
9
  */
10
- const defaultAuthHubHandler = async ({ payload }, service, options) => {
10
+ const defaultAuthHubHandler = ({ payload }, service, options) => {
11
11
  const { event } = payload;
12
12
  const { send } = service;
13
13
  const { onSignIn, onSignOut } = options ?? {};
@@ -32,21 +32,17 @@ const defaultAuthHubHandler = async ({ payload }, service, options) => {
32
32
  }
33
33
  }
34
34
  };
35
- const getHubEventHandler = (service, handler) => (data) => {
36
- handler(data, service);
37
- };
38
35
  /**
39
36
  * Listens to external auth Hub events and sends corresponding event to
40
- * the `authService` of interest
41
- *
42
- * @param send - `send` function associated with the `authService` of interest
37
+ * the `service.send` of interest
43
38
  *
39
+ * @param service - contains state machine `send` function
40
+ * @param handler - auth event handler
44
41
  * @returns function that unsubscribes to the hub evenmt
45
42
  */
46
- const listenToAuthHub = (service,
47
- // angular passes its own `handler` param
48
- handler = defaultAuthHubHandler) => {
49
- return Hub.listen('auth', getHubEventHandler(service, handler), 'authenticator-hub-handler');
43
+ const listenToAuthHub = (service, handler = defaultAuthHubHandler) => {
44
+ const eventHandler = (data) => handler(data, service);
45
+ return Hub.listen('auth', eventHandler, 'authenticator-hub-handler');
50
46
  };
51
47
 
52
48
  export { defaultAuthHubHandler, listenToAuthHub };
@@ -10,6 +10,17 @@ import '../../helpers/accountSettings/utils.mjs';
10
10
 
11
11
  // Cognito does not allow a password length less then 8 characters
12
12
  const DEFAULT_COGNITO_PASSWORD_MIN_LENGTH = 8;
13
+ const isInvalidUserAtributes = (userAttributes) => Array.isArray(userAttributes);
14
+ const parseUserAttributes = (userAttributes) => {
15
+ if (!userAttributes) {
16
+ return undefined;
17
+ }
18
+ // `aws-amplify` versions <= 6.0.5 return an array of `userAttributes` rather than an object
19
+ if (isInvalidUserAtributes(userAttributes)) {
20
+ return Object.entries(userAttributes).map(([_, value]) => Object.keys(value)[0]);
21
+ }
22
+ return Object.keys(userAttributes);
23
+ };
13
24
  const defaultServices = {
14
25
  async getAmplifyConfig() {
15
26
  const result = Amplify.getConfig();
@@ -25,9 +36,7 @@ const defaultServices = {
25
36
  : keyValueArray[0];
26
37
  })
27
38
  : undefined;
28
- const parsedSignupAttributes = userAttributes
29
- ? Object.entries(userAttributes).map(([_key, value]) => Object.keys(value)[0])
30
- : undefined;
39
+ const parsedSignupAttributes = parseUserAttributes(userAttributes);
31
40
  const parsedSocialProviders = loginWith?.oauth?.providers
32
41
  ? loginWith.oauth.providers?.map((provider) => provider.toString().toLowerCase())
33
42
  : undefined;
package/dist/index.js CHANGED
@@ -408,7 +408,7 @@ const classNames = (...args) => {
408
408
  * Handles Amplify JS Auth hub events, by forwarding hub events as appropriate
409
409
  * xstate events.
410
410
  */
411
- const defaultAuthHubHandler = async ({ payload }, service, options) => {
411
+ const defaultAuthHubHandler = ({ payload }, service, options) => {
412
412
  const { event } = payload;
413
413
  const { send } = service;
414
414
  const { onSignIn, onSignOut } = options ?? {};
@@ -433,21 +433,17 @@ const defaultAuthHubHandler = async ({ payload }, service, options) => {
433
433
  }
434
434
  }
435
435
  };
436
- const getHubEventHandler = (service, handler) => (data) => {
437
- handler(data, service);
438
- };
439
436
  /**
440
437
  * Listens to external auth Hub events and sends corresponding event to
441
- * the `authService` of interest
442
- *
443
- * @param send - `send` function associated with the `authService` of interest
438
+ * the `service.send` of interest
444
439
  *
440
+ * @param service - contains state machine `send` function
441
+ * @param handler - auth event handler
445
442
  * @returns function that unsubscribes to the hub evenmt
446
443
  */
447
- const listenToAuthHub = (service,
448
- // angular passes its own `handler` param
449
- handler = defaultAuthHubHandler) => {
450
- return utils$1.Hub.listen('auth', getHubEventHandler(service, handler), 'authenticator-hub-handler');
444
+ const listenToAuthHub = (service, handler = defaultAuthHubHandler) => {
445
+ const eventHandler = (data) => handler(data, service);
446
+ return utils$1.Hub.listen('auth', eventHandler, 'authenticator-hub-handler');
451
447
  };
452
448
 
453
449
  const countryDialCodes = [
@@ -3611,6 +3607,17 @@ const runValidators = async (formData, touchData, passwordSettings, validators)
3611
3607
 
3612
3608
  // Cognito does not allow a password length less then 8 characters
3613
3609
  const DEFAULT_COGNITO_PASSWORD_MIN_LENGTH = 8;
3610
+ const isInvalidUserAtributes = (userAttributes) => Array.isArray(userAttributes);
3611
+ const parseUserAttributes = (userAttributes) => {
3612
+ if (!userAttributes) {
3613
+ return undefined;
3614
+ }
3615
+ // `aws-amplify` versions <= 6.0.5 return an array of `userAttributes` rather than an object
3616
+ if (isInvalidUserAtributes(userAttributes)) {
3617
+ return Object.entries(userAttributes).map(([_, value]) => Object.keys(value)[0]);
3618
+ }
3619
+ return Object.keys(userAttributes);
3620
+ };
3614
3621
  const defaultServices = {
3615
3622
  async getAmplifyConfig() {
3616
3623
  const result = awsAmplify.Amplify.getConfig();
@@ -3626,9 +3633,7 @@ const defaultServices = {
3626
3633
  : keyValueArray[0];
3627
3634
  })
3628
3635
  : undefined;
3629
- const parsedSignupAttributes = userAttributes
3630
- ? Object.entries(userAttributes).map(([_key, value]) => Object.keys(value)[0])
3631
- : undefined;
3636
+ const parsedSignupAttributes = parseUserAttributes(userAttributes);
3632
3637
  const parsedSocialProviders = loginWith?.oauth?.providers
3633
3638
  ? loginWith.oauth.providers?.map((provider) => provider.toString().toLowerCase())
3634
3639
  : undefined;
@@ -5,6 +5,12 @@
5
5
  right: var(--amplify-space-medium);
6
6
  }
7
7
 
8
+ .liveness-detector .amplify-button--primary:focus {
9
+ box-shadow: unset;
10
+ outline: var(--amplify-components-button-focus-color) solid 2px;
11
+ outline-offset: 2px;
12
+ }
13
+
8
14
  .amplify-liveness-cancel-button {
9
15
  background-color: #fff;
10
16
  color: hsl(190, 95%, 30%);
@@ -39,6 +45,7 @@
39
45
  left: 0;
40
46
  height: 100%;
41
47
  width: 100%;
48
+ z-index: 2;
42
49
  }
43
50
 
44
51
  .amplify-liveness-video {
@@ -108,7 +115,7 @@
108
115
  }
109
116
 
110
117
  .amplify-liveness-instruction-overlay {
111
- z-index: 1;
118
+ z-index: 2;
112
119
  }
113
120
 
114
121
  .amplify-liveness-countdown-container {
@@ -342,6 +349,10 @@
342
349
  font-weight: var(--amplify-font-weights-bold);
343
350
  }
344
351
 
352
+ .amplify-liveness-hint--mobile {
353
+ margin-top: var(--amplify-space-xxxl);
354
+ }
355
+
345
356
  .amplify-liveness-hint__text {
346
357
  align-items: center;
347
358
  gap: var(--amplify-space-xs);
@@ -419,5 +430,6 @@
419
430
  flex-direction: column;
420
431
  align-items: center;
421
432
  justify-content: center;
433
+ text-align: center;
422
434
  height: 480px;
423
435
  }
@@ -6,6 +6,12 @@
6
6
  right: var(--amplify-space-medium);
7
7
  }
8
8
 
9
+ .liveness-detector .amplify-button--primary:focus {
10
+ box-shadow: unset;
11
+ outline: var(--amplify-components-button-focus-color) solid 2px;
12
+ outline-offset: 2px;
13
+ }
14
+
9
15
  .amplify-liveness-cancel-button {
10
16
  background-color: #fff;
11
17
  color: hsl(190, 95%, 30%);
@@ -40,6 +46,7 @@
40
46
  left: 0;
41
47
  height: 100%;
42
48
  width: 100%;
49
+ z-index: 2;
43
50
  }
44
51
 
45
52
  .amplify-liveness-video {
@@ -109,7 +116,7 @@
109
116
  }
110
117
 
111
118
  .amplify-liveness-instruction-overlay {
112
- z-index: 1;
119
+ z-index: 2;
113
120
  }
114
121
 
115
122
  .amplify-liveness-countdown-container {
@@ -343,6 +350,10 @@
343
350
  font-weight: var(--amplify-font-weights-bold);
344
351
  }
345
352
 
353
+ .amplify-liveness-hint--mobile {
354
+ margin-top: var(--amplify-space-xxxl);
355
+ }
356
+
346
357
  .amplify-liveness-hint__text {
347
358
  align-items: center;
348
359
  gap: var(--amplify-space-xs);
@@ -420,6 +431,7 @@
420
431
  flex-direction: column;
421
432
  align-items: center;
422
433
  justify-content: center;
434
+ text-align: center;
423
435
  height: 480px;
424
436
  }
425
437
  }
@@ -80,6 +80,9 @@
80
80
  var(--amplify-components-table-header-border-width)
81
81
  var(--amplify-components-table-header-border-width);
82
82
  }
83
+ .amplify-table--striped .amplify-table__row:not(.amplify-table__head *):nth-child(odd) {
84
+ background-color: var(--amplify-components-table-row-striped-background-color);
85
+ }
83
86
  .amplify-table__caption {
84
87
  caption-side: var(--amplify-components-table-caption-caption-side);
85
88
  color: var(--amplify-components-table-caption-color);
@@ -138,9 +141,6 @@
138
141
  .amplify-table__td:last-child {
139
142
  border-right-width: var(--amplify-components-table-data-border-width);
140
143
  }
141
- .amplify-table[data-variation=striped] .amplify-table__row:not(.amplify-table__head *):nth-child(odd) {
142
- background-color: var(--amplify-components-table-row-striped-background-color);
143
- }
144
144
  .amplify-table[data-highlightonhover=true] .amplify-table__row:not(.amplify-table__head *):hover {
145
145
  background-color: var(--amplify-components-table-row-hover-background-color);
146
146
  }
@@ -81,6 +81,9 @@
81
81
  var(--amplify-components-table-header-border-width)
82
82
  var(--amplify-components-table-header-border-width);
83
83
  }
84
+ .amplify-table--striped .amplify-table__row:not(.amplify-table__head *):nth-child(odd) {
85
+ background-color: var(--amplify-components-table-row-striped-background-color);
86
+ }
84
87
  .amplify-table__caption {
85
88
  caption-side: var(--amplify-components-table-caption-caption-side);
86
89
  color: var(--amplify-components-table-caption-color);
@@ -139,9 +142,6 @@
139
142
  .amplify-table__td:last-child {
140
143
  border-right-width: var(--amplify-components-table-data-border-width);
141
144
  }
142
- .amplify-table[data-variation=striped] .amplify-table__row:not(.amplify-table__head *):nth-child(odd) {
143
- background-color: var(--amplify-components-table-row-striped-background-color);
144
- }
145
145
  .amplify-table[data-highlightonhover=true] .amplify-table__row:not(.amplify-table__head *):hover {
146
146
  background-color: var(--amplify-components-table-row-hover-background-color);
147
147
  }
package/dist/styles.css CHANGED
@@ -3911,6 +3911,12 @@ html[dir=rtl] .amplify-field-group__inner-start {
3911
3911
  right: var(--amplify-space-medium);
3912
3912
  }
3913
3913
 
3914
+ .liveness-detector .amplify-button--primary:focus {
3915
+ box-shadow: unset;
3916
+ outline: var(--amplify-components-button-focus-color) solid 2px;
3917
+ outline-offset: 2px;
3918
+ }
3919
+
3914
3920
  .amplify-liveness-cancel-button {
3915
3921
  background-color: #fff;
3916
3922
  color: hsl(190, 95%, 30%);
@@ -3945,6 +3951,7 @@ html[dir=rtl] .amplify-field-group__inner-start {
3945
3951
  left: 0;
3946
3952
  height: 100%;
3947
3953
  width: 100%;
3954
+ z-index: 2;
3948
3955
  }
3949
3956
 
3950
3957
  .amplify-liveness-video {
@@ -4014,7 +4021,7 @@ html[dir=rtl] .amplify-field-group__inner-start {
4014
4021
  }
4015
4022
 
4016
4023
  .amplify-liveness-instruction-overlay {
4017
- z-index: 1;
4024
+ z-index: 2;
4018
4025
  }
4019
4026
 
4020
4027
  .amplify-liveness-countdown-container {
@@ -4248,6 +4255,10 @@ html[dir=rtl] .amplify-field-group__inner-start {
4248
4255
  font-weight: var(--amplify-font-weights-bold);
4249
4256
  }
4250
4257
 
4258
+ .amplify-liveness-hint--mobile {
4259
+ margin-top: var(--amplify-space-xxxl);
4260
+ }
4261
+
4251
4262
  .amplify-liveness-hint__text {
4252
4263
  align-items: center;
4253
4264
  gap: var(--amplify-space-xs);
@@ -4325,6 +4336,7 @@ html[dir=rtl] .amplify-field-group__inner-start {
4325
4336
  flex-direction: column;
4326
4337
  align-items: center;
4327
4338
  justify-content: center;
4339
+ text-align: center;
4328
4340
  height: 480px;
4329
4341
  }
4330
4342
 
@@ -5327,6 +5339,9 @@ html[dir=rtl] .amplify-field-group__inner-start {
5327
5339
  var(--amplify-components-table-header-border-width)
5328
5340
  var(--amplify-components-table-header-border-width);
5329
5341
  }
5342
+ .amplify-table--striped .amplify-table__row:not(.amplify-table__head *):nth-child(odd) {
5343
+ background-color: var(--amplify-components-table-row-striped-background-color);
5344
+ }
5330
5345
  .amplify-table__caption {
5331
5346
  caption-side: var(--amplify-components-table-caption-caption-side);
5332
5347
  color: var(--amplify-components-table-caption-color);
@@ -5385,9 +5400,6 @@ html[dir=rtl] .amplify-field-group__inner-start {
5385
5400
  .amplify-table__td:last-child {
5386
5401
  border-right-width: var(--amplify-components-table-data-border-width);
5387
5402
  }
5388
- .amplify-table[data-variation=striped] .amplify-table__row:not(.amplify-table__head *):nth-child(odd) {
5389
- background-color: var(--amplify-components-table-row-striped-background-color);
5390
- }
5391
5403
  .amplify-table[data-highlightonhover=true] .amplify-table__row:not(.amplify-table__head *):hover {
5392
5404
  background-color: var(--amplify-components-table-row-hover-background-color);
5393
5405
  }
@@ -3912,6 +3912,12 @@ html[dir=rtl] .amplify-field-group__inner-start {
3912
3912
  right: var(--amplify-space-medium);
3913
3913
  }
3914
3914
 
3915
+ .liveness-detector .amplify-button--primary:focus {
3916
+ box-shadow: unset;
3917
+ outline: var(--amplify-components-button-focus-color) solid 2px;
3918
+ outline-offset: 2px;
3919
+ }
3920
+
3915
3921
  .amplify-liveness-cancel-button {
3916
3922
  background-color: #fff;
3917
3923
  color: hsl(190, 95%, 30%);
@@ -3946,6 +3952,7 @@ html[dir=rtl] .amplify-field-group__inner-start {
3946
3952
  left: 0;
3947
3953
  height: 100%;
3948
3954
  width: 100%;
3955
+ z-index: 2;
3949
3956
  }
3950
3957
 
3951
3958
  .amplify-liveness-video {
@@ -4015,7 +4022,7 @@ html[dir=rtl] .amplify-field-group__inner-start {
4015
4022
  }
4016
4023
 
4017
4024
  .amplify-liveness-instruction-overlay {
4018
- z-index: 1;
4025
+ z-index: 2;
4019
4026
  }
4020
4027
 
4021
4028
  .amplify-liveness-countdown-container {
@@ -4249,6 +4256,10 @@ html[dir=rtl] .amplify-field-group__inner-start {
4249
4256
  font-weight: var(--amplify-font-weights-bold);
4250
4257
  }
4251
4258
 
4259
+ .amplify-liveness-hint--mobile {
4260
+ margin-top: var(--amplify-space-xxxl);
4261
+ }
4262
+
4252
4263
  .amplify-liveness-hint__text {
4253
4264
  align-items: center;
4254
4265
  gap: var(--amplify-space-xs);
@@ -4326,6 +4337,7 @@ html[dir=rtl] .amplify-field-group__inner-start {
4326
4337
  flex-direction: column;
4327
4338
  align-items: center;
4328
4339
  justify-content: center;
4340
+ text-align: center;
4329
4341
  height: 480px;
4330
4342
  }
4331
4343
 
@@ -5328,6 +5340,9 @@ html[dir=rtl] .amplify-field-group__inner-start {
5328
5340
  var(--amplify-components-table-header-border-width)
5329
5341
  var(--amplify-components-table-header-border-width);
5330
5342
  }
5343
+ .amplify-table--striped .amplify-table__row:not(.amplify-table__head *):nth-child(odd) {
5344
+ background-color: var(--amplify-components-table-row-striped-background-color);
5345
+ }
5331
5346
  .amplify-table__caption {
5332
5347
  caption-side: var(--amplify-components-table-caption-caption-side);
5333
5348
  color: var(--amplify-components-table-caption-color);
@@ -5386,9 +5401,6 @@ html[dir=rtl] .amplify-field-group__inner-start {
5386
5401
  .amplify-table__td:last-child {
5387
5402
  border-right-width: var(--amplify-components-table-data-border-width);
5388
5403
  }
5389
- .amplify-table[data-variation=striped] .amplify-table__row:not(.amplify-table__head *):nth-child(odd) {
5390
- background-color: var(--amplify-components-table-row-striped-background-color);
5391
- }
5392
5404
  .amplify-table[data-highlightonhover=true] .amplify-table__row:not(.amplify-table__head *):hover {
5393
5405
  background-color: var(--amplify-components-table-row-hover-background-color);
5394
5406
  }
@@ -6,10 +6,10 @@ import { AuthInterpreter, AuthMachineHubHandler } from './types';
6
6
  export declare const defaultAuthHubHandler: AuthMachineHubHandler;
7
7
  /**
8
8
  * Listens to external auth Hub events and sends corresponding event to
9
- * the `authService` of interest
10
- *
11
- * @param send - `send` function associated with the `authService` of interest
9
+ * the `service.send` of interest
12
10
  *
11
+ * @param service - contains state machine `send` function
12
+ * @param handler - auth event handler
13
13
  * @returns function that unsubscribes to the hub evenmt
14
14
  */
15
15
  export declare const listenToAuthHub: (service: AuthInterpreter, handler?: AuthMachineHubHandler) => import("@aws-amplify/core/dist/esm/Hub/types").StopListenerCallback;
@@ -23,4 +23,4 @@ export type AuthMachineSend = AuthInterpreter['send'];
23
23
  export type AuthMachineHubHandler = (data: HubCapsule<any, any>, service: AuthInterpreter, options?: {
24
24
  onSignIn?: (user: AuthUser) => void;
25
25
  onSignOut?: () => void;
26
- }) => Promise<void>;
26
+ }) => void;
@@ -1,9 +1,10 @@
1
+ import { UserAttributeKey } from 'aws-amplify/auth';
1
2
  import { confirmResetPassword, confirmSignIn, confirmSignUp, resetPassword, signIn, signUp } from 'aws-amplify/auth';
2
- import { AuthFormData, AuthTouchData, PasswordSettings, SignUpAttribute, SocialProvider, ValidatorResult } from '../../types';
3
+ import { AuthFormData, AuthTouchData, PasswordSettings, SocialProvider, ValidatorResult } from '../../types';
3
4
  export declare const defaultServices: {
4
5
  getAmplifyConfig(): Promise<{
5
6
  loginMechanisms: ("email" | "phone_number" | "username")[];
6
- signUpAttributes: SignUpAttribute[];
7
+ signUpAttributes: UserAttributeKey[];
7
8
  socialProviders: SocialProvider[];
8
9
  identityPoolId: string;
9
10
  allowGuestAccess?: boolean;
@@ -17,7 +18,7 @@ export declare const defaultServices: {
17
18
  passwordFormat?: never;
18
19
  } | {
19
20
  loginMechanisms: ("email" | "phone_number" | "username")[];
20
- signUpAttributes: SignUpAttribute[];
21
+ signUpAttributes: UserAttributeKey[];
21
22
  socialProviders: SocialProvider[];
22
23
  userPoolClientId: string;
23
24
  userPoolId: string;
@@ -48,7 +49,7 @@ export declare const defaultServices: {
48
49
  allowGuestAccess?: never;
49
50
  } | {
50
51
  loginMechanisms: ("email" | "phone_number" | "username")[];
51
- signUpAttributes: SignUpAttribute[];
52
+ signUpAttributes: UserAttributeKey[];
52
53
  socialProviders: SocialProvider[];
53
54
  identityPoolId: never;
54
55
  allowGuestAccess?: never;
@@ -62,7 +63,7 @@ export declare const defaultServices: {
62
63
  passwordFormat?: never;
63
64
  } | {
64
65
  loginMechanisms: ("email" | "phone_number" | "username")[];
65
- signUpAttributes: SignUpAttribute[];
66
+ signUpAttributes: UserAttributeKey[];
66
67
  socialProviders: SocialProvider[];
67
68
  identityPoolId: string;
68
69
  allowGuestAccess?: boolean;
@@ -76,7 +77,7 @@ export declare const defaultServices: {
76
77
  passwordFormat?: never;
77
78
  } | {
78
79
  loginMechanisms: ("email" | "phone_number" | "username")[];
79
- signUpAttributes: SignUpAttribute[];
80
+ signUpAttributes: UserAttributeKey[];
80
81
  socialProviders: SocialProvider[];
81
82
  userPoolClientId: never;
82
83
  userPoolId: never;
@@ -90,7 +91,7 @@ export declare const defaultServices: {
90
91
  allowGuestAccess?: never;
91
92
  } | {
92
93
  loginMechanisms: ("email" | "phone_number" | "username")[];
93
- signUpAttributes: SignUpAttribute[];
94
+ signUpAttributes: UserAttributeKey[];
94
95
  socialProviders: SocialProvider[];
95
96
  userPoolClientId: string;
96
97
  userPoolId: string;
@@ -121,7 +122,7 @@ export declare const defaultServices: {
121
122
  allowGuestAccess?: never;
122
123
  } | {
123
124
  loginMechanisms: ("email" | "phone_number" | "username")[];
124
- signUpAttributes: SignUpAttribute[];
125
+ signUpAttributes: UserAttributeKey[];
125
126
  socialProviders: SocialProvider[];
126
127
  userPoolClientId: never;
127
128
  userPoolId: never;
@@ -135,7 +136,7 @@ export declare const defaultServices: {
135
136
  allowGuestAccess?: boolean;
136
137
  } | {
137
138
  loginMechanisms: ("email" | "phone_number" | "username")[];
138
- signUpAttributes: SignUpAttribute[];
139
+ signUpAttributes: UserAttributeKey[];
139
140
  socialProviders: SocialProvider[];
140
141
  userPoolClientId: string;
141
142
  userPoolId: string;
@@ -166,7 +167,7 @@ export declare const defaultServices: {
166
167
  allowGuestAccess?: never;
167
168
  } | {
168
169
  loginMechanisms: ("email" | "phone_number" | "username")[];
169
- signUpAttributes: SignUpAttribute[];
170
+ signUpAttributes: UserAttributeKey[];
170
171
  socialProviders: SocialProvider[];
171
172
  userPoolClientId: string;
172
173
  userPoolId: string;
@@ -51,9 +51,14 @@ type GetPrefix = 'get';
51
51
  */
52
52
  type DisplayTextBody = string;
53
53
  type DisplayTextSuffix = FieldSuffix | TextSuffix;
54
- type GetDisplayTextKey = `${GetPrefix}${DisplayTextBody}${DisplayTextSuffix}`;
55
- type DisplayTextKey = `${DisplayTextBody}${DisplayTextSuffix}`;
56
- type DisplayTextBase = Record<GetDisplayTextKey, (...args: any) => string | undefined> | Record<DisplayTextKey, string>;
54
+ type DisplayTextFunctionKey = `${GetPrefix}${DisplayTextBody}${DisplayTextSuffix}`;
55
+ type DisplayTextStringKey = `${DisplayTextBody}${DisplayTextSuffix}`;
56
+ type DisplayTextFunction = (...args: any) => string | undefined;
57
+ type DisplayTextFunctions = Record<DisplayTextFunctionKey, DisplayTextFunction>;
58
+ type DisplayTextStrings = Record<DisplayTextStringKey, string>;
59
+ type IsDisplayTextFunction<T, K> = T extends DisplayTextFunctionKey ? K extends DisplayTextFunction ? T : never : never;
60
+ type IsDisplayTextString<T, K> = T extends DisplayTextStringKey ? K extends string ? T : never : never;
61
+ type FilterDisplayText<T, K> = IsDisplayTextFunction<T, K> | IsDisplayTextString<T, K>;
57
62
  /**
58
63
  * Display Text type utility for creating standardized `DisplayText` interfaces
59
64
  * for usage as public exports and extended with `Required` for default values.
@@ -66,6 +71,7 @@ type DisplayTextBase = Record<GetDisplayTextKey, (...args: any) => string | unde
66
71
  * type SomeComponentDisplayText = DisplayTextTemplate<{
67
72
  * getCopyButtonText?: GetCopyButtonText;
68
73
  * submitButtonText?: string;
74
+ * usernameFieldLabel?: string;
69
75
  * }>;
70
76
  *
71
77
  * // default interface
@@ -74,11 +80,12 @@ type DisplayTextBase = Record<GetDisplayTextKey, (...args: any) => string | unde
74
80
  * // default values
75
81
  * const someComponentDisplayText: SomeComponentDisplayTextDefault = {
76
82
  * getCopyButtonText: (hasCopied) => (hasCopied ? 'Copied' : 'Copy'),
77
- * submitButtonText: 'Submit'
83
+ * submitButtonText: 'Submit',
84
+ * usernameFieldLabel: 'Username',
78
85
  * };
79
86
  * ```
80
87
  */
81
- export type DisplayTextTemplate<T extends DisplayTextBase> = {
82
- [K in keyof T]: K extends GetDisplayTextKey | DisplayTextKey ? T[K] : never;
88
+ export type DisplayTextTemplate<T extends DisplayTextFunctions | DisplayTextStrings> = {
89
+ [K in keyof T as FilterDisplayText<K, T[K]>]: T[K];
83
90
  };
84
91
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/ui",
3
- "version": "6.0.5",
3
+ "version": "6.0.7",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/esm/index.mjs",
6
6
  "exports": {