@insforge/react 1.0.5-dev.0 → 1.0.5-dev.1

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.
@@ -1,7 +1,6 @@
1
1
  import * as React2 from 'react';
2
2
  import { createContext, forwardRef, useContext, useState, useMemo, useRef, useEffect, useCallback, isValidElement, cloneElement } from 'react';
3
3
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
4
- import '@insforge/sdk';
5
4
  import { InsforgeContext } from '@insforge/shared/react';
6
5
  import { AlertTriangle, Check, EyeOff, Eye, Loader2, CircleCheck, X, User, LogOut } from 'lucide-react';
7
6
  import { z } from 'zod';
@@ -4889,7 +4888,7 @@ function UserProfileModal({ onClose, onError }) {
4889
4888
  useEffect(() => {
4890
4889
  if (user) {
4891
4890
  const initialData = {
4892
- name: user.name || ""
4891
+ name: user.profile?.name || ""
4893
4892
  };
4894
4893
  if (user.profile) {
4895
4894
  Object.entries(user.profile).forEach(([key, value]) => {
@@ -4903,7 +4902,7 @@ function UserProfileModal({ onClose, onError }) {
4903
4902
  }, [user]);
4904
4903
  useEffect(() => {
4905
4904
  setImageError(false);
4906
- const avatarUrl = user?.avatarUrl;
4905
+ const avatarUrl = user?.profile?.avatar_url;
4907
4906
  if (!avatarUrl) {
4908
4907
  return;
4909
4908
  }
@@ -4921,7 +4920,7 @@ function UserProfileModal({ onClose, onError }) {
4921
4920
  }
4922
4921
  };
4923
4922
  void checkImageUrl();
4924
- }, [user?.avatarUrl]);
4923
+ }, [user?.profile?.avatar_url]);
4925
4924
  const handleFieldChange = useCallback((key, value) => {
4926
4925
  setFormData((prev2) => ({
4927
4926
  ...prev2,
@@ -4934,7 +4933,9 @@ function UserProfileModal({ onClose, onError }) {
4934
4933
  try {
4935
4934
  const { name, ...dynamicFields } = formData;
4936
4935
  const updateData = {
4937
- name
4936
+ profile: {
4937
+ name
4938
+ }
4938
4939
  };
4939
4940
  if (Object.keys(dynamicFields).length > 0) {
4940
4941
  updateData.profile = dynamicFields;
@@ -4954,7 +4955,7 @@ function UserProfileModal({ onClose, onError }) {
4954
4955
  const handleCancel = useCallback(() => {
4955
4956
  if (user) {
4956
4957
  const resetData = {
4957
- name: user.name || ""
4958
+ name: user.profile?.name || ""
4958
4959
  };
4959
4960
  if (user.profile) {
4960
4961
  Object.entries(user.profile).forEach(([key, value]) => {
@@ -4991,12 +4992,12 @@ function UserProfileModal({ onClose, onError }) {
4991
4992
  if (!isLoaded || !user) {
4992
4993
  return null;
4993
4994
  }
4994
- const initials = user.name ? user.name.charAt(0).toUpperCase() : user.email.split("@")[0].slice(0, 2).toUpperCase();
4995
+ const initials = user.profile?.name ? user.profile.name.charAt(0).toUpperCase() : user.email.split("@")[0].slice(0, 2).toUpperCase();
4995
4996
  const fields = [];
4996
4997
  fields.push({ key: "email", value: user.email, readOnly: true });
4997
4998
  fields.push({
4998
4999
  key: "name",
4999
- value: isEditing ? formData.name || "" : user.name || "",
5000
+ value: isEditing ? formData.name || "" : user.profile?.name || "",
5000
5001
  readOnly: false
5001
5002
  });
5002
5003
  if (user.profile) {
@@ -5016,11 +5017,11 @@ function UserProfileModal({ onClose, onError }) {
5016
5017
  /* @__PURE__ */ jsx(ProfileModalCloseButton, { onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx(X, {}) })
5017
5018
  ] }),
5018
5019
  /* @__PURE__ */ jsxs(ProfileModalBody, { children: [
5019
- /* @__PURE__ */ jsx(ProfileAvatarSection, { children: /* @__PURE__ */ jsx(ProfileAvatar, { children: user.avatarUrl && !imageError ? /* @__PURE__ */ jsx(
5020
+ /* @__PURE__ */ jsx(ProfileAvatarSection, { children: /* @__PURE__ */ jsx(ProfileAvatar, { children: user.profile?.avatar_url && !imageError ? /* @__PURE__ */ jsx(
5020
5021
  ProfileAvatarImage,
5021
5022
  {
5022
- src: user.avatarUrl,
5023
- alt: user.name || user.email,
5023
+ src: user.profile.avatar_url,
5024
+ alt: user.profile?.name || user.email,
5024
5025
  onError: () => setImageError(true)
5025
5026
  }
5026
5027
  ) : initials }) }),
@@ -5039,7 +5040,7 @@ function UserProfileModal({ onClose, onError }) {
5039
5040
  ] }),
5040
5041
  /* @__PURE__ */ jsx(ProfileModalFooter, { children: isEditing ? /* @__PURE__ */ jsxs(Fragment, { children: [
5041
5042
  /* @__PURE__ */ jsx(ProfileButton, { onClick: handleCancel, disabled: isSaving, children: "Cancel" }),
5042
- /* @__PURE__ */ jsxs(ProfileButton, { $primary: true, onClick: handleSave, disabled: isSaving, children: [
5043
+ /* @__PURE__ */ jsxs(ProfileButton, { $primary: true, onClick: () => void handleSave(), disabled: isSaving, children: [
5043
5044
  isSaving && /* @__PURE__ */ jsx(ProfileSpinner, {}),
5044
5045
  isSaving ? "Saving..." : "Save"
5045
5046
  ] })
@@ -5062,7 +5063,7 @@ function UserButton({
5062
5063
  const menuRef = useRef(null);
5063
5064
  useEffect(() => {
5064
5065
  setImageError(false);
5065
- const avatarUrl = user?.avatarUrl;
5066
+ const avatarUrl = user?.profile?.avatar_url;
5066
5067
  if (!avatarUrl) {
5067
5068
  return;
5068
5069
  }
@@ -5083,7 +5084,7 @@ function UserButton({
5083
5084
  }
5084
5085
  };
5085
5086
  void checkImageUrl();
5086
- }, [user?.avatarUrl]);
5087
+ }, [user?.profile?.avatar_url]);
5087
5088
  useEffect(() => {
5088
5089
  if (isOpen && dropdownRef.current) {
5089
5090
  const buttonRect = dropdownRef.current.getBoundingClientRect();
@@ -5127,7 +5128,7 @@ function UserButton({
5127
5128
  if (!user) {
5128
5129
  return null;
5129
5130
  }
5130
- const initials = user.name ? user.name.charAt(0).toUpperCase() : user.email.split("@")[0].slice(0, 2).toUpperCase();
5131
+ const initials = user.profile?.name ? user.profile.name.charAt(0).toUpperCase() : user.email.split("@")[0].slice(0, 2).toUpperCase();
5131
5132
  return /* @__PURE__ */ jsxs(UserButtonContainer, { ref: dropdownRef, children: [
5132
5133
  /* @__PURE__ */ jsxs(
5133
5134
  UserButtonButton,
@@ -5137,16 +5138,16 @@ function UserButton({
5137
5138
  "aria-expanded": isOpen,
5138
5139
  "aria-haspopup": "true",
5139
5140
  children: [
5140
- /* @__PURE__ */ jsx(UserButtonAvatar, { children: user.avatarUrl && !imageError ? /* @__PURE__ */ jsx(
5141
+ /* @__PURE__ */ jsx(UserButtonAvatar, { children: user.profile?.avatar_url && !imageError ? /* @__PURE__ */ jsx(
5141
5142
  UserButtonAvatarImage,
5142
5143
  {
5143
- src: user.avatarUrl,
5144
+ src: user.profile.avatar_url,
5144
5145
  alt: user.email,
5145
5146
  onError: () => setImageError(true)
5146
5147
  }
5147
5148
  ) : /* @__PURE__ */ jsx(UserButtonAvatarInitials, { children: initials }) }),
5148
5149
  mode === "detailed" && /* @__PURE__ */ jsxs(UserButtonInfo, { children: [
5149
- user.name && /* @__PURE__ */ jsx(UserButtonName, { children: user.name }),
5150
+ user.profile?.name && /* @__PURE__ */ jsx(UserButtonName, { children: user.profile.name }),
5150
5151
  /* @__PURE__ */ jsx(UserButtonEmail, { children: user.email })
5151
5152
  ] })
5152
5153
  ]
@@ -5171,13 +5172,7 @@ function UserButton({
5171
5172
  "Sign out"
5172
5173
  ] }) })
5173
5174
  ] }),
5174
- showProfileModal && /* @__PURE__ */ jsx(
5175
- UserProfileModal,
5176
- {
5177
- onClose: () => setShowProfileModal(false),
5178
- onError: onProfileError
5179
- }
5180
- )
5175
+ showProfileModal && /* @__PURE__ */ jsx(UserProfileModal, { onClose: () => setShowProfileModal(false), onError: onProfileError })
5181
5176
  ] });
5182
5177
  }
5183
5178
  function Protect({