@thetechfossil/auth2 1.2.16 → 1.2.18

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.
@@ -4137,6 +4137,96 @@ var ChangePassword = ({ onSuccess, appearance }) => {
4137
4137
  )
4138
4138
  ] }) });
4139
4139
  };
4140
+
4141
+ // src/react/components/utils/injectModalStyles.ts
4142
+ var injectModalStyles = () => {
4143
+ if (document.getElementById("ttf-auth-modal-styles")) {
4144
+ return;
4145
+ }
4146
+ const styleElement = document.createElement("style");
4147
+ styleElement.id = "ttf-auth-modal-styles";
4148
+ styleElement.textContent = `
4149
+ /* ImageManager Modal Styles - Critical for proper modal display */
4150
+ /* Radix UI Dialog styles - Force visibility */
4151
+ [data-radix-portal] {
4152
+ z-index: 99999 !important;
4153
+ position: fixed !important;
4154
+ inset: 0 !important;
4155
+ pointer-events: none !important;
4156
+ }
4157
+
4158
+ [data-radix-portal] > * {
4159
+ pointer-events: auto !important;
4160
+ }
4161
+
4162
+ /* Dialog Overlay */
4163
+ [data-state="open"][data-radix-dialog-overlay],
4164
+ [role="dialog"] + [data-radix-dialog-overlay] {
4165
+ position: fixed !important;
4166
+ inset: 0 !important;
4167
+ z-index: 99998 !important;
4168
+ background-color: rgba(0, 0, 0, 0.6) !important;
4169
+ pointer-events: auto !important;
4170
+ }
4171
+
4172
+ /* Dialog Content - Center the modal properly */
4173
+ [data-state="open"][data-radix-dialog-content],
4174
+ [role="dialog"][data-radix-dialog-content] {
4175
+ position: fixed !important;
4176
+ left: 50% !important;
4177
+ top: 50% !important;
4178
+ transform: translate(-50%, -50%) !important;
4179
+ z-index: 99999 !important;
4180
+ background: white !important;
4181
+ border-radius: 16px !important;
4182
+ box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
4183
+ pointer-events: auto !important;
4184
+ width: 95vw !important;
4185
+ max-width: 1280px !important;
4186
+ height: 90vh !important;
4187
+ max-height: 90vh !important;
4188
+ min-width: 800px !important;
4189
+ min-height: 600px !important;
4190
+ overflow: hidden !important;
4191
+ }
4192
+
4193
+ /* Dark mode support */
4194
+ .dark [data-state="open"][data-radix-dialog-content],
4195
+ .dark [role="dialog"][data-radix-dialog-content] {
4196
+ background: #0f172a !important;
4197
+ border: 1px solid #334155 !important;
4198
+ }
4199
+ `;
4200
+ document.head.appendChild(styleElement);
4201
+ };
4202
+
4203
+ // src/react/components/utils/getAnonymousUserId.ts
4204
+ var ANONYMOUS_USER_ID_KEY = "ttf_auth_anonymous_user_id";
4205
+ function generateUUID() {
4206
+ if (typeof crypto !== "undefined" && crypto.randomUUID) {
4207
+ return crypto.randomUUID();
4208
+ }
4209
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
4210
+ const r = Math.random() * 16 | 0;
4211
+ const v = c === "x" ? r : r & 3 | 8;
4212
+ return v.toString(16);
4213
+ });
4214
+ }
4215
+ function getAnonymousUserId() {
4216
+ if (typeof window === "undefined" || typeof localStorage === "undefined") {
4217
+ return null;
4218
+ }
4219
+ try {
4220
+ let anonymousId = localStorage.getItem(ANONYMOUS_USER_ID_KEY);
4221
+ if (!anonymousId) {
4222
+ anonymousId = generateUUID();
4223
+ localStorage.setItem(ANONYMOUS_USER_ID_KEY, anonymousId);
4224
+ }
4225
+ return anonymousId;
4226
+ } catch {
4227
+ return generateUUID();
4228
+ }
4229
+ }
4140
4230
  var AvatarUploader = ({
4141
4231
  onUploadComplete,
4142
4232
  onError,
@@ -4147,13 +4237,25 @@ var AvatarUploader = ({
4147
4237
  upfilesConfig,
4148
4238
  buttonText = "Upload Avatar"
4149
4239
  }) => {
4150
- const { uploadAndUpdateAvatar } = useAuth2();
4240
+ const { user, updateProfile } = useAuth2();
4151
4241
  const [open, setOpen] = React.useState(false);
4152
4242
  const [uploading, setUploading] = React.useState(false);
4243
+ React.useEffect(() => {
4244
+ injectModalStyles();
4245
+ }, []);
4246
+ const effectiveFolderPath = React.useMemo(() => {
4247
+ if (user?.id) {
4248
+ return `users/${user.id}/`;
4249
+ }
4250
+ const anonymousId = getAnonymousUserId();
4251
+ if (anonymousId) {
4252
+ return `anonymous/${anonymousId}/`;
4253
+ }
4254
+ return upfilesConfig.folderPath || "/";
4255
+ }, [user?.id, upfilesConfig.folderPath]);
4153
4256
  const handleSelect = async (image) => {
4154
4257
  setUploading(true);
4155
4258
  try {
4156
- const { updateProfile } = useAuth2();
4157
4259
  const response = await updateProfile({ avatar: image.url });
4158
4260
  if (response.success && response.user?.avatar) {
4159
4261
  onUploadComplete?.(response.user.avatar);
@@ -4192,7 +4294,7 @@ var AvatarUploader = ({
4192
4294
  presignPath: upfilesConfig.presignPath
4193
4295
  },
4194
4296
  projectId: upfilesConfig.projectId,
4195
- folderPath: upfilesConfig.folderPath || "avatars/",
4297
+ folderPath: effectiveFolderPath,
4196
4298
  title: "Select Avatar",
4197
4299
  description: "Upload a new avatar or select from existing images.",
4198
4300
  mode: "full",
@@ -4519,8 +4621,21 @@ var AvatarManager = ({
4519
4621
  onDelete,
4520
4622
  upfilesConfig
4521
4623
  }) => {
4522
- const { updateProfile } = useAuth2();
4624
+ const { user, updateProfile } = useAuth2();
4523
4625
  const [updating, setUpdating] = React.useState(false);
4626
+ React.useEffect(() => {
4627
+ injectModalStyles();
4628
+ }, []);
4629
+ const effectiveFolderPath = React.useMemo(() => {
4630
+ if (user?.id) {
4631
+ return `users/${user.id}/`;
4632
+ }
4633
+ const anonymousId = getAnonymousUserId();
4634
+ if (anonymousId) {
4635
+ return `anonymous/${anonymousId}/`;
4636
+ }
4637
+ return upfilesConfig.folderPath || "/";
4638
+ }, [user?.id, upfilesConfig.folderPath]);
4524
4639
  const handleSelect = async (image) => {
4525
4640
  setUpdating(true);
4526
4641
  try {
@@ -4553,7 +4668,7 @@ var AvatarManager = ({
4553
4668
  withCredentials: upfilesConfig.withCredentials
4554
4669
  },
4555
4670
  projectId,
4556
- folderPath: upfilesConfig.folderPath || "/",
4671
+ folderPath: effectiveFolderPath,
4557
4672
  title,
4558
4673
  description,
4559
4674
  className,