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

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';
@@ -4876,7 +4875,7 @@ var ProfileSpinner = styled.div`
4876
4875
  }
4877
4876
  `;
4878
4877
  var READ_ONLY_FIELDS = ["id", "email", "avatar_url", "created_at", "updated_at"];
4879
- var HIDDEN_FIELDS = ["id"];
4878
+ var HIDDEN_FIELDS = ["id", "avatar_url"];
4880
4879
  function formatFieldLabel(key) {
4881
4880
  return key.replace(/_/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").toLowerCase();
4882
4881
  }
@@ -4888,9 +4887,7 @@ function UserProfileModal({ onClose, onError }) {
4888
4887
  const [formData, setFormData] = useState({});
4889
4888
  useEffect(() => {
4890
4889
  if (user) {
4891
- const initialData = {
4892
- name: user.name || ""
4893
- };
4890
+ const initialData = {};
4894
4891
  if (user.profile) {
4895
4892
  Object.entries(user.profile).forEach(([key, value]) => {
4896
4893
  if (!HIDDEN_FIELDS.includes(key) && typeof value === "string") {
@@ -4903,7 +4900,7 @@ function UserProfileModal({ onClose, onError }) {
4903
4900
  }, [user]);
4904
4901
  useEffect(() => {
4905
4902
  setImageError(false);
4906
- const avatarUrl = user?.avatarUrl;
4903
+ const avatarUrl = user?.profile?.avatar_url;
4907
4904
  if (!avatarUrl) {
4908
4905
  return;
4909
4906
  }
@@ -4921,7 +4918,7 @@ function UserProfileModal({ onClose, onError }) {
4921
4918
  }
4922
4919
  };
4923
4920
  void checkImageUrl();
4924
- }, [user?.avatarUrl]);
4921
+ }, [user?.profile?.avatar_url]);
4925
4922
  const handleFieldChange = useCallback((key, value) => {
4926
4923
  setFormData((prev2) => ({
4927
4924
  ...prev2,
@@ -4934,7 +4931,9 @@ function UserProfileModal({ onClose, onError }) {
4934
4931
  try {
4935
4932
  const { name, ...dynamicFields } = formData;
4936
4933
  const updateData = {
4937
- name
4934
+ profile: {
4935
+ name
4936
+ }
4938
4937
  };
4939
4938
  if (Object.keys(dynamicFields).length > 0) {
4940
4939
  updateData.profile = dynamicFields;
@@ -4954,7 +4953,7 @@ function UserProfileModal({ onClose, onError }) {
4954
4953
  const handleCancel = useCallback(() => {
4955
4954
  if (user) {
4956
4955
  const resetData = {
4957
- name: user.name || ""
4956
+ name: user.profile?.name || ""
4958
4957
  };
4959
4958
  if (user.profile) {
4960
4959
  Object.entries(user.profile).forEach(([key, value]) => {
@@ -4991,12 +4990,12 @@ function UserProfileModal({ onClose, onError }) {
4991
4990
  if (!isLoaded || !user) {
4992
4991
  return null;
4993
4992
  }
4994
- const initials = user.name ? user.name.charAt(0).toUpperCase() : user.email.split("@")[0].slice(0, 2).toUpperCase();
4993
+ const initials = user.profile?.name ? user.profile.name.charAt(0).toUpperCase() : user.email.split("@")[0].slice(0, 2).toUpperCase();
4995
4994
  const fields = [];
4996
4995
  fields.push({ key: "email", value: user.email, readOnly: true });
4997
4996
  fields.push({
4998
4997
  key: "name",
4999
- value: isEditing ? formData.name || "" : user.name || "",
4998
+ value: isEditing ? formData.name || "" : user.profile?.name || "",
5000
4999
  readOnly: false
5001
5000
  });
5002
5001
  if (user.profile) {
@@ -5016,11 +5015,11 @@ function UserProfileModal({ onClose, onError }) {
5016
5015
  /* @__PURE__ */ jsx(ProfileModalCloseButton, { onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx(X, {}) })
5017
5016
  ] }),
5018
5017
  /* @__PURE__ */ jsxs(ProfileModalBody, { children: [
5019
- /* @__PURE__ */ jsx(ProfileAvatarSection, { children: /* @__PURE__ */ jsx(ProfileAvatar, { children: user.avatarUrl && !imageError ? /* @__PURE__ */ jsx(
5018
+ /* @__PURE__ */ jsx(ProfileAvatarSection, { children: /* @__PURE__ */ jsx(ProfileAvatar, { children: user.profile?.avatar_url && !imageError ? /* @__PURE__ */ jsx(
5020
5019
  ProfileAvatarImage,
5021
5020
  {
5022
- src: user.avatarUrl,
5023
- alt: user.name || user.email,
5021
+ src: user.profile.avatar_url,
5022
+ alt: user.profile?.name || user.email,
5024
5023
  onError: () => setImageError(true)
5025
5024
  }
5026
5025
  ) : initials }) }),
@@ -5039,7 +5038,7 @@ function UserProfileModal({ onClose, onError }) {
5039
5038
  ] }),
5040
5039
  /* @__PURE__ */ jsx(ProfileModalFooter, { children: isEditing ? /* @__PURE__ */ jsxs(Fragment, { children: [
5041
5040
  /* @__PURE__ */ jsx(ProfileButton, { onClick: handleCancel, disabled: isSaving, children: "Cancel" }),
5042
- /* @__PURE__ */ jsxs(ProfileButton, { $primary: true, onClick: handleSave, disabled: isSaving, children: [
5041
+ /* @__PURE__ */ jsxs(ProfileButton, { $primary: true, onClick: () => void handleSave(), disabled: isSaving, children: [
5043
5042
  isSaving && /* @__PURE__ */ jsx(ProfileSpinner, {}),
5044
5043
  isSaving ? "Saving..." : "Save"
5045
5044
  ] })
@@ -5062,7 +5061,7 @@ function UserButton({
5062
5061
  const menuRef = useRef(null);
5063
5062
  useEffect(() => {
5064
5063
  setImageError(false);
5065
- const avatarUrl = user?.avatarUrl;
5064
+ const avatarUrl = user?.profile?.avatar_url;
5066
5065
  if (!avatarUrl) {
5067
5066
  return;
5068
5067
  }
@@ -5083,7 +5082,7 @@ function UserButton({
5083
5082
  }
5084
5083
  };
5085
5084
  void checkImageUrl();
5086
- }, [user?.avatarUrl]);
5085
+ }, [user?.profile?.avatar_url]);
5087
5086
  useEffect(() => {
5088
5087
  if (isOpen && dropdownRef.current) {
5089
5088
  const buttonRect = dropdownRef.current.getBoundingClientRect();
@@ -5127,7 +5126,7 @@ function UserButton({
5127
5126
  if (!user) {
5128
5127
  return null;
5129
5128
  }
5130
- const initials = user.name ? user.name.charAt(0).toUpperCase() : user.email.split("@")[0].slice(0, 2).toUpperCase();
5129
+ const initials = user.profile?.name ? user.profile.name.charAt(0).toUpperCase() : user.email.split("@")[0].slice(0, 2).toUpperCase();
5131
5130
  return /* @__PURE__ */ jsxs(UserButtonContainer, { ref: dropdownRef, children: [
5132
5131
  /* @__PURE__ */ jsxs(
5133
5132
  UserButtonButton,
@@ -5137,16 +5136,16 @@ function UserButton({
5137
5136
  "aria-expanded": isOpen,
5138
5137
  "aria-haspopup": "true",
5139
5138
  children: [
5140
- /* @__PURE__ */ jsx(UserButtonAvatar, { children: user.avatarUrl && !imageError ? /* @__PURE__ */ jsx(
5139
+ /* @__PURE__ */ jsx(UserButtonAvatar, { children: user.profile?.avatar_url && !imageError ? /* @__PURE__ */ jsx(
5141
5140
  UserButtonAvatarImage,
5142
5141
  {
5143
- src: user.avatarUrl,
5142
+ src: user.profile.avatar_url,
5144
5143
  alt: user.email,
5145
5144
  onError: () => setImageError(true)
5146
5145
  }
5147
5146
  ) : /* @__PURE__ */ jsx(UserButtonAvatarInitials, { children: initials }) }),
5148
5147
  mode === "detailed" && /* @__PURE__ */ jsxs(UserButtonInfo, { children: [
5149
- user.name && /* @__PURE__ */ jsx(UserButtonName, { children: user.name }),
5148
+ user.profile?.name && /* @__PURE__ */ jsx(UserButtonName, { children: user.profile.name }),
5150
5149
  /* @__PURE__ */ jsx(UserButtonEmail, { children: user.email })
5151
5150
  ] })
5152
5151
  ]
@@ -5171,13 +5170,7 @@ function UserButton({
5171
5170
  "Sign out"
5172
5171
  ] }) })
5173
5172
  ] }),
5174
- showProfileModal && /* @__PURE__ */ jsx(
5175
- UserProfileModal,
5176
- {
5177
- onClose: () => setShowProfileModal(false),
5178
- onError: onProfileError
5179
- }
5180
- )
5173
+ showProfileModal && /* @__PURE__ */ jsx(UserProfileModal, { onClose: () => setShowProfileModal(false), onError: onProfileError })
5181
5174
  ] });
5182
5175
  }
5183
5176
  function Protect({