@aws-amplify/ui 6.0.17 → 6.2.0

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 (96) hide show
  1. package/dist/esm/i18n/dictionaries/authenticator/de.mjs +4 -4
  2. package/dist/esm/i18n/dictionaries/authenticator/ja.mjs +2 -2
  3. package/dist/esm/i18n/dictionaries/authenticator/kr.mjs +10 -0
  4. package/dist/esm/i18n/dictionaries/authenticator/th.mjs +101 -0
  5. package/dist/esm/i18n/dictionaries/index.mjs +3 -1
  6. package/dist/esm/i18n/translations.mjs +2 -1
  7. package/dist/esm/index.mjs +6 -3
  8. package/dist/esm/theme/createTheme/createAnimationCSS.mjs +23 -0
  9. package/dist/esm/theme/createTheme/createColorPalette.mjs +21 -0
  10. package/dist/esm/theme/createTheme/createComponentCSS.mjs +86 -0
  11. package/dist/esm/theme/createTheme/createComponentClasses.mjs +60 -0
  12. package/dist/esm/theme/{createTheme.mjs → createTheme/createTheme.mjs} +33 -44
  13. package/dist/esm/theme/createTheme/defineComponentTheme.mjs +55 -0
  14. package/dist/esm/theme/createTheme/utils.mjs +236 -0
  15. package/dist/esm/utils/humanFileSize.mjs +29 -0
  16. package/dist/esm/utils/utils.mjs +21 -1
  17. package/dist/index.js +566 -41
  18. package/dist/styles/breadcrumbs.css +2 -4
  19. package/dist/styles/breadcrumbs.layer.css +2 -4
  20. package/dist/styles/button.css +10 -19
  21. package/dist/styles/button.layer.css +10 -19
  22. package/dist/styles/input.css +2 -3
  23. package/dist/styles/input.layer.css +2 -3
  24. package/dist/styles/link.css +5 -10
  25. package/dist/styles/link.layer.css +5 -10
  26. package/dist/styles/reset.css +1 -3
  27. package/dist/styles/reset.layer.css +1 -3
  28. package/dist/styles/sliderField.css +2 -3
  29. package/dist/styles/sliderField.layer.css +2 -3
  30. package/dist/styles/textArea.css +2 -3
  31. package/dist/styles/textArea.layer.css +2 -3
  32. package/dist/styles.css +23 -42
  33. package/dist/styles.layer.css +23 -42
  34. package/dist/types/i18n/dictionaries/authenticator/index.d.ts +1 -0
  35. package/dist/types/i18n/dictionaries/authenticator/th.d.ts +2 -0
  36. package/dist/types/i18n/dictionaries/index.d.ts +52 -0
  37. package/dist/types/theme/components/accordion.d.ts +4 -0
  38. package/dist/types/theme/components/alert.d.ts +4 -0
  39. package/dist/types/theme/components/autocomplete.d.ts +8 -0
  40. package/dist/types/theme/components/badge.d.ts +4 -0
  41. package/dist/types/theme/components/breadcrumbs.d.ts +7 -0
  42. package/dist/types/theme/components/button.d.ts +7 -0
  43. package/dist/types/theme/components/buttonGroup.d.ts +2 -0
  44. package/dist/types/theme/components/card.d.ts +2 -0
  45. package/dist/types/theme/components/checkbox.d.ts +7 -0
  46. package/dist/types/theme/components/checkboxField.d.ts +2 -0
  47. package/dist/types/theme/components/collection.d.ts +4 -0
  48. package/dist/types/theme/components/divider.d.ts +2 -0
  49. package/dist/types/theme/components/dropZone.d.ts +2 -0
  50. package/dist/types/theme/components/field.d.ts +6 -0
  51. package/dist/types/theme/components/fieldGroup.d.ts +11 -0
  52. package/dist/types/theme/components/fieldset.d.ts +4 -0
  53. package/dist/types/theme/components/heading.d.ts +4 -0
  54. package/dist/types/theme/components/highlightMatch.d.ts +4 -0
  55. package/dist/types/theme/components/index.d.ts +92 -0
  56. package/dist/types/theme/components/input.d.ts +2 -0
  57. package/dist/types/theme/components/loader.d.ts +4 -0
  58. package/dist/types/theme/components/menu.d.ts +4 -0
  59. package/dist/types/theme/components/message.d.ts +4 -0
  60. package/dist/types/theme/components/pagination.d.ts +4 -0
  61. package/dist/types/theme/components/placeholder.d.ts +2 -0
  62. package/dist/types/theme/components/radio.d.ts +6 -0
  63. package/dist/types/theme/components/rating.d.ts +5 -0
  64. package/dist/types/theme/components/scrollview.d.ts +2 -0
  65. package/dist/types/theme/components/searchField.d.ts +4 -0
  66. package/dist/types/theme/components/select.d.ts +5 -0
  67. package/dist/types/theme/components/selectField.d.ts +2 -0
  68. package/dist/types/theme/components/sliderField.d.ts +9 -0
  69. package/dist/types/theme/components/stepperField.d.ts +6 -0
  70. package/dist/types/theme/components/storageManager.d.ts +20 -0
  71. package/dist/types/theme/components/switchField.d.ts +8 -0
  72. package/dist/types/theme/components/table.d.ts +4 -0
  73. package/dist/types/theme/components/tabs.d.ts +6 -0
  74. package/dist/types/theme/components/text.d.ts +3 -0
  75. package/dist/types/theme/components/textField.d.ts +2 -0
  76. package/dist/types/theme/components/textarea.d.ts +2 -0
  77. package/dist/types/theme/components/textareaField.d.ts +2 -0
  78. package/dist/types/theme/components/toggleButton.d.ts +3 -0
  79. package/dist/types/theme/components/utils.d.ts +52 -0
  80. package/dist/types/theme/createTheme/createAnimationCSS.d.ts +6 -0
  81. package/dist/types/theme/createTheme/createColorPalette.d.ts +16 -0
  82. package/dist/types/theme/createTheme/createComponentCSS.d.ts +7 -0
  83. package/dist/types/theme/createTheme/createComponentClasses.d.ts +25 -0
  84. package/dist/types/theme/{createTheme.d.ts → createTheme/createTheme.d.ts} +3 -2
  85. package/dist/types/theme/createTheme/defineComponentTheme.d.ts +54 -0
  86. package/dist/types/theme/createTheme/index.d.ts +4 -0
  87. package/dist/types/theme/createTheme/utils.d.ts +92 -0
  88. package/dist/types/theme/index.d.ts +1 -2
  89. package/dist/types/theme/types.d.ts +20 -3
  90. package/dist/types/utils/classNames.d.ts +1 -1
  91. package/dist/types/utils/humanFileSize.d.ts +11 -0
  92. package/dist/types/utils/index.d.ts +2 -1
  93. package/dist/types/utils/utils.d.ts +8 -0
  94. package/package.json +3 -3
  95. package/dist/esm/theme/utils.mjs +0 -81
  96. package/dist/types/theme/utils.d.ts +0 -35
@@ -18,7 +18,7 @@ const deDict = {
18
18
  'Create Account': 'Account erstellen',
19
19
  'Creating Account': 'Account wird erstellt',
20
20
  'Dismiss alert': 'Warnung verwerfen',
21
- Email: 'Email',
21
+ Email: 'E-Mail',
22
22
  'Enter your Birthdate': 'Geben Sie Ihr Geburtsdatum ein',
23
23
  'Enter your code': 'Geben Sie Ihren Code ein',
24
24
  'Enter your Confirmation Code': 'Geben Sie Ihren Bestätigungs-Code ein',
@@ -30,7 +30,7 @@ const deDict = {
30
30
  'Enter your Nickname': 'Geben Sie Ihren Spitznamen ein',
31
31
  'Enter your Password': 'Geben Sie Ihr Passwort ein',
32
32
  'Enter your password': 'Geben Sie Ihr Passwort ein',
33
- 'Enter your email': 'Geben Sie Ihre e-mail ein',
33
+ 'Enter your email': 'Geben Sie Ihre E-Mail ein',
34
34
  'Enter your phone number': 'Geben Sie Ihre Telefonnummer ein',
35
35
  'Enter your Preferred Username': 'Geben Sie Ihren bevorzugten Benutzernamen ein',
36
36
  'Enter your username': 'Geben Sie Ihren Benutzernamen ein',
@@ -65,14 +65,14 @@ const deDict = {
65
65
  Username: 'Benutzername',
66
66
  'Verify Contact': 'Kontakt verifizieren',
67
67
  Verify: 'Verifizieren',
68
- 'We Emailed You': 'Email wurde versendet',
68
+ 'We Emailed You': 'E-Mail wurde versendet',
69
69
  'We Sent A Code': 'Wir haben einen Code gesendet',
70
70
  'We Texted You': 'Wir haben Ihnen eine SMS gesendet',
71
71
  'Your code is on the way. To log in, enter the code we emailed to': 'Ihr Bestätigungscode ist unterwegs. Um sich einzuloggen geben Sie den Code ein, den wir per E-Mail verschickt haben',
72
72
  'Your code is on the way. To log in, enter the code we sent you': 'Ihr Code ist unterwegs. Um sich anzumelden, geben Sie den Code ein, den wir Ihnen gesendet haben',
73
73
  'Your code is on the way. To log in, enter the code we texted to': 'Ihr Bestätigungscode ist unterwegs. Um sich einzuloggen geben Sie den Code ein, den wir per SMS verschickt haben',
74
74
  // Additional translations provided by customers
75
- 'An account with the given email already exists.': 'Ein Account mit dieser Email existiert bereits.',
75
+ 'An account with the given email already exists.': 'Ein Account mit dieser E-Mail existiert bereits.',
76
76
  'Confirm a Code': 'Code bestätigen',
77
77
  'Confirm Sign In': 'Anmeldung bestätigen',
78
78
  'Create account': 'Hier registrieren',
@@ -23,7 +23,7 @@ const jaDict = {
23
23
  'Enter your Username': 'ユーザー名を入力 ',
24
24
  'Forgot your password?': 'パスワードを忘れましたか? ',
25
25
  'Hide password': 'パスワードを非表示',
26
- 'It may take a minute to arrive': '到着するまでに 1 分かかることがあります。',
26
+ 'It may take a minute to arrive': '到着するまでに 1 分かかることがあります',
27
27
  Loading: 'ロード中',
28
28
  'New password': '新しいパスワード',
29
29
  or: '又は',
@@ -53,7 +53,7 @@ const jaDict = {
53
53
  Verify: '確認',
54
54
  'We Sent A Code': 'コードが送信されました',
55
55
  'We Texted You': 'テキストが送信されました',
56
- 'Your code is on the way. To log in, enter the code we sent you': 'コードが途中です。ログインするには、送信したコードを入力してください。',
56
+ 'Your code is on the way. To log in, enter the code we sent you': 'コードが途中です。ログインするには、送信したコードを入力してください',
57
57
  // Additional translations provided by customers
58
58
  'An account with the given email already exists.': '入力されたメールアドレスのアカウントが既に存在します',
59
59
  'Confirm a Code': 'コードを確認',
@@ -16,10 +16,19 @@ const krDict = {
16
16
  'Creating Account': '회원가입중',
17
17
  'Dismiss alert': '알림 무시',
18
18
  Email: '이메일',
19
+ 'Enter your Birthdate': '생년월일 입력',
19
20
  'Enter your code': '인증번호를 입력해주세요',
21
+ 'Enter your Confirmation Code': '확인 코드 입력',
20
22
  'Enter your Email': '이메일 입력',
23
+ 'Enter your Family Name': '성 입력',
24
+ 'Enter your Given Name': '사용장 이름 입력',
25
+ 'Enter your Name': '이름 입력',
26
+ 'Enter your Nickname': '닉네임 입력',
27
+ 'Enter your Password': '비밀번호 입력',
21
28
  'Enter your phone number': '전화번호 입력',
29
+ 'Enter your Preferred Username': '선호하는 아이디 입력',
22
30
  'Enter your username': '아이디를 입력해주세요',
31
+ 'Forgot password?': '비밀번호를 잊으셨나요?',
23
32
  'Hide password': '비밀번호 숨기기',
24
33
  'It may take a minute to arrive': '도착하는 데 1분 정도 걸릴 수 있습니다',
25
34
  Loading: '로딩중',
@@ -27,6 +36,7 @@ const krDict = {
27
36
  or: '또는',
28
37
  Password: '비밀번호',
29
38
  'Phone Number': '전화번호',
39
+ 'Please confirm your Password': '비밀번호를 확인해 주세요.',
30
40
  'Resend Code': '인증번호 재전송',
31
41
  'Reset your password': '비밀번호 재설정',
32
42
  'Reset your Password': '비밀번호 재설정',
@@ -0,0 +1,101 @@
1
+ const thDict = {
2
+ 'Account recovery requires verified contact information': 'การกู้คืนบัญชีต้องมีข้อมูลติดต่อที่ได้รับการยืนยันแล้ว',
3
+ 'Add your Profile': 'เพิ่มโปรไฟล์ของคุณ',
4
+ 'Add your Website': 'เพิ่มเว็บไซต์ของคุณ',
5
+ 'Back to Sign In': 'กลับไปที่การเข้าสู่ระบบ',
6
+ 'Change Password': 'เปลี่ยนรหัสผ่าน',
7
+ Changing: 'กำลังเปลี่ยน',
8
+ Code: 'รหัส',
9
+ 'Confirm Password': 'ยืนยันรหัสผ่าน',
10
+ 'Please confirm your Password': 'กรุณายืนยันรหัสผ่านของคุณ',
11
+ 'Confirm Sign Up': 'ยืนยันการลงทะเบียน',
12
+ 'Confirm SMS Code': 'ยืนยันรหัส SMS',
13
+ 'Confirm MFA Code': 'ยืนยันรหัส MFA',
14
+ 'Confirm TOTP Code': 'ยืนยันรหัส TOTP',
15
+ Confirm: 'ยืนยัน',
16
+ 'Confirmation Code': 'รหัสยืนยัน',
17
+ Confirming: 'กำลังยืนยัน',
18
+ 'Create a new account': 'สร้างบัญชีใหม่',
19
+ 'Create Account': 'สร้างบัญชี',
20
+ 'Creating Account': 'กำลังสร้างบัญชี',
21
+ 'Dismiss alert': 'ปิดการแจ้งเตือน',
22
+ Email: 'อีเมล',
23
+ 'Enter your Birthdate': 'กรอกวันเกิดของคุณ',
24
+ 'Enter your code': 'กรอกรหัสของคุณ',
25
+ 'Enter your Confirmation Code': 'กรอกรหัสยืนยันของคุณ',
26
+ 'Enter your Email': 'กรอกอีเมลของคุณ',
27
+ 'Enter your Family Name': 'กรอกนามสกุลของคุณ',
28
+ 'Enter your Given Name': 'กรอกชื่อของคุณ',
29
+ 'Enter your Middle Name': 'กรอกชื่อกลางของคุณ',
30
+ 'Enter your Name': 'กรอกชื่อของคุณ',
31
+ 'Enter your Nickname': 'กรอกชื่อเล่นของคุณ',
32
+ 'Enter your Password': 'กรอกรหัสผ่านของคุณ',
33
+ 'Enter your email': 'กรอกอีเมลของคุณ',
34
+ 'Enter your phone number': 'กรอกหมายเลขโทรศัพท์ของคุณ',
35
+ 'Enter your Preferred Username': 'กรอกชื่อผู้ใช้ที่ต้องการ',
36
+ 'Enter your username': 'กรอกชื่อผู้ใช้ของคุณ',
37
+ 'Forgot password?': 'ลืมรหัสผ่าน?',
38
+ 'Forgot your password?': 'ลืมรหัสผ่านใช่หรือไม่?',
39
+ 'Hide password': 'ซ่อนรหัสผ่าน',
40
+ 'It may take a minute to arrive': 'อาจใช้เวลาสักครู่',
41
+ Loading: 'กำลังโหลด',
42
+ 'New password': 'รหัสผ่านใหม่',
43
+ or: 'หรือ',
44
+ Password: 'รหัสผ่าน',
45
+ 'Phone Number': 'หมายเลขโทรศัพท์',
46
+ 'Resend Code': 'ส่งรหัสอีกครั้ง',
47
+ 'Reset your Password': 'รีเซ็ตรหัสผ่านของคุณ',
48
+ 'Reset your password': 'รีเซ็ตรหัสผ่านของคุณ',
49
+ 'Send code': 'ส่งรหัส',
50
+ 'Send Code': 'ส่งรหัส',
51
+ Sending: 'กำลังส่ง',
52
+ 'Setup TOTP': 'ตั้งค่า TOTP',
53
+ 'Show password': 'แสดงรหัสผ่าน',
54
+ 'Sign in to your account': 'เข้าสู่ระบบบัญชีของคุณ',
55
+ 'Sign In with Amazon': 'เข้าสู่ระบบด้วย Amazon',
56
+ 'Sign In with Apple': 'เข้าสู่ระบบด้วย Apple',
57
+ 'Sign In with Facebook': 'เข้าสู่ระบบด้วย Facebook',
58
+ 'Sign In with Google': 'เข้าสู่ระบบด้วย Google',
59
+ 'Sign in': 'เข้าสู่ระบบ',
60
+ 'Sign In': 'เข้าสู่ระบบ',
61
+ 'Signing in': 'กำลังเข้าสู่ระบบ',
62
+ Skip: 'ข้าม',
63
+ Submit: 'ส่ง',
64
+ Submitting: 'กำลังส่ง',
65
+ Username: 'ชื่อผู้ใช้',
66
+ 'Verify Contact': 'ยืนยันการติดต่อ',
67
+ Verify: 'ยืนยัน',
68
+ 'We Emailed You': 'เราได้ส่งอีเมลถึงคุณแล้ว',
69
+ 'We Sent A Code': 'เราได้ส่งรหัสแล้ว',
70
+ 'We Texted You': 'เราได้ส่ง SMS ถึงคุณแล้ว',
71
+ 'Your code is on the way. To log in, enter the code we emailed to': 'รหัสของคุณกำลังมา เพื่อเข้าสู่ระบบ กรุณากรอกรหัสที่เราส่งไปยังอีเมล',
72
+ 'Your code is on the way. To log in, enter the code we sent you': 'รหัสของคุณกำลังมา เพื่อเข้าสู่ระบบ กรุณากรอกรหัสที่เราส่งให้คุณ',
73
+ 'Your code is on the way. To log in, enter the code we texted to': 'รหัสของคุณกำลังมา เพื่อเข้าสู่ระบบ กรุณากรอกรหัสที่เราส่งไปยัง SMS',
74
+ // Additional translations
75
+ 'An account with the given email already exists.': 'บัญชีที่ใช้อีเมลนี้มีอยู่แล้ว',
76
+ 'Confirm a Code': 'ยืนยันรหัส',
77
+ 'Confirm Sign In': 'ยืนยันการเข้าสู่ระบบ',
78
+ 'Create account': 'สร้างบัญชี',
79
+ 'Sign Up with Facebook': 'ลงทะเบียนด้วย Facebook',
80
+ 'Sign Up with Google': 'ลงทะเบียนด้วย Google',
81
+ 'Sign Up with Apple': 'ลงทะเบียนด้วย Apple',
82
+ 'Sign Up with Line': 'ลงทะเบียนด้วย Line',
83
+ 'Forgot Password': 'ลืมรหัสผ่าน',
84
+ 'Have an account? ': 'มีบัญชีอยู่แล้ว? ',
85
+ 'Incorrect username or password': 'ชื่อผู้ใช้หรือรหัสผ่านไม่ถูกต้อง',
86
+ 'Invalid password format': 'รูปแบบรหัสผ่านไม่ถูกต้อง',
87
+ 'It may take a minute to arrive.': 'อาจใช้เวลาสักครู่ในการมาถึง',
88
+ 'Lost your code? ': 'หารหัสไม่เจอ? ',
89
+ 'New Password': 'รหัสผ่านใหม่',
90
+ 'No account? ': 'ไม่มีบัญชี? ',
91
+ 'Password attempts exceeded': 'เกินจำนวนครั้งที่อนุญาตให้ใส่รหัสผ่าน',
92
+ 'Reset password': 'รีเซ็ตรหัสผ่าน',
93
+ 'Reset Password': 'รีเซ็ตรหัสผ่าน',
94
+ 'Sign Out': 'ออกจากระบบ',
95
+ 'Sign Up': 'ลงทะเบียน',
96
+ 'User already exists': 'ผู้ใช้นี้มีอยู่แล้ว',
97
+ 'User does not exist': 'ไม่มีผู้ใช้นี้',
98
+ 'Username cannot be empty': 'ต้องใส่ชื่อผู้ใช้งาน',
99
+ };
100
+
101
+ export { thDict };
@@ -16,6 +16,7 @@ import { trDict as trDict$1 } from './authenticator/tr.mjs';
16
16
  import { ruDict as ruDict$1 } from './authenticator/ru.mjs';
17
17
  import { heDict as heDict$1 } from './authenticator/he.mjs';
18
18
  import { uaDict as uaDict$1 } from './authenticator/ua.mjs';
19
+ import { thDict as thDict$1 } from './authenticator/th.mjs';
19
20
  import { defaultTexts as defaultTexts$1 } from './authenticator/defaultTexts.mjs';
20
21
 
21
22
  //merge all the new module translations in respective locale constants
@@ -39,9 +40,10 @@ const trDict = { ...trDict$1 };
39
40
  const ruDict = { ...ruDict$1 };
40
41
  const heDict = { ...heDict$1 };
41
42
  const uaDict = { ...uaDict$1 };
43
+ const thDict = { ...thDict$1 };
42
44
  const defaultTexts = {
43
45
  ...defaultTexts$1,
44
46
  // new module related default texts goes here
45
47
  };
46
48
 
47
- export { deDict, defaultTexts, enDict, esDict, frDict, heDict, idDict, itDict, jaDict, krDict, nbDict, nlDict, plDict, ptDict, ruDict, svDict, trDict, uaDict, zhDict };
49
+ export { deDict, defaultTexts, enDict, esDict, frDict, heDict, idDict, itDict, jaDict, krDict, nbDict, nlDict, plDict, ptDict, ruDict, svDict, thDict, trDict, uaDict, zhDict };
@@ -1,5 +1,5 @@
1
1
  import { I18n } from 'aws-amplify/utils';
2
- import { defaultTexts, deDict, enDict, esDict, frDict, idDict, itDict, jaDict, krDict, nbDict, nlDict, plDict, ptDict, zhDict, svDict, trDict, ruDict, heDict, uaDict } from './dictionaries/index.mjs';
2
+ import { defaultTexts, deDict, enDict, esDict, frDict, idDict, itDict, jaDict, krDict, nbDict, nlDict, plDict, ptDict, zhDict, svDict, trDict, ruDict, heDict, uaDict, thDict } from './dictionaries/index.mjs';
3
3
 
4
4
  /*
5
5
  * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -62,6 +62,7 @@ const translations = {
62
62
  ru: ruDict,
63
63
  he: heDict,
64
64
  ua: uaDict,
65
+ th: thDict,
65
66
  };
66
67
 
67
68
  export { DefaultTexts, hasTranslation, translate, translations };
@@ -14,15 +14,18 @@ export { getLogger } from './helpers/utils.mjs';
14
14
  export { countryDialCodes } from './i18n/country-dial-codes.mjs';
15
15
  export { DefaultTexts, hasTranslation, translate, translations } from './i18n/translations.mjs';
16
16
  export { createAuthenticatorMachine } from './machines/authenticator/index.mjs';
17
- export { createTheme } from './theme/createTheme.mjs';
17
+ export { createTheme } from './theme/createTheme/createTheme.mjs';
18
+ export { defineComponentTheme } from './theme/createTheme/defineComponentTheme.mjs';
19
+ export { cssNameTransform, isDesignToken, setupTokens } from './theme/createTheme/utils.mjs';
20
+ export { createComponentClasses } from './theme/createTheme/createComponentClasses.mjs';
18
21
  export { defaultTheme } from './theme/defaultTheme.mjs';
19
22
  export { defaultDarkModeOverride, reactNativeDarkTokens } from './theme/defaultDarkModeOverride.mjs';
20
23
  export { reactNativeTokens } from './theme/tokens/index.mjs';
21
- export { cssNameTransform, isDesignToken, setupTokens } from './theme/utils.mjs';
22
24
  export { FederatedIdentityProviders, UnverifiedContactMethodType } from './types/authenticator/user.mjs';
23
25
  export { isUnverifiedContactMethodType } from './types/authenticator/utils.mjs';
24
26
  export { LoginMechanismArray, authFieldsWithDefaults, isAuthFieldsWithDefaults, signUpFieldsWithDefault, signUpFieldsWithoutDefault } from './types/authenticator/attributes.mjs';
25
27
  export { ComponentClassName } from './types/primitives/componentClassName.mjs';
26
28
  export { setUserAgent } from './utils/setUserAgent/setUserAgent.mjs';
27
- export { areEmptyArrays, areEmptyObjects, capitalize, classNameModifier, classNameModifierByFlag, groupLog, has, isEmpty, isEmptyObject, isFunction, isMap, isNil, isObject, isSet, isString, isTypedFunction, isUndefined, noop, sanitizeNamespaceImport, templateJoin } from './utils/utils.mjs';
29
+ export { areEmptyArrays, areEmptyObjects, capitalize, classNameModifier, classNameModifierByFlag, groupLog, has, isEmpty, isEmptyObject, isFunction, isMap, isNil, isObject, isSet, isString, isTypedFunction, isUndefined, noop, sanitizeNamespaceImport, splitObject, templateJoin } from './utils/utils.mjs';
28
30
  export { classNames } from './utils/classNames.mjs';
31
+ export { humanFileSize } from './utils/humanFileSize.mjs';
@@ -0,0 +1,23 @@
1
+ import '@aws-amplify/core/internals/utils';
2
+ import '../../utils/setUserAgent/constants.mjs';
3
+ import { isFunction } from '../../utils/utils.mjs';
4
+ import { propsToString } from './utils.mjs';
5
+
6
+ function createAnimationCSS({ animations, tokens, }) {
7
+ let cssText = '';
8
+ Object.entries(animations).forEach(([key, value]) => {
9
+ cssText += `\n @keyframes ${key} {`;
10
+ Object.entries(value).forEach(([step, properties]) => {
11
+ cssText += `\n ${step} {\n`;
12
+ const animationProperties = isFunction(properties)
13
+ ? properties(tokens)
14
+ : properties;
15
+ cssText += propsToString(animationProperties);
16
+ cssText += `\n }`;
17
+ });
18
+ cssText += `\n }`;
19
+ });
20
+ return cssText;
21
+ }
22
+
23
+ export { createAnimationCSS };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Takes a set of keys and a color name and returns an object of design tokens,
3
+ * used for applying a primary color at the theme level to our tokens.
4
+ *
5
+ * createColorPalette({keys: ['10','20',...], value: 'red'})
6
+ * returns {
7
+ * 10: { value: '{colors.red.10.value}' },
8
+ * 20: { value: '{colors.red.20.value}' },
9
+ * ...
10
+ * }
11
+ */
12
+ function createColorPalette({ keys, value }) {
13
+ return keys.reduce((acc, key) => {
14
+ return {
15
+ ...acc,
16
+ [key]: { value: `{colors.${value}.${key}.value}` },
17
+ };
18
+ }, {});
19
+ }
20
+
21
+ export { createColorPalette };
@@ -0,0 +1,86 @@
1
+ import { propsToString } from './utils.mjs';
2
+ import '@aws-amplify/core/internals/utils';
3
+ import '../../utils/setUserAgent/constants.mjs';
4
+ import { isFunction, splitObject } from '../../utils/utils.mjs';
5
+
6
+ function addVars(selector, vars) {
7
+ if (!vars)
8
+ return '';
9
+ return `${selector} { ${Object.entries(vars)
10
+ .map(([key, value]) => {
11
+ return `--${key}:${value}; `;
12
+ })
13
+ .join(' ')}}\n`;
14
+ }
15
+ function recursiveComponentCSS(baseSelector, theme) {
16
+ let str = '';
17
+ const { _modifiers = {}, _element = {}, _vars, ...props } = theme;
18
+ // if there are no props, skip
19
+ if (Object.keys(props).length) {
20
+ // separate psuedo/attribute selectors
21
+ const [selectors, other] = splitObject(props, (key) => key.startsWith(':') || key.startsWith('['));
22
+ Object.entries(selectors).forEach(([selector, value]) => {
23
+ // need to remove nested things like vars and elements
24
+ const { _modifiers = {}, _element = {}, _vars, ...props } = value;
25
+ str += `${baseSelector}${selector} { ${propsToString(props)} }\n`;
26
+ str += addVars(`${baseSelector}${selector}`, _vars);
27
+ });
28
+ str += `${baseSelector} { ${propsToString(other)} }\n`;
29
+ }
30
+ str += addVars(baseSelector, _vars);
31
+ Object.entries(_modifiers).forEach(([key, value]) => {
32
+ if (value && Object.keys(value).length) {
33
+ str += recursiveComponentCSS(`${baseSelector}--${key}`, value);
34
+ }
35
+ });
36
+ Object.entries(_element).forEach(([key, value]) => {
37
+ if (value && Object.keys(value).length) {
38
+ str += recursiveComponentCSS(`${baseSelector}__${key}`, value);
39
+ }
40
+ });
41
+ return str;
42
+ }
43
+ /**
44
+ * This will take a component theme and create the appropriate CSS for it.
45
+ *
46
+ */
47
+ function createComponentCSS(themeName, components, tokens, breakpoints) {
48
+ let cssText = '';
49
+ components.forEach(({ name, theme, overrides }) => {
50
+ const baseComponentClassName = `amplify-${name}`;
51
+ const componentClassName = `[data-amplify-theme="${themeName}"] .${baseComponentClassName}`;
52
+ // unwrap the component theme
53
+ // if it is a function: call it with the defaultTheme to get a static object
54
+ const componentTheme = isFunction(theme)
55
+ ? theme(tokens)
56
+ : theme;
57
+ cssText += recursiveComponentCSS(componentClassName, componentTheme);
58
+ // if the component theme has overrides
59
+ // generate the appropriate CSS for each of them
60
+ if (overrides) {
61
+ overrides.forEach((override) => {
62
+ // unwrap the override component theme just like above
63
+ const componentTheme = isFunction(override.theme)
64
+ ? override.theme(tokens)
65
+ : override.theme;
66
+ if ('mediaQuery' in override) {
67
+ cssText += `@media (${override.mediaQuery}) {\n ${recursiveComponentCSS(componentClassName, componentTheme)} \n}`;
68
+ }
69
+ if ('breakpoint' in override) {
70
+ const breakpoint = breakpoints.values[override.breakpoint];
71
+ cssText += `\n@media (min-width: ${breakpoint}px) {\n ${recursiveComponentCSS(componentClassName, componentTheme)} \n}`;
72
+ }
73
+ if ('selector' in override) {
74
+ cssText += recursiveComponentCSS(`${override.selector} .${baseComponentClassName}`, componentTheme);
75
+ }
76
+ if ('colorMode' in override) {
77
+ cssText += `\n@media (prefers-color-scheme: ${override.colorMode}) {\n${recursiveComponentCSS(`[data-amplify-theme="${themeName}"][data-amplify-color-mode="system"] .${baseComponentClassName}`, componentTheme)}\n}\n`;
78
+ cssText += recursiveComponentCSS(`[data-amplify-theme="${themeName}"][data-amplify-color-mode="${override.colorMode}"] .${baseComponentClassName}`, componentTheme);
79
+ }
80
+ });
81
+ }
82
+ });
83
+ return cssText;
84
+ }
85
+
86
+ export { createComponentCSS };
@@ -0,0 +1,60 @@
1
+ import '@aws-amplify/core/internals/utils';
2
+ import '../../utils/setUserAgent/constants.mjs';
3
+ import { isString, isObject } from '../../utils/utils.mjs';
4
+ import { classNames } from '../../utils/classNames.mjs';
5
+
6
+ function createComponentClasses({ name, prefix = 'amplify-' }) {
7
+ const className = (props = {}, extraClassnames = []) => {
8
+ const baseComponentClassName = `${prefix}${name}`;
9
+ // get the element if there is one
10
+ // the _element argument can be a string
11
+ // like { _element: 'icon' }
12
+ // or it could be an object where the key is
13
+ // the element name and the value is the modifiers
14
+ // like { _element: { icon: [size] } }
15
+ const element = isString(props._element)
16
+ ? props._element
17
+ : isObject(props._element)
18
+ ? Object.keys(props._element)[0]
19
+ : undefined;
20
+ const className = element
21
+ ? `${baseComponentClassName}__${element}`
22
+ : baseComponentClassName;
23
+ const names = [className];
24
+ if (element) {
25
+ const modifiers = props._element[element];
26
+ names.push(...modifierClassnames({ className, modifiers }));
27
+ }
28
+ else {
29
+ names.push(...modifierClassnames({
30
+ className,
31
+ modifiers: props._modifiers,
32
+ }));
33
+ }
34
+ return classNames([...names, ...extraClassnames]);
35
+ };
36
+ return className;
37
+ }
38
+ function modifierClassnames({ className, modifiers, }) {
39
+ if (Array.isArray(modifiers)) {
40
+ return modifiers.map((modifier) => {
41
+ if (!modifier || !isString(modifier)) {
42
+ return;
43
+ }
44
+ return `${className}--${modifier}`;
45
+ });
46
+ }
47
+ if (isObject(modifiers)) {
48
+ return Object.entries(modifiers).map(([key, value]) => {
49
+ if (value) {
50
+ return `${className}--${key}`;
51
+ }
52
+ });
53
+ }
54
+ if (isString(modifiers)) {
55
+ return [`${className}--${modifiers}`];
56
+ }
57
+ return [];
58
+ }
59
+
60
+ export { createComponentClasses };
@@ -1,45 +1,12 @@
1
- import deepExtend from 'style-dictionary/lib/utils/deepExtend.js';
2
- import flattenProperties from 'style-dictionary/lib/utils/flattenProperties.js';
3
- import { defaultTheme } from './defaultTheme.mjs';
4
- import { setupTokens, cssNameTransform, cssValue } from './utils.mjs';
1
+ import { defaultTheme } from '../defaultTheme.mjs';
2
+ import { deepExtend, setupTokens, setupToken, flattenProperties } from './utils.mjs';
3
+ import { createComponentCSS } from './createComponentCSS.mjs';
5
4
  import '@aws-amplify/core/internals/utils';
6
- import '../utils/setUserAgent/constants.mjs';
7
- import { isString } from '../utils/utils.mjs';
5
+ import '../../utils/setUserAgent/constants.mjs';
6
+ import { isString } from '../../utils/utils.mjs';
7
+ import { createColorPalette } from './createColorPalette.mjs';
8
+ import { createAnimationCSS } from './createAnimationCSS.mjs';
8
9
 
9
- // Internal Style Dictionary methods
10
- /**
11
- * This will take a design token and add some data to it for it
12
- * to be used in JS/CSS. It will create its CSS var name and update
13
- * the value to use a CSS var if it is a reference. It will also
14
- * add a `.toString()` method to make it easier to use in JS.
15
- *
16
- * We should see if there is a way to share this logic with style dictionary...
17
- */
18
- const setupToken = ({ token, path }) => {
19
- const name = `--${cssNameTransform({ path })}`;
20
- const { value: original } = token;
21
- const value = cssValue(token);
22
- return { name, original, path, value, toString: () => `var(${name})` };
23
- };
24
- /**
25
- * Takes a set of keys and a color name and returns an object of design tokens,
26
- * used for applying a primary color at the theme level to our tokens.
27
- *
28
- * createColorPalette({keys: ['10','20',...], value: 'red'})
29
- * returns {
30
- * 10: { value: '{colors.red.10.value}' },
31
- * 20: { value: '{colors.red.20.value}' },
32
- * ...
33
- * }
34
- */
35
- function createColorPalette({ keys, value }) {
36
- return keys.reduce((acc, key) => {
37
- return {
38
- ...acc,
39
- [key]: { value: `{colors.${value}.${key}.value}` },
40
- };
41
- }, {});
42
- }
43
10
  /**
44
11
  * This will be used like `const myTheme = createTheme({})`
45
12
  * `myTheme` can then be passed to a Provider or the generated CSS
@@ -52,7 +19,14 @@ function createTheme(theme, DefaultTheme = defaultTheme) {
52
19
  // deepExtend is an internal Style Dictionary method
53
20
  // that performs a deep merge on n objects. We could change
54
21
  // this to another 3p deep merge solution too.
55
- const mergedTheme = deepExtend([{}, DefaultTheme, theme]);
22
+ const mergedTheme = deepExtend([
23
+ {},
24
+ DefaultTheme,
25
+ {
26
+ ...theme,
27
+ components: {},
28
+ },
29
+ ]);
56
30
  const { primaryColor, secondaryColor } = mergedTheme;
57
31
  // apply primaryColor and secondaryColor if present
58
32
  if (isString(primaryColor)) {
@@ -83,7 +57,16 @@ function createTheme(theme, DefaultTheme = defaultTheme) {
83
57
  .map((token) => `${token.name}: ${token.value};`)
84
58
  .join('\n') +
85
59
  `\n}\n`;
60
+ if (theme?.components) {
61
+ cssText += createComponentCSS(name, theme.components, tokens, mergedTheme.breakpoints);
62
+ }
86
63
  let overrides = [];
64
+ if (mergedTheme.animations) {
65
+ cssText += createAnimationCSS({
66
+ animations: mergedTheme.animations,
67
+ tokens,
68
+ });
69
+ }
87
70
  /**
88
71
  * For each override, we setup the tokens and then generate the CSS.
89
72
  * This allows us to have one single CSS string for all possible overrides
@@ -91,11 +74,11 @@ function createTheme(theme, DefaultTheme = defaultTheme) {
91
74
  */
92
75
  if (mergedTheme.overrides) {
93
76
  overrides = mergedTheme.overrides.map((override) => {
94
- const tokens = setupTokens({
77
+ const overrideTokens = setupTokens({
95
78
  tokens: override.tokens,
96
79
  setupToken,
97
80
  });
98
- const customProperties = flattenProperties(tokens)
81
+ const customProperties = flattenProperties(overrideTokens)
99
82
  .map((token) => `${token.name}: ${token.value};`)
100
83
  .join('\n');
101
84
  // Overrides can have a selector, media query, breakpoint, or color mode
@@ -132,7 +115,7 @@ function createTheme(theme, DefaultTheme = defaultTheme) {
132
115
  }
133
116
  return {
134
117
  ...override,
135
- tokens,
118
+ tokens: overrideTokens,
136
119
  };
137
120
  });
138
121
  }
@@ -141,6 +124,12 @@ function createTheme(theme, DefaultTheme = defaultTheme) {
141
124
  breakpoints,
142
125
  name,
143
126
  cssText,
127
+ containerProps: ({ colorMode } = {}) => {
128
+ return {
129
+ 'data-amplify-theme': name,
130
+ 'data-amplify-color-mode': colorMode,
131
+ };
132
+ },
144
133
  // keep overrides separate from base theme
145
134
  // this allows web platforms to use plain CSS scoped to a
146
135
  // selector and only override the CSS vars needed. This
@@ -0,0 +1,55 @@
1
+ import { createComponentClasses } from './createComponentClasses.mjs';
2
+
3
+ /**
4
+ * Use this to create the theme of a component. You can use this
5
+ * to both completely customize built-in components and
6
+ * build your own components!
7
+ *
8
+ * @experimental
9
+ *
10
+ * ```ts
11
+ * // built-in component styling
12
+ * const alertTheme = defineComponentTheme({
13
+ * name: 'alert',
14
+ * theme: (tokens) => {
15
+ * return {
16
+ * padding: tokens.space.large
17
+ * }
18
+ * }
19
+ * });
20
+ *
21
+ * // custom component styling
22
+ * const avatarTheme = defineComponentTheme({
23
+ * name: 'avatar',
24
+ * theme: (tokens) => {
25
+ * return {
26
+ * padding: tokens.space.large
27
+ * }
28
+ * }
29
+ * })
30
+ *
31
+ * const theme = createTheme({
32
+ * name: 'my-theme',
33
+ * components: [alertTheme, avatarTheme]
34
+ * })
35
+ * ```
36
+ *
37
+ * @param {Object} params
38
+ * @param {string} params.name - The name of the component. Use a built-in component name like button to theme buttons.
39
+ * @returns
40
+ */
41
+ function defineComponentTheme({ name, theme, overrides, }) {
42
+ const prefix = 'amplify-';
43
+ const className = createComponentClasses({
44
+ name,
45
+ prefix,
46
+ });
47
+ return {
48
+ className,
49
+ theme,
50
+ overrides,
51
+ name,
52
+ };
53
+ }
54
+
55
+ export { defineComponentTheme };