hazo_auth 10.19.0 → 10.22.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/README.md +6 -0
- package/SETUP_CHECKLIST.md +27 -0
- package/cli-src/lib/already_logged_in_config.server.ts +11 -7
- package/cli-src/lib/auth_hooks.ts +52 -0
- package/cli-src/lib/config/config_loader.server.ts +34 -0
- package/cli-src/lib/email_verification_config.server.ts +2 -2
- package/cli-src/lib/forgot_password_config.server.ts +2 -2
- package/cli-src/lib/login_config.server.ts +25 -19
- package/cli-src/lib/my_settings_config.server.ts +22 -15
- package/cli-src/lib/navbar_config.server.ts +12 -8
- package/cli-src/lib/oauth_config.server.ts +14 -22
- package/cli-src/lib/otp_config.server.ts +11 -4
- package/cli-src/lib/profile_pic_menu_config.server.ts +16 -5
- package/cli-src/lib/register_config.server.ts +21 -16
- package/cli-src/lib/reset_password_config.server.ts +11 -17
- package/cli-src/lib/services/oauth_service.ts +16 -0
- package/cli-src/lib/services/otp_service.ts +7 -0
- package/cli-src/lib/services/registration_service.ts +8 -0
- package/cli-src/lib/ui_shell_config.server.ts +11 -13
- package/dist/components/layouts/create_firm/index.d.ts.map +1 -1
- package/dist/components/layouts/create_firm/index.js +4 -3
- package/dist/components/layouts/dev_lock/index.d.ts.map +1 -1
- package/dist/components/layouts/dev_lock/index.js +4 -2
- package/dist/components/layouts/email_verification/config/email_verification_field_config.d.ts +5 -4
- package/dist/components/layouts/email_verification/config/email_verification_field_config.d.ts.map +1 -1
- package/dist/components/layouts/email_verification/config/email_verification_field_config.js +20 -20
- package/dist/components/layouts/email_verification/hooks/use_email_verification.d.ts.map +1 -1
- package/dist/components/layouts/email_verification/hooks/use_email_verification.js +5 -7
- package/dist/components/layouts/email_verification/index.d.ts.map +1 -1
- package/dist/components/layouts/email_verification/index.js +13 -12
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.d.ts +3 -2
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.d.ts.map +1 -1
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.js +16 -16
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.d.ts.map +1 -1
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.js +5 -7
- package/dist/components/layouts/forgot_password/index.d.ts.map +1 -1
- package/dist/components/layouts/forgot_password/index.js +15 -9
- package/dist/components/layouts/legal/legal_acceptance_gate.d.ts.map +1 -1
- package/dist/components/layouts/legal/legal_acceptance_gate.js +5 -3
- package/dist/components/layouts/legal/legal_doc_checkbox_list.d.ts.map +1 -1
- package/dist/components/layouts/legal/legal_doc_checkbox_list.js +3 -1
- package/dist/components/layouts/legal/legal_doc_combined_view.d.ts.map +1 -1
- package/dist/components/layouts/legal/legal_doc_combined_view.js +3 -1
- package/dist/components/layouts/login/config/login_field_config.d.ts +3 -2
- package/dist/components/layouts/login/config/login_field_config.d.ts.map +1 -1
- package/dist/components/layouts/login/config/login_field_config.js +24 -24
- package/dist/components/layouts/login/hooks/use_login_form.d.ts.map +1 -1
- package/dist/components/layouts/login/hooks/use_login_form.js +5 -7
- package/dist/components/layouts/login/index.d.ts +4 -4
- package/dist/components/layouts/login/index.d.ts.map +1 -1
- package/dist/components/layouts/login/index.js +30 -22
- package/dist/components/layouts/my_settings/components/connected_accounts_section.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/connected_accounts_section.js +5 -5
- package/dist/components/layouts/my_settings/components/danger_zone_section.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/danger_zone_section.js +12 -6
- package/dist/components/layouts/my_settings/components/editable_field.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/editable_field.js +4 -2
- package/dist/components/layouts/my_settings/components/language_picker_section.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/language_picker_section.js +7 -3
- package/dist/components/layouts/my_settings/components/password_change_dialog.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/password_change_dialog.js +28 -21
- package/dist/components/layouts/my_settings/components/profile_picture_dialog.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/profile_picture_dialog.js +12 -9
- package/dist/components/layouts/my_settings/components/profile_picture_gravatar_tab.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/profile_picture_gravatar_tab.js +3 -1
- package/dist/components/layouts/my_settings/components/profile_picture_library_tab.js +14 -11
- package/dist/components/layouts/my_settings/components/profile_picture_upload_tab.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/profile_picture_upload_tab.js +26 -15
- package/dist/components/layouts/my_settings/components/set_password_section.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/set_password_section.js +9 -6
- package/dist/components/layouts/my_settings/config/my_settings_field_config.d.ts +2 -1
- package/dist/components/layouts/my_settings/config/my_settings_field_config.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/config/my_settings_field_config.js +4 -7
- package/dist/components/layouts/my_settings/index.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/index.js +35 -27
- package/dist/components/layouts/otp/index.d.ts.map +1 -1
- package/dist/components/layouts/otp/index.js +8 -6
- package/dist/components/layouts/register/config/register_field_config.d.ts +3 -2
- package/dist/components/layouts/register/config/register_field_config.d.ts.map +1 -1
- package/dist/components/layouts/register/config/register_field_config.js +40 -40
- package/dist/components/layouts/register/hooks/use_register_form.d.ts.map +1 -1
- package/dist/components/layouts/register/hooks/use_register_form.js +7 -9
- package/dist/components/layouts/register/index.d.ts +4 -4
- package/dist/components/layouts/register/index.d.ts.map +1 -1
- package/dist/components/layouts/register/index.js +22 -19
- package/dist/components/layouts/reset_password/config/reset_password_field_config.d.ts +4 -3
- package/dist/components/layouts/reset_password/config/reset_password_field_config.d.ts.map +1 -1
- package/dist/components/layouts/reset_password/config/reset_password_field_config.js +7 -10
- package/dist/components/layouts/reset_password/hooks/use_reset_password_form.d.ts.map +1 -1
- package/dist/components/layouts/reset_password/hooks/use_reset_password_form.js +4 -6
- package/dist/components/layouts/reset_password/index.d.ts.map +1 -1
- package/dist/components/layouts/reset_password/index.js +12 -10
- package/dist/components/layouts/shared/components/already_logged_in_guard.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/already_logged_in_guard.js +6 -5
- package/dist/components/layouts/shared/components/auth_navbar.d.ts +1 -1
- package/dist/components/layouts/shared/components/auth_navbar.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/auth_navbar.js +7 -2
- package/dist/components/layouts/shared/components/facebook_sign_in_button.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/facebook_sign_in_button.js +5 -5
- package/dist/components/layouts/shared/components/floating_home_link.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/floating_home_link.js +6 -3
- package/dist/components/layouts/shared/components/form_action_buttons.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/form_action_buttons.js +9 -7
- package/dist/components/layouts/shared/components/google_sign_in_button.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/google_sign_in_button.js +5 -5
- package/dist/components/layouts/shared/components/logout_button.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/logout_button.js +2 -4
- package/dist/components/layouts/shared/components/oauth_divider.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/oauth_divider.js +8 -6
- package/dist/components/layouts/shared/components/password_field.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/password_field.js +2 -3
- package/dist/components/layouts/shared/components/profile_pic_menu.d.ts +4 -0
- package/dist/components/layouts/shared/components/profile_pic_menu.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/profile_pic_menu.js +26 -18
- package/dist/components/layouts/shared/components/profile_pic_menu_wrapper.d.ts +1 -0
- package/dist/components/layouts/shared/components/profile_pic_menu_wrapper.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/profile_pic_menu_wrapper.js +1 -1
- package/dist/components/layouts/shared/components/sidebar_layout_wrapper.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/sidebar_layout_wrapper.js +3 -1
- package/dist/components/layouts/shared/components/standalone_layout_wrapper.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/standalone_layout_wrapper.js +6 -2
- package/dist/components/layouts/shared/components/unauthorized_guard.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/unauthorized_guard.js +6 -5
- package/dist/components/layouts/shared/config/layout_customization.d.ts +2 -1
- package/dist/components/layouts/shared/config/layout_customization.d.ts.map +1 -1
- package/dist/components/layouts/shared/config/layout_customization.js +18 -7
- package/dist/components/layouts/shared/utils/validation.d.ts +5 -2
- package/dist/components/layouts/shared/utils/validation.d.ts.map +1 -1
- package/dist/components/layouts/shared/utils/validation.js +4 -8
- package/dist/components/layouts/user_management/components/roles_matrix.d.ts.map +1 -1
- package/dist/components/layouts/user_management/components/roles_matrix.js +2 -4
- package/dist/components/layouts/user_management/components/scope_hierarchy_tab.d.ts.map +1 -1
- package/dist/components/layouts/user_management/components/scope_hierarchy_tab.js +6 -8
- package/dist/components/layouts/user_management/components/user_scopes_tab.d.ts.map +1 -1
- package/dist/components/layouts/user_management/components/user_scopes_tab.js +2 -4
- package/dist/components/layouts/user_management/index.d.ts.map +1 -1
- package/dist/components/layouts/user_management/index.js +2 -4
- package/dist/components/otp/OTPRequestForm.d.ts.map +1 -1
- package/dist/components/otp/OTPRequestForm.js +7 -5
- package/dist/components/otp/OTPVerifyForm.d.ts.map +1 -1
- package/dist/components/otp/OTPVerifyForm.js +7 -5
- package/dist/components/permission_denied_dialog.client.d.ts.map +1 -1
- package/dist/components/permission_denied_dialog.client.js +6 -6
- package/dist/components/ui/sheet.d.ts +1 -1
- package/dist/components/ui/sidebar.js +5 -5
- package/dist/contexts/hazo_auth_config.d.ts +13 -0
- package/dist/contexts/hazo_auth_config.d.ts.map +1 -1
- package/dist/contexts/hazo_auth_config.js +4 -1
- package/dist/contexts/hazo_auth_provider.d.ts +22 -2
- package/dist/contexts/hazo_auth_provider.d.ts.map +1 -1
- package/dist/contexts/hazo_auth_provider.js +18 -2
- package/dist/lib/already_logged_in_config.server.d.ts +4 -2
- package/dist/lib/already_logged_in_config.server.d.ts.map +1 -1
- package/dist/lib/already_logged_in_config.server.js +7 -5
- package/dist/lib/auth_hooks.d.ts +20 -0
- package/dist/lib/auth_hooks.d.ts.map +1 -0
- package/dist/lib/auth_hooks.js +32 -0
- package/dist/lib/config/config_loader.server.d.ts +23 -0
- package/dist/lib/config/config_loader.server.d.ts.map +1 -1
- package/dist/lib/config/config_loader.server.js +29 -0
- package/dist/lib/email_verification_config.server.d.ts +2 -2
- package/dist/lib/email_verification_config.server.d.ts.map +1 -1
- package/dist/lib/forgot_password_config.server.d.ts +2 -2
- package/dist/lib/forgot_password_config.server.d.ts.map +1 -1
- package/dist/lib/login_config.server.d.ts +8 -5
- package/dist/lib/login_config.server.d.ts.map +1 -1
- package/dist/lib/login_config.server.js +13 -6
- package/dist/lib/my_settings_config.server.d.ts.map +1 -1
- package/dist/lib/my_settings_config.server.js +22 -15
- package/dist/lib/navbar_config.server.d.ts +3 -2
- package/dist/lib/navbar_config.server.d.ts.map +1 -1
- package/dist/lib/navbar_config.server.js +4 -2
- package/dist/lib/oauth_config.server.d.ts +6 -6
- package/dist/lib/oauth_config.server.d.ts.map +1 -1
- package/dist/lib/oauth_config.server.js +8 -4
- package/dist/lib/otp_config.server.d.ts +2 -2
- package/dist/lib/otp_config.server.d.ts.map +1 -1
- package/dist/lib/otp_config.server.js +4 -2
- package/dist/lib/profile_pic_menu_config.server.d.ts +6 -2
- package/dist/lib/profile_pic_menu_config.server.d.ts.map +1 -1
- package/dist/lib/profile_pic_menu_config.server.js +5 -3
- package/dist/lib/register_config.server.d.ts +7 -6
- package/dist/lib/register_config.server.d.ts.map +1 -1
- package/dist/lib/register_config.server.js +8 -4
- package/dist/lib/reset_password_config.server.d.ts +6 -4
- package/dist/lib/reset_password_config.server.d.ts.map +1 -1
- package/dist/lib/reset_password_config.server.js +5 -5
- package/dist/lib/services/oauth_service.d.ts.map +1 -1
- package/dist/lib/services/oauth_service.js +13 -0
- package/dist/lib/services/otp_service.d.ts.map +1 -1
- package/dist/lib/services/otp_service.js +6 -0
- package/dist/lib/services/registration_service.d.ts.map +1 -1
- package/dist/lib/services/registration_service.js +7 -0
- package/dist/lib/ui_shell_config.server.d.ts +6 -2
- package/dist/lib/ui_shell_config.server.d.ts.map +1 -1
- package/dist/lib/ui_shell_config.server.js +5 -3
- package/dist/locales/en.json +135 -1
- package/dist/server-lib.d.ts +2 -0
- package/dist/server-lib.d.ts.map +1 -1
- package/dist/server-lib.js +2 -0
- package/dist/server_pages/forgot_password.d.ts +3 -2
- package/dist/server_pages/forgot_password.d.ts.map +1 -1
- package/dist/server_pages/forgot_password.js +8 -7
- package/dist/server_pages/forgot_password_client_wrapper.d.ts +2 -1
- package/dist/server_pages/forgot_password_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/forgot_password_client_wrapper.js +3 -1
- package/dist/server_pages/login.d.ts.map +1 -1
- package/dist/server_pages/login.js +9 -7
- package/dist/server_pages/login_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/login_client_wrapper.js +3 -1
- package/dist/server_pages/otp.d.ts +6 -3
- package/dist/server_pages/otp.d.ts.map +1 -1
- package/dist/server_pages/otp.js +11 -8
- package/dist/server_pages/register.d.ts.map +1 -1
- package/dist/server_pages/register.js +7 -6
- package/dist/server_pages/register_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/register_client_wrapper.js +3 -1
- package/dist/server_pages/reset_password.d.ts.map +1 -1
- package/dist/server_pages/reset_password.js +7 -6
- package/dist/server_pages/reset_password_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/reset_password_client_wrapper.js +3 -1
- package/dist/server_pages/verify_email.d.ts.map +1 -1
- package/dist/server_pages/verify_email.js +6 -5
- package/dist/server_pages/verify_email_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/verify_email_client_wrapper.js +4 -2
- package/dist/strings/default_strings.d.ts +15 -0
- package/dist/strings/default_strings.d.ts.map +1 -1
- package/dist/strings/default_strings.js +53 -0
- package/dist/strings/index.d.ts +1 -1
- package/dist/strings/index.d.ts.map +1 -1
- package/dist/strings/index.js +1 -1
- package/dist/strings/strings_context.d.ts +20 -3
- package/dist/strings/strings_context.d.ts.map +1 -1
- package/dist/strings/strings_context.js +39 -5
- package/dist/strings/strings_provider.d.ts +1 -5
- package/dist/strings/strings_provider.d.ts.map +1 -1
- package/dist/strings/strings_provider.js +5 -1
- package/package.json +10 -6
|
@@ -11,6 +11,7 @@ import { Upload, X, Loader2, Info } from "lucide-react";
|
|
|
11
11
|
import { Button } from "../../../ui/button.js";
|
|
12
12
|
import imageCompression from "browser-image-compression";
|
|
13
13
|
import { HazoUiImageCropperDialog } from "hazo_ui";
|
|
14
|
+
import { useAuthT } from "../../../../contexts/hazo_auth_provider.js";
|
|
14
15
|
// section: helpers
|
|
15
16
|
/** Resolves true if the browser can decode this image file, false otherwise (e.g. desktop HEIC). */
|
|
16
17
|
function can_decode_image(file) {
|
|
@@ -33,7 +34,12 @@ function can_decode_image(file) {
|
|
|
33
34
|
* @returns Upload tab component
|
|
34
35
|
*/
|
|
35
36
|
export function ProfilePictureUploadTab({ useUpload, onUseUploadChange, onFileSelect, maxSize, uploadEnabled, disabled = false, currentPreview, photoUploadDisabledMessage, imageCompressionMaxDimension = 200, uploadFileHardLimitBytes = 10485760, // 10MB default
|
|
36
|
-
allowedImageMimeTypes = ["image/jpeg", "image/jpg", "image/png"], cropTitle
|
|
37
|
+
allowedImageMimeTypes = ["image/jpeg", "image/jpg", "image/png"], cropTitle, cropConfirmLabel, cropCancelLabel, cropZoomLabel, }) {
|
|
38
|
+
const t = useAuthT();
|
|
39
|
+
const resolvedCropTitle = cropTitle !== null && cropTitle !== void 0 ? cropTitle : t("my_settings.upload_tab.crop_title_default");
|
|
40
|
+
const resolvedCropConfirmLabel = cropConfirmLabel !== null && cropConfirmLabel !== void 0 ? cropConfirmLabel : t("my_settings.upload_tab.crop_confirm_label_default");
|
|
41
|
+
const resolvedCropCancelLabel = cropCancelLabel !== null && cropCancelLabel !== void 0 ? cropCancelLabel : t("shared.cancel_button");
|
|
42
|
+
const resolvedCropZoomLabel = cropZoomLabel !== null && cropZoomLabel !== void 0 ? cropZoomLabel : t("my_settings.upload_tab.crop_zoom_label_default");
|
|
37
43
|
const [dragActive, setDragActive] = useState(false);
|
|
38
44
|
const [preview, setPreview] = useState(currentPreview || null);
|
|
39
45
|
const [isNewImage, setIsNewImage] = useState(false); // Track if preview is showing a newly uploaded image
|
|
@@ -74,7 +80,10 @@ allowedImageMimeTypes = ["image/jpeg", "image/jpg", "image/png"], cropTitle = "C
|
|
|
74
80
|
setCompressing(false);
|
|
75
81
|
// Check if compressed file is still too large
|
|
76
82
|
if (compressedFile.size > maxSize) {
|
|
77
|
-
setError(
|
|
83
|
+
setError(t("my_settings.upload_tab.error_too_large_after_compression", {
|
|
84
|
+
maxKB: Math.round(maxSize / 1024),
|
|
85
|
+
actualKB: Math.round(compressedFile.size / 1024),
|
|
86
|
+
}));
|
|
78
87
|
return;
|
|
79
88
|
}
|
|
80
89
|
// Create preview
|
|
@@ -91,7 +100,7 @@ allowedImageMimeTypes = ["image/jpeg", "image/jpg", "image/png"], cropTitle = "C
|
|
|
91
100
|
}
|
|
92
101
|
catch (error) {
|
|
93
102
|
setCompressing(false);
|
|
94
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
103
|
+
const errorMessage = error instanceof Error ? error.message : t("my_settings.upload_tab.error_compress_default");
|
|
95
104
|
setError(errorMessage);
|
|
96
105
|
}
|
|
97
106
|
}
|
|
@@ -110,23 +119,25 @@ allowedImageMimeTypes = ["image/jpeg", "image/jpg", "image/png"], cropTitle = "C
|
|
|
110
119
|
await onFileSelect(file);
|
|
111
120
|
}
|
|
112
121
|
catch (error) {
|
|
113
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
122
|
+
const errorMessage = error instanceof Error ? error.message : t("my_settings.upload_tab.error_process_default");
|
|
114
123
|
setError(errorMessage);
|
|
115
124
|
}
|
|
116
125
|
finally {
|
|
117
126
|
setUploading(false);
|
|
118
127
|
}
|
|
119
128
|
}
|
|
120
|
-
}, [maxSize, onFileSelect, imageCompressionMaxDimension]);
|
|
129
|
+
}, [maxSize, onFileSelect, imageCompressionMaxDimension, t]);
|
|
121
130
|
const handleFile = useCallback(async (file) => {
|
|
122
131
|
// Validate file type
|
|
123
132
|
if (!allowedImageMimeTypes.includes(file.type)) {
|
|
124
|
-
setError(
|
|
133
|
+
setError(t("my_settings.upload_tab.error_invalid_type", {
|
|
134
|
+
types: allowedImageMimeTypes.map(mime => mime.split("/")[1].toUpperCase()).join(", "),
|
|
135
|
+
}));
|
|
125
136
|
return;
|
|
126
137
|
}
|
|
127
138
|
// Hard limit: reject files larger than configured limit (too large to process efficiently)
|
|
128
139
|
if (file.size > uploadFileHardLimitBytes) {
|
|
129
|
-
setError(
|
|
140
|
+
setError(t("my_settings.upload_tab.error_too_large", { maxKB: Math.round(maxSize / 1024) }));
|
|
130
141
|
return;
|
|
131
142
|
}
|
|
132
143
|
setError(null);
|
|
@@ -137,7 +148,7 @@ allowedImageMimeTypes = ["image/jpeg", "image/jpg", "image/png"], cropTitle = "C
|
|
|
137
148
|
else {
|
|
138
149
|
await process_and_upload(file); // HEIC/undecodable fallback: direct path
|
|
139
150
|
}
|
|
140
|
-
}, [allowedImageMimeTypes, uploadFileHardLimitBytes, maxSize, process_and_upload]);
|
|
151
|
+
}, [allowedImageMimeTypes, uploadFileHardLimitBytes, maxSize, process_and_upload, t]);
|
|
141
152
|
const handle_crop_confirm = useCallback(async (blob) => {
|
|
142
153
|
const cropped = new File([blob], "avatar.webp", { type: "image/webp" });
|
|
143
154
|
await process_and_upload(cropped);
|
|
@@ -158,23 +169,23 @@ allowedImageMimeTypes = ["image/jpeg", "image/jpg", "image/png"], cropTitle = "C
|
|
|
158
169
|
e.stopPropagation();
|
|
159
170
|
setDragActive(false);
|
|
160
171
|
if (!uploadEnabled || disabled) {
|
|
161
|
-
setError("
|
|
172
|
+
setError(t("my_settings.upload_tab.error_upload_disabled"));
|
|
162
173
|
return;
|
|
163
174
|
}
|
|
164
175
|
if (e.dataTransfer.files && e.dataTransfer.files[0]) {
|
|
165
176
|
void handleFile(e.dataTransfer.files[0]);
|
|
166
177
|
}
|
|
167
|
-
}, [uploadEnabled, disabled, handleFile]);
|
|
178
|
+
}, [uploadEnabled, disabled, handleFile, t]);
|
|
168
179
|
const handleChange = useCallback((e) => {
|
|
169
180
|
e.preventDefault();
|
|
170
181
|
if (!uploadEnabled || disabled) {
|
|
171
|
-
setError("
|
|
182
|
+
setError(t("my_settings.upload_tab.error_upload_disabled"));
|
|
172
183
|
return;
|
|
173
184
|
}
|
|
174
185
|
if (e.target.files && e.target.files[0]) {
|
|
175
186
|
void handleFile(e.target.files[0]);
|
|
176
187
|
}
|
|
177
|
-
}, [uploadEnabled, disabled, handleFile]);
|
|
188
|
+
}, [uploadEnabled, disabled, handleFile, t]);
|
|
178
189
|
const handleRemove = useCallback(() => {
|
|
179
190
|
setPreview(currentPreview || null); // Reset to current preview if available
|
|
180
191
|
setIsNewImage(false); // Reset to showing current image
|
|
@@ -183,7 +194,7 @@ allowedImageMimeTypes = ["image/jpeg", "image/jpg", "image/png"], cropTitle = "C
|
|
|
183
194
|
const getInitials = () => {
|
|
184
195
|
return "U";
|
|
185
196
|
};
|
|
186
|
-
return (_jsxs("div", { className: "cls_profile_picture_upload_tab flex flex-col gap-4", children: [_jsxs("div", { className: "cls_profile_picture_upload_tab_switch flex items-center gap-3", children: [_jsx(Switch, { id: "use-upload", checked: useUpload, onCheckedChange: onUseUploadChange, disabled: disabled || !uploadEnabled, className: "cls_profile_picture_upload_tab_switch_input", "aria-label": "
|
|
197
|
+
return (_jsxs("div", { className: "cls_profile_picture_upload_tab flex flex-col gap-4", children: [_jsxs("div", { className: "cls_profile_picture_upload_tab_switch flex items-center gap-3", children: [_jsx(Switch, { id: "use-upload", checked: useUpload, onCheckedChange: onUseUploadChange, disabled: disabled || !uploadEnabled, className: "cls_profile_picture_upload_tab_switch_input", "aria-label": t("my_settings.upload_tab.use_uploaded_label") }), _jsx(Label, { htmlFor: "use-upload", className: "cls_profile_picture_upload_tab_switch_label text-sm font-medium text-[var(--hazo-text-secondary)] cursor-pointer", children: t("my_settings.upload_tab.use_uploaded_label") })] }), !uploadEnabled && (_jsxs("div", { className: "cls_profile_picture_upload_tab_disabled flex items-center gap-2 p-3 bg-yellow-50 border border-yellow-200 rounded-lg", children: [_jsx(Info, { className: "h-4 w-4 text-yellow-600", "aria-hidden": "true" }), _jsx("p", { className: "cls_profile_picture_upload_tab_disabled_text text-sm text-yellow-800", children: photoUploadDisabledMessage })] })), _jsxs("div", { className: "cls_profile_picture_upload_tab_content grid grid-cols-1 md:grid-cols-2 gap-6", children: [_jsxs("div", { className: "cls_profile_picture_upload_tab_dropzone_container flex flex-col gap-2", children: [_jsx(Label, { className: "cls_profile_picture_upload_tab_dropzone_label text-sm font-medium text-[var(--hazo-text-secondary)]", children: t("my_settings.upload_tab.upload_photo_label") }), _jsxs("div", { className: `
|
|
187
198
|
cls_profile_picture_upload_tab_dropzone
|
|
188
199
|
flex flex-col items-center justify-center
|
|
189
200
|
border-2 border-dashed rounded-lg p-8
|
|
@@ -195,6 +206,6 @@ allowedImageMimeTypes = ["image/jpeg", "image/jpg", "image/png"], cropTitle = "C
|
|
|
195
206
|
if (!disabled && uploadEnabled) {
|
|
196
207
|
(_a = document.getElementById("file-upload-input")) === null || _a === void 0 ? void 0 : _a.click();
|
|
197
208
|
}
|
|
198
|
-
}, children: [_jsx("input", { id: "file-upload-input", type: "file", accept: allowedImageMimeTypes.join(","), onChange: handleChange, disabled: disabled || !uploadEnabled, className: "hidden", "aria-label": "
|
|
199
|
-
setCropFile(null); }, file: cropFile, onConfirm: handle_crop_confirm, title:
|
|
209
|
+
}, children: [_jsx("input", { id: "file-upload-input", type: "file", accept: allowedImageMimeTypes.join(","), onChange: handleChange, disabled: disabled || !uploadEnabled, className: "hidden", "aria-label": t("my_settings.upload_tab.upload_input_aria") }), _jsx(Upload, { className: "h-8 w-8 text-[var(--hazo-text-subtle)] mb-2", "aria-hidden": "true" }), _jsx("p", { className: "cls_profile_picture_upload_tab_dropzone_text text-sm text-[var(--hazo-text-muted)] text-center", children: t("my_settings.upload_tab.dropzone_text") }), _jsx("p", { className: "cls_profile_picture_upload_tab_dropzone_hint text-xs text-[var(--hazo-text-muted)] text-center mt-1", children: t("my_settings.upload_tab.dropzone_hint", { maxKB: Math.round(maxSize / 1024) }) })] }), error && (_jsx("p", { className: "cls_profile_picture_upload_tab_error text-sm text-red-600", role: "alert", children: error }))] }), _jsxs("div", { className: "cls_profile_picture_upload_tab_preview_container flex flex-col gap-2", children: [_jsx(Label, { className: "cls_profile_picture_upload_tab_preview_label text-sm font-medium text-[var(--hazo-text-secondary)]", children: isNewImage ? t("my_settings.upload_tab.preview_new_label") : t("my_settings.upload_tab.preview_current_label") }), _jsx("div", { className: "cls_profile_picture_upload_tab_preview_content flex flex-col items-center justify-center border border-[var(--hazo-border)] rounded-lg p-6 bg-[var(--hazo-bg-subtle)] min-h-[200px]", children: compressing ? (_jsxs("div", { className: "cls_profile_picture_upload_tab_compressing flex flex-col items-center gap-2", children: [_jsx(Loader2, { className: "h-8 w-8 text-[var(--hazo-text-subtle)] animate-spin", "aria-hidden": "true" }), _jsx("p", { className: "cls_profile_picture_upload_tab_compressing_text text-sm text-[var(--hazo-text-muted)]", children: t("my_settings.upload_tab.compressing_text") })] })) : uploading ? (_jsxs("div", { className: "cls_profile_picture_upload_tab_uploading flex flex-col items-center gap-2", children: [_jsx(Loader2, { className: "h-8 w-8 text-[var(--hazo-text-subtle)] animate-spin", "aria-hidden": "true" }), _jsx("p", { className: "cls_profile_picture_upload_tab_uploading_text text-sm text-[var(--hazo-text-muted)]", children: t("my_settings.upload_tab.uploading_text") })] })) : preview ? (_jsxs("div", { className: "cls_profile_picture_upload_tab_preview_image_container flex flex-col items-center gap-4", children: [_jsxs("div", { className: "cls_profile_picture_upload_tab_preview_image_wrapper relative", children: [_jsxs(Avatar, { className: "cls_profile_picture_upload_tab_preview_avatar h-32 w-32", children: [_jsx(AvatarImage, { src: preview, alt: t("my_settings.upload_tab.preview_alt"), className: "cls_profile_picture_upload_tab_preview_avatar_image" }), _jsx(AvatarFallback, { className: "cls_profile_picture_upload_tab_preview_avatar_fallback bg-[var(--hazo-bg-emphasis)] text-[var(--hazo-text-muted)] text-3xl", children: getInitials() })] }), _jsx(Button, { type: "button", onClick: handleRemove, variant: "ghost", size: "icon", className: "cls_profile_picture_upload_tab_preview_remove absolute -top-2 -right-2 rounded-full h-6 w-6 border border-[var(--hazo-border-emphasis)] bg-white hover:bg-[var(--hazo-bg-subtle)]", "aria-label": t("my_settings.upload_tab.remove_preview_aria"), children: _jsx(X, { className: "h-4 w-4", "aria-hidden": "true" }) })] }), _jsx("p", { className: "cls_profile_picture_upload_tab_preview_success_text text-sm text-[var(--hazo-text-muted)] text-center", children: t("my_settings.upload_tab.preview_success_text") })] })) : (_jsxs("div", { className: "cls_profile_picture_upload_tab_preview_empty flex flex-col items-center gap-2", children: [_jsx(Avatar, { className: "cls_profile_picture_upload_tab_preview_empty_avatar h-32 w-32", children: _jsx(AvatarFallback, { className: "cls_profile_picture_upload_tab_preview_empty_avatar_fallback bg-[var(--hazo-bg-emphasis)] text-[var(--hazo-text-muted)] text-3xl", children: getInitials() }) }), _jsx("p", { className: "cls_profile_picture_upload_tab_preview_empty_text text-sm text-[var(--hazo-text-muted)] text-center", children: t("my_settings.upload_tab.preview_empty_text") })] })) })] })] }), _jsx(HazoUiImageCropperDialog, { open: cropFile !== null, onOpenChange: (open) => { if (!open && !uploading && !compressing)
|
|
210
|
+
setCropFile(null); }, file: cropFile, onConfirm: handle_crop_confirm, title: resolvedCropTitle, confirmLabel: resolvedCropConfirmLabel, cancelLabel: resolvedCropCancelLabel, zoomLabel: resolvedCropZoomLabel })] }));
|
|
200
211
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set_password_section.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/components/set_password_section.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"set_password_section.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/components/set_password_section.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AAI3F,MAAM,MAAM,uBAAuB,GAAG;IACpC,2CAA2C;IAC3C,oBAAoB,EAAE,0BAA0B,CAAC;IACjD,iDAAiD;IACjD,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,sBAAsB;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uBAAuB;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yBAAyB;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,6BAA6B;IAC7B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,0BAA0B;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gCAAgC;IAChC,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAGF;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,oBAAoB,EACpB,aAAa,EACb,OAAO,EACP,WAAW,EACX,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,aAAqB,GACtB,EAAE,uBAAuB,+BA6NzB"}
|
|
@@ -8,18 +8,21 @@ import { Button } from "../../../ui/button.js";
|
|
|
8
8
|
import { PasswordField } from "../../shared/components/password_field.js";
|
|
9
9
|
import { FormFieldWrapper } from "../../shared/components/form_field_wrapper.js";
|
|
10
10
|
import { toast } from "sonner";
|
|
11
|
-
import { useHazoAuthConfig } from "../../../../contexts/hazo_auth_provider.js";
|
|
12
|
-
import en from "../../../../locales/en.json" with { type: "json" };
|
|
13
|
-
import { createPackageT } from "hazo_core/i18n";
|
|
14
|
-
const t = createPackageT("hazo_auth", en);
|
|
11
|
+
import { useHazoAuthConfig, useAuthT } from "../../../../contexts/hazo_auth_provider.js";
|
|
15
12
|
// section: component
|
|
16
13
|
/**
|
|
17
14
|
* Set Password Section for My Settings
|
|
18
15
|
* Allows Google-only users to set a password for email/password login
|
|
19
16
|
* Only shown when user has no password set (Google-only account)
|
|
20
17
|
*/
|
|
21
|
-
export function SetPasswordSection({ passwordRequirements, onPasswordSet, heading
|
|
18
|
+
export function SetPasswordSection({ passwordRequirements, onPasswordSet, heading, description, newPasswordLabel, confirmPasswordLabel, submitButtonLabel, parentLoading = false, }) {
|
|
22
19
|
const { apiBasePath } = useHazoAuthConfig();
|
|
20
|
+
const t = useAuthT();
|
|
21
|
+
const resolvedHeading = heading !== null && heading !== void 0 ? heading : t("my_settings.set_password.heading");
|
|
22
|
+
const resolvedDescription = description !== null && description !== void 0 ? description : t("my_settings.set_password.description");
|
|
23
|
+
const resolvedNewPasswordLabel = newPasswordLabel !== null && newPasswordLabel !== void 0 ? newPasswordLabel : t("my_settings.set_password.new_password_label");
|
|
24
|
+
const resolvedConfirmPasswordLabel = confirmPasswordLabel !== null && confirmPasswordLabel !== void 0 ? confirmPasswordLabel : t("my_settings.set_password.confirm_password_label");
|
|
25
|
+
const resolvedSubmitButtonLabel = submitButtonLabel !== null && submitButtonLabel !== void 0 ? submitButtonLabel : t("my_settings.set_password.submit_button");
|
|
23
26
|
const [newPassword, setNewPassword] = useState("");
|
|
24
27
|
const [confirmPassword, setConfirmPassword] = useState("");
|
|
25
28
|
const [newPasswordVisible, setNewPasswordVisible] = useState(false);
|
|
@@ -130,5 +133,5 @@ export function SetPasswordSection({ passwordRequirements, onPasswordSet, headin
|
|
|
130
133
|
setErrors((prev) => (Object.assign(Object.assign({}, prev), { confirmPassword: undefined })));
|
|
131
134
|
}, []);
|
|
132
135
|
const isSubmitDisabled = loading || parentLoading || !newPassword || !confirmPassword;
|
|
133
|
-
return (_jsxs("div", { className: "cls_my_settings_set_password_section bg-white rounded-lg border border-[var(--hazo-border)] p-6", children: [_jsx("h2", { className: "cls_my_settings_section_heading text-lg font-semibold text-[var(--hazo-text-primary)] mb-2", children:
|
|
136
|
+
return (_jsxs("div", { className: "cls_my_settings_set_password_section bg-white rounded-lg border border-[var(--hazo-border)] p-6", children: [_jsx("h2", { className: "cls_my_settings_section_heading text-lg font-semibold text-[var(--hazo-text-primary)] mb-2", children: resolvedHeading }), _jsx("p", { className: "cls_set_password_description text-sm text-[var(--hazo-text-muted)] mb-4", children: resolvedDescription }), _jsxs("div", { className: "cls_set_password_fields flex flex-col gap-4", children: [_jsxs("div", { className: "cls_set_password_fields_row grid grid-cols-1 md:grid-cols-2 gap-4", children: [_jsx(FormFieldWrapper, { fieldId: "set-new-password", label: resolvedNewPasswordLabel, input: _jsx(PasswordField, { inputId: "set-new-password", ariaLabel: resolvedNewPasswordLabel, value: newPassword, placeholder: t("my_settings.set_password.new_password_placeholder"), autoComplete: "new-password", isVisible: newPasswordVisible, onChange: handleNewPasswordChange, onToggleVisibility: () => setNewPasswordVisible(!newPasswordVisible), errorMessage: errors.newPassword }) }), _jsx(FormFieldWrapper, { fieldId: "set-confirm-password", label: resolvedConfirmPasswordLabel, input: _jsx(PasswordField, { inputId: "set-confirm-password", ariaLabel: resolvedConfirmPasswordLabel, value: confirmPassword, placeholder: t("my_settings.set_password.confirm_password_placeholder"), autoComplete: "new-password", isVisible: confirmPasswordVisible, onChange: handleConfirmPasswordChange, onToggleVisibility: () => setConfirmPasswordVisible(!confirmPasswordVisible), errorMessage: errors.confirmPassword }) })] }), _jsx("div", { className: "cls_set_password_actions flex justify-end", children: _jsx(Button, { type: "button", onClick: handleSubmit, disabled: isSubmitDisabled, className: "cls_set_password_submit_button", "aria-label": resolvedSubmitButtonLabel, children: loading ? t("my_settings.set_password.submitting") : resolvedSubmitButtonLabel }) })] })] }));
|
|
134
137
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ButtonPaletteDefaults, type ButtonPaletteOverrides } from "../../shared/config/layout_customization.js";
|
|
2
|
+
import type { AuthTFunction } from "../../../../contexts/hazo_auth_config";
|
|
2
3
|
export declare const MY_SETTINGS_FIELD_IDS: {
|
|
3
4
|
readonly NAME: "name";
|
|
4
5
|
readonly EMAIL: "email_address";
|
|
@@ -14,6 +15,6 @@ export type MySettingsLabelDefaults = {
|
|
|
14
15
|
changePasswordButton: string;
|
|
15
16
|
};
|
|
16
17
|
export type MySettingsLabelOverrides = Partial<MySettingsLabelDefaults>;
|
|
17
|
-
export declare const resolveMySettingsLabels: (overrides?: MySettingsLabelOverrides) => MySettingsLabelDefaults;
|
|
18
|
+
export declare const resolveMySettingsLabels: (t: AuthTFunction, overrides?: MySettingsLabelOverrides) => MySettingsLabelDefaults;
|
|
18
19
|
export declare const resolveMySettingsButtonPalette: (overrides?: ButtonPaletteOverrides) => ButtonPaletteDefaults;
|
|
19
20
|
//# sourceMappingURL=my_settings_field_config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"my_settings_field_config.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/config/my_settings_field_config.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAE5B,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"my_settings_field_config.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/config/my_settings_field_config.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAE5B,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAG3E,eAAO,MAAM,qBAAqB;;;;CAIxB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,OAAO,qBAAqB,CAAC,CAAC;AAGnG,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,oBAAoB,EAAE,MAAM,CAAC;CAC9B,CAAC;AAWF,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,uBAAuB,GAClC,GAAG,aAAa,EAChB,YAAY,wBAAwB,KACnC,uBAKF,CAAC;AAUF,eAAO,MAAM,8BAA8B,GACzC,YAAY,sBAAsB,0BACqC,CAAC"}
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import { resolveButtonPalette, } from "../../shared/config/layout_customization.js";
|
|
2
|
-
import en from "../../../../locales/en.json" with { type: "json" };
|
|
3
|
-
import { createPackageT } from "hazo_core/i18n";
|
|
4
|
-
const t = createPackageT("hazo_auth", en);
|
|
5
2
|
// section: field_identifiers
|
|
6
3
|
export const MY_SETTINGS_FIELD_IDS = {
|
|
7
4
|
NAME: "name",
|
|
8
5
|
EMAIL: "email_address",
|
|
9
6
|
PASSWORD: "password",
|
|
10
7
|
};
|
|
11
|
-
const
|
|
8
|
+
const buildMySettingsLabelDefaults = (t) => ({
|
|
12
9
|
heading: t("my_settings.heading"),
|
|
13
10
|
profileTab: t("my_settings.profile_tab"),
|
|
14
11
|
securityTab: t("my_settings.security_tab"),
|
|
15
12
|
lastLoggedInLabel: t("my_settings.last_logged_in_label"),
|
|
16
13
|
profilePictureLabel: t("my_settings.profile_picture_label"),
|
|
17
14
|
changePasswordButton: t("my_settings.change_password_button"),
|
|
18
|
-
};
|
|
19
|
-
export const resolveMySettingsLabels = (overrides) => {
|
|
20
|
-
return Object.assign(Object.assign({},
|
|
15
|
+
});
|
|
16
|
+
export const resolveMySettingsLabels = (t, overrides) => {
|
|
17
|
+
return Object.assign(Object.assign({}, buildMySettingsLabelDefaults(t)), overrides);
|
|
21
18
|
};
|
|
22
19
|
// section: button_palette_defaults
|
|
23
20
|
const MY_SETTINGS_BUTTON_PALETTE_DEFAULTS = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/my_settings/index.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAGnG,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EACV,0BAA0B,EAC1B,sBAAsB,EACvB,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/my_settings/index.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAGnG,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EACV,0BAA0B,EAC1B,sBAAsB,EACvB,MAAM,uCAAuC,CAAC;AAS/C,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,wBAAwB,CAAC;IAClC,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,qBAAqB,EAAE,0BAA0B,CAAC;IAClD,cAAc,EAAE;QACd,kBAAkB,EAAE,OAAO,CAAC;QAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,cAAc,EAAE,MAAM,CAAC;QACvB,kBAAkB,EAAE,OAAO,CAAC;QAC5B,4BAA4B,EAAE,UAAU,GAAG,SAAS,CAAC;QACrD,4BAA4B,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;QACtD,kBAAkB,EAAE,MAAM,CAAC;KAC5B,CAAC;IACF,UAAU,EAAE;QACV,eAAe,EAAE,OAAO,CAAC;QACzB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,mBAAmB,EAAE,OAAO,CAAC;KAC9B,CAAC;IACF,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;IACrC;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,EAAE;QACR,6BAA6B,EAAE,MAAM,CAAC;QACtC,sBAAsB,EAAE,MAAM,CAAC;QAC/B,2BAA2B,EAAE,MAAM,CAAC;QACpC,uBAAuB,EAAE,MAAM,CAAC;KACjC,CAAC;IACF,OAAO,EAAE;QACP,aAAa,EAAE,MAAM,CAAC;QACtB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,yBAAyB,EAAE,MAAM,CAAC;QAClC,uBAAuB,EAAE,MAAM,CAAC;QAChC,0BAA0B,EAAE,MAAM,CAAC;QACnC,0BAA0B,EAAE,MAAM,CAAC;QACnC,+BAA+B,EAAE,MAAM,CAAC;QACxC,4BAA4B,EAAE,MAAM,CAAC;KACtC,CAAC;IACF,SAAS,EAAE;QACT,wBAAwB,EAAE,MAAM,EAAE,CAAC;QACnC,wBAAwB,EAAE,MAAM,EAAE,CAAC;KACpC,CAAC;CACH,CAAC;AAGF;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,SAAS,EACT,MAAM,EACN,aAAa,EACb,qBAAqB,EACrB,cAAc,EACd,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,SAA8B,EAC9B,gBAAgB,EAChB,qBAA6B,EAC7B,OAAO,EACP,UAAU,EACV,iBAAiB,EACjB,0BAA0B,EAC1B,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACvB,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,QAAQ,EACR,OAAO,EACP,SAAS,GACV,EAAE,qBAAqB,+BAiRvB"}
|
|
@@ -18,6 +18,7 @@ import { PasswordField } from "../shared/components/password_field.js";
|
|
|
18
18
|
import { FormFieldWrapper } from "../shared/components/form_field_wrapper.js";
|
|
19
19
|
import { Pencil, Trash2 } from "lucide-react";
|
|
20
20
|
import { cn } from "../../../lib/utils.js";
|
|
21
|
+
import { useAuthT } from "../../../contexts/hazo_auth_provider.js";
|
|
21
22
|
// section: component
|
|
22
23
|
/**
|
|
23
24
|
* My Settings layout component with tabs for profile and security settings
|
|
@@ -26,17 +27,47 @@ import { cn } from "../../../lib/utils.js";
|
|
|
26
27
|
* @param props - Component props including labels, button colors, password requirements, etc.
|
|
27
28
|
* @returns My settings layout component
|
|
28
29
|
*/
|
|
29
|
-
export default function my_settings_layout({ className, labels, button_colors, password_requirements, profilePicture, userFields, unauthorizedMessage
|
|
30
|
+
export default function my_settings_layout({ className, labels, button_colors, password_requirements, profilePicture, userFields, unauthorizedMessage, loginButtonLabel, loginPath = "/hazo_auth/login", availableLocales, enableAccountDeletion = false, heading, subHeading, profilePhotoLabel, profilePhotoRecommendation, uploadPhotoButtonLabel, removePhotoButtonLabel, profileInformationLabel, passwordLabel, currentPasswordLabel, newPasswordLabel, confirmPasswordLabel, messages, uiSizes, fileTypes, }) {
|
|
30
31
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
31
|
-
const
|
|
32
|
+
const t = useAuthT();
|
|
33
|
+
const resolvedLabels = resolveMySettingsLabels(t, labels);
|
|
32
34
|
const resolvedButtonPalette = resolveMySettingsButtonPalette(button_colors);
|
|
35
|
+
const resolvedUnauthorizedMessage = unauthorizedMessage !== null && unauthorizedMessage !== void 0 ? unauthorizedMessage : t("shared.guard.unauthorized_message_default");
|
|
36
|
+
const resolvedLoginButtonLabel = loginButtonLabel !== null && loginButtonLabel !== void 0 ? loginButtonLabel : t("shared.guard.login_button_default");
|
|
37
|
+
const resolvedHeading = heading !== null && heading !== void 0 ? heading : t("my_settings.page_title");
|
|
38
|
+
const resolvedSubHeading = subHeading !== null && subHeading !== void 0 ? subHeading : t("my_settings.sub_heading_default");
|
|
39
|
+
const resolvedProfilePhotoLabel = profilePhotoLabel !== null && profilePhotoLabel !== void 0 ? profilePhotoLabel : t("my_settings.profile_photo_label_default");
|
|
40
|
+
const resolvedProfilePhotoRecommendation = profilePhotoRecommendation !== null && profilePhotoRecommendation !== void 0 ? profilePhotoRecommendation : t("my_settings.profile_photo_recommendation_default");
|
|
41
|
+
const resolvedUploadPhotoButtonLabel = uploadPhotoButtonLabel !== null && uploadPhotoButtonLabel !== void 0 ? uploadPhotoButtonLabel : t("my_settings.upload_photo_button_default");
|
|
42
|
+
const resolvedRemovePhotoButtonLabel = removePhotoButtonLabel !== null && removePhotoButtonLabel !== void 0 ? removePhotoButtonLabel : t("my_settings.remove_photo_button_default");
|
|
43
|
+
const resolvedProfileInformationLabel = profileInformationLabel !== null && profileInformationLabel !== void 0 ? profileInformationLabel : t("my_settings.profile_information_label_default");
|
|
44
|
+
const resolvedPasswordLabel = passwordLabel !== null && passwordLabel !== void 0 ? passwordLabel : t("my_settings.password_label_default");
|
|
45
|
+
const resolvedCurrentPasswordLabel = currentPasswordLabel !== null && currentPasswordLabel !== void 0 ? currentPasswordLabel : t("my_settings.current_password_label_default");
|
|
46
|
+
const resolvedNewPasswordLabel = newPasswordLabel !== null && newPasswordLabel !== void 0 ? newPasswordLabel : t("my_settings.set_password.new_password_label");
|
|
47
|
+
const resolvedConfirmPasswordLabel = confirmPasswordLabel !== null && confirmPasswordLabel !== void 0 ? confirmPasswordLabel : t("my_settings.set_password.confirm_password_label");
|
|
48
|
+
const validateName = (name) => {
|
|
49
|
+
if (name.trim() === "") {
|
|
50
|
+
return t("my_settings.name_field.validation_empty_default");
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
};
|
|
54
|
+
const validateEmail = (email) => {
|
|
55
|
+
if (!email || email.trim() === "") {
|
|
56
|
+
return t("my_settings.email_field.validation_required_default");
|
|
57
|
+
}
|
|
58
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
59
|
+
if (!emailRegex.test(email)) {
|
|
60
|
+
return t("my_settings.email_field.validation_invalid_format_default");
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
};
|
|
33
64
|
const settings = use_my_settings({
|
|
34
65
|
passwordRequirements: password_requirements,
|
|
35
66
|
});
|
|
36
|
-
return (_jsx(UnauthorizedGuard, { message:
|
|
67
|
+
return (_jsx(UnauthorizedGuard, { message: resolvedUnauthorizedMessage, loginButtonLabel: resolvedLoginButtonLabel, loginPath: loginPath, children: _jsxs("div", { className: cn("cls_my_settings_layout flex flex-col gap-6 p-6 w-full", className), children: [_jsxs("div", { className: "cls_my_settings_layout_header flex flex-col gap-2", children: [_jsx("h1", { className: "cls_my_settings_layout_heading text-3xl font-bold text-[var(--hazo-text-primary)]", children: resolvedHeading }), _jsx("p", { className: "cls_my_settings_layout_subheading text-[var(--hazo-text-muted)]", children: resolvedSubHeading })] }), _jsxs("div", { className: "cls_my_settings_layout_profile_photo_section bg-white rounded-lg border border-[var(--hazo-border)] p-6", children: [_jsx("h2", { className: "cls_my_settings_layout_section_heading text-lg font-semibold text-[var(--hazo-text-primary)] mb-4", children: resolvedProfilePhotoLabel }), _jsx("div", { className: "cls_my_settings_layout_profile_photo_content flex flex-col items-center", children: _jsxs("div", { className: "cls_my_settings_layout_profile_photo_display relative", children: [_jsx(ProfilePictureDisplay, { profilePictureUrl: settings.profilePictureUrl, name: settings.name, email: settings.email, onEdit: settings.handleProfilePictureEdit }), _jsxs("div", { className: "cls_my_settings_layout_profile_photo_actions absolute left-0 right-0 flex items-center justify-between px-2", style: { bottom: '-20px' }, children: [_jsx(Button, { type: "button", onClick: settings.handleProfilePictureEdit, disabled: settings.loading, variant: "ghost", size: "icon", className: "cls_my_settings_layout_upload_photo_button", "aria-label": resolvedUploadPhotoButtonLabel, children: _jsx(Pencil, { className: "h-4 w-4", "aria-hidden": "true" }) }), _jsx(Button, { type: "button", onClick: settings.handleProfilePictureRemove, disabled: settings.loading || !settings.profilePictureUrl, variant: "ghost", size: "icon", className: "cls_my_settings_layout_remove_photo_button text-red-600 hover:text-red-700 hover:bg-red-50", "aria-label": resolvedRemovePhotoButtonLabel, children: _jsx(Trash2, { className: "h-4 w-4", "aria-hidden": "true" }) })] })] }) })] }), _jsxs("div", { className: "cls_my_settings_layout_profile_information_section bg-white rounded-lg border border-[var(--hazo-border)] p-6", children: [_jsx("h2", { className: "cls_my_settings_layout_section_heading text-lg font-semibold text-[var(--hazo-text-primary)] mb-4", children: resolvedProfileInformationLabel }), _jsxs("div", { className: "cls_my_settings_layout_profile_information_fields grid grid-cols-1 md:grid-cols-2 gap-6", children: [userFields.show_name_field && (_jsx(EditableField, { label: t("my_settings.name_field.label_default"), value: settings.name, type: "text", placeholder: t("my_settings.name_field.placeholder_default"), onSave: settings.handleNameSave, validation: validateName, disabled: settings.loading, ariaLabel: t("my_settings.name_field.aria_label_default") })), userFields.show_email_field && (_jsx(EditableField, { label: t("my_settings.email_field.label_default"), value: settings.email, type: "email", placeholder: t("my_settings.email_field.placeholder_default"), onSave: settings.handleEmailSave, validation: validateEmail, disabled: settings.loading, ariaLabel: t("my_settings.email_field.aria_label_default") })), _jsx(LanguagePickerSection, { availableLocales: availableLocales, currentLocale: settings.preferredLocale, onLocaleChange: settings.handlePreferredLocaleSave, disabled: settings.loading })] })] }), userFields.show_password_field && settings.hasPassword && (_jsxs("div", { className: "cls_my_settings_layout_password_section bg-white rounded-lg border border-[var(--hazo-border)] p-6", children: [_jsx("h2", { className: "cls_my_settings_layout_section_heading text-lg font-semibold text-[var(--hazo-text-primary)] mb-4", children: resolvedPasswordLabel }), _jsxs("div", { className: "cls_my_settings_layout_password_fields flex flex-col gap-6", children: [_jsx(FormFieldWrapper, { fieldId: "current-password", label: resolvedCurrentPasswordLabel, input: _jsx(PasswordField, { inputId: "current-password", ariaLabel: resolvedCurrentPasswordLabel, value: ((_a = settings.passwordFields) === null || _a === void 0 ? void 0 : _a.currentPassword) || "", placeholder: t("my_settings.current_password_placeholder_default"), autoComplete: "current-password", isVisible: ((_b = settings.passwordFields) === null || _b === void 0 ? void 0 : _b.currentPasswordVisible) || false, onChange: (value) => settings.handlePasswordFieldChange("currentPassword", value), onToggleVisibility: () => settings.togglePasswordVisibility("currentPassword"), errorMessage: (_d = (_c = settings.passwordFields) === null || _c === void 0 ? void 0 : _c.errors) === null || _d === void 0 ? void 0 : _d.currentPassword }) }), _jsxs("div", { className: "cls_my_settings_layout_password_fields_row grid grid-cols-1 md:grid-cols-2 gap-6", children: [_jsx(FormFieldWrapper, { fieldId: "new-password", label: resolvedNewPasswordLabel, input: _jsx(PasswordField, { inputId: "new-password", ariaLabel: resolvedNewPasswordLabel, value: ((_e = settings.passwordFields) === null || _e === void 0 ? void 0 : _e.newPassword) || "", placeholder: t("my_settings.set_password.new_password_placeholder"), autoComplete: "new-password", isVisible: ((_f = settings.passwordFields) === null || _f === void 0 ? void 0 : _f.newPasswordVisible) || false, onChange: (value) => settings.handlePasswordFieldChange("newPassword", value), onToggleVisibility: () => settings.togglePasswordVisibility("newPassword"), errorMessage: (_h = (_g = settings.passwordFields) === null || _g === void 0 ? void 0 : _g.errors) === null || _h === void 0 ? void 0 : _h.newPassword }) }), _jsx(FormFieldWrapper, { fieldId: "confirm-password", label: resolvedConfirmPasswordLabel, input: _jsx(PasswordField, { inputId: "confirm-password", ariaLabel: resolvedConfirmPasswordLabel, value: ((_j = settings.passwordFields) === null || _j === void 0 ? void 0 : _j.confirmPassword) || "", placeholder: t("my_settings.set_password.confirm_password_placeholder"), autoComplete: "new-password", isVisible: ((_k = settings.passwordFields) === null || _k === void 0 ? void 0 : _k.confirmPasswordVisible) || false, onChange: (value) => settings.handlePasswordFieldChange("confirmPassword", value), onToggleVisibility: () => settings.togglePasswordVisibility("confirmPassword"), errorMessage: (_m = (_l = settings.passwordFields) === null || _l === void 0 ? void 0 : _l.errors) === null || _m === void 0 ? void 0 : _m.confirmPassword }) })] })] }), _jsx("div", { className: "cls_my_settings_layout_password_actions flex justify-end mt-4", children: _jsx(Button, { type: "button", onClick: settings.handlePasswordSave, disabled: settings.loading || settings.isPasswordSaveDisabled, className: "cls_my_settings_layout_save_password_button", style: {
|
|
37
68
|
backgroundColor: resolvedButtonPalette.submitBackground,
|
|
38
69
|
color: resolvedButtonPalette.submitText,
|
|
39
|
-
}, "aria-label": "
|
|
70
|
+
}, "aria-label": t("my_settings.save_password_aria_default"), children: t("my_settings.save_password_button_default") }) })] })), !settings.hasPassword && settings.googleConnected && (_jsx(SetPasswordSection, { passwordRequirements: password_requirements, onPasswordSet: settings.refreshUserData, parentLoading: settings.loading })), _jsx(ConnectedAccountsSection, { googleConnected: settings.googleConnected || false, email: settings.email, loading: settings.loading }), _jsx(DangerZoneSection, { enabled: enableAccountDeletion, email: settings.email }), _jsx(ProfilePictureDialog, { open: settings.profilePictureDialogOpen, onOpenChange: (open) => {
|
|
40
71
|
if (open) {
|
|
41
72
|
settings.handleProfilePictureEdit();
|
|
42
73
|
}
|
|
@@ -45,26 +76,3 @@ export default function my_settings_layout({ className, labels, button_colors, p
|
|
|
45
76
|
}
|
|
46
77
|
}, onSave: settings.handleProfilePictureSave, email: settings.email, allowPhotoUpload: profilePicture.allow_photo_upload, maxPhotoSize: profilePicture.max_photo_size, libraryPhotoPath: profilePicture.library_photo_path, currentProfilePictureUrl: settings.profilePictureUrl, currentProfileSource: settings.profileSource, disabled: settings.loading, messages: messages, uiSizes: uiSizes, fileTypes: fileTypes })] }) }));
|
|
47
78
|
}
|
|
48
|
-
// section: validation_helpers
|
|
49
|
-
/**
|
|
50
|
-
* Validates name (optional, but if provided should not be empty)
|
|
51
|
-
*/
|
|
52
|
-
function validateName(name) {
|
|
53
|
-
if (name.trim() === "") {
|
|
54
|
-
return "Name cannot be empty";
|
|
55
|
-
}
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Validates email format
|
|
60
|
-
*/
|
|
61
|
-
function validateEmail(email) {
|
|
62
|
-
if (!email || email.trim() === "") {
|
|
63
|
-
return "Email is required";
|
|
64
|
-
}
|
|
65
|
-
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
66
|
-
if (!emailRegex.test(email)) {
|
|
67
|
-
return "Invalid email address format";
|
|
68
|
-
}
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/otp/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/otp/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAIhE,MAAM,WAAW,cAAc;IAC7B,mEAAmE;IACnE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,kFAAkF;IAClF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAGD,wBAAgB,SAAS,CAAC,EACxB,YAAkB,EAClB,KAAK,EACL,QAAQ,EACR,OAAO,EACP,KAAK,EACL,SAAiD,EACjD,SAAS,GACV,EAAE,cAAc,GAAG,KAAK,CAAC,YAAY,CAgCrC;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -7,13 +7,15 @@ import * as React from "react";
|
|
|
7
7
|
import { OTPRequestForm } from "../../otp/OTPRequestForm.js";
|
|
8
8
|
import { OTPVerifyForm } from "../../otp/OTPVerifyForm.js";
|
|
9
9
|
import { TwoColumnAuthLayout } from "../shared/components/two_column_auth_layout.js";
|
|
10
|
-
import
|
|
11
|
-
import { createPackageT } from "hazo_core/i18n";
|
|
12
|
-
const t = createPackageT("hazo_auth", en);
|
|
10
|
+
import { useAuthT } from "../../../contexts/hazo_auth_provider.js";
|
|
13
11
|
// section: component
|
|
14
|
-
export function OTPLayout({ redirect_url = "/", title
|
|
12
|
+
export function OTPLayout({ redirect_url = "/", title, subtitle, ctaText, theme, image_src = "/hazo_auth/images/login_default.jpg", image_alt, }) {
|
|
13
|
+
const t = useAuthT();
|
|
14
|
+
const resolvedTitle = title !== null && title !== void 0 ? title : t("otp.layout.title");
|
|
15
|
+
const resolvedSubtitle = subtitle !== null && subtitle !== void 0 ? subtitle : t("otp.layout.subtitle");
|
|
16
|
+
const resolvedImageAlt = image_alt !== null && image_alt !== void 0 ? image_alt : t("otp.layout.image_alt");
|
|
15
17
|
const [sent_to, set_sent_to] = React.useState(null);
|
|
16
|
-
const formContent = (_jsxs("div", { className: "mx-auto w-full max-w-sm py-12", children: [_jsx("h1", { className: `text-2xl font-semibold ${
|
|
17
|
-
return (_jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt:
|
|
18
|
+
const formContent = (_jsxs("div", { className: "mx-auto w-full max-w-sm py-12", children: [_jsx("h1", { className: `text-2xl font-semibold ${resolvedSubtitle ? "mb-2" : "mb-6"}`, children: resolvedTitle }), resolvedSubtitle && (_jsx("p", { className: "text-sm text-muted-foreground mb-6", children: resolvedSubtitle })), sent_to ? (_jsx(OTPVerifyForm, { email: sent_to, redirect_url: redirect_url, submit_label: ctaText })) : (_jsx(OTPRequestForm, { on_sent: (email) => set_sent_to(email) }))] }));
|
|
19
|
+
return (_jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: resolvedImageAlt, formContent: formContent }));
|
|
18
20
|
}
|
|
19
21
|
export default OTPLayout;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { LayoutFieldMap, LayoutFieldMapOverrides } from "../../shared/config/layout_customization";
|
|
2
2
|
import { type ButtonPaletteDefaults, type ButtonPaletteOverrides, type LayoutLabelDefaults, type LayoutLabelOverrides, type PasswordRequirementOptions, type PasswordRequirementOverrides } from "../../shared/config/layout_customization.js";
|
|
3
|
+
import type { AuthTFunction } from "../../../../contexts/hazo_auth_config";
|
|
3
4
|
export declare const REGISTER_FIELD_IDS: {
|
|
4
5
|
readonly NAME: "name";
|
|
5
6
|
readonly EMAIL: "email_address";
|
|
@@ -7,8 +8,8 @@ export declare const REGISTER_FIELD_IDS: {
|
|
|
7
8
|
readonly CONFIRM_PASSWORD: "confirm_password";
|
|
8
9
|
};
|
|
9
10
|
export type RegisterFieldId = (typeof REGISTER_FIELD_IDS)[keyof typeof REGISTER_FIELD_IDS];
|
|
10
|
-
export declare const createRegisterFieldDefinitions: (overrides?: LayoutFieldMapOverrides) => LayoutFieldMap;
|
|
11
|
-
export declare const resolveRegisterLabels: (overrides?: LayoutLabelOverrides) => LayoutLabelDefaults;
|
|
11
|
+
export declare const createRegisterFieldDefinitions: (t: AuthTFunction, overrides?: LayoutFieldMapOverrides) => LayoutFieldMap;
|
|
12
|
+
export declare const resolveRegisterLabels: (t: AuthTFunction, overrides?: LayoutLabelOverrides) => LayoutLabelDefaults;
|
|
12
13
|
export declare const resolveRegisterButtonPalette: (overrides?: ButtonPaletteOverrides) => ButtonPaletteDefaults;
|
|
13
14
|
export declare const resolveRegisterPasswordRequirements: (overrides?: PasswordRequirementOverrides) => PasswordRequirementOptions;
|
|
14
15
|
//# sourceMappingURL=register_field_config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register_field_config.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/register/config/register_field_config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACxG,OAAO,EAML,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,4BAA4B,EAClC,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"register_field_config.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/register/config/register_field_config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACxG,OAAO,EAML,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,4BAA4B,EAClC,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAG3E,eAAO,MAAM,kBAAkB;;;;;CAKrB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC;AA0C3F,eAAO,MAAM,8BAA8B,GACzC,GAAG,aAAa,EAChB,YAAY,uBAAuB,mBACoC,CAAC;AAU1E,eAAO,MAAM,qBAAqB,GAAI,GAAG,aAAa,EAAE,YAAY,oBAAoB,wBAC/B,CAAC;AAU1D,eAAO,MAAM,4BAA4B,GAAI,YAAY,sBAAsB,0BACZ,CAAC;AAWpE,eAAO,MAAM,mCAAmC,GAC9C,YAAY,4BAA4B,+BACiC,CAAC"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { resolveButtonPalette, resolveFieldDefinitions, resolveLabels, resolvePasswordRequirements, SHARED_EMAIL_FIELD_COPY, } from "../../shared/config/layout_customization.js";
|
|
2
|
-
import en from "../../../../locales/en.json" with { type: "json" };
|
|
3
|
-
import { createPackageT } from "hazo_core/i18n";
|
|
4
|
-
const t = createPackageT("hazo_auth", en);
|
|
5
2
|
// section: field_identifiers
|
|
6
3
|
export const REGISTER_FIELD_IDS = {
|
|
7
4
|
NAME: "name",
|
|
@@ -10,49 +7,52 @@ export const REGISTER_FIELD_IDS = {
|
|
|
10
7
|
CONFIRM_PASSWORD: "confirm_password",
|
|
11
8
|
};
|
|
12
9
|
// section: field_definitions
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
10
|
+
const buildRegisterFieldDefinitions = (t) => {
|
|
11
|
+
const sharedEmailFieldCopy = SHARED_EMAIL_FIELD_COPY(t);
|
|
12
|
+
return {
|
|
13
|
+
[REGISTER_FIELD_IDS.NAME]: {
|
|
14
|
+
id: REGISTER_FIELD_IDS.NAME,
|
|
15
|
+
label: t("register.field.name.label"),
|
|
16
|
+
type: "text",
|
|
17
|
+
autoComplete: "name",
|
|
18
|
+
placeholder: t("register.field.name.placeholder"),
|
|
19
|
+
ariaLabel: t("register.field.name.aria_label"),
|
|
20
|
+
},
|
|
21
|
+
[REGISTER_FIELD_IDS.EMAIL]: {
|
|
22
|
+
id: REGISTER_FIELD_IDS.EMAIL,
|
|
23
|
+
label: sharedEmailFieldCopy.label,
|
|
24
|
+
type: "email",
|
|
25
|
+
autoComplete: "email",
|
|
26
|
+
placeholder: sharedEmailFieldCopy.placeholder,
|
|
27
|
+
ariaLabel: sharedEmailFieldCopy.ariaLabel,
|
|
28
|
+
},
|
|
29
|
+
[REGISTER_FIELD_IDS.PASSWORD]: {
|
|
30
|
+
id: REGISTER_FIELD_IDS.PASSWORD,
|
|
31
|
+
label: t("register.field.password.label"),
|
|
32
|
+
type: "password",
|
|
33
|
+
autoComplete: "new-password",
|
|
34
|
+
placeholder: t("register.field.password.placeholder"),
|
|
35
|
+
ariaLabel: t("register.field.password.aria_label"),
|
|
36
|
+
},
|
|
37
|
+
[REGISTER_FIELD_IDS.CONFIRM_PASSWORD]: {
|
|
38
|
+
id: REGISTER_FIELD_IDS.CONFIRM_PASSWORD,
|
|
39
|
+
label: t("register.field.confirm_password.label"),
|
|
40
|
+
type: "password",
|
|
41
|
+
autoComplete: "new-password",
|
|
42
|
+
placeholder: t("register.field.confirm_password.placeholder"),
|
|
43
|
+
ariaLabel: t("register.field.confirm_password.aria_label"),
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
46
|
};
|
|
47
|
-
export const createRegisterFieldDefinitions = (overrides) => resolveFieldDefinitions(
|
|
47
|
+
export const createRegisterFieldDefinitions = (t, overrides) => resolveFieldDefinitions(buildRegisterFieldDefinitions(t), overrides);
|
|
48
48
|
// section: label_defaults
|
|
49
|
-
const
|
|
49
|
+
const buildRegisterLabelDefaults = (t) => ({
|
|
50
50
|
heading: t("register.heading"),
|
|
51
51
|
subHeading: t("register.sub_heading"),
|
|
52
52
|
submitButton: t("register.submit_button"),
|
|
53
53
|
cancelButton: t("shared.cancel_button"),
|
|
54
|
-
};
|
|
55
|
-
export const resolveRegisterLabels = (overrides) => resolveLabels(
|
|
54
|
+
});
|
|
55
|
+
export const resolveRegisterLabels = (t, overrides) => resolveLabels(buildRegisterLabelDefaults(t), overrides);
|
|
56
56
|
// section: button_palette_defaults
|
|
57
57
|
const REGISTER_BUTTON_PALETTE_DEFAULTS = {
|
|
58
58
|
submitBackground: "#0f172a",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_register_form.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/register/hooks/use_register_form.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,KAAK,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AACzH,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAG3F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"use_register_form.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/register/hooks/use_register_form.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,KAAK,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AACzH,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAG3F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AASvE,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AACjE,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,GAAG;IACrF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AACF,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAC1C,OAAO,CAAC,eAAe,EAAE,UAAU,GAAG,kBAAkB,CAAC,EACzD,OAAO,CACR,CAAC;AAEF,MAAM,MAAM,qBAAqB,CAAC,OAAO,GAAG,OAAO,IAAI;IACrD,aAAa,EAAE,OAAO,CAAC;IACvB,oBAAoB,EAAE,0BAA0B,CAAC;IACjD,4BAA4B,CAAC,EAAE,4BAA4B,CAAC;IAC5D,UAAU,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,kBAAkB,EAAE,uBAAuB,CAAC;IAC5C,gBAAgB,EAAE,OAAO,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,iBAAiB,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrE,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,wBAAwB,EAAE,CAAC,OAAO,EAAE,UAAU,GAAG,kBAAkB,KAAK,IAAI,CAAC;IAC7E,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;IAChE,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,yBAAyB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAClE,CAAC;AAYF,eAAO,MAAM,iBAAiB,GAAI,OAAO,EAAG,6EAMzC,qBAAqB,CAAC,OAAO,CAAC,KAAG,qBAgRnC,CAAC"}
|