@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.
@@ -2,7 +2,6 @@
2
2
 
3
3
  var React2 = require('react');
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
- require('@insforge/sdk');
6
5
  var react = require('@insforge/shared/react');
7
6
  var lucideReact = require('lucide-react');
8
7
  var zod = require('zod');
@@ -4897,7 +4896,7 @@ var ProfileSpinner = styled.div`
4897
4896
  }
4898
4897
  `;
4899
4898
  var READ_ONLY_FIELDS = ["id", "email", "avatar_url", "created_at", "updated_at"];
4900
- var HIDDEN_FIELDS = ["id"];
4899
+ var HIDDEN_FIELDS = ["id", "avatar_url"];
4901
4900
  function formatFieldLabel(key) {
4902
4901
  return key.replace(/_/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").toLowerCase();
4903
4902
  }
@@ -4909,9 +4908,7 @@ function UserProfileModal({ onClose, onError }) {
4909
4908
  const [formData, setFormData] = React2.useState({});
4910
4909
  React2.useEffect(() => {
4911
4910
  if (user) {
4912
- const initialData = {
4913
- name: user.name || ""
4914
- };
4911
+ const initialData = {};
4915
4912
  if (user.profile) {
4916
4913
  Object.entries(user.profile).forEach(([key, value]) => {
4917
4914
  if (!HIDDEN_FIELDS.includes(key) && typeof value === "string") {
@@ -4924,7 +4921,7 @@ function UserProfileModal({ onClose, onError }) {
4924
4921
  }, [user]);
4925
4922
  React2.useEffect(() => {
4926
4923
  setImageError(false);
4927
- const avatarUrl = user?.avatarUrl;
4924
+ const avatarUrl = user?.profile?.avatar_url;
4928
4925
  if (!avatarUrl) {
4929
4926
  return;
4930
4927
  }
@@ -4942,7 +4939,7 @@ function UserProfileModal({ onClose, onError }) {
4942
4939
  }
4943
4940
  };
4944
4941
  void checkImageUrl();
4945
- }, [user?.avatarUrl]);
4942
+ }, [user?.profile?.avatar_url]);
4946
4943
  const handleFieldChange = React2.useCallback((key, value) => {
4947
4944
  setFormData((prev2) => ({
4948
4945
  ...prev2,
@@ -4955,7 +4952,9 @@ function UserProfileModal({ onClose, onError }) {
4955
4952
  try {
4956
4953
  const { name, ...dynamicFields } = formData;
4957
4954
  const updateData = {
4958
- name
4955
+ profile: {
4956
+ name
4957
+ }
4959
4958
  };
4960
4959
  if (Object.keys(dynamicFields).length > 0) {
4961
4960
  updateData.profile = dynamicFields;
@@ -4975,7 +4974,7 @@ function UserProfileModal({ onClose, onError }) {
4975
4974
  const handleCancel = React2.useCallback(() => {
4976
4975
  if (user) {
4977
4976
  const resetData = {
4978
- name: user.name || ""
4977
+ name: user.profile?.name || ""
4979
4978
  };
4980
4979
  if (user.profile) {
4981
4980
  Object.entries(user.profile).forEach(([key, value]) => {
@@ -5012,12 +5011,12 @@ function UserProfileModal({ onClose, onError }) {
5012
5011
  if (!isLoaded || !user) {
5013
5012
  return null;
5014
5013
  }
5015
- const initials = user.name ? user.name.charAt(0).toUpperCase() : user.email.split("@")[0].slice(0, 2).toUpperCase();
5014
+ const initials = user.profile?.name ? user.profile.name.charAt(0).toUpperCase() : user.email.split("@")[0].slice(0, 2).toUpperCase();
5016
5015
  const fields = [];
5017
5016
  fields.push({ key: "email", value: user.email, readOnly: true });
5018
5017
  fields.push({
5019
5018
  key: "name",
5020
- value: isEditing ? formData.name || "" : user.name || "",
5019
+ value: isEditing ? formData.name || "" : user.profile?.name || "",
5021
5020
  readOnly: false
5022
5021
  });
5023
5022
  if (user.profile) {
@@ -5037,11 +5036,11 @@ function UserProfileModal({ onClose, onError }) {
5037
5036
  /* @__PURE__ */ jsxRuntime.jsx(ProfileModalCloseButton, { onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {}) })
5038
5037
  ] }),
5039
5038
  /* @__PURE__ */ jsxRuntime.jsxs(ProfileModalBody, { children: [
5040
- /* @__PURE__ */ jsxRuntime.jsx(ProfileAvatarSection, { children: /* @__PURE__ */ jsxRuntime.jsx(ProfileAvatar, { children: user.avatarUrl && !imageError ? /* @__PURE__ */ jsxRuntime.jsx(
5039
+ /* @__PURE__ */ jsxRuntime.jsx(ProfileAvatarSection, { children: /* @__PURE__ */ jsxRuntime.jsx(ProfileAvatar, { children: user.profile?.avatar_url && !imageError ? /* @__PURE__ */ jsxRuntime.jsx(
5041
5040
  ProfileAvatarImage,
5042
5041
  {
5043
- src: user.avatarUrl,
5044
- alt: user.name || user.email,
5042
+ src: user.profile.avatar_url,
5043
+ alt: user.profile?.name || user.email,
5045
5044
  onError: () => setImageError(true)
5046
5045
  }
5047
5046
  ) : initials }) }),
@@ -5060,7 +5059,7 @@ function UserProfileModal({ onClose, onError }) {
5060
5059
  ] }),
5061
5060
  /* @__PURE__ */ jsxRuntime.jsx(ProfileModalFooter, { children: isEditing ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5062
5061
  /* @__PURE__ */ jsxRuntime.jsx(ProfileButton, { onClick: handleCancel, disabled: isSaving, children: "Cancel" }),
5063
- /* @__PURE__ */ jsxRuntime.jsxs(ProfileButton, { $primary: true, onClick: handleSave, disabled: isSaving, children: [
5062
+ /* @__PURE__ */ jsxRuntime.jsxs(ProfileButton, { $primary: true, onClick: () => void handleSave(), disabled: isSaving, children: [
5064
5063
  isSaving && /* @__PURE__ */ jsxRuntime.jsx(ProfileSpinner, {}),
5065
5064
  isSaving ? "Saving..." : "Save"
5066
5065
  ] })
@@ -5083,7 +5082,7 @@ function UserButton({
5083
5082
  const menuRef = React2.useRef(null);
5084
5083
  React2.useEffect(() => {
5085
5084
  setImageError(false);
5086
- const avatarUrl = user?.avatarUrl;
5085
+ const avatarUrl = user?.profile?.avatar_url;
5087
5086
  if (!avatarUrl) {
5088
5087
  return;
5089
5088
  }
@@ -5104,7 +5103,7 @@ function UserButton({
5104
5103
  }
5105
5104
  };
5106
5105
  void checkImageUrl();
5107
- }, [user?.avatarUrl]);
5106
+ }, [user?.profile?.avatar_url]);
5108
5107
  React2.useEffect(() => {
5109
5108
  if (isOpen && dropdownRef.current) {
5110
5109
  const buttonRect = dropdownRef.current.getBoundingClientRect();
@@ -5148,7 +5147,7 @@ function UserButton({
5148
5147
  if (!user) {
5149
5148
  return null;
5150
5149
  }
5151
- const initials = user.name ? user.name.charAt(0).toUpperCase() : user.email.split("@")[0].slice(0, 2).toUpperCase();
5150
+ const initials = user.profile?.name ? user.profile.name.charAt(0).toUpperCase() : user.email.split("@")[0].slice(0, 2).toUpperCase();
5152
5151
  return /* @__PURE__ */ jsxRuntime.jsxs(UserButtonContainer, { ref: dropdownRef, children: [
5153
5152
  /* @__PURE__ */ jsxRuntime.jsxs(
5154
5153
  UserButtonButton,
@@ -5158,16 +5157,16 @@ function UserButton({
5158
5157
  "aria-expanded": isOpen,
5159
5158
  "aria-haspopup": "true",
5160
5159
  children: [
5161
- /* @__PURE__ */ jsxRuntime.jsx(UserButtonAvatar, { children: user.avatarUrl && !imageError ? /* @__PURE__ */ jsxRuntime.jsx(
5160
+ /* @__PURE__ */ jsxRuntime.jsx(UserButtonAvatar, { children: user.profile?.avatar_url && !imageError ? /* @__PURE__ */ jsxRuntime.jsx(
5162
5161
  UserButtonAvatarImage,
5163
5162
  {
5164
- src: user.avatarUrl,
5163
+ src: user.profile.avatar_url,
5165
5164
  alt: user.email,
5166
5165
  onError: () => setImageError(true)
5167
5166
  }
5168
5167
  ) : /* @__PURE__ */ jsxRuntime.jsx(UserButtonAvatarInitials, { children: initials }) }),
5169
5168
  mode === "detailed" && /* @__PURE__ */ jsxRuntime.jsxs(UserButtonInfo, { children: [
5170
- user.name && /* @__PURE__ */ jsxRuntime.jsx(UserButtonName, { children: user.name }),
5169
+ user.profile?.name && /* @__PURE__ */ jsxRuntime.jsx(UserButtonName, { children: user.profile.name }),
5171
5170
  /* @__PURE__ */ jsxRuntime.jsx(UserButtonEmail, { children: user.email })
5172
5171
  ] })
5173
5172
  ]
@@ -5192,13 +5191,7 @@ function UserButton({
5192
5191
  "Sign out"
5193
5192
  ] }) })
5194
5193
  ] }),
5195
- showProfileModal && /* @__PURE__ */ jsxRuntime.jsx(
5196
- UserProfileModal,
5197
- {
5198
- onClose: () => setShowProfileModal(false),
5199
- onError: onProfileError
5200
- }
5201
- )
5194
+ showProfileModal && /* @__PURE__ */ jsxRuntime.jsx(UserProfileModal, { onClose: () => setShowProfileModal(false), onError: onProfileError })
5202
5195
  ] });
5203
5196
  }
5204
5197
  function Protect({