@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.
- package/dist/esm/i18n/dictionaries/authenticator/de.mjs +4 -4
- package/dist/esm/i18n/dictionaries/authenticator/ja.mjs +2 -2
- package/dist/esm/i18n/dictionaries/authenticator/kr.mjs +10 -0
- package/dist/esm/i18n/dictionaries/authenticator/th.mjs +101 -0
- package/dist/esm/i18n/dictionaries/index.mjs +3 -1
- package/dist/esm/i18n/translations.mjs +2 -1
- package/dist/esm/index.mjs +6 -3
- package/dist/esm/theme/createTheme/createAnimationCSS.mjs +23 -0
- package/dist/esm/theme/createTheme/createColorPalette.mjs +21 -0
- package/dist/esm/theme/createTheme/createComponentCSS.mjs +86 -0
- package/dist/esm/theme/createTheme/createComponentClasses.mjs +60 -0
- package/dist/esm/theme/{createTheme.mjs → createTheme/createTheme.mjs} +33 -44
- package/dist/esm/theme/createTheme/defineComponentTheme.mjs +55 -0
- package/dist/esm/theme/createTheme/utils.mjs +236 -0
- package/dist/esm/utils/humanFileSize.mjs +29 -0
- package/dist/esm/utils/utils.mjs +21 -1
- package/dist/index.js +566 -41
- package/dist/styles/breadcrumbs.css +2 -4
- package/dist/styles/breadcrumbs.layer.css +2 -4
- package/dist/styles/button.css +10 -19
- package/dist/styles/button.layer.css +10 -19
- package/dist/styles/input.css +2 -3
- package/dist/styles/input.layer.css +2 -3
- package/dist/styles/link.css +5 -10
- package/dist/styles/link.layer.css +5 -10
- package/dist/styles/reset.css +1 -3
- package/dist/styles/reset.layer.css +1 -3
- package/dist/styles/sliderField.css +2 -3
- package/dist/styles/sliderField.layer.css +2 -3
- package/dist/styles/textArea.css +2 -3
- package/dist/styles/textArea.layer.css +2 -3
- package/dist/styles.css +23 -42
- package/dist/styles.layer.css +23 -42
- package/dist/types/i18n/dictionaries/authenticator/index.d.ts +1 -0
- package/dist/types/i18n/dictionaries/authenticator/th.d.ts +2 -0
- package/dist/types/i18n/dictionaries/index.d.ts +52 -0
- package/dist/types/theme/components/accordion.d.ts +4 -0
- package/dist/types/theme/components/alert.d.ts +4 -0
- package/dist/types/theme/components/autocomplete.d.ts +8 -0
- package/dist/types/theme/components/badge.d.ts +4 -0
- package/dist/types/theme/components/breadcrumbs.d.ts +7 -0
- package/dist/types/theme/components/button.d.ts +7 -0
- package/dist/types/theme/components/buttonGroup.d.ts +2 -0
- package/dist/types/theme/components/card.d.ts +2 -0
- package/dist/types/theme/components/checkbox.d.ts +7 -0
- package/dist/types/theme/components/checkboxField.d.ts +2 -0
- package/dist/types/theme/components/collection.d.ts +4 -0
- package/dist/types/theme/components/divider.d.ts +2 -0
- package/dist/types/theme/components/dropZone.d.ts +2 -0
- package/dist/types/theme/components/field.d.ts +6 -0
- package/dist/types/theme/components/fieldGroup.d.ts +11 -0
- package/dist/types/theme/components/fieldset.d.ts +4 -0
- package/dist/types/theme/components/heading.d.ts +4 -0
- package/dist/types/theme/components/highlightMatch.d.ts +4 -0
- package/dist/types/theme/components/index.d.ts +92 -0
- package/dist/types/theme/components/input.d.ts +2 -0
- package/dist/types/theme/components/loader.d.ts +4 -0
- package/dist/types/theme/components/menu.d.ts +4 -0
- package/dist/types/theme/components/message.d.ts +4 -0
- package/dist/types/theme/components/pagination.d.ts +4 -0
- package/dist/types/theme/components/placeholder.d.ts +2 -0
- package/dist/types/theme/components/radio.d.ts +6 -0
- package/dist/types/theme/components/rating.d.ts +5 -0
- package/dist/types/theme/components/scrollview.d.ts +2 -0
- package/dist/types/theme/components/searchField.d.ts +4 -0
- package/dist/types/theme/components/select.d.ts +5 -0
- package/dist/types/theme/components/selectField.d.ts +2 -0
- package/dist/types/theme/components/sliderField.d.ts +9 -0
- package/dist/types/theme/components/stepperField.d.ts +6 -0
- package/dist/types/theme/components/storageManager.d.ts +20 -0
- package/dist/types/theme/components/switchField.d.ts +8 -0
- package/dist/types/theme/components/table.d.ts +4 -0
- package/dist/types/theme/components/tabs.d.ts +6 -0
- package/dist/types/theme/components/text.d.ts +3 -0
- package/dist/types/theme/components/textField.d.ts +2 -0
- package/dist/types/theme/components/textarea.d.ts +2 -0
- package/dist/types/theme/components/textareaField.d.ts +2 -0
- package/dist/types/theme/components/toggleButton.d.ts +3 -0
- package/dist/types/theme/components/utils.d.ts +52 -0
- package/dist/types/theme/createTheme/createAnimationCSS.d.ts +6 -0
- package/dist/types/theme/createTheme/createColorPalette.d.ts +16 -0
- package/dist/types/theme/createTheme/createComponentCSS.d.ts +7 -0
- package/dist/types/theme/createTheme/createComponentClasses.d.ts +25 -0
- package/dist/types/theme/{createTheme.d.ts → createTheme/createTheme.d.ts} +3 -2
- package/dist/types/theme/createTheme/defineComponentTheme.d.ts +54 -0
- package/dist/types/theme/createTheme/index.d.ts +4 -0
- package/dist/types/theme/createTheme/utils.d.ts +92 -0
- package/dist/types/theme/index.d.ts +1 -2
- package/dist/types/theme/types.d.ts +20 -3
- package/dist/types/utils/classNames.d.ts +1 -1
- package/dist/types/utils/humanFileSize.d.ts +11 -0
- package/dist/types/utils/index.d.ts +2 -1
- package/dist/types/utils/utils.d.ts +8 -0
- package/package.json +3 -3
- package/dist/esm/theme/utils.mjs +0 -81
- package/dist/types/theme/utils.d.ts +0 -35
package/dist/index.js
CHANGED
|
@@ -9,19 +9,13 @@ var awsAmplify = require('aws-amplify');
|
|
|
9
9
|
var xstate = require('xstate');
|
|
10
10
|
var pickBy = require('lodash/pickBy.js');
|
|
11
11
|
var merge = require('lodash/merge.js');
|
|
12
|
-
var deepExtend = require('style-dictionary/lib/utils/deepExtend.js');
|
|
13
|
-
var flattenProperties = require('style-dictionary/lib/utils/flattenProperties.js');
|
|
14
12
|
var kebabCase = require('lodash/kebabCase.js');
|
|
15
|
-
var usesReference = require('style-dictionary/lib/utils/references/usesReference.js');
|
|
16
13
|
|
|
17
14
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
15
|
|
|
19
16
|
var pickBy__default = /*#__PURE__*/_interopDefaultLegacy(pickBy);
|
|
20
17
|
var merge__default = /*#__PURE__*/_interopDefaultLegacy(merge);
|
|
21
|
-
var deepExtend__default = /*#__PURE__*/_interopDefaultLegacy(deepExtend);
|
|
22
|
-
var flattenProperties__default = /*#__PURE__*/_interopDefaultLegacy(flattenProperties);
|
|
23
18
|
var kebabCase__default = /*#__PURE__*/_interopDefaultLegacy(kebabCase);
|
|
24
|
-
var usesReference__default = /*#__PURE__*/_interopDefaultLegacy(usesReference);
|
|
25
19
|
|
|
26
20
|
/**
|
|
27
21
|
* This file contains helpers that lets you easily access current actor's state
|
|
@@ -307,6 +301,26 @@ function groupLog(groupName, ...events) {
|
|
|
307
301
|
console.log(groupName);
|
|
308
302
|
}
|
|
309
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
* Splits an object into 2 objects based on a predicate
|
|
306
|
+
*
|
|
307
|
+
* @param {object} obj an object to split into two
|
|
308
|
+
* @param {function} predicate function to determin where an element should go
|
|
309
|
+
* @returns
|
|
310
|
+
*/
|
|
311
|
+
function splitObject(obj, predicate) {
|
|
312
|
+
const left = {};
|
|
313
|
+
const right = {};
|
|
314
|
+
Object.entries(obj).forEach(([key, value]) => {
|
|
315
|
+
if (predicate(key)) {
|
|
316
|
+
left[key] = value;
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
right[key] = value;
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
return [left, right];
|
|
323
|
+
}
|
|
310
324
|
|
|
311
325
|
/**
|
|
312
326
|
* @example
|
|
@@ -404,6 +418,34 @@ const classNames = (...args) => {
|
|
|
404
418
|
return classes.join(' ');
|
|
405
419
|
};
|
|
406
420
|
|
|
421
|
+
/**
|
|
422
|
+
* Format bytes as human-readable text.
|
|
423
|
+
*
|
|
424
|
+
* @param bytes Number of bytes.
|
|
425
|
+
* @param si True to use metric (SI) units, aka powers of 1000. False to use
|
|
426
|
+
* binary (IEC), aka powers of 1024.
|
|
427
|
+
* @param dp Number of decimal places to display.
|
|
428
|
+
*
|
|
429
|
+
* @return Formatted string.
|
|
430
|
+
*/
|
|
431
|
+
function humanFileSize(bytes, si = false, dp = 1) {
|
|
432
|
+
const thresh = si ? 1000 : 1024;
|
|
433
|
+
if (Math.abs(bytes) < thresh) {
|
|
434
|
+
return `${bytes} B`;
|
|
435
|
+
}
|
|
436
|
+
const units = si
|
|
437
|
+
? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
|
438
|
+
: ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
|
|
439
|
+
let unit = -1;
|
|
440
|
+
const range = 10 ** dp;
|
|
441
|
+
do {
|
|
442
|
+
bytes /= thresh;
|
|
443
|
+
++unit;
|
|
444
|
+
} while (Math.round(Math.abs(bytes) * range) / range >= thresh &&
|
|
445
|
+
unit < units.length - 1);
|
|
446
|
+
return bytes.toFixed(dp) + ' ' + units[unit];
|
|
447
|
+
}
|
|
448
|
+
|
|
407
449
|
/**
|
|
408
450
|
* Handles Amplify JS Auth hub events, by forwarding hub events as appropriate
|
|
409
451
|
* xstate events.
|
|
@@ -675,7 +717,7 @@ const deDict$1 = {
|
|
|
675
717
|
'Create Account': 'Account erstellen',
|
|
676
718
|
'Creating Account': 'Account wird erstellt',
|
|
677
719
|
'Dismiss alert': 'Warnung verwerfen',
|
|
678
|
-
Email: '
|
|
720
|
+
Email: 'E-Mail',
|
|
679
721
|
'Enter your Birthdate': 'Geben Sie Ihr Geburtsdatum ein',
|
|
680
722
|
'Enter your code': 'Geben Sie Ihren Code ein',
|
|
681
723
|
'Enter your Confirmation Code': 'Geben Sie Ihren Bestätigungs-Code ein',
|
|
@@ -687,7 +729,7 @@ const deDict$1 = {
|
|
|
687
729
|
'Enter your Nickname': 'Geben Sie Ihren Spitznamen ein',
|
|
688
730
|
'Enter your Password': 'Geben Sie Ihr Passwort ein',
|
|
689
731
|
'Enter your password': 'Geben Sie Ihr Passwort ein',
|
|
690
|
-
'Enter your email': 'Geben Sie Ihre
|
|
732
|
+
'Enter your email': 'Geben Sie Ihre E-Mail ein',
|
|
691
733
|
'Enter your phone number': 'Geben Sie Ihre Telefonnummer ein',
|
|
692
734
|
'Enter your Preferred Username': 'Geben Sie Ihren bevorzugten Benutzernamen ein',
|
|
693
735
|
'Enter your username': 'Geben Sie Ihren Benutzernamen ein',
|
|
@@ -722,14 +764,14 @@ const deDict$1 = {
|
|
|
722
764
|
Username: 'Benutzername',
|
|
723
765
|
'Verify Contact': 'Kontakt verifizieren',
|
|
724
766
|
Verify: 'Verifizieren',
|
|
725
|
-
'We Emailed You': '
|
|
767
|
+
'We Emailed You': 'E-Mail wurde versendet',
|
|
726
768
|
'We Sent A Code': 'Wir haben einen Code gesendet',
|
|
727
769
|
'We Texted You': 'Wir haben Ihnen eine SMS gesendet',
|
|
728
770
|
'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',
|
|
729
771
|
'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',
|
|
730
772
|
'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',
|
|
731
773
|
// Additional translations provided by customers
|
|
732
|
-
'An account with the given email already exists.': 'Ein Account mit dieser
|
|
774
|
+
'An account with the given email already exists.': 'Ein Account mit dieser E-Mail existiert bereits.',
|
|
733
775
|
'Confirm a Code': 'Code bestätigen',
|
|
734
776
|
'Confirm Sign In': 'Anmeldung bestätigen',
|
|
735
777
|
'Create account': 'Hier registrieren',
|
|
@@ -1128,7 +1170,7 @@ const jaDict$1 = {
|
|
|
1128
1170
|
'Enter your Username': 'ユーザー名を入力 ',
|
|
1129
1171
|
'Forgot your password?': 'パスワードを忘れましたか? ',
|
|
1130
1172
|
'Hide password': 'パスワードを非表示',
|
|
1131
|
-
'It may take a minute to arrive': '到着するまでに 1
|
|
1173
|
+
'It may take a minute to arrive': '到着するまでに 1 分かかることがあります',
|
|
1132
1174
|
Loading: 'ロード中',
|
|
1133
1175
|
'New password': '新しいパスワード',
|
|
1134
1176
|
or: '又は',
|
|
@@ -1158,7 +1200,7 @@ const jaDict$1 = {
|
|
|
1158
1200
|
Verify: '確認',
|
|
1159
1201
|
'We Sent A Code': 'コードが送信されました',
|
|
1160
1202
|
'We Texted You': 'テキストが送信されました',
|
|
1161
|
-
'Your code is on the way. To log in, enter the code we sent you': '
|
|
1203
|
+
'Your code is on the way. To log in, enter the code we sent you': 'コードが途中です。ログインするには、送信したコードを入力してください',
|
|
1162
1204
|
// Additional translations provided by customers
|
|
1163
1205
|
'An account with the given email already exists.': '入力されたメールアドレスのアカウントが既に存在します',
|
|
1164
1206
|
'Confirm a Code': 'コードを確認',
|
|
@@ -1207,10 +1249,19 @@ const krDict$1 = {
|
|
|
1207
1249
|
'Creating Account': '회원가입중',
|
|
1208
1250
|
'Dismiss alert': '알림 무시',
|
|
1209
1251
|
Email: '이메일',
|
|
1252
|
+
'Enter your Birthdate': '생년월일 입력',
|
|
1210
1253
|
'Enter your code': '인증번호를 입력해주세요',
|
|
1254
|
+
'Enter your Confirmation Code': '확인 코드 입력',
|
|
1211
1255
|
'Enter your Email': '이메일 입력',
|
|
1256
|
+
'Enter your Family Name': '성 입력',
|
|
1257
|
+
'Enter your Given Name': '사용장 이름 입력',
|
|
1258
|
+
'Enter your Name': '이름 입력',
|
|
1259
|
+
'Enter your Nickname': '닉네임 입력',
|
|
1260
|
+
'Enter your Password': '비밀번호 입력',
|
|
1212
1261
|
'Enter your phone number': '전화번호 입력',
|
|
1262
|
+
'Enter your Preferred Username': '선호하는 아이디 입력',
|
|
1213
1263
|
'Enter your username': '아이디를 입력해주세요',
|
|
1264
|
+
'Forgot password?': '비밀번호를 잊으셨나요?',
|
|
1214
1265
|
'Hide password': '비밀번호 숨기기',
|
|
1215
1266
|
'It may take a minute to arrive': '도착하는 데 1분 정도 걸릴 수 있습니다',
|
|
1216
1267
|
Loading: '로딩중',
|
|
@@ -1218,6 +1269,7 @@ const krDict$1 = {
|
|
|
1218
1269
|
or: '또는',
|
|
1219
1270
|
Password: '비밀번호',
|
|
1220
1271
|
'Phone Number': '전화번호',
|
|
1272
|
+
'Please confirm your Password': '비밀번호를 확인해 주세요.',
|
|
1221
1273
|
'Resend Code': '인증번호 재전송',
|
|
1222
1274
|
'Reset your password': '비밀번호 재설정',
|
|
1223
1275
|
'Reset your Password': '비밀번호 재설정',
|
|
@@ -2123,6 +2175,106 @@ const uaDict$1 = {
|
|
|
2123
2175
|
'Your passwords must match': 'Паролі мають збігатися',
|
|
2124
2176
|
};
|
|
2125
2177
|
|
|
2178
|
+
const thDict$1 = {
|
|
2179
|
+
'Account recovery requires verified contact information': 'การกู้คืนบัญชีต้องมีข้อมูลติดต่อที่ได้รับการยืนยันแล้ว',
|
|
2180
|
+
'Add your Profile': 'เพิ่มโปรไฟล์ของคุณ',
|
|
2181
|
+
'Add your Website': 'เพิ่มเว็บไซต์ของคุณ',
|
|
2182
|
+
'Back to Sign In': 'กลับไปที่การเข้าสู่ระบบ',
|
|
2183
|
+
'Change Password': 'เปลี่ยนรหัสผ่าน',
|
|
2184
|
+
Changing: 'กำลังเปลี่ยน',
|
|
2185
|
+
Code: 'รหัส',
|
|
2186
|
+
'Confirm Password': 'ยืนยันรหัสผ่าน',
|
|
2187
|
+
'Please confirm your Password': 'กรุณายืนยันรหัสผ่านของคุณ',
|
|
2188
|
+
'Confirm Sign Up': 'ยืนยันการลงทะเบียน',
|
|
2189
|
+
'Confirm SMS Code': 'ยืนยันรหัส SMS',
|
|
2190
|
+
'Confirm MFA Code': 'ยืนยันรหัส MFA',
|
|
2191
|
+
'Confirm TOTP Code': 'ยืนยันรหัส TOTP',
|
|
2192
|
+
Confirm: 'ยืนยัน',
|
|
2193
|
+
'Confirmation Code': 'รหัสยืนยัน',
|
|
2194
|
+
Confirming: 'กำลังยืนยัน',
|
|
2195
|
+
'Create a new account': 'สร้างบัญชีใหม่',
|
|
2196
|
+
'Create Account': 'สร้างบัญชี',
|
|
2197
|
+
'Creating Account': 'กำลังสร้างบัญชี',
|
|
2198
|
+
'Dismiss alert': 'ปิดการแจ้งเตือน',
|
|
2199
|
+
Email: 'อีเมล',
|
|
2200
|
+
'Enter your Birthdate': 'กรอกวันเกิดของคุณ',
|
|
2201
|
+
'Enter your code': 'กรอกรหัสของคุณ',
|
|
2202
|
+
'Enter your Confirmation Code': 'กรอกรหัสยืนยันของคุณ',
|
|
2203
|
+
'Enter your Email': 'กรอกอีเมลของคุณ',
|
|
2204
|
+
'Enter your Family Name': 'กรอกนามสกุลของคุณ',
|
|
2205
|
+
'Enter your Given Name': 'กรอกชื่อของคุณ',
|
|
2206
|
+
'Enter your Middle Name': 'กรอกชื่อกลางของคุณ',
|
|
2207
|
+
'Enter your Name': 'กรอกชื่อของคุณ',
|
|
2208
|
+
'Enter your Nickname': 'กรอกชื่อเล่นของคุณ',
|
|
2209
|
+
'Enter your Password': 'กรอกรหัสผ่านของคุณ',
|
|
2210
|
+
'Enter your email': 'กรอกอีเมลของคุณ',
|
|
2211
|
+
'Enter your phone number': 'กรอกหมายเลขโทรศัพท์ของคุณ',
|
|
2212
|
+
'Enter your Preferred Username': 'กรอกชื่อผู้ใช้ที่ต้องการ',
|
|
2213
|
+
'Enter your username': 'กรอกชื่อผู้ใช้ของคุณ',
|
|
2214
|
+
'Forgot password?': 'ลืมรหัสผ่าน?',
|
|
2215
|
+
'Forgot your password?': 'ลืมรหัสผ่านใช่หรือไม่?',
|
|
2216
|
+
'Hide password': 'ซ่อนรหัสผ่าน',
|
|
2217
|
+
'It may take a minute to arrive': 'อาจใช้เวลาสักครู่',
|
|
2218
|
+
Loading: 'กำลังโหลด',
|
|
2219
|
+
'New password': 'รหัสผ่านใหม่',
|
|
2220
|
+
or: 'หรือ',
|
|
2221
|
+
Password: 'รหัสผ่าน',
|
|
2222
|
+
'Phone Number': 'หมายเลขโทรศัพท์',
|
|
2223
|
+
'Resend Code': 'ส่งรหัสอีกครั้ง',
|
|
2224
|
+
'Reset your Password': 'รีเซ็ตรหัสผ่านของคุณ',
|
|
2225
|
+
'Reset your password': 'รีเซ็ตรหัสผ่านของคุณ',
|
|
2226
|
+
'Send code': 'ส่งรหัส',
|
|
2227
|
+
'Send Code': 'ส่งรหัส',
|
|
2228
|
+
Sending: 'กำลังส่ง',
|
|
2229
|
+
'Setup TOTP': 'ตั้งค่า TOTP',
|
|
2230
|
+
'Show password': 'แสดงรหัสผ่าน',
|
|
2231
|
+
'Sign in to your account': 'เข้าสู่ระบบบัญชีของคุณ',
|
|
2232
|
+
'Sign In with Amazon': 'เข้าสู่ระบบด้วย Amazon',
|
|
2233
|
+
'Sign In with Apple': 'เข้าสู่ระบบด้วย Apple',
|
|
2234
|
+
'Sign In with Facebook': 'เข้าสู่ระบบด้วย Facebook',
|
|
2235
|
+
'Sign In with Google': 'เข้าสู่ระบบด้วย Google',
|
|
2236
|
+
'Sign in': 'เข้าสู่ระบบ',
|
|
2237
|
+
'Sign In': 'เข้าสู่ระบบ',
|
|
2238
|
+
'Signing in': 'กำลังเข้าสู่ระบบ',
|
|
2239
|
+
Skip: 'ข้าม',
|
|
2240
|
+
Submit: 'ส่ง',
|
|
2241
|
+
Submitting: 'กำลังส่ง',
|
|
2242
|
+
Username: 'ชื่อผู้ใช้',
|
|
2243
|
+
'Verify Contact': 'ยืนยันการติดต่อ',
|
|
2244
|
+
Verify: 'ยืนยัน',
|
|
2245
|
+
'We Emailed You': 'เราได้ส่งอีเมลถึงคุณแล้ว',
|
|
2246
|
+
'We Sent A Code': 'เราได้ส่งรหัสแล้ว',
|
|
2247
|
+
'We Texted You': 'เราได้ส่ง SMS ถึงคุณแล้ว',
|
|
2248
|
+
'Your code is on the way. To log in, enter the code we emailed to': 'รหัสของคุณกำลังมา เพื่อเข้าสู่ระบบ กรุณากรอกรหัสที่เราส่งไปยังอีเมล',
|
|
2249
|
+
'Your code is on the way. To log in, enter the code we sent you': 'รหัสของคุณกำลังมา เพื่อเข้าสู่ระบบ กรุณากรอกรหัสที่เราส่งให้คุณ',
|
|
2250
|
+
'Your code is on the way. To log in, enter the code we texted to': 'รหัสของคุณกำลังมา เพื่อเข้าสู่ระบบ กรุณากรอกรหัสที่เราส่งไปยัง SMS',
|
|
2251
|
+
// Additional translations
|
|
2252
|
+
'An account with the given email already exists.': 'บัญชีที่ใช้อีเมลนี้มีอยู่แล้ว',
|
|
2253
|
+
'Confirm a Code': 'ยืนยันรหัส',
|
|
2254
|
+
'Confirm Sign In': 'ยืนยันการเข้าสู่ระบบ',
|
|
2255
|
+
'Create account': 'สร้างบัญชี',
|
|
2256
|
+
'Sign Up with Facebook': 'ลงทะเบียนด้วย Facebook',
|
|
2257
|
+
'Sign Up with Google': 'ลงทะเบียนด้วย Google',
|
|
2258
|
+
'Sign Up with Apple': 'ลงทะเบียนด้วย Apple',
|
|
2259
|
+
'Sign Up with Line': 'ลงทะเบียนด้วย Line',
|
|
2260
|
+
'Forgot Password': 'ลืมรหัสผ่าน',
|
|
2261
|
+
'Have an account? ': 'มีบัญชีอยู่แล้ว? ',
|
|
2262
|
+
'Incorrect username or password': 'ชื่อผู้ใช้หรือรหัสผ่านไม่ถูกต้อง',
|
|
2263
|
+
'Invalid password format': 'รูปแบบรหัสผ่านไม่ถูกต้อง',
|
|
2264
|
+
'It may take a minute to arrive.': 'อาจใช้เวลาสักครู่ในการมาถึง',
|
|
2265
|
+
'Lost your code? ': 'หารหัสไม่เจอ? ',
|
|
2266
|
+
'New Password': 'รหัสผ่านใหม่',
|
|
2267
|
+
'No account? ': 'ไม่มีบัญชี? ',
|
|
2268
|
+
'Password attempts exceeded': 'เกินจำนวนครั้งที่อนุญาตให้ใส่รหัสผ่าน',
|
|
2269
|
+
'Reset password': 'รีเซ็ตรหัสผ่าน',
|
|
2270
|
+
'Reset Password': 'รีเซ็ตรหัสผ่าน',
|
|
2271
|
+
'Sign Out': 'ออกจากระบบ',
|
|
2272
|
+
'Sign Up': 'ลงทะเบียน',
|
|
2273
|
+
'User already exists': 'ผู้ใช้นี้มีอยู่แล้ว',
|
|
2274
|
+
'User does not exist': 'ไม่มีผู้ใช้นี้',
|
|
2275
|
+
'Username cannot be empty': 'ต้องใส่ชื่อผู้ใช้งาน',
|
|
2276
|
+
};
|
|
2277
|
+
|
|
2126
2278
|
const defaultTexts$1 = {
|
|
2127
2279
|
ADD_PROFILE: 'Add your Profile',
|
|
2128
2280
|
ADD_WEBSITE: 'Add your Website',
|
|
@@ -2228,6 +2380,7 @@ const trDict = { ...trDict$1 };
|
|
|
2228
2380
|
const ruDict = { ...ruDict$1 };
|
|
2229
2381
|
const heDict = { ...heDict$1 };
|
|
2230
2382
|
const uaDict = { ...uaDict$1 };
|
|
2383
|
+
const thDict = { ...thDict$1 };
|
|
2231
2384
|
const defaultTexts = {
|
|
2232
2385
|
...defaultTexts$1,
|
|
2233
2386
|
// new module related default texts goes here
|
|
@@ -2294,6 +2447,7 @@ const translations = {
|
|
|
2294
2447
|
ru: ruDict,
|
|
2295
2448
|
he: heDict,
|
|
2296
2449
|
ua: uaDict,
|
|
2450
|
+
th: thDict,
|
|
2297
2451
|
};
|
|
2298
2452
|
|
|
2299
2453
|
/**
|
|
@@ -8073,6 +8227,26 @@ const defaultTheme = {
|
|
|
8073
8227
|
};
|
|
8074
8228
|
|
|
8075
8229
|
const CSS_VARIABLE_PREFIX = 'amplify';
|
|
8230
|
+
/**
|
|
8231
|
+
* This will take an object like:
|
|
8232
|
+
* {paddingTop:'20px',color:'{colors.font.primary}'}
|
|
8233
|
+
* and turn it into a CSS string:
|
|
8234
|
+
* `padding-top:20px; color: var(--colors-font-primary);`
|
|
8235
|
+
*/
|
|
8236
|
+
function propsToString(props) {
|
|
8237
|
+
return Object.entries(props)
|
|
8238
|
+
.map(([key, value]) => {
|
|
8239
|
+
const _value = isDesignToken(value)
|
|
8240
|
+
? value.toString()
|
|
8241
|
+
: // @ts-ignore
|
|
8242
|
+
cssValue({ value });
|
|
8243
|
+
return `${kebabCase__default["default"](key)}:${_value}; `;
|
|
8244
|
+
})
|
|
8245
|
+
.join(' ');
|
|
8246
|
+
}
|
|
8247
|
+
function cssNameTransform({ path = [] }) {
|
|
8248
|
+
return `${kebabCase__default["default"]([CSS_VARIABLE_PREFIX, ...path].join(' '))}`;
|
|
8249
|
+
}
|
|
8076
8250
|
// Important: these properties should not be altered in
|
|
8077
8251
|
// order to maintain the expected order of the CSS `box-shadow` property
|
|
8078
8252
|
const SHADOW_PROPERTIES = [
|
|
@@ -8082,15 +8256,12 @@ const SHADOW_PROPERTIES = [
|
|
|
8082
8256
|
'spreadRadius',
|
|
8083
8257
|
'color',
|
|
8084
8258
|
];
|
|
8085
|
-
|
|
8086
|
-
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
}
|
|
8092
|
-
return value;
|
|
8093
|
-
}
|
|
8259
|
+
/**
|
|
8260
|
+
* Will take a design token in a theme and return its value as CSS
|
|
8261
|
+
*
|
|
8262
|
+
* @param token
|
|
8263
|
+
* @returns
|
|
8264
|
+
*/
|
|
8094
8265
|
function cssValue(token) {
|
|
8095
8266
|
const { value } = token;
|
|
8096
8267
|
if (isString(value)) {
|
|
@@ -8106,9 +8277,6 @@ function cssValue(token) {
|
|
|
8106
8277
|
}
|
|
8107
8278
|
return value;
|
|
8108
8279
|
}
|
|
8109
|
-
function cssNameTransform({ path = [] }) {
|
|
8110
|
-
return `${kebabCase__default["default"]([CSS_VARIABLE_PREFIX, ...path].join(' '))}`;
|
|
8111
|
-
}
|
|
8112
8280
|
/**
|
|
8113
8281
|
* Helper function to test if something is a design token or not.
|
|
8114
8282
|
* Used in the React component style props.
|
|
@@ -8122,6 +8290,36 @@ function isDesignToken(value) {
|
|
|
8122
8290
|
function isShadowTokenObject(value) {
|
|
8123
8291
|
return isObject(value) && has(value, 'offsetX');
|
|
8124
8292
|
}
|
|
8293
|
+
/**
|
|
8294
|
+
* Function that sees if a string contains a design token reference
|
|
8295
|
+
* and if so will turn that into a CSS variable.
|
|
8296
|
+
*
|
|
8297
|
+
* @param {string} value
|
|
8298
|
+
* @returns string
|
|
8299
|
+
*/
|
|
8300
|
+
function referenceValue(value) {
|
|
8301
|
+
if (!value)
|
|
8302
|
+
return '';
|
|
8303
|
+
if (usesReference(value)) {
|
|
8304
|
+
const path = value.replace(/\{|\}/g, '').replace('.value', '').split('.');
|
|
8305
|
+
return `var(--${cssNameTransform({ path })})`;
|
|
8306
|
+
}
|
|
8307
|
+
return value;
|
|
8308
|
+
}
|
|
8309
|
+
/**
|
|
8310
|
+
* This will take a design token and add some data to it for it
|
|
8311
|
+
* to be used in JS/CSS. It will create its CSS var name and update
|
|
8312
|
+
* the value to use a CSS var if it is a reference. It will also
|
|
8313
|
+
* add a `.toString()` method to make it easier to use in JS.
|
|
8314
|
+
*
|
|
8315
|
+
* We should see if there is a way to share this logic with style dictionary...
|
|
8316
|
+
*/
|
|
8317
|
+
const setupToken = ({ token, path }) => {
|
|
8318
|
+
const name = `--${cssNameTransform({ path })}`;
|
|
8319
|
+
const { value: original } = token;
|
|
8320
|
+
const value = cssValue(token);
|
|
8321
|
+
return { name, original, path, value, toString: () => `var(${name})` };
|
|
8322
|
+
};
|
|
8125
8323
|
/**
|
|
8126
8324
|
* Recursive function that will walk down the token object
|
|
8127
8325
|
* and perform the setupToken function on each token.
|
|
@@ -8145,22 +8343,199 @@ function setupTokens({ tokens, path = [], setupToken, }) {
|
|
|
8145
8343
|
}
|
|
8146
8344
|
return output;
|
|
8147
8345
|
}
|
|
8148
|
-
|
|
8149
8346
|
// Internal Style Dictionary methods
|
|
8347
|
+
// copied from amzn/style-dictionary with the owner's permission
|
|
8150
8348
|
/**
|
|
8151
|
-
*
|
|
8152
|
-
*
|
|
8153
|
-
*
|
|
8154
|
-
*
|
|
8349
|
+
* Takes an plain javascript object and will make a flat array of all the leaf nodes.
|
|
8350
|
+
* A leaf node in this context has a 'value' property. Potentially refactor this to
|
|
8351
|
+
* be more generic.
|
|
8352
|
+
* @private
|
|
8353
|
+
* @param {Object} properties - The plain object you want flattened into an array.
|
|
8354
|
+
* @param {Array} [to_ret=[]] - Properties array. This function is recursive therefore this is what gets passed along.
|
|
8355
|
+
* @return {Array}
|
|
8356
|
+
*/
|
|
8357
|
+
function flattenProperties(properties, to_ret) {
|
|
8358
|
+
to_ret = to_ret || [];
|
|
8359
|
+
for (var name in properties) {
|
|
8360
|
+
if (has(properties, name)) {
|
|
8361
|
+
if (isObject(properties[name]) && 'value' in properties[name]) {
|
|
8362
|
+
to_ret.push(properties[name]);
|
|
8363
|
+
}
|
|
8364
|
+
else if (isObject(properties[name])) {
|
|
8365
|
+
flattenProperties(properties[name], to_ret);
|
|
8366
|
+
}
|
|
8367
|
+
}
|
|
8368
|
+
}
|
|
8369
|
+
return to_ret;
|
|
8370
|
+
}
|
|
8371
|
+
/**
|
|
8372
|
+
* Performs an deep extend on the objects, from right to left.
|
|
8373
|
+
* @private
|
|
8374
|
+
* @param {Object[]} objects - An array of JS objects
|
|
8375
|
+
* @param {Function} collision - A function to be called when a merge collision happens.
|
|
8376
|
+
* @param {string[]} path - (for internal use) An array of strings which is the current path down the object when this is called recursively.
|
|
8377
|
+
* @returns {Object}
|
|
8378
|
+
*/
|
|
8379
|
+
function deepExtend(objects, collision, path) {
|
|
8380
|
+
if (objects == null)
|
|
8381
|
+
return {};
|
|
8382
|
+
var src, copyIsArray, copy, name, options, clone, target = objects[0] || {}, i = 1, length = objects.length;
|
|
8383
|
+
path = path || [];
|
|
8384
|
+
// Handle case when target is a string or something (possible in deep copy)
|
|
8385
|
+
if (typeof target !== 'object') {
|
|
8386
|
+
target = {};
|
|
8387
|
+
}
|
|
8388
|
+
for (; i < length; i++) {
|
|
8389
|
+
// Only deal with non-null/undefined values
|
|
8390
|
+
if ((options = objects[i]) != null) {
|
|
8391
|
+
// Extend the base object
|
|
8392
|
+
for (name in options) {
|
|
8393
|
+
if (!has(options, name))
|
|
8394
|
+
continue;
|
|
8395
|
+
if (name === '__proto__')
|
|
8396
|
+
continue;
|
|
8397
|
+
src = target[name];
|
|
8398
|
+
copy = options[name];
|
|
8399
|
+
// Prevent never-ending loop
|
|
8400
|
+
if (target === copy) {
|
|
8401
|
+
continue;
|
|
8402
|
+
}
|
|
8403
|
+
// Recurse if we're merging plain objects or arrays
|
|
8404
|
+
if (copy && (isObject(copy) || (copyIsArray = Array.isArray(copy)))) {
|
|
8405
|
+
if (copyIsArray) {
|
|
8406
|
+
copyIsArray = false;
|
|
8407
|
+
clone = src && Array.isArray(src) ? src : [];
|
|
8408
|
+
}
|
|
8409
|
+
else {
|
|
8410
|
+
clone = src && isObject(src) ? src : {};
|
|
8411
|
+
}
|
|
8412
|
+
var nextPath = path.slice(0);
|
|
8413
|
+
nextPath.push(name);
|
|
8414
|
+
// Never move original objects, clone them
|
|
8415
|
+
target[name] = deepExtend([clone, copy], collision, nextPath);
|
|
8416
|
+
// Don't bring in undefined values
|
|
8417
|
+
}
|
|
8418
|
+
else if (copy !== undefined) {
|
|
8419
|
+
if (src != null && typeof collision == 'function') {
|
|
8420
|
+
collision({ target: target, copy: options, path: path, key: name });
|
|
8421
|
+
}
|
|
8422
|
+
target[name] = copy;
|
|
8423
|
+
}
|
|
8424
|
+
}
|
|
8425
|
+
}
|
|
8426
|
+
}
|
|
8427
|
+
return target;
|
|
8428
|
+
}
|
|
8429
|
+
/**
|
|
8430
|
+
* Checks if the value uses a value reference.
|
|
8431
|
+
* @param {string} value
|
|
8432
|
+
* @returns {boolean} - True, if the value uses a value reference
|
|
8433
|
+
*/
|
|
8434
|
+
function usesReference(value) {
|
|
8435
|
+
const regex = new RegExp('\\{([^}]+)\\}', 'g');
|
|
8436
|
+
if (typeof value === 'string') {
|
|
8437
|
+
return regex.test(value);
|
|
8438
|
+
}
|
|
8439
|
+
if (typeof value === 'object') {
|
|
8440
|
+
let hasReference = false;
|
|
8441
|
+
// iterate over each property in the object,
|
|
8442
|
+
// if any element passes the regex test,
|
|
8443
|
+
// the whole thing should be true
|
|
8444
|
+
for (const key in value) {
|
|
8445
|
+
if (has(value, key)) {
|
|
8446
|
+
const element = value[key];
|
|
8447
|
+
let reference = usesReference(element);
|
|
8448
|
+
if (reference) {
|
|
8449
|
+
hasReference = true;
|
|
8450
|
+
break;
|
|
8451
|
+
}
|
|
8452
|
+
}
|
|
8453
|
+
}
|
|
8454
|
+
return hasReference;
|
|
8455
|
+
}
|
|
8456
|
+
return false;
|
|
8457
|
+
}
|
|
8458
|
+
|
|
8459
|
+
function addVars(selector, vars) {
|
|
8460
|
+
if (!vars)
|
|
8461
|
+
return '';
|
|
8462
|
+
return `${selector} { ${Object.entries(vars)
|
|
8463
|
+
.map(([key, value]) => {
|
|
8464
|
+
return `--${key}:${value}; `;
|
|
8465
|
+
})
|
|
8466
|
+
.join(' ')}}\n`;
|
|
8467
|
+
}
|
|
8468
|
+
function recursiveComponentCSS(baseSelector, theme) {
|
|
8469
|
+
let str = '';
|
|
8470
|
+
const { _modifiers = {}, _element = {}, _vars, ...props } = theme;
|
|
8471
|
+
// if there are no props, skip
|
|
8472
|
+
if (Object.keys(props).length) {
|
|
8473
|
+
// separate psuedo/attribute selectors
|
|
8474
|
+
const [selectors, other] = splitObject(props, (key) => key.startsWith(':') || key.startsWith('['));
|
|
8475
|
+
Object.entries(selectors).forEach(([selector, value]) => {
|
|
8476
|
+
// need to remove nested things like vars and elements
|
|
8477
|
+
const { _modifiers = {}, _element = {}, _vars, ...props } = value;
|
|
8478
|
+
str += `${baseSelector}${selector} { ${propsToString(props)} }\n`;
|
|
8479
|
+
str += addVars(`${baseSelector}${selector}`, _vars);
|
|
8480
|
+
});
|
|
8481
|
+
str += `${baseSelector} { ${propsToString(other)} }\n`;
|
|
8482
|
+
}
|
|
8483
|
+
str += addVars(baseSelector, _vars);
|
|
8484
|
+
Object.entries(_modifiers).forEach(([key, value]) => {
|
|
8485
|
+
if (value && Object.keys(value).length) {
|
|
8486
|
+
str += recursiveComponentCSS(`${baseSelector}--${key}`, value);
|
|
8487
|
+
}
|
|
8488
|
+
});
|
|
8489
|
+
Object.entries(_element).forEach(([key, value]) => {
|
|
8490
|
+
if (value && Object.keys(value).length) {
|
|
8491
|
+
str += recursiveComponentCSS(`${baseSelector}__${key}`, value);
|
|
8492
|
+
}
|
|
8493
|
+
});
|
|
8494
|
+
return str;
|
|
8495
|
+
}
|
|
8496
|
+
/**
|
|
8497
|
+
* This will take a component theme and create the appropriate CSS for it.
|
|
8155
8498
|
*
|
|
8156
|
-
* We should see if there is a way to share this logic with style dictionary...
|
|
8157
8499
|
*/
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
|
|
8162
|
-
|
|
8163
|
-
|
|
8500
|
+
function createComponentCSS(themeName, components, tokens, breakpoints) {
|
|
8501
|
+
let cssText = '';
|
|
8502
|
+
components.forEach(({ name, theme, overrides }) => {
|
|
8503
|
+
const baseComponentClassName = `amplify-${name}`;
|
|
8504
|
+
const componentClassName = `[data-amplify-theme="${themeName}"] .${baseComponentClassName}`;
|
|
8505
|
+
// unwrap the component theme
|
|
8506
|
+
// if it is a function: call it with the defaultTheme to get a static object
|
|
8507
|
+
const componentTheme = isFunction(theme)
|
|
8508
|
+
? theme(tokens)
|
|
8509
|
+
: theme;
|
|
8510
|
+
cssText += recursiveComponentCSS(componentClassName, componentTheme);
|
|
8511
|
+
// if the component theme has overrides
|
|
8512
|
+
// generate the appropriate CSS for each of them
|
|
8513
|
+
if (overrides) {
|
|
8514
|
+
overrides.forEach((override) => {
|
|
8515
|
+
// unwrap the override component theme just like above
|
|
8516
|
+
const componentTheme = isFunction(override.theme)
|
|
8517
|
+
? override.theme(tokens)
|
|
8518
|
+
: override.theme;
|
|
8519
|
+
if ('mediaQuery' in override) {
|
|
8520
|
+
cssText += `@media (${override.mediaQuery}) {\n ${recursiveComponentCSS(componentClassName, componentTheme)} \n}`;
|
|
8521
|
+
}
|
|
8522
|
+
if ('breakpoint' in override) {
|
|
8523
|
+
const breakpoint = breakpoints.values[override.breakpoint];
|
|
8524
|
+
cssText += `\n@media (min-width: ${breakpoint}px) {\n ${recursiveComponentCSS(componentClassName, componentTheme)} \n}`;
|
|
8525
|
+
}
|
|
8526
|
+
if ('selector' in override) {
|
|
8527
|
+
cssText += recursiveComponentCSS(`${override.selector} .${baseComponentClassName}`, componentTheme);
|
|
8528
|
+
}
|
|
8529
|
+
if ('colorMode' in override) {
|
|
8530
|
+
cssText += `\n@media (prefers-color-scheme: ${override.colorMode}) {\n${recursiveComponentCSS(`[data-amplify-theme="${themeName}"][data-amplify-color-mode="system"] .${baseComponentClassName}`, componentTheme)}\n}\n`;
|
|
8531
|
+
cssText += recursiveComponentCSS(`[data-amplify-theme="${themeName}"][data-amplify-color-mode="${override.colorMode}"] .${baseComponentClassName}`, componentTheme);
|
|
8532
|
+
}
|
|
8533
|
+
});
|
|
8534
|
+
}
|
|
8535
|
+
});
|
|
8536
|
+
return cssText;
|
|
8537
|
+
}
|
|
8538
|
+
|
|
8164
8539
|
/**
|
|
8165
8540
|
* Takes a set of keys and a color name and returns an object of design tokens,
|
|
8166
8541
|
* used for applying a primary color at the theme level to our tokens.
|
|
@@ -8180,6 +8555,24 @@ function createColorPalette({ keys, value }) {
|
|
|
8180
8555
|
};
|
|
8181
8556
|
}, {});
|
|
8182
8557
|
}
|
|
8558
|
+
|
|
8559
|
+
function createAnimationCSS({ animations, tokens, }) {
|
|
8560
|
+
let cssText = '';
|
|
8561
|
+
Object.entries(animations).forEach(([key, value]) => {
|
|
8562
|
+
cssText += `\n @keyframes ${key} {`;
|
|
8563
|
+
Object.entries(value).forEach(([step, properties]) => {
|
|
8564
|
+
cssText += `\n ${step} {\n`;
|
|
8565
|
+
const animationProperties = isFunction(properties)
|
|
8566
|
+
? properties(tokens)
|
|
8567
|
+
: properties;
|
|
8568
|
+
cssText += propsToString(animationProperties);
|
|
8569
|
+
cssText += `\n }`;
|
|
8570
|
+
});
|
|
8571
|
+
cssText += `\n }`;
|
|
8572
|
+
});
|
|
8573
|
+
return cssText;
|
|
8574
|
+
}
|
|
8575
|
+
|
|
8183
8576
|
/**
|
|
8184
8577
|
* This will be used like `const myTheme = createTheme({})`
|
|
8185
8578
|
* `myTheme` can then be passed to a Provider or the generated CSS
|
|
@@ -8192,7 +8585,14 @@ function createTheme(theme, DefaultTheme = defaultTheme) {
|
|
|
8192
8585
|
// deepExtend is an internal Style Dictionary method
|
|
8193
8586
|
// that performs a deep merge on n objects. We could change
|
|
8194
8587
|
// this to another 3p deep merge solution too.
|
|
8195
|
-
const mergedTheme =
|
|
8588
|
+
const mergedTheme = deepExtend([
|
|
8589
|
+
{},
|
|
8590
|
+
DefaultTheme,
|
|
8591
|
+
{
|
|
8592
|
+
...theme,
|
|
8593
|
+
components: {},
|
|
8594
|
+
},
|
|
8595
|
+
]);
|
|
8196
8596
|
const { primaryColor, secondaryColor } = mergedTheme;
|
|
8197
8597
|
// apply primaryColor and secondaryColor if present
|
|
8198
8598
|
if (isString(primaryColor)) {
|
|
@@ -8219,11 +8619,20 @@ function createTheme(theme, DefaultTheme = defaultTheme) {
|
|
|
8219
8619
|
// flattenProperties is another internal Style Dictionary function
|
|
8220
8620
|
// that creates an array of all tokens.
|
|
8221
8621
|
let cssText = `[data-amplify-theme="${name}"] {\n` +
|
|
8222
|
-
|
|
8622
|
+
flattenProperties(tokens)
|
|
8223
8623
|
.map((token) => `${token.name}: ${token.value};`)
|
|
8224
8624
|
.join('\n') +
|
|
8225
8625
|
`\n}\n`;
|
|
8626
|
+
if (theme?.components) {
|
|
8627
|
+
cssText += createComponentCSS(name, theme.components, tokens, mergedTheme.breakpoints);
|
|
8628
|
+
}
|
|
8226
8629
|
let overrides = [];
|
|
8630
|
+
if (mergedTheme.animations) {
|
|
8631
|
+
cssText += createAnimationCSS({
|
|
8632
|
+
animations: mergedTheme.animations,
|
|
8633
|
+
tokens,
|
|
8634
|
+
});
|
|
8635
|
+
}
|
|
8227
8636
|
/**
|
|
8228
8637
|
* For each override, we setup the tokens and then generate the CSS.
|
|
8229
8638
|
* This allows us to have one single CSS string for all possible overrides
|
|
@@ -8231,11 +8640,11 @@ function createTheme(theme, DefaultTheme = defaultTheme) {
|
|
|
8231
8640
|
*/
|
|
8232
8641
|
if (mergedTheme.overrides) {
|
|
8233
8642
|
overrides = mergedTheme.overrides.map((override) => {
|
|
8234
|
-
const
|
|
8643
|
+
const overrideTokens = setupTokens({
|
|
8235
8644
|
tokens: override.tokens,
|
|
8236
8645
|
setupToken,
|
|
8237
8646
|
});
|
|
8238
|
-
const customProperties =
|
|
8647
|
+
const customProperties = flattenProperties(overrideTokens)
|
|
8239
8648
|
.map((token) => `${token.name}: ${token.value};`)
|
|
8240
8649
|
.join('\n');
|
|
8241
8650
|
// Overrides can have a selector, media query, breakpoint, or color mode
|
|
@@ -8272,7 +8681,7 @@ function createTheme(theme, DefaultTheme = defaultTheme) {
|
|
|
8272
8681
|
}
|
|
8273
8682
|
return {
|
|
8274
8683
|
...override,
|
|
8275
|
-
tokens,
|
|
8684
|
+
tokens: overrideTokens,
|
|
8276
8685
|
};
|
|
8277
8686
|
});
|
|
8278
8687
|
}
|
|
@@ -8281,6 +8690,12 @@ function createTheme(theme, DefaultTheme = defaultTheme) {
|
|
|
8281
8690
|
breakpoints,
|
|
8282
8691
|
name,
|
|
8283
8692
|
cssText,
|
|
8693
|
+
containerProps: ({ colorMode } = {}) => {
|
|
8694
|
+
return {
|
|
8695
|
+
'data-amplify-theme': name,
|
|
8696
|
+
'data-amplify-color-mode': colorMode,
|
|
8697
|
+
};
|
|
8698
|
+
},
|
|
8284
8699
|
// keep overrides separate from base theme
|
|
8285
8700
|
// this allows web platforms to use plain CSS scoped to a
|
|
8286
8701
|
// selector and only override the CSS vars needed. This
|
|
@@ -8293,6 +8708,112 @@ function createTheme(theme, DefaultTheme = defaultTheme) {
|
|
|
8293
8708
|
};
|
|
8294
8709
|
}
|
|
8295
8710
|
|
|
8711
|
+
function createComponentClasses({ name, prefix = 'amplify-' }) {
|
|
8712
|
+
const className = (props = {}, extraClassnames = []) => {
|
|
8713
|
+
const baseComponentClassName = `${prefix}${name}`;
|
|
8714
|
+
// get the element if there is one
|
|
8715
|
+
// the _element argument can be a string
|
|
8716
|
+
// like { _element: 'icon' }
|
|
8717
|
+
// or it could be an object where the key is
|
|
8718
|
+
// the element name and the value is the modifiers
|
|
8719
|
+
// like { _element: { icon: [size] } }
|
|
8720
|
+
const element = isString(props._element)
|
|
8721
|
+
? props._element
|
|
8722
|
+
: isObject(props._element)
|
|
8723
|
+
? Object.keys(props._element)[0]
|
|
8724
|
+
: undefined;
|
|
8725
|
+
const className = element
|
|
8726
|
+
? `${baseComponentClassName}__${element}`
|
|
8727
|
+
: baseComponentClassName;
|
|
8728
|
+
const names = [className];
|
|
8729
|
+
if (element) {
|
|
8730
|
+
const modifiers = props._element[element];
|
|
8731
|
+
names.push(...modifierClassnames({ className, modifiers }));
|
|
8732
|
+
}
|
|
8733
|
+
else {
|
|
8734
|
+
names.push(...modifierClassnames({
|
|
8735
|
+
className,
|
|
8736
|
+
modifiers: props._modifiers,
|
|
8737
|
+
}));
|
|
8738
|
+
}
|
|
8739
|
+
return classNames([...names, ...extraClassnames]);
|
|
8740
|
+
};
|
|
8741
|
+
return className;
|
|
8742
|
+
}
|
|
8743
|
+
function modifierClassnames({ className, modifiers, }) {
|
|
8744
|
+
if (Array.isArray(modifiers)) {
|
|
8745
|
+
return modifiers.map((modifier) => {
|
|
8746
|
+
if (!modifier || !isString(modifier)) {
|
|
8747
|
+
return;
|
|
8748
|
+
}
|
|
8749
|
+
return `${className}--${modifier}`;
|
|
8750
|
+
});
|
|
8751
|
+
}
|
|
8752
|
+
if (isObject(modifiers)) {
|
|
8753
|
+
return Object.entries(modifiers).map(([key, value]) => {
|
|
8754
|
+
if (value) {
|
|
8755
|
+
return `${className}--${key}`;
|
|
8756
|
+
}
|
|
8757
|
+
});
|
|
8758
|
+
}
|
|
8759
|
+
if (isString(modifiers)) {
|
|
8760
|
+
return [`${className}--${modifiers}`];
|
|
8761
|
+
}
|
|
8762
|
+
return [];
|
|
8763
|
+
}
|
|
8764
|
+
|
|
8765
|
+
/**
|
|
8766
|
+
* Use this to create the theme of a component. You can use this
|
|
8767
|
+
* to both completely customize built-in components and
|
|
8768
|
+
* build your own components!
|
|
8769
|
+
*
|
|
8770
|
+
* @experimental
|
|
8771
|
+
*
|
|
8772
|
+
* ```ts
|
|
8773
|
+
* // built-in component styling
|
|
8774
|
+
* const alertTheme = defineComponentTheme({
|
|
8775
|
+
* name: 'alert',
|
|
8776
|
+
* theme: (tokens) => {
|
|
8777
|
+
* return {
|
|
8778
|
+
* padding: tokens.space.large
|
|
8779
|
+
* }
|
|
8780
|
+
* }
|
|
8781
|
+
* });
|
|
8782
|
+
*
|
|
8783
|
+
* // custom component styling
|
|
8784
|
+
* const avatarTheme = defineComponentTheme({
|
|
8785
|
+
* name: 'avatar',
|
|
8786
|
+
* theme: (tokens) => {
|
|
8787
|
+
* return {
|
|
8788
|
+
* padding: tokens.space.large
|
|
8789
|
+
* }
|
|
8790
|
+
* }
|
|
8791
|
+
* })
|
|
8792
|
+
*
|
|
8793
|
+
* const theme = createTheme({
|
|
8794
|
+
* name: 'my-theme',
|
|
8795
|
+
* components: [alertTheme, avatarTheme]
|
|
8796
|
+
* })
|
|
8797
|
+
* ```
|
|
8798
|
+
*
|
|
8799
|
+
* @param {Object} params
|
|
8800
|
+
* @param {string} params.name - The name of the component. Use a built-in component name like button to theme buttons.
|
|
8801
|
+
* @returns
|
|
8802
|
+
*/
|
|
8803
|
+
function defineComponentTheme({ name, theme, overrides, }) {
|
|
8804
|
+
const prefix = 'amplify-';
|
|
8805
|
+
const className = createComponentClasses({
|
|
8806
|
+
name,
|
|
8807
|
+
prefix,
|
|
8808
|
+
});
|
|
8809
|
+
return {
|
|
8810
|
+
className,
|
|
8811
|
+
theme,
|
|
8812
|
+
overrides,
|
|
8813
|
+
name,
|
|
8814
|
+
};
|
|
8815
|
+
}
|
|
8816
|
+
|
|
8296
8817
|
const darkModeTokens = {
|
|
8297
8818
|
colors: {
|
|
8298
8819
|
red: {
|
|
@@ -8440,6 +8961,7 @@ exports.classNameModifierByFlag = classNameModifierByFlag;
|
|
|
8440
8961
|
exports.classNames = classNames;
|
|
8441
8962
|
exports.countryDialCodes = countryDialCodes;
|
|
8442
8963
|
exports.createAuthenticatorMachine = createAuthenticatorMachine;
|
|
8964
|
+
exports.createComponentClasses = createComponentClasses;
|
|
8443
8965
|
exports.createTheme = createTheme;
|
|
8444
8966
|
exports.cssNameTransform = cssNameTransform;
|
|
8445
8967
|
exports.defaultAuthHubHandler = defaultAuthHubHandler;
|
|
@@ -8447,6 +8969,7 @@ exports.defaultDarkModeOverride = defaultDarkModeOverride;
|
|
|
8447
8969
|
exports.defaultFormFieldOptions = defaultFormFieldOptions;
|
|
8448
8970
|
exports.defaultFormFieldsGetters = defaultFormFieldsGetters;
|
|
8449
8971
|
exports.defaultTheme = defaultTheme;
|
|
8972
|
+
exports.defineComponentTheme = defineComponentTheme;
|
|
8450
8973
|
exports.deleteUser = deleteUser;
|
|
8451
8974
|
exports.emailRegex = emailRegex;
|
|
8452
8975
|
exports.getActorContext = getActorContext$1;
|
|
@@ -8472,6 +8995,7 @@ exports.groupLog = groupLog;
|
|
|
8472
8995
|
exports.has = has;
|
|
8473
8996
|
exports.hasSpecialChars = hasSpecialChars;
|
|
8474
8997
|
exports.hasTranslation = hasTranslation;
|
|
8998
|
+
exports.humanFileSize = humanFileSize;
|
|
8475
8999
|
exports.isAuthFieldWithDefaults = isAuthFieldWithDefaults;
|
|
8476
9000
|
exports.isAuthFieldsWithDefaults = isAuthFieldsWithDefaults;
|
|
8477
9001
|
exports.isDesignToken = isDesignToken;
|
|
@@ -8500,6 +9024,7 @@ exports.setupTokens = setupTokens;
|
|
|
8500
9024
|
exports.signUpFieldsWithDefault = signUpFieldsWithDefault;
|
|
8501
9025
|
exports.signUpFieldsWithoutDefault = signUpFieldsWithoutDefault;
|
|
8502
9026
|
exports.sortFormFields = sortFormFields;
|
|
9027
|
+
exports.splitObject = splitObject;
|
|
8503
9028
|
exports.templateJoin = templateJoin;
|
|
8504
9029
|
exports.translate = translate;
|
|
8505
9030
|
exports.translations = translations;
|