@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.
@@ -4459,6 +4459,96 @@ var ChangePassword = ({ onSuccess, appearance }) => {
4459
4459
  )
4460
4460
  ] }) });
4461
4461
  };
4462
+
4463
+ // src/react/components/utils/injectModalStyles.ts
4464
+ var injectModalStyles = () => {
4465
+ if (document.getElementById("ttf-auth-modal-styles")) {
4466
+ return;
4467
+ }
4468
+ const styleElement = document.createElement("style");
4469
+ styleElement.id = "ttf-auth-modal-styles";
4470
+ styleElement.textContent = `
4471
+ /* ImageManager Modal Styles - Critical for proper modal display */
4472
+ /* Radix UI Dialog styles - Force visibility */
4473
+ [data-radix-portal] {
4474
+ z-index: 99999 !important;
4475
+ position: fixed !important;
4476
+ inset: 0 !important;
4477
+ pointer-events: none !important;
4478
+ }
4479
+
4480
+ [data-radix-portal] > * {
4481
+ pointer-events: auto !important;
4482
+ }
4483
+
4484
+ /* Dialog Overlay */
4485
+ [data-state="open"][data-radix-dialog-overlay],
4486
+ [role="dialog"] + [data-radix-dialog-overlay] {
4487
+ position: fixed !important;
4488
+ inset: 0 !important;
4489
+ z-index: 99998 !important;
4490
+ background-color: rgba(0, 0, 0, 0.6) !important;
4491
+ pointer-events: auto !important;
4492
+ }
4493
+
4494
+ /* Dialog Content - Center the modal properly */
4495
+ [data-state="open"][data-radix-dialog-content],
4496
+ [role="dialog"][data-radix-dialog-content] {
4497
+ position: fixed !important;
4498
+ left: 50% !important;
4499
+ top: 50% !important;
4500
+ transform: translate(-50%, -50%) !important;
4501
+ z-index: 99999 !important;
4502
+ background: white !important;
4503
+ border-radius: 16px !important;
4504
+ box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
4505
+ pointer-events: auto !important;
4506
+ width: 95vw !important;
4507
+ max-width: 1280px !important;
4508
+ height: 90vh !important;
4509
+ max-height: 90vh !important;
4510
+ min-width: 800px !important;
4511
+ min-height: 600px !important;
4512
+ overflow: hidden !important;
4513
+ }
4514
+
4515
+ /* Dark mode support */
4516
+ .dark [data-state="open"][data-radix-dialog-content],
4517
+ .dark [role="dialog"][data-radix-dialog-content] {
4518
+ background: #0f172a !important;
4519
+ border: 1px solid #334155 !important;
4520
+ }
4521
+ `;
4522
+ document.head.appendChild(styleElement);
4523
+ };
4524
+
4525
+ // src/react/components/utils/getAnonymousUserId.ts
4526
+ var ANONYMOUS_USER_ID_KEY = "ttf_auth_anonymous_user_id";
4527
+ function generateUUID() {
4528
+ if (typeof crypto !== "undefined" && crypto.randomUUID) {
4529
+ return crypto.randomUUID();
4530
+ }
4531
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
4532
+ const r = Math.random() * 16 | 0;
4533
+ const v = c === "x" ? r : r & 3 | 8;
4534
+ return v.toString(16);
4535
+ });
4536
+ }
4537
+ function getAnonymousUserId() {
4538
+ if (typeof window === "undefined" || typeof localStorage === "undefined") {
4539
+ return null;
4540
+ }
4541
+ try {
4542
+ let anonymousId = localStorage.getItem(ANONYMOUS_USER_ID_KEY);
4543
+ if (!anonymousId) {
4544
+ anonymousId = generateUUID();
4545
+ localStorage.setItem(ANONYMOUS_USER_ID_KEY, anonymousId);
4546
+ }
4547
+ return anonymousId;
4548
+ } catch {
4549
+ return generateUUID();
4550
+ }
4551
+ }
4462
4552
  var AvatarUploader = ({
4463
4553
  onUploadComplete,
4464
4554
  onError,
@@ -4469,13 +4559,25 @@ var AvatarUploader = ({
4469
4559
  upfilesConfig,
4470
4560
  buttonText = "Upload Avatar"
4471
4561
  }) => {
4472
- const { uploadAndUpdateAvatar } = useAuth2();
4562
+ const { user, updateProfile } = useAuth2();
4473
4563
  const [open, setOpen] = useState(false);
4474
4564
  const [uploading, setUploading] = useState(false);
4565
+ useEffect(() => {
4566
+ injectModalStyles();
4567
+ }, []);
4568
+ const effectiveFolderPath = useMemo(() => {
4569
+ if (user?.id) {
4570
+ return `users/${user.id}/`;
4571
+ }
4572
+ const anonymousId = getAnonymousUserId();
4573
+ if (anonymousId) {
4574
+ return `anonymous/${anonymousId}/`;
4575
+ }
4576
+ return upfilesConfig.folderPath || "/";
4577
+ }, [user?.id, upfilesConfig.folderPath]);
4475
4578
  const handleSelect = async (image) => {
4476
4579
  setUploading(true);
4477
4580
  try {
4478
- const { updateProfile } = useAuth2();
4479
4581
  const response = await updateProfile({ avatar: image.url });
4480
4582
  if (response.success && response.user?.avatar) {
4481
4583
  onUploadComplete?.(response.user.avatar);
@@ -4514,7 +4616,7 @@ var AvatarUploader = ({
4514
4616
  presignPath: upfilesConfig.presignPath
4515
4617
  },
4516
4618
  projectId: upfilesConfig.projectId,
4517
- folderPath: upfilesConfig.folderPath || "avatars/",
4619
+ folderPath: effectiveFolderPath,
4518
4620
  title: "Select Avatar",
4519
4621
  description: "Upload a new avatar or select from existing images.",
4520
4622
  mode: "full",
@@ -4841,8 +4943,21 @@ var AvatarManager = ({
4841
4943
  onDelete,
4842
4944
  upfilesConfig
4843
4945
  }) => {
4844
- const { updateProfile } = useAuth2();
4946
+ const { user, updateProfile } = useAuth2();
4845
4947
  const [updating, setUpdating] = useState(false);
4948
+ useEffect(() => {
4949
+ injectModalStyles();
4950
+ }, []);
4951
+ const effectiveFolderPath = useMemo(() => {
4952
+ if (user?.id) {
4953
+ return `users/${user.id}/`;
4954
+ }
4955
+ const anonymousId = getAnonymousUserId();
4956
+ if (anonymousId) {
4957
+ return `anonymous/${anonymousId}/`;
4958
+ }
4959
+ return upfilesConfig.folderPath || "/";
4960
+ }, [user?.id, upfilesConfig.folderPath]);
4846
4961
  const handleSelect = async (image) => {
4847
4962
  setUpdating(true);
4848
4963
  try {
@@ -4875,7 +4990,7 @@ var AvatarManager = ({
4875
4990
  withCredentials: upfilesConfig.withCredentials
4876
4991
  },
4877
4992
  projectId,
4878
- folderPath: upfilesConfig.folderPath || "/",
4993
+ folderPath: effectiveFolderPath,
4879
4994
  title,
4880
4995
  description,
4881
4996
  className,