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.
Files changed (238) hide show
  1. package/README.md +6 -0
  2. package/SETUP_CHECKLIST.md +27 -0
  3. package/cli-src/lib/already_logged_in_config.server.ts +11 -7
  4. package/cli-src/lib/auth_hooks.ts +52 -0
  5. package/cli-src/lib/config/config_loader.server.ts +34 -0
  6. package/cli-src/lib/email_verification_config.server.ts +2 -2
  7. package/cli-src/lib/forgot_password_config.server.ts +2 -2
  8. package/cli-src/lib/login_config.server.ts +25 -19
  9. package/cli-src/lib/my_settings_config.server.ts +22 -15
  10. package/cli-src/lib/navbar_config.server.ts +12 -8
  11. package/cli-src/lib/oauth_config.server.ts +14 -22
  12. package/cli-src/lib/otp_config.server.ts +11 -4
  13. package/cli-src/lib/profile_pic_menu_config.server.ts +16 -5
  14. package/cli-src/lib/register_config.server.ts +21 -16
  15. package/cli-src/lib/reset_password_config.server.ts +11 -17
  16. package/cli-src/lib/services/oauth_service.ts +16 -0
  17. package/cli-src/lib/services/otp_service.ts +7 -0
  18. package/cli-src/lib/services/registration_service.ts +8 -0
  19. package/cli-src/lib/ui_shell_config.server.ts +11 -13
  20. package/dist/components/layouts/create_firm/index.d.ts.map +1 -1
  21. package/dist/components/layouts/create_firm/index.js +4 -3
  22. package/dist/components/layouts/dev_lock/index.d.ts.map +1 -1
  23. package/dist/components/layouts/dev_lock/index.js +4 -2
  24. package/dist/components/layouts/email_verification/config/email_verification_field_config.d.ts +5 -4
  25. package/dist/components/layouts/email_verification/config/email_verification_field_config.d.ts.map +1 -1
  26. package/dist/components/layouts/email_verification/config/email_verification_field_config.js +20 -20
  27. package/dist/components/layouts/email_verification/hooks/use_email_verification.d.ts.map +1 -1
  28. package/dist/components/layouts/email_verification/hooks/use_email_verification.js +5 -7
  29. package/dist/components/layouts/email_verification/index.d.ts.map +1 -1
  30. package/dist/components/layouts/email_verification/index.js +13 -12
  31. package/dist/components/layouts/forgot_password/config/forgot_password_field_config.d.ts +3 -2
  32. package/dist/components/layouts/forgot_password/config/forgot_password_field_config.d.ts.map +1 -1
  33. package/dist/components/layouts/forgot_password/config/forgot_password_field_config.js +16 -16
  34. package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.d.ts.map +1 -1
  35. package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.js +5 -7
  36. package/dist/components/layouts/forgot_password/index.d.ts.map +1 -1
  37. package/dist/components/layouts/forgot_password/index.js +15 -9
  38. package/dist/components/layouts/legal/legal_acceptance_gate.d.ts.map +1 -1
  39. package/dist/components/layouts/legal/legal_acceptance_gate.js +5 -3
  40. package/dist/components/layouts/legal/legal_doc_checkbox_list.d.ts.map +1 -1
  41. package/dist/components/layouts/legal/legal_doc_checkbox_list.js +3 -1
  42. package/dist/components/layouts/legal/legal_doc_combined_view.d.ts.map +1 -1
  43. package/dist/components/layouts/legal/legal_doc_combined_view.js +3 -1
  44. package/dist/components/layouts/login/config/login_field_config.d.ts +3 -2
  45. package/dist/components/layouts/login/config/login_field_config.d.ts.map +1 -1
  46. package/dist/components/layouts/login/config/login_field_config.js +24 -24
  47. package/dist/components/layouts/login/hooks/use_login_form.d.ts.map +1 -1
  48. package/dist/components/layouts/login/hooks/use_login_form.js +5 -7
  49. package/dist/components/layouts/login/index.d.ts +4 -4
  50. package/dist/components/layouts/login/index.d.ts.map +1 -1
  51. package/dist/components/layouts/login/index.js +30 -22
  52. package/dist/components/layouts/my_settings/components/connected_accounts_section.d.ts.map +1 -1
  53. package/dist/components/layouts/my_settings/components/connected_accounts_section.js +5 -5
  54. package/dist/components/layouts/my_settings/components/danger_zone_section.d.ts.map +1 -1
  55. package/dist/components/layouts/my_settings/components/danger_zone_section.js +12 -6
  56. package/dist/components/layouts/my_settings/components/editable_field.d.ts.map +1 -1
  57. package/dist/components/layouts/my_settings/components/editable_field.js +4 -2
  58. package/dist/components/layouts/my_settings/components/language_picker_section.d.ts.map +1 -1
  59. package/dist/components/layouts/my_settings/components/language_picker_section.js +7 -3
  60. package/dist/components/layouts/my_settings/components/password_change_dialog.d.ts.map +1 -1
  61. package/dist/components/layouts/my_settings/components/password_change_dialog.js +28 -21
  62. package/dist/components/layouts/my_settings/components/profile_picture_dialog.d.ts.map +1 -1
  63. package/dist/components/layouts/my_settings/components/profile_picture_dialog.js +12 -9
  64. package/dist/components/layouts/my_settings/components/profile_picture_gravatar_tab.d.ts.map +1 -1
  65. package/dist/components/layouts/my_settings/components/profile_picture_gravatar_tab.js +3 -1
  66. package/dist/components/layouts/my_settings/components/profile_picture_library_tab.js +14 -11
  67. package/dist/components/layouts/my_settings/components/profile_picture_upload_tab.d.ts.map +1 -1
  68. package/dist/components/layouts/my_settings/components/profile_picture_upload_tab.js +26 -15
  69. package/dist/components/layouts/my_settings/components/set_password_section.d.ts.map +1 -1
  70. package/dist/components/layouts/my_settings/components/set_password_section.js +9 -6
  71. package/dist/components/layouts/my_settings/config/my_settings_field_config.d.ts +2 -1
  72. package/dist/components/layouts/my_settings/config/my_settings_field_config.d.ts.map +1 -1
  73. package/dist/components/layouts/my_settings/config/my_settings_field_config.js +4 -7
  74. package/dist/components/layouts/my_settings/index.d.ts.map +1 -1
  75. package/dist/components/layouts/my_settings/index.js +35 -27
  76. package/dist/components/layouts/otp/index.d.ts.map +1 -1
  77. package/dist/components/layouts/otp/index.js +8 -6
  78. package/dist/components/layouts/register/config/register_field_config.d.ts +3 -2
  79. package/dist/components/layouts/register/config/register_field_config.d.ts.map +1 -1
  80. package/dist/components/layouts/register/config/register_field_config.js +40 -40
  81. package/dist/components/layouts/register/hooks/use_register_form.d.ts.map +1 -1
  82. package/dist/components/layouts/register/hooks/use_register_form.js +7 -9
  83. package/dist/components/layouts/register/index.d.ts +4 -4
  84. package/dist/components/layouts/register/index.d.ts.map +1 -1
  85. package/dist/components/layouts/register/index.js +22 -19
  86. package/dist/components/layouts/reset_password/config/reset_password_field_config.d.ts +4 -3
  87. package/dist/components/layouts/reset_password/config/reset_password_field_config.d.ts.map +1 -1
  88. package/dist/components/layouts/reset_password/config/reset_password_field_config.js +7 -10
  89. package/dist/components/layouts/reset_password/hooks/use_reset_password_form.d.ts.map +1 -1
  90. package/dist/components/layouts/reset_password/hooks/use_reset_password_form.js +4 -6
  91. package/dist/components/layouts/reset_password/index.d.ts.map +1 -1
  92. package/dist/components/layouts/reset_password/index.js +12 -10
  93. package/dist/components/layouts/shared/components/already_logged_in_guard.d.ts.map +1 -1
  94. package/dist/components/layouts/shared/components/already_logged_in_guard.js +6 -5
  95. package/dist/components/layouts/shared/components/auth_navbar.d.ts +1 -1
  96. package/dist/components/layouts/shared/components/auth_navbar.d.ts.map +1 -1
  97. package/dist/components/layouts/shared/components/auth_navbar.js +7 -2
  98. package/dist/components/layouts/shared/components/facebook_sign_in_button.d.ts.map +1 -1
  99. package/dist/components/layouts/shared/components/facebook_sign_in_button.js +5 -5
  100. package/dist/components/layouts/shared/components/floating_home_link.d.ts.map +1 -1
  101. package/dist/components/layouts/shared/components/floating_home_link.js +6 -3
  102. package/dist/components/layouts/shared/components/form_action_buttons.d.ts.map +1 -1
  103. package/dist/components/layouts/shared/components/form_action_buttons.js +9 -7
  104. package/dist/components/layouts/shared/components/google_sign_in_button.d.ts.map +1 -1
  105. package/dist/components/layouts/shared/components/google_sign_in_button.js +5 -5
  106. package/dist/components/layouts/shared/components/logout_button.d.ts.map +1 -1
  107. package/dist/components/layouts/shared/components/logout_button.js +2 -4
  108. package/dist/components/layouts/shared/components/oauth_divider.d.ts.map +1 -1
  109. package/dist/components/layouts/shared/components/oauth_divider.js +8 -6
  110. package/dist/components/layouts/shared/components/password_field.d.ts.map +1 -1
  111. package/dist/components/layouts/shared/components/password_field.js +2 -3
  112. package/dist/components/layouts/shared/components/profile_pic_menu.d.ts +4 -0
  113. package/dist/components/layouts/shared/components/profile_pic_menu.d.ts.map +1 -1
  114. package/dist/components/layouts/shared/components/profile_pic_menu.js +26 -18
  115. package/dist/components/layouts/shared/components/profile_pic_menu_wrapper.d.ts +1 -0
  116. package/dist/components/layouts/shared/components/profile_pic_menu_wrapper.d.ts.map +1 -1
  117. package/dist/components/layouts/shared/components/profile_pic_menu_wrapper.js +1 -1
  118. package/dist/components/layouts/shared/components/sidebar_layout_wrapper.d.ts.map +1 -1
  119. package/dist/components/layouts/shared/components/sidebar_layout_wrapper.js +3 -1
  120. package/dist/components/layouts/shared/components/standalone_layout_wrapper.d.ts.map +1 -1
  121. package/dist/components/layouts/shared/components/standalone_layout_wrapper.js +6 -2
  122. package/dist/components/layouts/shared/components/unauthorized_guard.d.ts.map +1 -1
  123. package/dist/components/layouts/shared/components/unauthorized_guard.js +6 -5
  124. package/dist/components/layouts/shared/config/layout_customization.d.ts +2 -1
  125. package/dist/components/layouts/shared/config/layout_customization.d.ts.map +1 -1
  126. package/dist/components/layouts/shared/config/layout_customization.js +18 -7
  127. package/dist/components/layouts/shared/utils/validation.d.ts +5 -2
  128. package/dist/components/layouts/shared/utils/validation.d.ts.map +1 -1
  129. package/dist/components/layouts/shared/utils/validation.js +4 -8
  130. package/dist/components/layouts/user_management/components/roles_matrix.d.ts.map +1 -1
  131. package/dist/components/layouts/user_management/components/roles_matrix.js +2 -4
  132. package/dist/components/layouts/user_management/components/scope_hierarchy_tab.d.ts.map +1 -1
  133. package/dist/components/layouts/user_management/components/scope_hierarchy_tab.js +6 -8
  134. package/dist/components/layouts/user_management/components/user_scopes_tab.d.ts.map +1 -1
  135. package/dist/components/layouts/user_management/components/user_scopes_tab.js +2 -4
  136. package/dist/components/layouts/user_management/index.d.ts.map +1 -1
  137. package/dist/components/layouts/user_management/index.js +2 -4
  138. package/dist/components/otp/OTPRequestForm.d.ts.map +1 -1
  139. package/dist/components/otp/OTPRequestForm.js +7 -5
  140. package/dist/components/otp/OTPVerifyForm.d.ts.map +1 -1
  141. package/dist/components/otp/OTPVerifyForm.js +7 -5
  142. package/dist/components/permission_denied_dialog.client.d.ts.map +1 -1
  143. package/dist/components/permission_denied_dialog.client.js +6 -6
  144. package/dist/components/ui/sheet.d.ts +1 -1
  145. package/dist/components/ui/sidebar.js +5 -5
  146. package/dist/contexts/hazo_auth_config.d.ts +13 -0
  147. package/dist/contexts/hazo_auth_config.d.ts.map +1 -1
  148. package/dist/contexts/hazo_auth_config.js +4 -1
  149. package/dist/contexts/hazo_auth_provider.d.ts +22 -2
  150. package/dist/contexts/hazo_auth_provider.d.ts.map +1 -1
  151. package/dist/contexts/hazo_auth_provider.js +18 -2
  152. package/dist/lib/already_logged_in_config.server.d.ts +4 -2
  153. package/dist/lib/already_logged_in_config.server.d.ts.map +1 -1
  154. package/dist/lib/already_logged_in_config.server.js +7 -5
  155. package/dist/lib/auth_hooks.d.ts +20 -0
  156. package/dist/lib/auth_hooks.d.ts.map +1 -0
  157. package/dist/lib/auth_hooks.js +32 -0
  158. package/dist/lib/config/config_loader.server.d.ts +23 -0
  159. package/dist/lib/config/config_loader.server.d.ts.map +1 -1
  160. package/dist/lib/config/config_loader.server.js +29 -0
  161. package/dist/lib/email_verification_config.server.d.ts +2 -2
  162. package/dist/lib/email_verification_config.server.d.ts.map +1 -1
  163. package/dist/lib/forgot_password_config.server.d.ts +2 -2
  164. package/dist/lib/forgot_password_config.server.d.ts.map +1 -1
  165. package/dist/lib/login_config.server.d.ts +8 -5
  166. package/dist/lib/login_config.server.d.ts.map +1 -1
  167. package/dist/lib/login_config.server.js +13 -6
  168. package/dist/lib/my_settings_config.server.d.ts.map +1 -1
  169. package/dist/lib/my_settings_config.server.js +22 -15
  170. package/dist/lib/navbar_config.server.d.ts +3 -2
  171. package/dist/lib/navbar_config.server.d.ts.map +1 -1
  172. package/dist/lib/navbar_config.server.js +4 -2
  173. package/dist/lib/oauth_config.server.d.ts +6 -6
  174. package/dist/lib/oauth_config.server.d.ts.map +1 -1
  175. package/dist/lib/oauth_config.server.js +8 -4
  176. package/dist/lib/otp_config.server.d.ts +2 -2
  177. package/dist/lib/otp_config.server.d.ts.map +1 -1
  178. package/dist/lib/otp_config.server.js +4 -2
  179. package/dist/lib/profile_pic_menu_config.server.d.ts +6 -2
  180. package/dist/lib/profile_pic_menu_config.server.d.ts.map +1 -1
  181. package/dist/lib/profile_pic_menu_config.server.js +5 -3
  182. package/dist/lib/register_config.server.d.ts +7 -6
  183. package/dist/lib/register_config.server.d.ts.map +1 -1
  184. package/dist/lib/register_config.server.js +8 -4
  185. package/dist/lib/reset_password_config.server.d.ts +6 -4
  186. package/dist/lib/reset_password_config.server.d.ts.map +1 -1
  187. package/dist/lib/reset_password_config.server.js +5 -5
  188. package/dist/lib/services/oauth_service.d.ts.map +1 -1
  189. package/dist/lib/services/oauth_service.js +13 -0
  190. package/dist/lib/services/otp_service.d.ts.map +1 -1
  191. package/dist/lib/services/otp_service.js +6 -0
  192. package/dist/lib/services/registration_service.d.ts.map +1 -1
  193. package/dist/lib/services/registration_service.js +7 -0
  194. package/dist/lib/ui_shell_config.server.d.ts +6 -2
  195. package/dist/lib/ui_shell_config.server.d.ts.map +1 -1
  196. package/dist/lib/ui_shell_config.server.js +5 -3
  197. package/dist/locales/en.json +135 -1
  198. package/dist/server-lib.d.ts +2 -0
  199. package/dist/server-lib.d.ts.map +1 -1
  200. package/dist/server-lib.js +2 -0
  201. package/dist/server_pages/forgot_password.d.ts +3 -2
  202. package/dist/server_pages/forgot_password.d.ts.map +1 -1
  203. package/dist/server_pages/forgot_password.js +8 -7
  204. package/dist/server_pages/forgot_password_client_wrapper.d.ts +2 -1
  205. package/dist/server_pages/forgot_password_client_wrapper.d.ts.map +1 -1
  206. package/dist/server_pages/forgot_password_client_wrapper.js +3 -1
  207. package/dist/server_pages/login.d.ts.map +1 -1
  208. package/dist/server_pages/login.js +9 -7
  209. package/dist/server_pages/login_client_wrapper.d.ts.map +1 -1
  210. package/dist/server_pages/login_client_wrapper.js +3 -1
  211. package/dist/server_pages/otp.d.ts +6 -3
  212. package/dist/server_pages/otp.d.ts.map +1 -1
  213. package/dist/server_pages/otp.js +11 -8
  214. package/dist/server_pages/register.d.ts.map +1 -1
  215. package/dist/server_pages/register.js +7 -6
  216. package/dist/server_pages/register_client_wrapper.d.ts.map +1 -1
  217. package/dist/server_pages/register_client_wrapper.js +3 -1
  218. package/dist/server_pages/reset_password.d.ts.map +1 -1
  219. package/dist/server_pages/reset_password.js +7 -6
  220. package/dist/server_pages/reset_password_client_wrapper.d.ts.map +1 -1
  221. package/dist/server_pages/reset_password_client_wrapper.js +3 -1
  222. package/dist/server_pages/verify_email.d.ts.map +1 -1
  223. package/dist/server_pages/verify_email.js +6 -5
  224. package/dist/server_pages/verify_email_client_wrapper.d.ts.map +1 -1
  225. package/dist/server_pages/verify_email_client_wrapper.js +4 -2
  226. package/dist/strings/default_strings.d.ts +15 -0
  227. package/dist/strings/default_strings.d.ts.map +1 -1
  228. package/dist/strings/default_strings.js +53 -0
  229. package/dist/strings/index.d.ts +1 -1
  230. package/dist/strings/index.d.ts.map +1 -1
  231. package/dist/strings/index.js +1 -1
  232. package/dist/strings/strings_context.d.ts +20 -3
  233. package/dist/strings/strings_context.d.ts.map +1 -1
  234. package/dist/strings/strings_context.js +39 -5
  235. package/dist/strings/strings_provider.d.ts +1 -5
  236. package/dist/strings/strings_provider.d.ts.map +1 -1
  237. package/dist/strings/strings_provider.js +5 -1
  238. 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 = "Crop photo", cropConfirmLabel = "Save photo", cropCancelLabel = "Cancel", cropZoomLabel = "Zoom", }) {
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(`File is too large. Maximum size is ${Math.round(maxSize / 1024)}KB. After compression, file is ${Math.round(compressedFile.size / 1024)}KB.`);
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 : "Failed to compress image";
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 : "Failed to process image";
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(`Invalid file type. Only ${allowedImageMimeTypes.map(t => t.split("/")[1].toUpperCase()).join(", ")} files are allowed.`);
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(`File is too large. Maximum size is ${Math.round(maxSize / 1024)}KB.`);
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("Photo upload is not enabled");
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("Photo upload is not enabled");
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": "Use uploaded photo" }), _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: "Use uploaded photo" })] }), !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: "Upload Photo" }), _jsxs("div", { className: `
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": "Upload profile picture" }), _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: "Drag and drop an image here, or click to select" }), _jsxs("p", { className: "cls_profile_picture_upload_tab_dropzone_hint text-xs text-[var(--hazo-text-muted)] text-center mt-1", children: ["JPG or PNG, max ", Math.round(maxSize / 1024), "KB"] })] }), 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 ? "Preview (new)" : "Preview (current)" }), _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: "Compressing image..." })] })) : 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: "Uploading..." })] })) : 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: "Uploaded profile picture preview", 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": "Remove preview", 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: "Preview of your uploaded photo" })] })) : (_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: "Upload an image to see preview" })] })) })] })] }), _jsx(HazoUiImageCropperDialog, { open: cropFile !== null, onOpenChange: (open) => { if (!open && !uploading && !compressing)
199
- setCropFile(null); }, file: cropFile, onConfirm: handle_crop_confirm, title: cropTitle, confirmLabel: cropConfirmLabel, cancelLabel: cropCancelLabel, zoomLabel: cropZoomLabel })] }));
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;AAQ3F,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,OAA+C,EAC/C,WAAuD,EACvD,gBAAmE,EACnE,oBAA2E,EAC3E,iBAA+D,EAC/D,aAAqB,GACtB,EAAE,uBAAuB,+BAsNzB"}
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 = t("my_settings.set_password.heading"), description = t("my_settings.set_password.description"), newPasswordLabel = t("my_settings.set_password.new_password_label"), confirmPasswordLabel = t("my_settings.set_password.confirm_password_label"), submitButtonLabel = t("my_settings.set_password.submit_button"), parentLoading = false, }) {
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: heading }), _jsx("p", { className: "cls_set_password_description text-sm text-[var(--hazo-text-muted)] mb-4", children: description }), _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: newPasswordLabel, input: _jsx(PasswordField, { inputId: "set-new-password", ariaLabel: newPasswordLabel, 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: confirmPasswordLabel, input: _jsx(PasswordField, { inputId: "set-confirm-password", ariaLabel: confirmPasswordLabel, 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": submitButtonLabel, children: loading ? t("my_settings.set_password.submitting") : submitButtonLabel }) })] })] }));
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;AAOlD,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,YAAY,wBAAwB,KACnC,uBAKF,CAAC;AAUF,eAAO,MAAM,8BAA8B,GACzC,YAAY,sBAAsB,0BACqC,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 MY_SETTINGS_LABEL_DEFAULTS = {
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({}, MY_SETTINGS_LABEL_DEFAULTS), overrides);
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":"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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/my_settings/index.tsx"],"names":[],"mappings":"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"}
@@ -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 = "You must be logged in to access this page.", loginButtonLabel = "Go to login", loginPath = "/hazo_auth/login", availableLocales, enableAccountDeletion = false, heading = "Account Settings", subHeading = "Manage your profile, password, and email preferences.", profilePhotoLabel = "Profile Photo", profilePhotoRecommendation = "Recommended size: 200x200px. JPG, PNG.", uploadPhotoButtonLabel = "Upload New Photo", removePhotoButtonLabel = "Remove", profileInformationLabel = "Profile Information", passwordLabel = "Password", currentPasswordLabel = "Current Password", newPasswordLabel = "New Password", confirmPasswordLabel = "Confirm Password", messages, uiSizes, fileTypes, }) {
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 resolvedLabels = resolveMySettingsLabels(labels);
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: unauthorizedMessage, loginButtonLabel: loginButtonLabel, 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: heading }), _jsx("p", { className: "cls_my_settings_layout_subheading text-[var(--hazo-text-muted)]", children: subHeading })] }), _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: profilePhotoLabel }), _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": uploadPhotoButtonLabel, 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": removePhotoButtonLabel, 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: profileInformationLabel }), _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: "Full Name", value: settings.name, type: "text", placeholder: "Enter your full name", onSave: settings.handleNameSave, validation: validateName, disabled: settings.loading, ariaLabel: "Full name input field" })), userFields.show_email_field && (_jsx(EditableField, { label: "Email Address", value: settings.email, type: "email", placeholder: "Enter your email address", onSave: settings.handleEmailSave, validation: validateEmail, disabled: settings.loading, ariaLabel: "Email address input field" })), _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: passwordLabel }), _jsxs("div", { className: "cls_my_settings_layout_password_fields flex flex-col gap-6", children: [_jsx(FormFieldWrapper, { fieldId: "current-password", label: currentPasswordLabel, input: _jsx(PasswordField, { inputId: "current-password", ariaLabel: currentPasswordLabel, value: ((_a = settings.passwordFields) === null || _a === void 0 ? void 0 : _a.currentPassword) || "", placeholder: "Enter your current password", 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: newPasswordLabel, input: _jsx(PasswordField, { inputId: "new-password", ariaLabel: newPasswordLabel, value: ((_e = settings.passwordFields) === null || _e === void 0 ? void 0 : _e.newPassword) || "", placeholder: "Enter your new password", 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: confirmPasswordLabel, input: _jsx(PasswordField, { inputId: "confirm-password", ariaLabel: confirmPasswordLabel, value: ((_j = settings.passwordFields) === null || _j === void 0 ? void 0 : _j.confirmPassword) || "", placeholder: "Confirm your new password", 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: {
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": "Save password", children: "Save Password" }) })] })), !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) => {
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;AAOhE,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,KAA6B,EAC7B,QAAQ,EACR,OAAO,EACP,KAAK,EACL,SAAiD,EACjD,SAAqC,GACtC,EAAE,cAAc,GAAG,KAAK,CAAC,YAAY,CA4BrC;AAED,eAAe,SAAS,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 en from "../../../locales/en.json" with { type: "json" };
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 = t("otp.layout.title"), subtitle, ctaText, theme, image_src = "/hazo_auth/images/login_default.jpg", image_alt = t("otp.layout.image_alt"), }) {
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 ${subtitle ? "mb-2" : "mb-6"}`, children: title }), subtitle && (_jsx("p", { className: "text-sm text-muted-foreground mb-6", children: subtitle })), sent_to ? (_jsx(OTPVerifyForm, { email: sent_to, redirect_url: redirect_url, submit_label: ctaText })) : (_jsx(OTPRequestForm, { on_sent: (email) => set_sent_to(email) }))] }));
17
- return (_jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, formContent: formContent }));
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;AAOlD,eAAO,MAAM,kBAAkB;;;;;CAKrB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC;AAsC3F,eAAO,MAAM,8BAA8B,GACzC,YAAY,uBAAuB,mBAC8B,CAAC;AAUpE,eAAO,MAAM,qBAAqB,GAAI,YAAY,oBAAoB,wBACnB,CAAC;AAUpD,eAAO,MAAM,4BAA4B,GAAI,YAAY,sBAAsB,0BACZ,CAAC;AAWpE,eAAO,MAAM,mCAAmC,GAC9C,YAAY,4BAA4B,+BACiC,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 REGISTER_FIELD_DEFINITIONS = {
14
- [REGISTER_FIELD_IDS.NAME]: {
15
- id: REGISTER_FIELD_IDS.NAME,
16
- label: t("register.field.name.label"),
17
- type: "text",
18
- autoComplete: "name",
19
- placeholder: t("register.field.name.placeholder"),
20
- ariaLabel: t("register.field.name.aria_label"),
21
- },
22
- [REGISTER_FIELD_IDS.EMAIL]: {
23
- id: REGISTER_FIELD_IDS.EMAIL,
24
- label: SHARED_EMAIL_FIELD_COPY.label,
25
- type: "email",
26
- autoComplete: "email",
27
- placeholder: SHARED_EMAIL_FIELD_COPY.placeholder,
28
- ariaLabel: SHARED_EMAIL_FIELD_COPY.ariaLabel,
29
- },
30
- [REGISTER_FIELD_IDS.PASSWORD]: {
31
- id: REGISTER_FIELD_IDS.PASSWORD,
32
- label: t("register.field.password.label"),
33
- type: "password",
34
- autoComplete: "new-password",
35
- placeholder: t("register.field.password.placeholder"),
36
- ariaLabel: t("register.field.password.aria_label"),
37
- },
38
- [REGISTER_FIELD_IDS.CONFIRM_PASSWORD]: {
39
- id: REGISTER_FIELD_IDS.CONFIRM_PASSWORD,
40
- label: t("register.field.confirm_password.label"),
41
- type: "password",
42
- autoComplete: "new-password",
43
- placeholder: t("register.field.confirm_password.placeholder"),
44
- ariaLabel: t("register.field.confirm_password.aria_label"),
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(REGISTER_FIELD_DEFINITIONS, overrides);
47
+ export const createRegisterFieldDefinitions = (t, overrides) => resolveFieldDefinitions(buildRegisterFieldDefinitions(t), overrides);
48
48
  // section: label_defaults
49
- const REGISTER_LABEL_DEFAULTS = {
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(REGISTER_LABEL_DEFAULTS, overrides);
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;AAavE,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,qBA6QnC,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"}