@insforge/react 1.0.3 → 1.0.5-dev.0
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/components.cjs +410 -12
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +20 -9
- package/dist/components.d.ts +20 -9
- package/dist/components.js +411 -14
- package/dist/components.js.map +1 -1
- package/dist/index.cjs +437 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +438 -36
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -246,7 +246,7 @@ var require_react_is_development = __commonJS({
|
|
|
246
246
|
var ContextProvider = REACT_PROVIDER_TYPE;
|
|
247
247
|
var Element = REACT_ELEMENT_TYPE;
|
|
248
248
|
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
249
|
-
var
|
|
249
|
+
var Fragment10 = REACT_FRAGMENT_TYPE;
|
|
250
250
|
var Lazy = REACT_LAZY_TYPE;
|
|
251
251
|
var Memo = REACT_MEMO_TYPE;
|
|
252
252
|
var Portal = REACT_PORTAL_TYPE;
|
|
@@ -305,7 +305,7 @@ var require_react_is_development = __commonJS({
|
|
|
305
305
|
exports$1.ContextProvider = ContextProvider;
|
|
306
306
|
exports$1.Element = Element;
|
|
307
307
|
exports$1.ForwardRef = ForwardRef;
|
|
308
|
-
exports$1.Fragment =
|
|
308
|
+
exports$1.Fragment = Fragment10;
|
|
309
309
|
exports$1.Lazy = Lazy;
|
|
310
310
|
exports$1.Memo = Memo;
|
|
311
311
|
exports$1.Portal = Portal;
|
|
@@ -589,11 +589,14 @@ var InsforgeManager = class _InsforgeManager {
|
|
|
589
589
|
const userResult = await this.sdk.auth.getCurrentUser();
|
|
590
590
|
if (userResult.data) {
|
|
591
591
|
const profile = userResult.data.user.profile;
|
|
592
|
+
const { name, avatar_url, ...dynamicFields } = profile || {};
|
|
592
593
|
const userData = {
|
|
593
594
|
id: userResult.data.user.id,
|
|
594
595
|
email: userResult.data.user.email,
|
|
595
|
-
name:
|
|
596
|
-
avatarUrl:
|
|
596
|
+
name: name || "",
|
|
597
|
+
avatarUrl: avatar_url || "",
|
|
598
|
+
// Store additional dynamic fields
|
|
599
|
+
profile: Object.keys(dynamicFields).length > 0 ? dynamicFields : void 0
|
|
597
600
|
};
|
|
598
601
|
this.user = userData;
|
|
599
602
|
if (this.config.onAuthChange) {
|
|
@@ -630,11 +633,14 @@ var InsforgeManager = class _InsforgeManager {
|
|
|
630
633
|
const userResult = await this.sdk.auth.getCurrentUser();
|
|
631
634
|
if (userResult.data) {
|
|
632
635
|
const profile = userResult.data.user.profile;
|
|
636
|
+
const { name, avatar_url, ...dynamicFields } = profile || {};
|
|
633
637
|
const userData = {
|
|
634
638
|
id: userResult.data.user.id,
|
|
635
639
|
email: userResult.data.user.email,
|
|
636
|
-
name:
|
|
637
|
-
avatarUrl:
|
|
640
|
+
name: name || "",
|
|
641
|
+
avatarUrl: avatar_url || "",
|
|
642
|
+
// Store additional dynamic fields
|
|
643
|
+
profile: Object.keys(dynamicFields).length > 0 ? dynamicFields : void 0
|
|
638
644
|
};
|
|
639
645
|
this.user = userData;
|
|
640
646
|
this.notifyListeners();
|
|
@@ -735,27 +741,32 @@ var InsforgeManager = class _InsforgeManager {
|
|
|
735
741
|
if (!this.user) {
|
|
736
742
|
return { error: "No user signed in" };
|
|
737
743
|
}
|
|
738
|
-
const profileUpdate = {
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
}
|
|
744
|
+
const profileUpdate = {};
|
|
745
|
+
if (data.name !== void 0) {
|
|
746
|
+
profileUpdate.name = data.name;
|
|
747
|
+
}
|
|
748
|
+
if (data.avatarUrl !== void 0) {
|
|
749
|
+
profileUpdate.avatar_url = data.avatarUrl;
|
|
750
|
+
}
|
|
751
|
+
if (data.profile) {
|
|
752
|
+
Object.assign(profileUpdate, data.profile);
|
|
753
|
+
}
|
|
742
754
|
const result = await this.sdk.auth.setProfile(profileUpdate);
|
|
743
755
|
if (result.data) {
|
|
744
|
-
const
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
}
|
|
757
|
-
this.notifyListeners();
|
|
756
|
+
const updatedUser = {
|
|
757
|
+
id: this.user.id,
|
|
758
|
+
email: this.user.email,
|
|
759
|
+
// Use sent value if provided, otherwise keep existing
|
|
760
|
+
name: profileUpdate.name !== void 0 ? profileUpdate.name : this.user.name || "",
|
|
761
|
+
avatarUrl: profileUpdate.avatar_url !== void 0 ? profileUpdate.avatar_url : this.user.avatarUrl || "",
|
|
762
|
+
// Merge existing profile with new dynamic fields
|
|
763
|
+
profile: data.profile ? { ...this.user.profile, ...data.profile } : this.user.profile
|
|
764
|
+
};
|
|
765
|
+
this.user = updatedUser;
|
|
766
|
+
if (this.config.onAuthChange) {
|
|
767
|
+
this.config.onAuthChange(updatedUser);
|
|
758
768
|
}
|
|
769
|
+
this.notifyListeners();
|
|
759
770
|
return null;
|
|
760
771
|
}
|
|
761
772
|
const error = result.error;
|
|
@@ -5118,11 +5129,7 @@ function VerifyEmail({ token: token2, onSuccess, onError, ...uiProps }) {
|
|
|
5118
5129
|
}
|
|
5119
5130
|
setStatus("success");
|
|
5120
5131
|
if (onSuccess) {
|
|
5121
|
-
onSuccess(
|
|
5122
|
-
accessToken: result.accessToken,
|
|
5123
|
-
user: result.user,
|
|
5124
|
-
redirectTo: result.redirectTo
|
|
5125
|
-
});
|
|
5132
|
+
onSuccess(result);
|
|
5126
5133
|
}
|
|
5127
5134
|
} catch (err) {
|
|
5128
5135
|
const errorMessage = err instanceof Error ? err.message : "Email verification failed";
|
|
@@ -5282,9 +5289,382 @@ var UserButtonMenuItemIcon = styled.div`
|
|
|
5282
5289
|
height: 100%;
|
|
5283
5290
|
}
|
|
5284
5291
|
`;
|
|
5285
|
-
|
|
5292
|
+
var ProfileModalOverlay = styled.div`
|
|
5293
|
+
position: fixed;
|
|
5294
|
+
inset: 0;
|
|
5295
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
5296
|
+
display: flex;
|
|
5297
|
+
align-items: center;
|
|
5298
|
+
justify-content: center;
|
|
5299
|
+
z-index: 100;
|
|
5300
|
+
padding: ${theme.spacing[4]};
|
|
5301
|
+
`;
|
|
5302
|
+
var ProfileModalContainer = styled.div`
|
|
5303
|
+
background-color: ${theme.colors.bgWhite};
|
|
5304
|
+
border-radius: ${theme.radius.xl};
|
|
5305
|
+
box-shadow: ${theme.shadow.lg};
|
|
5306
|
+
width: 100%;
|
|
5307
|
+
max-width: 400px;
|
|
5308
|
+
max-height: 90vh;
|
|
5309
|
+
overflow: hidden;
|
|
5310
|
+
display: flex;
|
|
5311
|
+
flex-direction: column;
|
|
5312
|
+
font-family: ${theme.fontFamily.base};
|
|
5313
|
+
`;
|
|
5314
|
+
var ProfileModalHeader = styled.div`
|
|
5315
|
+
display: flex;
|
|
5316
|
+
align-items: center;
|
|
5317
|
+
justify-content: space-between;
|
|
5318
|
+
padding: ${theme.spacing[4]} ${theme.spacing[6]};
|
|
5319
|
+
border-bottom: 1px solid ${theme.colors.border};
|
|
5320
|
+
`;
|
|
5321
|
+
var ProfileModalTitle = styled.h2`
|
|
5322
|
+
font-size: ${theme.fontSize.lg};
|
|
5323
|
+
font-weight: ${theme.fontWeight.semibold};
|
|
5324
|
+
color: ${theme.colors.text};
|
|
5325
|
+
margin: 0;
|
|
5326
|
+
`;
|
|
5327
|
+
var ProfileModalCloseButton = styled.button`
|
|
5328
|
+
display: flex;
|
|
5329
|
+
align-items: center;
|
|
5330
|
+
justify-content: center;
|
|
5331
|
+
width: 2rem;
|
|
5332
|
+
height: 2rem;
|
|
5333
|
+
border-radius: ${theme.radius.md};
|
|
5334
|
+
background: none;
|
|
5335
|
+
border: none;
|
|
5336
|
+
cursor: pointer;
|
|
5337
|
+
color: ${theme.colors.textSecondary};
|
|
5338
|
+
transition: all ${theme.transition.fast};
|
|
5339
|
+
|
|
5340
|
+
&:hover {
|
|
5341
|
+
background-color: ${theme.colors.bgLight};
|
|
5342
|
+
color: ${theme.colors.text};
|
|
5343
|
+
}
|
|
5344
|
+
|
|
5345
|
+
svg {
|
|
5346
|
+
width: 1.25rem;
|
|
5347
|
+
height: 1.25rem;
|
|
5348
|
+
}
|
|
5349
|
+
`;
|
|
5350
|
+
var ProfileModalBody = styled.div`
|
|
5351
|
+
padding: ${theme.spacing[6]};
|
|
5352
|
+
overflow-y: auto;
|
|
5353
|
+
flex: 1;
|
|
5354
|
+
`;
|
|
5355
|
+
var ProfileAvatarSection = styled.div`
|
|
5356
|
+
display: flex;
|
|
5357
|
+
flex-direction: column;
|
|
5358
|
+
align-items: center;
|
|
5359
|
+
margin-bottom: ${theme.spacing[6]};
|
|
5360
|
+
`;
|
|
5361
|
+
var ProfileAvatar = styled.div`
|
|
5362
|
+
width: 5rem;
|
|
5363
|
+
height: 5rem;
|
|
5364
|
+
border-radius: ${theme.radius.full};
|
|
5365
|
+
background-color: ${theme.colors.primary};
|
|
5366
|
+
color: ${theme.colors.bgWhite};
|
|
5367
|
+
display: flex;
|
|
5368
|
+
align-items: center;
|
|
5369
|
+
justify-content: center;
|
|
5370
|
+
font-weight: ${theme.fontWeight.semibold};
|
|
5371
|
+
font-size: ${theme.fontSize["2xl"]};
|
|
5372
|
+
overflow: hidden;
|
|
5373
|
+
`;
|
|
5374
|
+
var ProfileAvatarImage = styled.img`
|
|
5375
|
+
width: 100%;
|
|
5376
|
+
height: 100%;
|
|
5377
|
+
object-fit: cover;
|
|
5378
|
+
`;
|
|
5379
|
+
var ProfileFieldsContainer = styled.div`
|
|
5380
|
+
display: flex;
|
|
5381
|
+
flex-direction: column;
|
|
5382
|
+
gap: ${theme.spacing[4]};
|
|
5383
|
+
`;
|
|
5384
|
+
var ProfileField = styled.div`
|
|
5385
|
+
display: flex;
|
|
5386
|
+
flex-direction: column;
|
|
5387
|
+
gap: ${theme.spacing[1]};
|
|
5388
|
+
`;
|
|
5389
|
+
var ProfileFieldLabel = styled.label`
|
|
5390
|
+
font-size: ${theme.fontSize.sm};
|
|
5391
|
+
font-weight: ${theme.fontWeight.medium};
|
|
5392
|
+
color: ${theme.colors.textSecondary};
|
|
5393
|
+
text-transform: capitalize;
|
|
5394
|
+
`;
|
|
5395
|
+
var ProfileFieldValue = styled.div`
|
|
5396
|
+
font-size: ${theme.fontSize.base};
|
|
5397
|
+
color: ${theme.colors.text};
|
|
5398
|
+
padding: ${theme.spacing[2]} 0;
|
|
5399
|
+
word-break: break-word;
|
|
5400
|
+
`;
|
|
5401
|
+
var ProfileFieldInput = styled.input`
|
|
5402
|
+
width: 100%;
|
|
5403
|
+
height: ${theme.sizes.input.height};
|
|
5404
|
+
padding: 0 ${theme.spacing[3]};
|
|
5405
|
+
border: 1px solid ${theme.colors.border};
|
|
5406
|
+
border-radius: ${theme.radius.md};
|
|
5407
|
+
font-size: ${theme.fontSize.base};
|
|
5408
|
+
font-family: ${theme.fontFamily.base};
|
|
5409
|
+
color: ${theme.colors.text};
|
|
5410
|
+
background-color: ${theme.colors.bgWhite};
|
|
5411
|
+
transition: border-color ${theme.transition.fast};
|
|
5412
|
+
|
|
5413
|
+
&:focus {
|
|
5414
|
+
outline: none;
|
|
5415
|
+
border-color: ${theme.colors.borderFocus};
|
|
5416
|
+
}
|
|
5417
|
+
|
|
5418
|
+
&:disabled {
|
|
5419
|
+
background-color: ${theme.colors.bgLight};
|
|
5420
|
+
color: ${theme.colors.textSecondary};
|
|
5421
|
+
cursor: not-allowed;
|
|
5422
|
+
}
|
|
5423
|
+
`;
|
|
5424
|
+
var ProfileModalFooter = styled.div`
|
|
5425
|
+
display: flex;
|
|
5426
|
+
align-items: center;
|
|
5427
|
+
justify-content: flex-end;
|
|
5428
|
+
gap: ${theme.spacing[3]};
|
|
5429
|
+
padding: ${theme.spacing[4]} ${theme.spacing[6]};
|
|
5430
|
+
border-top: 1px solid ${theme.colors.border};
|
|
5431
|
+
`;
|
|
5432
|
+
var ProfileButton = styled.button`
|
|
5433
|
+
display: flex;
|
|
5434
|
+
align-items: center;
|
|
5435
|
+
justify-content: center;
|
|
5436
|
+
gap: ${theme.spacing[2]};
|
|
5437
|
+
height: ${theme.sizes.button.height};
|
|
5438
|
+
padding: 0 ${theme.spacing[4]};
|
|
5439
|
+
border-radius: ${theme.radius.md};
|
|
5440
|
+
font-size: ${theme.fontSize.sm};
|
|
5441
|
+
font-weight: ${theme.fontWeight.medium};
|
|
5442
|
+
font-family: ${theme.fontFamily.base};
|
|
5443
|
+
cursor: pointer;
|
|
5444
|
+
transition: all ${theme.transition.fast};
|
|
5445
|
+
|
|
5446
|
+
${(props) => props.$primary ? `
|
|
5447
|
+
background-color: ${theme.colors.primary};
|
|
5448
|
+
color: ${theme.colors.bgWhite};
|
|
5449
|
+
border: none;
|
|
5450
|
+
|
|
5451
|
+
&:hover:not(:disabled) {
|
|
5452
|
+
background-color: ${theme.colors.primaryHover};
|
|
5453
|
+
}
|
|
5454
|
+
|
|
5455
|
+
&:disabled {
|
|
5456
|
+
opacity: 0.5;
|
|
5457
|
+
cursor: not-allowed;
|
|
5458
|
+
}
|
|
5459
|
+
` : `
|
|
5460
|
+
background-color: ${theme.colors.bgWhite};
|
|
5461
|
+
color: ${theme.colors.text};
|
|
5462
|
+
border: 1px solid ${theme.colors.border};
|
|
5463
|
+
|
|
5464
|
+
&:hover:not(:disabled) {
|
|
5465
|
+
background-color: ${theme.colors.bgLight};
|
|
5466
|
+
}
|
|
5467
|
+
|
|
5468
|
+
&:disabled {
|
|
5469
|
+
opacity: 0.5;
|
|
5470
|
+
cursor: not-allowed;
|
|
5471
|
+
}
|
|
5472
|
+
`}
|
|
5473
|
+
`;
|
|
5474
|
+
var ProfileSpinner = styled.div`
|
|
5475
|
+
width: 1rem;
|
|
5476
|
+
height: 1rem;
|
|
5477
|
+
border: 2px solid transparent;
|
|
5478
|
+
border-top-color: currentColor;
|
|
5479
|
+
border-radius: ${theme.radius.full};
|
|
5480
|
+
animation: spin 0.6s linear infinite;
|
|
5481
|
+
|
|
5482
|
+
@keyframes spin {
|
|
5483
|
+
to {
|
|
5484
|
+
transform: rotate(360deg);
|
|
5485
|
+
}
|
|
5486
|
+
}
|
|
5487
|
+
`;
|
|
5488
|
+
var READ_ONLY_FIELDS = ["id", "email", "avatar_url", "created_at", "updated_at"];
|
|
5489
|
+
var HIDDEN_FIELDS = ["id"];
|
|
5490
|
+
function formatFieldLabel(key) {
|
|
5491
|
+
return key.replace(/_/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").toLowerCase();
|
|
5492
|
+
}
|
|
5493
|
+
function UserProfileModal({ onClose, onError }) {
|
|
5494
|
+
const { user, updateUser, isLoaded } = useInsforge();
|
|
5495
|
+
const [isEditing, setIsEditing] = React2.useState(false);
|
|
5496
|
+
const [isSaving, setIsSaving] = React2.useState(false);
|
|
5497
|
+
const [imageError, setImageError] = React2.useState(false);
|
|
5498
|
+
const [formData, setFormData] = React2.useState({});
|
|
5499
|
+
React2.useEffect(() => {
|
|
5500
|
+
if (user) {
|
|
5501
|
+
const initialData = {
|
|
5502
|
+
name: user.name || ""
|
|
5503
|
+
};
|
|
5504
|
+
if (user.profile) {
|
|
5505
|
+
Object.entries(user.profile).forEach(([key, value]) => {
|
|
5506
|
+
if (!HIDDEN_FIELDS.includes(key) && typeof value === "string") {
|
|
5507
|
+
initialData[key] = value;
|
|
5508
|
+
}
|
|
5509
|
+
});
|
|
5510
|
+
}
|
|
5511
|
+
setFormData(initialData);
|
|
5512
|
+
}
|
|
5513
|
+
}, [user]);
|
|
5514
|
+
React2.useEffect(() => {
|
|
5515
|
+
setImageError(false);
|
|
5516
|
+
const avatarUrl = user?.avatarUrl;
|
|
5517
|
+
if (!avatarUrl) {
|
|
5518
|
+
return;
|
|
5519
|
+
}
|
|
5520
|
+
const checkImageUrl = async () => {
|
|
5521
|
+
try {
|
|
5522
|
+
const response = await fetch(avatarUrl, {
|
|
5523
|
+
method: "HEAD",
|
|
5524
|
+
cache: "no-cache"
|
|
5525
|
+
});
|
|
5526
|
+
if (!response.ok) {
|
|
5527
|
+
setImageError(true);
|
|
5528
|
+
}
|
|
5529
|
+
} catch {
|
|
5530
|
+
setImageError(true);
|
|
5531
|
+
}
|
|
5532
|
+
};
|
|
5533
|
+
void checkImageUrl();
|
|
5534
|
+
}, [user?.avatarUrl]);
|
|
5535
|
+
const handleFieldChange = React2.useCallback((key, value) => {
|
|
5536
|
+
setFormData((prev2) => ({
|
|
5537
|
+
...prev2,
|
|
5538
|
+
[key]: value
|
|
5539
|
+
}));
|
|
5540
|
+
}, []);
|
|
5541
|
+
const handleSave = React2.useCallback(async () => {
|
|
5542
|
+
if (!user) return;
|
|
5543
|
+
setIsSaving(true);
|
|
5544
|
+
try {
|
|
5545
|
+
const { name, ...dynamicFields } = formData;
|
|
5546
|
+
const updateData = {
|
|
5547
|
+
name
|
|
5548
|
+
};
|
|
5549
|
+
if (Object.keys(dynamicFields).length > 0) {
|
|
5550
|
+
updateData.profile = dynamicFields;
|
|
5551
|
+
}
|
|
5552
|
+
const result = await updateUser(updateData);
|
|
5553
|
+
if (result?.error) {
|
|
5554
|
+
onError?.(result.error);
|
|
5555
|
+
} else {
|
|
5556
|
+
setIsEditing(false);
|
|
5557
|
+
}
|
|
5558
|
+
} catch (error) {
|
|
5559
|
+
onError?.(error instanceof Error ? error.message : "Failed to update profile");
|
|
5560
|
+
} finally {
|
|
5561
|
+
setIsSaving(false);
|
|
5562
|
+
}
|
|
5563
|
+
}, [user, formData, updateUser, onError]);
|
|
5564
|
+
const handleCancel = React2.useCallback(() => {
|
|
5565
|
+
if (user) {
|
|
5566
|
+
const resetData = {
|
|
5567
|
+
name: user.name || ""
|
|
5568
|
+
};
|
|
5569
|
+
if (user.profile) {
|
|
5570
|
+
Object.entries(user.profile).forEach(([key, value]) => {
|
|
5571
|
+
if (!HIDDEN_FIELDS.includes(key) && typeof value === "string") {
|
|
5572
|
+
resetData[key] = value;
|
|
5573
|
+
}
|
|
5574
|
+
});
|
|
5575
|
+
}
|
|
5576
|
+
setFormData(resetData);
|
|
5577
|
+
}
|
|
5578
|
+
setIsEditing(false);
|
|
5579
|
+
}, [user]);
|
|
5580
|
+
const handleOverlayClick = React2.useCallback(
|
|
5581
|
+
(e) => {
|
|
5582
|
+
if (e.target === e.currentTarget) {
|
|
5583
|
+
onClose();
|
|
5584
|
+
}
|
|
5585
|
+
},
|
|
5586
|
+
[onClose]
|
|
5587
|
+
);
|
|
5588
|
+
React2.useEffect(() => {
|
|
5589
|
+
const handleEscape = (e) => {
|
|
5590
|
+
if (e.key === "Escape") {
|
|
5591
|
+
if (isEditing) {
|
|
5592
|
+
handleCancel();
|
|
5593
|
+
} else {
|
|
5594
|
+
onClose();
|
|
5595
|
+
}
|
|
5596
|
+
}
|
|
5597
|
+
};
|
|
5598
|
+
document.addEventListener("keydown", handleEscape);
|
|
5599
|
+
return () => document.removeEventListener("keydown", handleEscape);
|
|
5600
|
+
}, [isEditing, handleCancel, onClose]);
|
|
5601
|
+
if (!isLoaded || !user) {
|
|
5602
|
+
return null;
|
|
5603
|
+
}
|
|
5604
|
+
const initials = user.name ? user.name.charAt(0).toUpperCase() : user.email.split("@")[0].slice(0, 2).toUpperCase();
|
|
5605
|
+
const fields = [];
|
|
5606
|
+
fields.push({ key: "email", value: user.email, readOnly: true });
|
|
5607
|
+
fields.push({
|
|
5608
|
+
key: "name",
|
|
5609
|
+
value: isEditing ? formData.name || "" : user.name || "",
|
|
5610
|
+
readOnly: false
|
|
5611
|
+
});
|
|
5612
|
+
if (user.profile) {
|
|
5613
|
+
Object.entries(user.profile).forEach(([key, value]) => {
|
|
5614
|
+
if (!HIDDEN_FIELDS.includes(key) && typeof value === "string") {
|
|
5615
|
+
fields.push({
|
|
5616
|
+
key,
|
|
5617
|
+
value: isEditing ? formData[key] ?? value : value,
|
|
5618
|
+
readOnly: READ_ONLY_FIELDS.includes(key)
|
|
5619
|
+
});
|
|
5620
|
+
}
|
|
5621
|
+
});
|
|
5622
|
+
}
|
|
5623
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ProfileModalOverlay, { onClick: handleOverlayClick, children: /* @__PURE__ */ jsxRuntime.jsxs(ProfileModalContainer, { onClick: (e) => e.stopPropagation(), children: [
|
|
5624
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ProfileModalHeader, { children: [
|
|
5625
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProfileModalTitle, { children: "Profile" }),
|
|
5626
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProfileModalCloseButton, { onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, {}) })
|
|
5627
|
+
] }),
|
|
5628
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ProfileModalBody, { children: [
|
|
5629
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProfileAvatarSection, { children: /* @__PURE__ */ jsxRuntime.jsx(ProfileAvatar, { children: user.avatarUrl && !imageError ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
5630
|
+
ProfileAvatarImage,
|
|
5631
|
+
{
|
|
5632
|
+
src: user.avatarUrl,
|
|
5633
|
+
alt: user.name || user.email,
|
|
5634
|
+
onError: () => setImageError(true)
|
|
5635
|
+
}
|
|
5636
|
+
) : initials }) }),
|
|
5637
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProfileFieldsContainer, { children: fields.map(({ key, value, readOnly }) => /* @__PURE__ */ jsxRuntime.jsxs(ProfileField, { children: [
|
|
5638
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProfileFieldLabel, { children: formatFieldLabel(key) }),
|
|
5639
|
+
isEditing && !readOnly ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
5640
|
+
ProfileFieldInput,
|
|
5641
|
+
{
|
|
5642
|
+
type: "text",
|
|
5643
|
+
value: formData[key] ?? value,
|
|
5644
|
+
onChange: (e) => handleFieldChange(key, e.target.value),
|
|
5645
|
+
disabled: isSaving
|
|
5646
|
+
}
|
|
5647
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(ProfileFieldValue, { children: value || "-" })
|
|
5648
|
+
] }, key)) })
|
|
5649
|
+
] }),
|
|
5650
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProfileModalFooter, { children: isEditing ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5651
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProfileButton, { onClick: handleCancel, disabled: isSaving, children: "Cancel" }),
|
|
5652
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ProfileButton, { $primary: true, onClick: handleSave, disabled: isSaving, children: [
|
|
5653
|
+
isSaving && /* @__PURE__ */ jsxRuntime.jsx(ProfileSpinner, {}),
|
|
5654
|
+
isSaving ? "Saving..." : "Save"
|
|
5655
|
+
] })
|
|
5656
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(ProfileButton, { $primary: true, onClick: () => setIsEditing(true), children: "Edit Profile" }) })
|
|
5657
|
+
] }) });
|
|
5658
|
+
}
|
|
5659
|
+
function UserButton({
|
|
5660
|
+
afterSignOutUrl = "/",
|
|
5661
|
+
mode = "simple",
|
|
5662
|
+
showProfile = true,
|
|
5663
|
+
onProfileError
|
|
5664
|
+
}) {
|
|
5286
5665
|
const { user } = useInsforge();
|
|
5287
5666
|
const [isOpen, setIsOpen] = React2.useState(false);
|
|
5667
|
+
const [showProfileModal, setShowProfileModal] = React2.useState(false);
|
|
5288
5668
|
const [imageError, setImageError] = React2.useState(false);
|
|
5289
5669
|
const [openUpward, setOpenUpward] = React2.useState(false);
|
|
5290
5670
|
const [horizontalOffset, setHorizontalOffset] = React2.useState(0);
|
|
@@ -5382,10 +5762,32 @@ function UserButton({ afterSignOutUrl = "/", mode = "simple" }) {
|
|
|
5382
5762
|
]
|
|
5383
5763
|
}
|
|
5384
5764
|
),
|
|
5385
|
-
isOpen && /* @__PURE__ */ jsxRuntime.
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
|
|
5765
|
+
isOpen && /* @__PURE__ */ jsxRuntime.jsxs(UserButtonMenu, { ref: menuRef, $openUpward: openUpward, $horizontalOffset: horizontalOffset, children: [
|
|
5766
|
+
showProfile && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5767
|
+
UserButtonMenuItem,
|
|
5768
|
+
{
|
|
5769
|
+
onClick: () => {
|
|
5770
|
+
setShowProfileModal(true);
|
|
5771
|
+
setIsOpen(false);
|
|
5772
|
+
},
|
|
5773
|
+
children: [
|
|
5774
|
+
/* @__PURE__ */ jsxRuntime.jsx(UserButtonMenuItemIcon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.User, {}) }),
|
|
5775
|
+
"Profile"
|
|
5776
|
+
]
|
|
5777
|
+
}
|
|
5778
|
+
),
|
|
5779
|
+
/* @__PURE__ */ jsxRuntime.jsx(SignOutButton, { afterSignOutUrl, children: /* @__PURE__ */ jsxRuntime.jsxs(UserButtonMenuItem, { $signout: true, onClick: () => setIsOpen(false), children: [
|
|
5780
|
+
/* @__PURE__ */ jsxRuntime.jsx(UserButtonMenuItemIcon, { children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.LogOut, {}) }),
|
|
5781
|
+
"Sign out"
|
|
5782
|
+
] }) })
|
|
5783
|
+
] }),
|
|
5784
|
+
showProfileModal && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5785
|
+
UserProfileModal,
|
|
5786
|
+
{
|
|
5787
|
+
onClose: () => setShowProfileModal(false),
|
|
5788
|
+
onError: onProfileError
|
|
5789
|
+
}
|
|
5790
|
+
)
|
|
5389
5791
|
] });
|
|
5390
5792
|
}
|
|
5391
5793
|
function Protect({
|
|
@@ -5552,6 +5954,7 @@ exports.SignedIn = SignedIn;
|
|
|
5552
5954
|
exports.SignedOut = SignedOut;
|
|
5553
5955
|
exports.StyleProvider = StyleProvider;
|
|
5554
5956
|
exports.UserButton = UserButton;
|
|
5957
|
+
exports.UserProfileModal = UserProfileModal;
|
|
5555
5958
|
exports.VerifyEmail = VerifyEmail;
|
|
5556
5959
|
exports.VerifyEmailStatus = VerifyEmailStatus;
|
|
5557
5960
|
exports.checkPasswordStrength = checkPasswordStrength;
|