@insforge/react 1.0.4 → 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.
- package/dist/atoms.cjs +0 -1
- package/dist/atoms.cjs.map +1 -1
- package/dist/atoms.js +0 -1
- package/dist/atoms.js.map +1 -1
- package/dist/components.cjs +411 -14
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +18 -2
- package/dist/components.d.ts +18 -2
- package/dist/components.js +412 -16
- package/dist/components.js.map +1 -1
- package/dist/forms.cjs +0 -1
- package/dist/forms.cjs.map +1 -1
- package/dist/forms.js +0 -1
- package/dist/forms.js.map +1 -1
- package/dist/hooks.cjs +0 -1
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.js +0 -1
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +435 -52
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +436 -54
- package/dist/index.js.map +1 -1
- package/package.json +114 -114
package/dist/components.cjs
CHANGED
|
@@ -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');
|
|
@@ -232,7 +231,7 @@ var require_react_is_development = __commonJS({
|
|
|
232
231
|
var ContextProvider = REACT_PROVIDER_TYPE;
|
|
233
232
|
var Element = REACT_ELEMENT_TYPE;
|
|
234
233
|
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
235
|
-
var
|
|
234
|
+
var Fragment10 = REACT_FRAGMENT_TYPE;
|
|
236
235
|
var Lazy = REACT_LAZY_TYPE;
|
|
237
236
|
var Memo = REACT_MEMO_TYPE;
|
|
238
237
|
var Portal = REACT_PORTAL_TYPE;
|
|
@@ -291,7 +290,7 @@ var require_react_is_development = __commonJS({
|
|
|
291
290
|
exports$1.ContextProvider = ContextProvider;
|
|
292
291
|
exports$1.Element = Element;
|
|
293
292
|
exports$1.ForwardRef = ForwardRef;
|
|
294
|
-
exports$1.Fragment =
|
|
293
|
+
exports$1.Fragment = Fragment10;
|
|
295
294
|
exports$1.Lazy = Lazy;
|
|
296
295
|
exports$1.Memo = Memo;
|
|
297
296
|
exports$1.Portal = Portal;
|
|
@@ -2148,6 +2147,8 @@ var theme = {
|
|
|
2148
2147
|
sm: "0.875rem",
|
|
2149
2148
|
// 14px
|
|
2150
2149
|
base: "1rem",
|
|
2150
|
+
// 16px
|
|
2151
|
+
lg: "1.125rem",
|
|
2151
2152
|
// 20px
|
|
2152
2153
|
"2xl": "1.5rem"
|
|
2153
2154
|
// 24px
|
|
@@ -2179,6 +2180,10 @@ var theme = {
|
|
|
2179
2180
|
base: "200ms cubic-bezier(0.4, 0, 0.2, 1)"
|
|
2180
2181
|
},
|
|
2181
2182
|
sizes: {
|
|
2183
|
+
input: {
|
|
2184
|
+
height: "2.5rem"
|
|
2185
|
+
// 40px
|
|
2186
|
+
},
|
|
2182
2187
|
button: {
|
|
2183
2188
|
height: "2.5rem",
|
|
2184
2189
|
// 40px for submit
|
|
@@ -4694,9 +4699,384 @@ var UserButtonMenuItemIcon = styled.div`
|
|
|
4694
4699
|
height: 100%;
|
|
4695
4700
|
}
|
|
4696
4701
|
`;
|
|
4697
|
-
|
|
4702
|
+
var ProfileModalOverlay = styled.div`
|
|
4703
|
+
position: fixed;
|
|
4704
|
+
inset: 0;
|
|
4705
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
4706
|
+
display: flex;
|
|
4707
|
+
align-items: center;
|
|
4708
|
+
justify-content: center;
|
|
4709
|
+
z-index: 100;
|
|
4710
|
+
padding: ${theme.spacing[4]};
|
|
4711
|
+
`;
|
|
4712
|
+
var ProfileModalContainer = styled.div`
|
|
4713
|
+
background-color: ${theme.colors.bgWhite};
|
|
4714
|
+
border-radius: ${theme.radius.xl};
|
|
4715
|
+
box-shadow: ${theme.shadow.lg};
|
|
4716
|
+
width: 100%;
|
|
4717
|
+
max-width: 400px;
|
|
4718
|
+
max-height: 90vh;
|
|
4719
|
+
overflow: hidden;
|
|
4720
|
+
display: flex;
|
|
4721
|
+
flex-direction: column;
|
|
4722
|
+
font-family: ${theme.fontFamily.base};
|
|
4723
|
+
`;
|
|
4724
|
+
var ProfileModalHeader = styled.div`
|
|
4725
|
+
display: flex;
|
|
4726
|
+
align-items: center;
|
|
4727
|
+
justify-content: space-between;
|
|
4728
|
+
padding: ${theme.spacing[4]} ${theme.spacing[6]};
|
|
4729
|
+
border-bottom: 1px solid ${theme.colors.border};
|
|
4730
|
+
`;
|
|
4731
|
+
var ProfileModalTitle = styled.h2`
|
|
4732
|
+
font-size: ${theme.fontSize.lg};
|
|
4733
|
+
font-weight: ${theme.fontWeight.semibold};
|
|
4734
|
+
color: ${theme.colors.text};
|
|
4735
|
+
margin: 0;
|
|
4736
|
+
`;
|
|
4737
|
+
var ProfileModalCloseButton = styled.button`
|
|
4738
|
+
display: flex;
|
|
4739
|
+
align-items: center;
|
|
4740
|
+
justify-content: center;
|
|
4741
|
+
width: 2rem;
|
|
4742
|
+
height: 2rem;
|
|
4743
|
+
border-radius: ${theme.radius.md};
|
|
4744
|
+
background: none;
|
|
4745
|
+
border: none;
|
|
4746
|
+
cursor: pointer;
|
|
4747
|
+
color: ${theme.colors.textSecondary};
|
|
4748
|
+
transition: all ${theme.transition.fast};
|
|
4749
|
+
|
|
4750
|
+
&:hover {
|
|
4751
|
+
background-color: ${theme.colors.bgLight};
|
|
4752
|
+
color: ${theme.colors.text};
|
|
4753
|
+
}
|
|
4754
|
+
|
|
4755
|
+
svg {
|
|
4756
|
+
width: 1.25rem;
|
|
4757
|
+
height: 1.25rem;
|
|
4758
|
+
}
|
|
4759
|
+
`;
|
|
4760
|
+
var ProfileModalBody = styled.div`
|
|
4761
|
+
padding: ${theme.spacing[6]};
|
|
4762
|
+
overflow-y: auto;
|
|
4763
|
+
flex: 1;
|
|
4764
|
+
`;
|
|
4765
|
+
var ProfileAvatarSection = styled.div`
|
|
4766
|
+
display: flex;
|
|
4767
|
+
flex-direction: column;
|
|
4768
|
+
align-items: center;
|
|
4769
|
+
margin-bottom: ${theme.spacing[6]};
|
|
4770
|
+
`;
|
|
4771
|
+
var ProfileAvatar = styled.div`
|
|
4772
|
+
width: 5rem;
|
|
4773
|
+
height: 5rem;
|
|
4774
|
+
border-radius: ${theme.radius.full};
|
|
4775
|
+
background-color: ${theme.colors.primary};
|
|
4776
|
+
color: ${theme.colors.bgWhite};
|
|
4777
|
+
display: flex;
|
|
4778
|
+
align-items: center;
|
|
4779
|
+
justify-content: center;
|
|
4780
|
+
font-weight: ${theme.fontWeight.semibold};
|
|
4781
|
+
font-size: ${theme.fontSize["2xl"]};
|
|
4782
|
+
overflow: hidden;
|
|
4783
|
+
`;
|
|
4784
|
+
var ProfileAvatarImage = styled.img`
|
|
4785
|
+
width: 100%;
|
|
4786
|
+
height: 100%;
|
|
4787
|
+
object-fit: cover;
|
|
4788
|
+
`;
|
|
4789
|
+
var ProfileFieldsContainer = styled.div`
|
|
4790
|
+
display: flex;
|
|
4791
|
+
flex-direction: column;
|
|
4792
|
+
gap: ${theme.spacing[4]};
|
|
4793
|
+
`;
|
|
4794
|
+
var ProfileField = styled.div`
|
|
4795
|
+
display: flex;
|
|
4796
|
+
flex-direction: column;
|
|
4797
|
+
gap: ${theme.spacing[1]};
|
|
4798
|
+
`;
|
|
4799
|
+
var ProfileFieldLabel = styled.label`
|
|
4800
|
+
font-size: ${theme.fontSize.sm};
|
|
4801
|
+
font-weight: ${theme.fontWeight.medium};
|
|
4802
|
+
color: ${theme.colors.textSecondary};
|
|
4803
|
+
text-transform: capitalize;
|
|
4804
|
+
`;
|
|
4805
|
+
var ProfileFieldValue = styled.div`
|
|
4806
|
+
font-size: ${theme.fontSize.base};
|
|
4807
|
+
color: ${theme.colors.text};
|
|
4808
|
+
padding: ${theme.spacing[2]} 0;
|
|
4809
|
+
word-break: break-word;
|
|
4810
|
+
`;
|
|
4811
|
+
var ProfileFieldInput = styled.input`
|
|
4812
|
+
width: 100%;
|
|
4813
|
+
height: ${theme.sizes.input.height};
|
|
4814
|
+
padding: 0 ${theme.spacing[3]};
|
|
4815
|
+
border: 1px solid ${theme.colors.border};
|
|
4816
|
+
border-radius: ${theme.radius.md};
|
|
4817
|
+
font-size: ${theme.fontSize.base};
|
|
4818
|
+
font-family: ${theme.fontFamily.base};
|
|
4819
|
+
color: ${theme.colors.text};
|
|
4820
|
+
background-color: ${theme.colors.bgWhite};
|
|
4821
|
+
transition: border-color ${theme.transition.fast};
|
|
4822
|
+
|
|
4823
|
+
&:focus {
|
|
4824
|
+
outline: none;
|
|
4825
|
+
border-color: ${theme.colors.borderFocus};
|
|
4826
|
+
}
|
|
4827
|
+
|
|
4828
|
+
&:disabled {
|
|
4829
|
+
background-color: ${theme.colors.bgLight};
|
|
4830
|
+
color: ${theme.colors.textSecondary};
|
|
4831
|
+
cursor: not-allowed;
|
|
4832
|
+
}
|
|
4833
|
+
`;
|
|
4834
|
+
var ProfileModalFooter = styled.div`
|
|
4835
|
+
display: flex;
|
|
4836
|
+
align-items: center;
|
|
4837
|
+
justify-content: flex-end;
|
|
4838
|
+
gap: ${theme.spacing[3]};
|
|
4839
|
+
padding: ${theme.spacing[4]} ${theme.spacing[6]};
|
|
4840
|
+
border-top: 1px solid ${theme.colors.border};
|
|
4841
|
+
`;
|
|
4842
|
+
var ProfileButton = styled.button`
|
|
4843
|
+
display: flex;
|
|
4844
|
+
align-items: center;
|
|
4845
|
+
justify-content: center;
|
|
4846
|
+
gap: ${theme.spacing[2]};
|
|
4847
|
+
height: ${theme.sizes.button.height};
|
|
4848
|
+
padding: 0 ${theme.spacing[4]};
|
|
4849
|
+
border-radius: ${theme.radius.md};
|
|
4850
|
+
font-size: ${theme.fontSize.sm};
|
|
4851
|
+
font-weight: ${theme.fontWeight.medium};
|
|
4852
|
+
font-family: ${theme.fontFamily.base};
|
|
4853
|
+
cursor: pointer;
|
|
4854
|
+
transition: all ${theme.transition.fast};
|
|
4855
|
+
|
|
4856
|
+
${(props) => props.$primary ? `
|
|
4857
|
+
background-color: ${theme.colors.primary};
|
|
4858
|
+
color: ${theme.colors.bgWhite};
|
|
4859
|
+
border: none;
|
|
4860
|
+
|
|
4861
|
+
&:hover:not(:disabled) {
|
|
4862
|
+
background-color: ${theme.colors.primaryHover};
|
|
4863
|
+
}
|
|
4864
|
+
|
|
4865
|
+
&:disabled {
|
|
4866
|
+
opacity: 0.5;
|
|
4867
|
+
cursor: not-allowed;
|
|
4868
|
+
}
|
|
4869
|
+
` : `
|
|
4870
|
+
background-color: ${theme.colors.bgWhite};
|
|
4871
|
+
color: ${theme.colors.text};
|
|
4872
|
+
border: 1px solid ${theme.colors.border};
|
|
4873
|
+
|
|
4874
|
+
&:hover:not(:disabled) {
|
|
4875
|
+
background-color: ${theme.colors.bgLight};
|
|
4876
|
+
}
|
|
4877
|
+
|
|
4878
|
+
&:disabled {
|
|
4879
|
+
opacity: 0.5;
|
|
4880
|
+
cursor: not-allowed;
|
|
4881
|
+
}
|
|
4882
|
+
`}
|
|
4883
|
+
`;
|
|
4884
|
+
var ProfileSpinner = styled.div`
|
|
4885
|
+
width: 1rem;
|
|
4886
|
+
height: 1rem;
|
|
4887
|
+
border: 2px solid transparent;
|
|
4888
|
+
border-top-color: currentColor;
|
|
4889
|
+
border-radius: ${theme.radius.full};
|
|
4890
|
+
animation: spin 0.6s linear infinite;
|
|
4891
|
+
|
|
4892
|
+
@keyframes spin {
|
|
4893
|
+
to {
|
|
4894
|
+
transform: rotate(360deg);
|
|
4895
|
+
}
|
|
4896
|
+
}
|
|
4897
|
+
`;
|
|
4898
|
+
var READ_ONLY_FIELDS = ["id", "email", "avatar_url", "created_at", "updated_at"];
|
|
4899
|
+
var HIDDEN_FIELDS = ["id"];
|
|
4900
|
+
function formatFieldLabel(key) {
|
|
4901
|
+
return key.replace(/_/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").toLowerCase();
|
|
4902
|
+
}
|
|
4903
|
+
function UserProfileModal({ onClose, onError }) {
|
|
4904
|
+
const { user, updateUser, isLoaded } = useInsforge();
|
|
4905
|
+
const [isEditing, setIsEditing] = React2.useState(false);
|
|
4906
|
+
const [isSaving, setIsSaving] = React2.useState(false);
|
|
4907
|
+
const [imageError, setImageError] = React2.useState(false);
|
|
4908
|
+
const [formData, setFormData] = React2.useState({});
|
|
4909
|
+
React2.useEffect(() => {
|
|
4910
|
+
if (user) {
|
|
4911
|
+
const initialData = {
|
|
4912
|
+
name: user.profile?.name || ""
|
|
4913
|
+
};
|
|
4914
|
+
if (user.profile) {
|
|
4915
|
+
Object.entries(user.profile).forEach(([key, value]) => {
|
|
4916
|
+
if (!HIDDEN_FIELDS.includes(key) && typeof value === "string") {
|
|
4917
|
+
initialData[key] = value;
|
|
4918
|
+
}
|
|
4919
|
+
});
|
|
4920
|
+
}
|
|
4921
|
+
setFormData(initialData);
|
|
4922
|
+
}
|
|
4923
|
+
}, [user]);
|
|
4924
|
+
React2.useEffect(() => {
|
|
4925
|
+
setImageError(false);
|
|
4926
|
+
const avatarUrl = user?.profile?.avatar_url;
|
|
4927
|
+
if (!avatarUrl) {
|
|
4928
|
+
return;
|
|
4929
|
+
}
|
|
4930
|
+
const checkImageUrl = async () => {
|
|
4931
|
+
try {
|
|
4932
|
+
const response = await fetch(avatarUrl, {
|
|
4933
|
+
method: "HEAD",
|
|
4934
|
+
cache: "no-cache"
|
|
4935
|
+
});
|
|
4936
|
+
if (!response.ok) {
|
|
4937
|
+
setImageError(true);
|
|
4938
|
+
}
|
|
4939
|
+
} catch {
|
|
4940
|
+
setImageError(true);
|
|
4941
|
+
}
|
|
4942
|
+
};
|
|
4943
|
+
void checkImageUrl();
|
|
4944
|
+
}, [user?.profile?.avatar_url]);
|
|
4945
|
+
const handleFieldChange = React2.useCallback((key, value) => {
|
|
4946
|
+
setFormData((prev2) => ({
|
|
4947
|
+
...prev2,
|
|
4948
|
+
[key]: value
|
|
4949
|
+
}));
|
|
4950
|
+
}, []);
|
|
4951
|
+
const handleSave = React2.useCallback(async () => {
|
|
4952
|
+
if (!user) return;
|
|
4953
|
+
setIsSaving(true);
|
|
4954
|
+
try {
|
|
4955
|
+
const { name, ...dynamicFields } = formData;
|
|
4956
|
+
const updateData = {
|
|
4957
|
+
profile: {
|
|
4958
|
+
name
|
|
4959
|
+
}
|
|
4960
|
+
};
|
|
4961
|
+
if (Object.keys(dynamicFields).length > 0) {
|
|
4962
|
+
updateData.profile = dynamicFields;
|
|
4963
|
+
}
|
|
4964
|
+
const result = await updateUser(updateData);
|
|
4965
|
+
if (result?.error) {
|
|
4966
|
+
onError?.(result.error);
|
|
4967
|
+
} else {
|
|
4968
|
+
setIsEditing(false);
|
|
4969
|
+
}
|
|
4970
|
+
} catch (error) {
|
|
4971
|
+
onError?.(error instanceof Error ? error.message : "Failed to update profile");
|
|
4972
|
+
} finally {
|
|
4973
|
+
setIsSaving(false);
|
|
4974
|
+
}
|
|
4975
|
+
}, [user, formData, updateUser, onError]);
|
|
4976
|
+
const handleCancel = React2.useCallback(() => {
|
|
4977
|
+
if (user) {
|
|
4978
|
+
const resetData = {
|
|
4979
|
+
name: user.profile?.name || ""
|
|
4980
|
+
};
|
|
4981
|
+
if (user.profile) {
|
|
4982
|
+
Object.entries(user.profile).forEach(([key, value]) => {
|
|
4983
|
+
if (!HIDDEN_FIELDS.includes(key) && typeof value === "string") {
|
|
4984
|
+
resetData[key] = value;
|
|
4985
|
+
}
|
|
4986
|
+
});
|
|
4987
|
+
}
|
|
4988
|
+
setFormData(resetData);
|
|
4989
|
+
}
|
|
4990
|
+
setIsEditing(false);
|
|
4991
|
+
}, [user]);
|
|
4992
|
+
const handleOverlayClick = React2.useCallback(
|
|
4993
|
+
(e) => {
|
|
4994
|
+
if (e.target === e.currentTarget) {
|
|
4995
|
+
onClose();
|
|
4996
|
+
}
|
|
4997
|
+
},
|
|
4998
|
+
[onClose]
|
|
4999
|
+
);
|
|
5000
|
+
React2.useEffect(() => {
|
|
5001
|
+
const handleEscape = (e) => {
|
|
5002
|
+
if (e.key === "Escape") {
|
|
5003
|
+
if (isEditing) {
|
|
5004
|
+
handleCancel();
|
|
5005
|
+
} else {
|
|
5006
|
+
onClose();
|
|
5007
|
+
}
|
|
5008
|
+
}
|
|
5009
|
+
};
|
|
5010
|
+
document.addEventListener("keydown", handleEscape);
|
|
5011
|
+
return () => document.removeEventListener("keydown", handleEscape);
|
|
5012
|
+
}, [isEditing, handleCancel, onClose]);
|
|
5013
|
+
if (!isLoaded || !user) {
|
|
5014
|
+
return null;
|
|
5015
|
+
}
|
|
5016
|
+
const initials = user.profile?.name ? user.profile.name.charAt(0).toUpperCase() : user.email.split("@")[0].slice(0, 2).toUpperCase();
|
|
5017
|
+
const fields = [];
|
|
5018
|
+
fields.push({ key: "email", value: user.email, readOnly: true });
|
|
5019
|
+
fields.push({
|
|
5020
|
+
key: "name",
|
|
5021
|
+
value: isEditing ? formData.name || "" : user.profile?.name || "",
|
|
5022
|
+
readOnly: false
|
|
5023
|
+
});
|
|
5024
|
+
if (user.profile) {
|
|
5025
|
+
Object.entries(user.profile).forEach(([key, value]) => {
|
|
5026
|
+
if (!HIDDEN_FIELDS.includes(key) && typeof value === "string") {
|
|
5027
|
+
fields.push({
|
|
5028
|
+
key,
|
|
5029
|
+
value: isEditing ? formData[key] ?? value : value,
|
|
5030
|
+
readOnly: READ_ONLY_FIELDS.includes(key)
|
|
5031
|
+
});
|
|
5032
|
+
}
|
|
5033
|
+
});
|
|
5034
|
+
}
|
|
5035
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ProfileModalOverlay, { onClick: handleOverlayClick, children: /* @__PURE__ */ jsxRuntime.jsxs(ProfileModalContainer, { onClick: (e) => e.stopPropagation(), children: [
|
|
5036
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ProfileModalHeader, { children: [
|
|
5037
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProfileModalTitle, { children: "Profile" }),
|
|
5038
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProfileModalCloseButton, { onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {}) })
|
|
5039
|
+
] }),
|
|
5040
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ProfileModalBody, { children: [
|
|
5041
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProfileAvatarSection, { children: /* @__PURE__ */ jsxRuntime.jsx(ProfileAvatar, { children: user.profile?.avatar_url && !imageError ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
5042
|
+
ProfileAvatarImage,
|
|
5043
|
+
{
|
|
5044
|
+
src: user.profile.avatar_url,
|
|
5045
|
+
alt: user.profile?.name || user.email,
|
|
5046
|
+
onError: () => setImageError(true)
|
|
5047
|
+
}
|
|
5048
|
+
) : initials }) }),
|
|
5049
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProfileFieldsContainer, { children: fields.map(({ key, value, readOnly }) => /* @__PURE__ */ jsxRuntime.jsxs(ProfileField, { children: [
|
|
5050
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProfileFieldLabel, { children: formatFieldLabel(key) }),
|
|
5051
|
+
isEditing && !readOnly ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
5052
|
+
ProfileFieldInput,
|
|
5053
|
+
{
|
|
5054
|
+
type: "text",
|
|
5055
|
+
value: formData[key] ?? value,
|
|
5056
|
+
onChange: (e) => handleFieldChange(key, e.target.value),
|
|
5057
|
+
disabled: isSaving
|
|
5058
|
+
}
|
|
5059
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(ProfileFieldValue, { children: value || "-" })
|
|
5060
|
+
] }, key)) })
|
|
5061
|
+
] }),
|
|
5062
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProfileModalFooter, { children: isEditing ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5063
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProfileButton, { onClick: handleCancel, disabled: isSaving, children: "Cancel" }),
|
|
5064
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ProfileButton, { $primary: true, onClick: () => void handleSave(), disabled: isSaving, children: [
|
|
5065
|
+
isSaving && /* @__PURE__ */ jsxRuntime.jsx(ProfileSpinner, {}),
|
|
5066
|
+
isSaving ? "Saving..." : "Save"
|
|
5067
|
+
] })
|
|
5068
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(ProfileButton, { $primary: true, onClick: () => setIsEditing(true), children: "Edit Profile" }) })
|
|
5069
|
+
] }) });
|
|
5070
|
+
}
|
|
5071
|
+
function UserButton({
|
|
5072
|
+
afterSignOutUrl = "/",
|
|
5073
|
+
mode = "simple",
|
|
5074
|
+
showProfile = true,
|
|
5075
|
+
onProfileError
|
|
5076
|
+
}) {
|
|
4698
5077
|
const { user } = useInsforge();
|
|
4699
5078
|
const [isOpen, setIsOpen] = React2.useState(false);
|
|
5079
|
+
const [showProfileModal, setShowProfileModal] = React2.useState(false);
|
|
4700
5080
|
const [imageError, setImageError] = React2.useState(false);
|
|
4701
5081
|
const [openUpward, setOpenUpward] = React2.useState(false);
|
|
4702
5082
|
const [horizontalOffset, setHorizontalOffset] = React2.useState(0);
|
|
@@ -4704,7 +5084,7 @@ function UserButton({ afterSignOutUrl = "/", mode = "simple" }) {
|
|
|
4704
5084
|
const menuRef = React2.useRef(null);
|
|
4705
5085
|
React2.useEffect(() => {
|
|
4706
5086
|
setImageError(false);
|
|
4707
|
-
const avatarUrl = user?.
|
|
5087
|
+
const avatarUrl = user?.profile?.avatar_url;
|
|
4708
5088
|
if (!avatarUrl) {
|
|
4709
5089
|
return;
|
|
4710
5090
|
}
|
|
@@ -4725,7 +5105,7 @@ function UserButton({ afterSignOutUrl = "/", mode = "simple" }) {
|
|
|
4725
5105
|
}
|
|
4726
5106
|
};
|
|
4727
5107
|
void checkImageUrl();
|
|
4728
|
-
}, [user?.
|
|
5108
|
+
}, [user?.profile?.avatar_url]);
|
|
4729
5109
|
React2.useEffect(() => {
|
|
4730
5110
|
if (isOpen && dropdownRef.current) {
|
|
4731
5111
|
const buttonRect = dropdownRef.current.getBoundingClientRect();
|
|
@@ -4769,7 +5149,7 @@ function UserButton({ afterSignOutUrl = "/", mode = "simple" }) {
|
|
|
4769
5149
|
if (!user) {
|
|
4770
5150
|
return null;
|
|
4771
5151
|
}
|
|
4772
|
-
const initials = user.name ? user.name.charAt(0).toUpperCase() : user.email.split("@")[0].slice(0, 2).toUpperCase();
|
|
5152
|
+
const initials = user.profile?.name ? user.profile.name.charAt(0).toUpperCase() : user.email.split("@")[0].slice(0, 2).toUpperCase();
|
|
4773
5153
|
return /* @__PURE__ */ jsxRuntime.jsxs(UserButtonContainer, { ref: dropdownRef, children: [
|
|
4774
5154
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4775
5155
|
UserButtonButton,
|
|
@@ -4779,25 +5159,41 @@ function UserButton({ afterSignOutUrl = "/", mode = "simple" }) {
|
|
|
4779
5159
|
"aria-expanded": isOpen,
|
|
4780
5160
|
"aria-haspopup": "true",
|
|
4781
5161
|
children: [
|
|
4782
|
-
/* @__PURE__ */ jsxRuntime.jsx(UserButtonAvatar, { children: user.
|
|
5162
|
+
/* @__PURE__ */ jsxRuntime.jsx(UserButtonAvatar, { children: user.profile?.avatar_url && !imageError ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4783
5163
|
UserButtonAvatarImage,
|
|
4784
5164
|
{
|
|
4785
|
-
src: user.
|
|
5165
|
+
src: user.profile.avatar_url,
|
|
4786
5166
|
alt: user.email,
|
|
4787
5167
|
onError: () => setImageError(true)
|
|
4788
5168
|
}
|
|
4789
5169
|
) : /* @__PURE__ */ jsxRuntime.jsx(UserButtonAvatarInitials, { children: initials }) }),
|
|
4790
5170
|
mode === "detailed" && /* @__PURE__ */ jsxRuntime.jsxs(UserButtonInfo, { children: [
|
|
4791
|
-
user.name && /* @__PURE__ */ jsxRuntime.jsx(UserButtonName, { children: user.name }),
|
|
5171
|
+
user.profile?.name && /* @__PURE__ */ jsxRuntime.jsx(UserButtonName, { children: user.profile.name }),
|
|
4792
5172
|
/* @__PURE__ */ jsxRuntime.jsx(UserButtonEmail, { children: user.email })
|
|
4793
5173
|
] })
|
|
4794
5174
|
]
|
|
4795
5175
|
}
|
|
4796
5176
|
),
|
|
4797
|
-
isOpen && /* @__PURE__ */ jsxRuntime.
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
5177
|
+
isOpen && /* @__PURE__ */ jsxRuntime.jsxs(UserButtonMenu, { ref: menuRef, $openUpward: openUpward, $horizontalOffset: horizontalOffset, children: [
|
|
5178
|
+
showProfile && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5179
|
+
UserButtonMenuItem,
|
|
5180
|
+
{
|
|
5181
|
+
onClick: () => {
|
|
5182
|
+
setShowProfileModal(true);
|
|
5183
|
+
setIsOpen(false);
|
|
5184
|
+
},
|
|
5185
|
+
children: [
|
|
5186
|
+
/* @__PURE__ */ jsxRuntime.jsx(UserButtonMenuItemIcon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.User, {}) }),
|
|
5187
|
+
"Profile"
|
|
5188
|
+
]
|
|
5189
|
+
}
|
|
5190
|
+
),
|
|
5191
|
+
/* @__PURE__ */ jsxRuntime.jsx(SignOutButton, { afterSignOutUrl, children: /* @__PURE__ */ jsxRuntime.jsxs(UserButtonMenuItem, { $signout: true, onClick: () => setIsOpen(false), children: [
|
|
5192
|
+
/* @__PURE__ */ jsxRuntime.jsx(UserButtonMenuItemIcon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.LogOut, {}) }),
|
|
5193
|
+
"Sign out"
|
|
5194
|
+
] }) })
|
|
5195
|
+
] }),
|
|
5196
|
+
showProfileModal && /* @__PURE__ */ jsxRuntime.jsx(UserProfileModal, { onClose: () => setShowProfileModal(false), onError: onProfileError })
|
|
4801
5197
|
] });
|
|
4802
5198
|
}
|
|
4803
5199
|
function Protect({
|
|
@@ -4946,6 +5342,7 @@ exports.SignUpForm = SignUpForm;
|
|
|
4946
5342
|
exports.SignedIn = SignedIn;
|
|
4947
5343
|
exports.SignedOut = SignedOut;
|
|
4948
5344
|
exports.UserButton = UserButton;
|
|
5345
|
+
exports.UserProfileModal = UserProfileModal;
|
|
4949
5346
|
exports.VerifyEmail = VerifyEmail;
|
|
4950
5347
|
exports.VerifyEmailStatus = VerifyEmailStatus;
|
|
4951
5348
|
//# sourceMappingURL=components.cjs.map
|