@joelbarron/react-web-dev-kit 0.1.9 → 0.1.10
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/auth/client.d.ts +46 -0
- package/dist/auth/client.d.ts.map +1 -0
- package/dist/auth/client.js +379 -0
- package/dist/auth/constants/countryCallingCodes.d.ts +9 -0
- package/dist/auth/constants/countryCallingCodes.d.ts.map +1 -0
- package/dist/auth/constants/countryCallingCodes.js +209 -0
- package/dist/auth/constants/gender.d.ts +9 -0
- package/dist/auth/constants/gender.d.ts.map +1 -0
- package/dist/auth/constants/gender.js +12 -0
- package/dist/auth/constants/index.d.ts +3 -0
- package/dist/auth/constants/index.d.ts.map +1 -0
- package/dist/auth/constants/index.js +2 -0
- package/dist/auth/forms/account/AuthAccountConfirmationForm.d.ts +18 -0
- package/dist/auth/forms/account/AuthAccountConfirmationForm.d.ts.map +1 -0
- package/dist/auth/forms/account/AuthAccountConfirmationForm.js +167 -0
- package/dist/auth/forms/account/index.d.ts +2 -0
- package/dist/auth/forms/account/index.d.ts.map +1 -0
- package/dist/auth/forms/account/index.js +1 -0
- package/dist/auth/forms/errorParser.d.ts +7 -0
- package/dist/auth/forms/errorParser.d.ts.map +1 -0
- package/dist/auth/forms/errorParser.js +65 -0
- package/dist/auth/forms/index.d.ts +6 -0
- package/dist/auth/forms/index.d.ts.map +1 -0
- package/dist/auth/forms/index.js +5 -0
- package/dist/auth/forms/password/AuthForgotPasswordForm.d.ts +16 -0
- package/dist/auth/forms/password/AuthForgotPasswordForm.d.ts.map +1 -0
- package/dist/auth/forms/password/AuthForgotPasswordForm.js +109 -0
- package/dist/auth/forms/password/AuthPasswordResetConfirmForm.d.ts +17 -0
- package/dist/auth/forms/password/AuthPasswordResetConfirmForm.d.ts.map +1 -0
- package/dist/auth/forms/password/AuthPasswordResetConfirmForm.js +163 -0
- package/dist/auth/forms/password/AuthResetPasswordForm.d.ts +12 -0
- package/dist/auth/forms/password/AuthResetPasswordForm.d.ts.map +1 -0
- package/dist/auth/forms/password/AuthResetPasswordForm.js +22 -0
- package/dist/auth/forms/password/index.d.ts +4 -0
- package/dist/auth/forms/password/index.d.ts.map +1 -0
- package/dist/auth/forms/password/index.js +3 -0
- package/dist/auth/forms/password/passwordValidation.d.ts +3 -0
- package/dist/auth/forms/password/passwordValidation.d.ts.map +1 -0
- package/dist/auth/forms/password/passwordValidation.js +45 -0
- package/dist/auth/forms/sign-in/AuthOtpSignInForm.d.ts +24 -0
- package/dist/auth/forms/sign-in/AuthOtpSignInForm.d.ts.map +1 -0
- package/dist/auth/forms/sign-in/AuthOtpSignInForm.js +227 -0
- package/dist/auth/forms/sign-in/AuthPasswordSignInForm.d.ts +22 -0
- package/dist/auth/forms/sign-in/AuthPasswordSignInForm.d.ts.map +1 -0
- package/dist/auth/forms/sign-in/AuthPasswordSignInForm.js +148 -0
- package/dist/auth/forms/sign-in/index.d.ts +3 -0
- package/dist/auth/forms/sign-in/index.d.ts.map +1 -0
- package/dist/auth/forms/sign-in/index.js +2 -0
- package/dist/auth/forms/sign-up/AuthSignUpForm.d.ts +37 -0
- package/dist/auth/forms/sign-up/AuthSignUpForm.d.ts.map +1 -0
- package/dist/auth/forms/sign-up/AuthSignUpForm.js +193 -0
- package/dist/auth/forms/sign-up/index.d.ts +2 -0
- package/dist/auth/forms/sign-up/index.d.ts.map +1 -0
- package/dist/auth/forms/sign-up/index.js +1 -0
- package/dist/auth/fuse/createFuseAuthViews.d.ts +25 -0
- package/dist/auth/fuse/createFuseAuthViews.d.ts.map +1 -0
- package/dist/auth/fuse/createFuseAuthViews.js +510 -0
- package/dist/auth/fuse/fuseAdapter.d.ts +42 -0
- package/dist/auth/fuse/fuseAdapter.d.ts.map +1 -0
- package/dist/auth/fuse/fuseAdapter.js +291 -0
- package/dist/auth/fuse/fuseIntegration.d.ts +74 -0
- package/dist/auth/fuse/fuseIntegration.d.ts.map +1 -0
- package/dist/auth/fuse/fuseIntegration.js +121 -0
- package/dist/auth/fuse/index.d.ts +4 -0
- package/dist/auth/fuse/index.d.ts.map +1 -0
- package/dist/auth/fuse/index.js +3 -0
- package/dist/auth/index.d.ts +11 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +10 -0
- package/dist/auth/provider.d.ts +35 -0
- package/dist/auth/provider.d.ts.map +1 -0
- package/dist/auth/provider.js +133 -0
- package/dist/auth/query.d.ts +23 -0
- package/dist/auth/query.d.ts.map +1 -0
- package/dist/auth/query.js +103 -0
- package/dist/auth/routes.d.ts +37 -0
- package/dist/auth/routes.d.ts.map +1 -0
- package/dist/auth/routes.js +75 -0
- package/dist/auth/social/providerAuth.d.ts +101 -0
- package/dist/auth/social/providerAuth.d.ts.map +1 -0
- package/dist/auth/social/providerAuth.js +207 -0
- package/dist/auth/storage.d.ts +3 -0
- package/dist/auth/storage.d.ts.map +1 -0
- package/dist/auth/storage.js +20 -0
- package/dist/auth/types.d.ts +238 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +1 -0
- package/dist/auth/ui/AuthPageTitle.d.ts +7 -0
- package/dist/auth/ui/AuthPageTitle.d.ts.map +1 -0
- package/dist/auth/ui/AuthPageTitle.js +7 -0
- package/dist/auth/ui/AuthPagesMessageSection.d.ts +3 -0
- package/dist/auth/ui/AuthPagesMessageSection.d.ts.map +1 -0
- package/dist/auth/ui/AuthPagesMessageSection.js +39 -0
- package/dist/auth/ui/AuthPrimaryButton.d.ts +9 -0
- package/dist/auth/ui/AuthPrimaryButton.d.ts.map +1 -0
- package/dist/auth/ui/AuthPrimaryButton.js +19 -0
- package/dist/auth/ui/AuthRoleSelectionDialog.d.ts +14 -0
- package/dist/auth/ui/AuthRoleSelectionDialog.d.ts.map +1 -0
- package/dist/auth/ui/AuthRoleSelectionDialog.js +39 -0
- package/dist/auth/ui/AuthRoutePageWrapper.d.ts +12 -0
- package/dist/auth/ui/AuthRoutePageWrapper.d.ts.map +1 -0
- package/dist/auth/ui/AuthRoutePageWrapper.js +61 -0
- package/dist/auth/ui/AuthSecondaryButton.d.ts +7 -0
- package/dist/auth/ui/AuthSecondaryButton.d.ts.map +1 -0
- package/dist/auth/ui/AuthSecondaryButton.js +18 -0
- package/dist/auth/ui/AuthSocialProviderButton.d.ts +11 -0
- package/dist/auth/ui/AuthSocialProviderButton.d.ts.map +1 -0
- package/dist/auth/ui/AuthSocialProviderButton.js +33 -0
- package/dist/auth/ui/index.d.ts +9 -0
- package/dist/auth/ui/index.d.ts.map +1 -0
- package/dist/auth/ui/index.js +8 -0
- package/dist/auth/ui/types.d.ts +15 -0
- package/dist/auth/ui/types.d.ts.map +1 -0
- package/dist/auth/ui/types.js +1 -0
- package/dist/config/createConfig.d.ts +14 -0
- package/dist/config/createConfig.d.ts.map +1 -0
- package/dist/config/createConfig.js +179 -0
- package/dist/config/defaults.d.ts +3 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +39 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +4 -0
- package/dist/config/merge.d.ts +2 -0
- package/dist/config/merge.d.ts.map +1 -0
- package/dist/config/merge.js +18 -0
- package/dist/config/types.d.ts +53 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +1 -0
- package/dist/core/buttons/JBButton.d.ts +8 -0
- package/dist/core/buttons/JBButton.d.ts.map +1 -0
- package/dist/core/buttons/JBButton.js +55 -0
- package/dist/core/buttons/index.d.ts +2 -0
- package/dist/core/buttons/index.d.ts.map +1 -0
- package/dist/core/buttons/index.js +1 -0
- package/dist/core/dialogs/JBConfirmDialog.d.ts +15 -0
- package/dist/core/dialogs/JBConfirmDialog.d.ts.map +1 -0
- package/dist/core/dialogs/JBConfirmDialog.js +6 -0
- package/dist/core/dialogs/index.d.ts +2 -0
- package/dist/core/dialogs/index.d.ts.map +1 -0
- package/dist/core/dialogs/index.js +1 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +4 -0
- package/dist/core/layout/JBContentContainer.d.ts +31 -0
- package/dist/core/layout/JBContentContainer.d.ts.map +1 -0
- package/dist/core/layout/JBContentContainer.js +50 -0
- package/dist/core/layout/JBFormHeader.d.ts +3 -0
- package/dist/core/layout/JBFormHeader.d.ts.map +1 -0
- package/dist/core/layout/JBFormHeader.js +131 -0
- package/dist/core/layout/index.d.ts +3 -0
- package/dist/core/layout/index.d.ts.map +1 -0
- package/dist/core/layout/index.js +2 -0
- package/dist/core/skeletons/JBFormContentSkeleton.d.ts +5 -0
- package/dist/core/skeletons/JBFormContentSkeleton.d.ts.map +1 -0
- package/dist/core/skeletons/JBFormContentSkeleton.js +12 -0
- package/dist/core/skeletons/JBFormHeaderSkeleton.d.ts +6 -0
- package/dist/core/skeletons/JBFormHeaderSkeleton.d.ts.map +1 -0
- package/dist/core/skeletons/JBFormHeaderSkeleton.js +19 -0
- package/dist/core/skeletons/index.d.ts +3 -0
- package/dist/core/skeletons/index.d.ts.map +1 -0
- package/dist/core/skeletons/index.js +2 -0
- package/dist/forms/JBAutocompleteField.d.ts +12 -0
- package/dist/forms/JBAutocompleteField.d.ts.map +1 -0
- package/dist/forms/JBAutocompleteField.js +20 -0
- package/dist/forms/JBCheckboxField.d.ts +12 -0
- package/dist/forms/JBCheckboxField.d.ts.map +1 -0
- package/dist/forms/JBCheckboxField.js +36 -0
- package/dist/forms/JBDatePickerField.d.ts +13 -0
- package/dist/forms/JBDatePickerField.d.ts.map +1 -0
- package/dist/forms/JBDatePickerField.js +67 -0
- package/dist/forms/JBRadioGroupField.d.ts +10 -0
- package/dist/forms/JBRadioGroupField.d.ts.map +1 -0
- package/dist/forms/JBRadioGroupField.js +8 -0
- package/dist/forms/JBSelectField.d.ts +9 -0
- package/dist/forms/JBSelectField.d.ts.map +1 -0
- package/dist/forms/JBSelectField.js +8 -0
- package/dist/forms/JBSwitchField.d.ts +11 -0
- package/dist/forms/JBSwitchField.d.ts.map +1 -0
- package/dist/forms/JBSwitchField.js +10 -0
- package/dist/forms/JBTextField.d.ts +6 -0
- package/dist/forms/JBTextField.d.ts.map +1 -0
- package/dist/forms/JBTextField.js +8 -0
- package/dist/forms/JBTimePickerField.d.ts +12 -0
- package/dist/forms/JBTimePickerField.d.ts.map +1 -0
- package/dist/forms/JBTimePickerField.js +35 -0
- package/dist/forms/index.d.ts +13 -0
- package/dist/forms/index.d.ts.map +1 -0
- package/dist/forms/index.js +12 -0
- package/dist/forms/rules.d.ts +16 -0
- package/dist/forms/rules.d.ts.map +1 -0
- package/dist/forms/rules.js +21 -0
- package/dist/forms/types.d.ts +12 -0
- package/dist/forms/types.d.ts.map +1 -0
- package/dist/forms/types.js +1 -0
- package/dist/forms/utils.d.ts +5 -0
- package/dist/forms/utils.d.ts.map +1 -0
- package/dist/forms/utils.js +7 -0
- package/dist/forms/zod.d.ts +4 -0
- package/dist/forms/zod.d.ts.map +1 -0
- package/dist/forms/zod.js +9 -0
- package/dist/grid/JBGrid.d.ts +3 -0
- package/dist/grid/JBGrid.d.ts.map +1 -0
- package/dist/grid/JBGrid.js +338 -0
- package/dist/grid/JBGridHeader.d.ts +3 -0
- package/dist/grid/JBGridHeader.d.ts.map +1 -0
- package/dist/grid/JBGridHeader.js +93 -0
- package/dist/grid/JBGridLoading.d.ts +9 -0
- package/dist/grid/JBGridLoading.d.ts.map +1 -0
- package/dist/grid/JBGridLoading.js +14 -0
- package/dist/grid/JBGridProviders.d.ts +13 -0
- package/dist/grid/JBGridProviders.d.ts.map +1 -0
- package/dist/grid/JBGridProviders.js +54 -0
- package/dist/grid/JBGridSkeleton.d.ts +7 -0
- package/dist/grid/JBGridSkeleton.d.ts.map +1 -0
- package/dist/grid/JBGridSkeleton.js +6 -0
- package/dist/grid/defaults.d.ts +4 -0
- package/dist/grid/defaults.d.ts.map +1 -0
- package/dist/grid/defaults.js +29 -0
- package/dist/grid/index.d.ts +8 -0
- package/dist/grid/index.d.ts.map +1 -0
- package/dist/grid/index.js +7 -0
- package/dist/grid/types.d.ts +197 -0
- package/dist/grid/types.d.ts.map +1 -0
- package/dist/grid/types.js +1 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +3 -0
- package/dist/hooks/useJBDebouncedValue.d.ts +2 -0
- package/dist/hooks/useJBDebouncedValue.d.ts.map +1 -0
- package/dist/hooks/useJBDebouncedValue.js +11 -0
- package/dist/hooks/useJBEntityFormController.d.ts +54 -0
- package/dist/hooks/useJBEntityFormController.d.ts.map +1 -0
- package/dist/hooks/useJBEntityFormController.js +156 -0
- package/dist/hooks/useJBRedirect.d.ts +10 -0
- package/dist/hooks/useJBRedirect.d.ts.map +1 -0
- package/dist/hooks/useJBRedirect.js +11 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/query/createQueryClient.d.ts +8 -0
- package/dist/query/createQueryClient.d.ts.map +1 -0
- package/dist/query/createQueryClient.js +25 -0
- package/dist/query/http.d.ts +3 -0
- package/dist/query/http.d.ts.map +1 -0
- package/dist/query/http.js +12 -0
- package/dist/query/index.d.ts +4 -0
- package/dist/query/index.d.ts.map +1 -0
- package/dist/query/index.js +3 -0
- package/dist/query/types.d.ts +7 -0
- package/dist/query/types.d.ts.map +1 -0
- package/dist/query/types.js +1 -0
- package/dist/utils/errors.d.ts +10 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +55 -0
- package/dist/utils/format.d.ts +4 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +28 -0
- package/dist/utils/geo.d.ts +9 -0
- package/dist/utils/geo.d.ts.map +1 -0
- package/dist/utils/geo.js +186 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/query.d.ts +2 -0
- package/dist/utils/query.d.ts.map +1 -0
- package/dist/utils/query.js +4 -0
- package/dist/utils/regex.d.ts +7 -0
- package/dist/utils/regex.d.ts.map +1 -0
- package/dist/utils/regex.js +6 -0
- package/package.json +3 -1
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
const scriptLoaders = new Map();
|
|
2
|
+
const loadScript = (src) => {
|
|
3
|
+
const existing = scriptLoaders.get(src);
|
|
4
|
+
if (existing) {
|
|
5
|
+
return existing;
|
|
6
|
+
}
|
|
7
|
+
const loader = new Promise((resolve, reject) => {
|
|
8
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
9
|
+
reject(new Error('Social auth is only available in browser environments.'));
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const script = document.createElement('script');
|
|
13
|
+
script.src = src;
|
|
14
|
+
script.async = true;
|
|
15
|
+
script.defer = true;
|
|
16
|
+
script.onload = () => resolve();
|
|
17
|
+
script.onerror = () => reject(new Error(`Failed to load script: ${src}`));
|
|
18
|
+
document.head.appendChild(script);
|
|
19
|
+
});
|
|
20
|
+
scriptLoaders.set(src, loader);
|
|
21
|
+
return loader;
|
|
22
|
+
};
|
|
23
|
+
const ensureGoogleSdk = async () => {
|
|
24
|
+
await loadScript('https://accounts.google.com/gsi/client');
|
|
25
|
+
if (!window.google?.accounts?.id?.initialize) {
|
|
26
|
+
throw new Error('Google SDK is not available.');
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const ensureAppleSdk = async () => {
|
|
30
|
+
await loadScript('https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js');
|
|
31
|
+
if (!window.AppleID?.auth) {
|
|
32
|
+
throw new Error('Apple SDK is not available.');
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const ensureFacebookSdk = async (clientId) => {
|
|
36
|
+
await loadScript('https://connect.facebook.net/en_US/sdk.js');
|
|
37
|
+
if (!window.FB?.init) {
|
|
38
|
+
throw new Error('Facebook SDK is not available.');
|
|
39
|
+
}
|
|
40
|
+
window.FB.init({
|
|
41
|
+
appId: clientId,
|
|
42
|
+
cookie: true,
|
|
43
|
+
xfbml: false,
|
|
44
|
+
version: 'v20.0'
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
const isLikelyMobileBrowser = () => {
|
|
48
|
+
if (typeof navigator === 'undefined' || typeof window === 'undefined') {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
const userAgent = navigator.userAgent || '';
|
|
52
|
+
const hasTouch = (navigator.maxTouchPoints ?? 0) > 0;
|
|
53
|
+
const hasCoarsePointer = typeof window.matchMedia === 'function'
|
|
54
|
+
? window.matchMedia('(pointer: coarse)').matches
|
|
55
|
+
: false;
|
|
56
|
+
const smallViewport = typeof window.innerWidth === 'number' ? window.innerWidth <= 1024 : false;
|
|
57
|
+
const isMobileUserAgent = /Android|iPhone|iPad|iPod|IEMobile|Opera Mini|Mobile/i.test(userAgent);
|
|
58
|
+
const isIpadOsDesktopMode = /Macintosh/i.test(userAgent) && hasTouch;
|
|
59
|
+
return isMobileUserAgent || isIpadOsDesktopMode || ((hasTouch || hasCoarsePointer) && smallViewport);
|
|
60
|
+
};
|
|
61
|
+
const logSocialDebug = (enabled, message, payload) => {
|
|
62
|
+
if (!enabled) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (typeof payload === 'undefined') {
|
|
66
|
+
console.info(`[jb-auth][social] ${message}`);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
console.info(`[jb-auth][social] ${message}`, payload);
|
|
70
|
+
};
|
|
71
|
+
const authenticateWithGoogle = async (config) => {
|
|
72
|
+
logSocialDebug(config.debug, 'google provider auth start', {
|
|
73
|
+
clientId: config.clientId
|
|
74
|
+
});
|
|
75
|
+
await ensureGoogleSdk();
|
|
76
|
+
const response = await new Promise((resolve, reject) => {
|
|
77
|
+
let settled = false;
|
|
78
|
+
const timeoutId = window.setTimeout(() => {
|
|
79
|
+
if (settled) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
settled = true;
|
|
83
|
+
reject(new Error('Google authentication timeout.'));
|
|
84
|
+
}, 30000);
|
|
85
|
+
window.google.accounts.id.initialize({
|
|
86
|
+
client_id: config.clientId,
|
|
87
|
+
callback: (credentialResponse) => {
|
|
88
|
+
if (settled) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
settled = true;
|
|
92
|
+
window.clearTimeout(timeoutId);
|
|
93
|
+
resolve(credentialResponse);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
window.google.accounts.id.cancel();
|
|
97
|
+
window.google.accounts.id.prompt((notification) => {
|
|
98
|
+
if (settled) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const isNotDisplayed = notification?.isNotDisplayed?.() ?? false;
|
|
102
|
+
const isSkipped = notification?.isSkippedMoment?.() ?? false;
|
|
103
|
+
const isDismissed = notification?.isDismissedMoment?.() ?? false;
|
|
104
|
+
if (!isNotDisplayed && !isSkipped && !isDismissed) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
settled = true;
|
|
108
|
+
window.clearTimeout(timeoutId);
|
|
109
|
+
const reason = notification?.getNotDisplayedReason?.() ||
|
|
110
|
+
notification?.getSkippedReason?.() ||
|
|
111
|
+
notification?.getDismissedReason?.() ||
|
|
112
|
+
'Google sign-in cancelled';
|
|
113
|
+
reject(new Error(`Google authentication was not completed: ${reason}`));
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
if (!response.credential) {
|
|
117
|
+
throw new Error('Google authentication failed.');
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
provider: 'google',
|
|
121
|
+
idToken: response.credential,
|
|
122
|
+
clientId: config.clientId
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
const authenticateWithApple = async (config) => {
|
|
126
|
+
logSocialDebug(config.debug, 'apple provider auth start', {
|
|
127
|
+
clientId: config.clientId,
|
|
128
|
+
redirectUri: config.redirectUri,
|
|
129
|
+
usePopup: config.usePopup,
|
|
130
|
+
responseMode: config.responseMode,
|
|
131
|
+
responseType: config.responseType
|
|
132
|
+
});
|
|
133
|
+
await ensureAppleSdk();
|
|
134
|
+
const usePopup = config.usePopup ?? true;
|
|
135
|
+
const resolvedScope = config.scope ?? config.scopes?.join(' ') ?? 'name email';
|
|
136
|
+
const resolvedRedirectUri = config.redirectUri || window.location.origin;
|
|
137
|
+
const resolvedResponseMode = config.responseMode ?? (usePopup ? 'web_message' : 'form_post');
|
|
138
|
+
const resolvedResponseType = config.responseType ?? (usePopup ? 'code id_token' : 'code');
|
|
139
|
+
window.AppleID.auth.init({
|
|
140
|
+
clientId: config.clientId,
|
|
141
|
+
scope: resolvedScope,
|
|
142
|
+
redirectURI: resolvedRedirectUri,
|
|
143
|
+
usePopup,
|
|
144
|
+
responseMode: resolvedResponseMode,
|
|
145
|
+
responseType: resolvedResponseType,
|
|
146
|
+
state: config.state,
|
|
147
|
+
nonce: config.nonce
|
|
148
|
+
});
|
|
149
|
+
const response = await window.AppleID.auth.signIn();
|
|
150
|
+
const authorizationCode = response.authorization?.code ??
|
|
151
|
+
response.authorization?.grant_code ??
|
|
152
|
+
response.authorization?.grantCode ??
|
|
153
|
+
response.authorization?.authorizationCode;
|
|
154
|
+
const idToken = response.authorization?.id_token ?? response.authorization?.idToken;
|
|
155
|
+
if (!authorizationCode && !idToken) {
|
|
156
|
+
throw new Error('Apple authentication failed.');
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
provider: 'apple',
|
|
160
|
+
authorizationCode,
|
|
161
|
+
idToken,
|
|
162
|
+
redirectUri: resolvedRedirectUri,
|
|
163
|
+
clientId: config.clientId
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
const authenticateWithFacebook = async (config) => {
|
|
167
|
+
const mobileBrowser = isLikelyMobileBrowser();
|
|
168
|
+
const shouldUsePopup = config.usePopup ?? !mobileBrowser;
|
|
169
|
+
const resolvedDisplay = shouldUsePopup
|
|
170
|
+
? 'popup'
|
|
171
|
+
: mobileBrowser
|
|
172
|
+
? 'touch'
|
|
173
|
+
: 'page';
|
|
174
|
+
logSocialDebug(config.debug, 'facebook provider auth start', {
|
|
175
|
+
clientId: config.clientId,
|
|
176
|
+
display: resolvedDisplay,
|
|
177
|
+
usePopup: shouldUsePopup
|
|
178
|
+
});
|
|
179
|
+
await ensureFacebookSdk(config.clientId);
|
|
180
|
+
const response = await new Promise((resolve) => {
|
|
181
|
+
window.FB.login(resolve, {
|
|
182
|
+
scope: config.scope ?? 'email,public_profile',
|
|
183
|
+
display: resolvedDisplay
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
const accessToken = response.authResponse?.accessToken;
|
|
187
|
+
if (!accessToken) {
|
|
188
|
+
throw new Error('Facebook authentication failed.');
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
provider: 'facebook',
|
|
192
|
+
accessToken,
|
|
193
|
+
clientId: config.clientId
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
export const authenticateWithSocialProvider = async (provider, config) => {
|
|
197
|
+
if (!config.clientId?.trim()) {
|
|
198
|
+
throw new Error(`Missing social clientId for provider "${provider}".`);
|
|
199
|
+
}
|
|
200
|
+
if (provider === 'google') {
|
|
201
|
+
return authenticateWithGoogle(config);
|
|
202
|
+
}
|
|
203
|
+
if (provider === 'facebook') {
|
|
204
|
+
return authenticateWithFacebook(config);
|
|
205
|
+
}
|
|
206
|
+
return authenticateWithApple(config);
|
|
207
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/auth/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,eAAO,MAAM,8BAA8B,GAAI,iBAAiB,MAAM,KAAG,YAiBxE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const createLocalStorageTokenStorage = (tokenStorageKey) => {
|
|
2
|
+
const hasWindow = typeof window !== 'undefined' && !!window.localStorage;
|
|
3
|
+
return {
|
|
4
|
+
getAccessToken: () => {
|
|
5
|
+
if (!hasWindow)
|
|
6
|
+
return null;
|
|
7
|
+
return window.localStorage.getItem(tokenStorageKey);
|
|
8
|
+
},
|
|
9
|
+
setAccessToken: (token) => {
|
|
10
|
+
if (!hasWindow)
|
|
11
|
+
return;
|
|
12
|
+
window.localStorage.setItem(tokenStorageKey, token);
|
|
13
|
+
},
|
|
14
|
+
removeAccessToken: () => {
|
|
15
|
+
if (!hasWindow)
|
|
16
|
+
return;
|
|
17
|
+
window.localStorage.removeItem(tokenStorageKey);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { Gender } from './constants';
|
|
3
|
+
export type TokenPair = {
|
|
4
|
+
accessToken: string;
|
|
5
|
+
refreshToken: string;
|
|
6
|
+
};
|
|
7
|
+
export type TokenStorage = {
|
|
8
|
+
getAccessToken: () => string | null;
|
|
9
|
+
setAccessToken: (token: string) => void;
|
|
10
|
+
removeAccessToken: () => void;
|
|
11
|
+
};
|
|
12
|
+
export type JbDrfAuthEndpoints = {
|
|
13
|
+
loginBasic: string;
|
|
14
|
+
loginSocial: string;
|
|
15
|
+
loginSocialPrecheck: string;
|
|
16
|
+
loginSocialLink: string;
|
|
17
|
+
loginSocialUnlink: string;
|
|
18
|
+
loginMagicLinkConsume: string;
|
|
19
|
+
loginOtpVerify: string;
|
|
20
|
+
otpRequest: string;
|
|
21
|
+
register: string;
|
|
22
|
+
accountConfirmation: string;
|
|
23
|
+
accountConfirmationResend: string;
|
|
24
|
+
me: string;
|
|
25
|
+
profilePicture: string;
|
|
26
|
+
refresh: string;
|
|
27
|
+
switchProfile: string;
|
|
28
|
+
profiles: string;
|
|
29
|
+
accountUpdate: string;
|
|
30
|
+
accountDelete: string;
|
|
31
|
+
passwordResetRequest: string;
|
|
32
|
+
passwordResetConfirm: string;
|
|
33
|
+
passwordResetChange: string;
|
|
34
|
+
adminCreateSuperuser: string;
|
|
35
|
+
adminCreateStaff: string;
|
|
36
|
+
};
|
|
37
|
+
export type JbDrfAuthConfig = {
|
|
38
|
+
apiBaseUrl: string;
|
|
39
|
+
apiBasePath?: string;
|
|
40
|
+
endpoints?: Partial<JbDrfAuthEndpoints>;
|
|
41
|
+
tokenStorageKey?: string;
|
|
42
|
+
refreshTokenStorageKey?: string;
|
|
43
|
+
tokenStorage?: TokenStorage;
|
|
44
|
+
defaultClient?: 'web' | 'mobile';
|
|
45
|
+
onUnauthorized?: () => void;
|
|
46
|
+
};
|
|
47
|
+
export type LoginBasicPayload = {
|
|
48
|
+
login: string;
|
|
49
|
+
password: string;
|
|
50
|
+
client?: 'web' | 'mobile';
|
|
51
|
+
device?: {
|
|
52
|
+
platform?: string;
|
|
53
|
+
name?: string;
|
|
54
|
+
token?: string;
|
|
55
|
+
notificationToken?: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
export type SocialProvider = 'google' | 'facebook' | 'apple';
|
|
59
|
+
export type SocialDevicePayload = {
|
|
60
|
+
platform?: string;
|
|
61
|
+
name?: string;
|
|
62
|
+
token?: string;
|
|
63
|
+
notificationToken?: string;
|
|
64
|
+
};
|
|
65
|
+
export type LoginSocialPayload = {
|
|
66
|
+
provider: SocialProvider;
|
|
67
|
+
idToken?: string;
|
|
68
|
+
accessToken?: string;
|
|
69
|
+
authorizationCode?: string;
|
|
70
|
+
redirectUri?: string;
|
|
71
|
+
codeVerifier?: string;
|
|
72
|
+
clientId?: string;
|
|
73
|
+
role?: string;
|
|
74
|
+
client?: 'web' | 'mobile';
|
|
75
|
+
termsAndConditionsAccepted?: boolean;
|
|
76
|
+
device?: SocialDevicePayload;
|
|
77
|
+
};
|
|
78
|
+
export type LoginSocialPrecheckResponse = {
|
|
79
|
+
provider?: SocialProvider;
|
|
80
|
+
email?: string;
|
|
81
|
+
emailVerified?: boolean;
|
|
82
|
+
email_verified?: boolean;
|
|
83
|
+
socialAccountExists?: boolean;
|
|
84
|
+
social_account_exists?: boolean;
|
|
85
|
+
linkedExistingUser?: boolean;
|
|
86
|
+
linked_existing_user?: boolean;
|
|
87
|
+
userExists?: boolean;
|
|
88
|
+
user_exists?: boolean;
|
|
89
|
+
wouldCreateUser?: boolean;
|
|
90
|
+
would_create_user?: boolean;
|
|
91
|
+
canLogin?: boolean;
|
|
92
|
+
can_login?: boolean;
|
|
93
|
+
[key: string]: unknown;
|
|
94
|
+
};
|
|
95
|
+
export type LinkSocialPayload = {
|
|
96
|
+
provider: SocialProvider;
|
|
97
|
+
idToken?: string;
|
|
98
|
+
accessToken?: string;
|
|
99
|
+
authorizationCode?: string;
|
|
100
|
+
redirectUri?: string;
|
|
101
|
+
codeVerifier?: string;
|
|
102
|
+
clientId?: string;
|
|
103
|
+
};
|
|
104
|
+
export type UnlinkSocialPayload = {
|
|
105
|
+
provider: SocialProvider;
|
|
106
|
+
};
|
|
107
|
+
export type SwitchProfilePayload = {
|
|
108
|
+
profile: number;
|
|
109
|
+
client?: 'web' | 'mobile';
|
|
110
|
+
device?: {
|
|
111
|
+
platform?: string;
|
|
112
|
+
name?: string;
|
|
113
|
+
token?: string;
|
|
114
|
+
notificationToken?: string;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
export type ProfilePicturePayload = {
|
|
118
|
+
profile?: number;
|
|
119
|
+
picture: string;
|
|
120
|
+
};
|
|
121
|
+
export type RefreshPayload = {
|
|
122
|
+
refreshToken?: string;
|
|
123
|
+
};
|
|
124
|
+
export type OtpChannel = 'sms' | 'email';
|
|
125
|
+
export type RequestOtpPayload = {
|
|
126
|
+
channel: OtpChannel;
|
|
127
|
+
email?: string;
|
|
128
|
+
phone?: string;
|
|
129
|
+
};
|
|
130
|
+
export type VerifyOtpPayload = {
|
|
131
|
+
channel: OtpChannel;
|
|
132
|
+
code: string;
|
|
133
|
+
client?: 'web' | 'mobile';
|
|
134
|
+
role?: string;
|
|
135
|
+
email?: string;
|
|
136
|
+
phone?: string;
|
|
137
|
+
device?: {
|
|
138
|
+
platform?: string;
|
|
139
|
+
name?: string;
|
|
140
|
+
token?: string;
|
|
141
|
+
notificationToken?: string;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
export type MagicLinkConsumePayload = {
|
|
145
|
+
token: string;
|
|
146
|
+
role?: string;
|
|
147
|
+
client?: 'web' | 'mobile';
|
|
148
|
+
device?: {
|
|
149
|
+
platform?: string;
|
|
150
|
+
name?: string;
|
|
151
|
+
token?: string;
|
|
152
|
+
notificationToken?: string;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
export type RegisterPayload = {
|
|
156
|
+
email: string;
|
|
157
|
+
phone?: string | null;
|
|
158
|
+
username?: string | null;
|
|
159
|
+
password: string;
|
|
160
|
+
passwordConfirm?: string;
|
|
161
|
+
firstName?: string;
|
|
162
|
+
lastName1?: string;
|
|
163
|
+
lastName2?: string;
|
|
164
|
+
birthday?: string;
|
|
165
|
+
gender?: Gender;
|
|
166
|
+
role?: string;
|
|
167
|
+
termsAndConditionsAccepted?: boolean;
|
|
168
|
+
};
|
|
169
|
+
export type PasswordResetRequestPayload = {
|
|
170
|
+
email: string;
|
|
171
|
+
};
|
|
172
|
+
export type PasswordResetConfirmPayload = {
|
|
173
|
+
uid: string;
|
|
174
|
+
token: string;
|
|
175
|
+
newPassword: string;
|
|
176
|
+
newPasswordConfirm: string;
|
|
177
|
+
};
|
|
178
|
+
export type PasswordChangePayload = {
|
|
179
|
+
oldPassword: string;
|
|
180
|
+
newPassword: string;
|
|
181
|
+
newPasswordConfirm: string;
|
|
182
|
+
};
|
|
183
|
+
export type AccountUpdatePayload = {
|
|
184
|
+
email?: string;
|
|
185
|
+
username?: string;
|
|
186
|
+
phone?: string;
|
|
187
|
+
termsAndConditions?: boolean;
|
|
188
|
+
language?: string;
|
|
189
|
+
timezone?: string;
|
|
190
|
+
[key: string]: unknown;
|
|
191
|
+
};
|
|
192
|
+
export type DeleteAccountPayload = {
|
|
193
|
+
confirmation: boolean;
|
|
194
|
+
};
|
|
195
|
+
export type CreateProfilePayload = Record<string, unknown>;
|
|
196
|
+
export type UpdateProfilePayload = Record<string, unknown>;
|
|
197
|
+
export type CreateAdminUserPayload = {
|
|
198
|
+
email: string;
|
|
199
|
+
password: string;
|
|
200
|
+
};
|
|
201
|
+
export type AccountConfirmationPayload = {
|
|
202
|
+
uid: string;
|
|
203
|
+
token: string;
|
|
204
|
+
};
|
|
205
|
+
export type AccountConfirmationResendPayload = {
|
|
206
|
+
email: string;
|
|
207
|
+
};
|
|
208
|
+
export type JbDrfWebAuthUser = {
|
|
209
|
+
data: {
|
|
210
|
+
displayName: string;
|
|
211
|
+
photoUrl: string;
|
|
212
|
+
email: string;
|
|
213
|
+
username: string;
|
|
214
|
+
birthday: string | null;
|
|
215
|
+
shortcuts: string[];
|
|
216
|
+
};
|
|
217
|
+
loginRedirectUrl: string;
|
|
218
|
+
role: string[];
|
|
219
|
+
status: string;
|
|
220
|
+
};
|
|
221
|
+
export type JbDrfWebAuthResponse = {
|
|
222
|
+
user: JbDrfWebAuthUser;
|
|
223
|
+
activeProfile: Record<string, unknown>;
|
|
224
|
+
termsAndConditions?: string | null;
|
|
225
|
+
tokens?: TokenPair;
|
|
226
|
+
};
|
|
227
|
+
export type ApiDetailResponse = {
|
|
228
|
+
detail?: string;
|
|
229
|
+
emailSent?: boolean;
|
|
230
|
+
[key: string]: unknown;
|
|
231
|
+
};
|
|
232
|
+
export type ProfilesResponse = {
|
|
233
|
+
results?: Record<string, unknown>[];
|
|
234
|
+
} | Record<string, unknown>[];
|
|
235
|
+
export type CreateAuthenticatedAxiosOptions = {
|
|
236
|
+
requestConfig?: AxiosRequestConfig;
|
|
237
|
+
};
|
|
238
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/auth/types.ts"],"names":[],"mapp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;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;CACrC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;AAE9B,MAAM,MAAM,+BAA+B,GAAG;IAC5C,aAAa,CAAC,EAAE,kBAAkB,CAAC;CACpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthPageTitle.d.ts","sourceRoot":"","sources":["../../../src/auth/ui/AuthPageTitle.tsx"],"names":[],"mappings":"AAGA,KAAK,kBAAkB,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,2CAiBtD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Box from '@mui/material/Box';
|
|
3
|
+
import Typography from '@mui/material/Typography';
|
|
4
|
+
export function AuthPageTitle(props) {
|
|
5
|
+
const { title, logoSrc = '/assets/images/logo/logo.svg' } = props;
|
|
6
|
+
return (_jsxs(Box, { sx: { width: '100%', display: 'flex', flexDirection: 'column', alignItems: 'center' }, children: [_jsx("img", { style: { width: 48 }, src: logoSrc, alt: "logo" }), _jsx(Typography, { sx: { mt: 4, textAlign: 'center', fontSize: 36, lineHeight: 1.25, fontWeight: 800, letterSpacing: '-0.02em' }, children: title })] }));
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthPagesMessageSection.d.ts","sourceRoot":"","sources":["../../../src/auth/ui/AuthPagesMessageSection.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAalD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,uBAAuB,2CAoHrE"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Avatar from '@mui/material/Avatar';
|
|
3
|
+
import AvatarGroup from '@mui/material/AvatarGroup';
|
|
4
|
+
import Box from '@mui/material/Box';
|
|
5
|
+
const defaultTitleLines = ['Bienvenido a', 'nuestra comunidad'];
|
|
6
|
+
const defaultDescription = 'Fuse ayuda a desarrolladores a construir paneles organizados, bien estructurados y con módulos visuales de alta calidad. Únete y empieza a construir tu aplicación hoy.';
|
|
7
|
+
const defaultFooterText = 'Más de 17k personas ya se unieron, ahora te toca a ti.';
|
|
8
|
+
const defaultAvatarUrls = [
|
|
9
|
+
'/assets/images/avatars/female-18.jpg',
|
|
10
|
+
'/assets/images/avatars/female-11.jpg',
|
|
11
|
+
'/assets/images/avatars/male-09.jpg',
|
|
12
|
+
'/assets/images/avatars/male-16.jpg'
|
|
13
|
+
];
|
|
14
|
+
export function AuthPagesMessageSection(props) {
|
|
15
|
+
const { titleLines = defaultTitleLines, description = defaultDescription, footerText = defaultFooterText, avatarUrls = defaultAvatarUrls } = props;
|
|
16
|
+
return (_jsxs(Box, { sx: {
|
|
17
|
+
position: 'relative',
|
|
18
|
+
display: { xs: 'none', md: 'flex' },
|
|
19
|
+
height: '100%',
|
|
20
|
+
flex: '1 1 auto',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
justifyContent: 'center',
|
|
23
|
+
overflow: 'hidden',
|
|
24
|
+
p: 6,
|
|
25
|
+
px: { lg: 10 },
|
|
26
|
+
backgroundColor: 'primary.dark',
|
|
27
|
+
color: 'primary.contrastText'
|
|
28
|
+
}, children: [_jsx("svg", { style: { pointerEvents: 'none', position: 'absolute', inset: 0 }, viewBox: "0 0 960 540", width: "100%", height: "100%", preserveAspectRatio: "xMidYMax slice", xmlns: "http://www.w3.org/2000/svg", children: _jsxs(Box, { component: "g", sx: { opacity: 0.05 }, fill: "none", stroke: "currentColor", strokeWidth: "100", children: [_jsx("circle", { r: "234", cx: "196", cy: "23" }), _jsx("circle", { r: "234", cx: "790", cy: "491" })] }) }), _jsxs(Box, { component: "svg", sx: {
|
|
29
|
+
position: 'absolute',
|
|
30
|
+
top: -64,
|
|
31
|
+
right: -64,
|
|
32
|
+
opacity: 0.2,
|
|
33
|
+
color: 'primary.light'
|
|
34
|
+
}, viewBox: "0 0 220 192", width: "220px", height: "192px", fill: "none", children: [_jsx("defs", { children: _jsx("pattern", { id: "jb-auth-message-pattern", x: "0", y: "0", width: "20", height: "20", patternUnits: "userSpaceOnUse", children: _jsx("rect", { x: "0", y: "0", width: "4", height: "4", fill: "currentColor" }) }) }), _jsx("rect", { width: "220", height: "192", fill: "url(#jb-auth-message-pattern)" })] }), _jsxs(Box, { sx: { position: 'relative', zIndex: 10, width: '100%', maxWidth: 896 }, children: [_jsx(Box, { sx: { fontSize: 64, lineHeight: 1, fontWeight: 700, color: 'grey.100' }, children: titleLines.map((line) => (_jsx(Box, { children: line }, line))) }), _jsx(Box, { sx: { mt: 3, fontSize: 18, lineHeight: 1.5, letterSpacing: '-0.01em', color: 'grey.400' }, children: description }), _jsxs(Box, { sx: { mt: 4, display: 'flex', alignItems: 'center' }, children: [_jsx(AvatarGroup, { sx: {
|
|
35
|
+
'& .MuiAvatar-root': {
|
|
36
|
+
borderColor: 'primary.main'
|
|
37
|
+
}
|
|
38
|
+
}, children: avatarUrls.map((avatarUrl) => (_jsx(Avatar, { src: avatarUrl }, avatarUrl))) }), _jsx(Box, { sx: { ml: 2, fontWeight: 500, letterSpacing: '-0.01em', color: 'grey.400' }, children: footerText })] })] })] }));
|
|
39
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ButtonProps } from '@mui/material/Button';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
type AuthPrimaryButtonProps = Omit<ButtonProps, 'variant' | 'color'> & {
|
|
4
|
+
loading?: boolean;
|
|
5
|
+
loadingLabel?: ReactNode;
|
|
6
|
+
};
|
|
7
|
+
export declare function AuthPrimaryButton(props: AuthPrimaryButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=AuthPrimaryButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthPrimaryButton.d.ts","sourceRoot":"","sources":["../../../src/auth/ui/AuthPrimaryButton.tsx"],"names":[],"mappings":"AAAA,OAAe,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,KAAK,sBAAsB,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,OAAO,CAAC,GAAG;IACrE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,SAAS,CAAC;CAC1B,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,2CAiC9D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import Button from '@mui/material/Button';
|
|
3
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
|
4
|
+
export function AuthPrimaryButton(props) {
|
|
5
|
+
const { loading = false, loadingLabel, children, disabled, sx, startIcon, ...rest } = props;
|
|
6
|
+
return (_jsx(Button, { ...rest, variant: "contained", color: "primary", disabled: Boolean(disabled) || loading, startIcon: loading ? (_jsx(CircularProgress, { size: 16, color: "inherit" })) : startIcon, sx: {
|
|
7
|
+
width: '100%',
|
|
8
|
+
minHeight: 38,
|
|
9
|
+
'&.Mui-disabled': {
|
|
10
|
+
opacity: 1,
|
|
11
|
+
color: 'common.white',
|
|
12
|
+
backgroundColor: 'primary.main'
|
|
13
|
+
},
|
|
14
|
+
'&.Mui-disabled.MuiButton-contained': {
|
|
15
|
+
opacity: 0.6
|
|
16
|
+
},
|
|
17
|
+
...(sx ?? {})
|
|
18
|
+
}, children: loading ? loadingLabel ?? children : children }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SelectOption } from '../../forms';
|
|
2
|
+
export type AuthRoleSelectionDialogProps = {
|
|
3
|
+
open: boolean;
|
|
4
|
+
options: SelectOption<string>[];
|
|
5
|
+
initialRole?: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
confirmLabel?: string;
|
|
9
|
+
cancelLabel?: string;
|
|
10
|
+
onCancel: () => void;
|
|
11
|
+
onConfirm: (role: string) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare function AuthRoleSelectionDialog(props: AuthRoleSelectionDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=AuthRoleSelectionDialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthRoleSelectionDialog.d.ts","sourceRoot":"","sources":["../../../src/auth/ui/AuthRoleSelectionDialog.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAqB,YAAY,EAAE,MAAM,aAAa,CAAC;AAQ9D,MAAM,MAAM,4BAA4B,GAAG;IACzC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC,CAAC;AAMF,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,4BAA4B,2CAuE1E"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
3
|
+
import Dialog from '@mui/material/Dialog';
|
|
4
|
+
import DialogActions from '@mui/material/DialogActions';
|
|
5
|
+
import DialogContent from '@mui/material/DialogContent';
|
|
6
|
+
import DialogContentText from '@mui/material/DialogContentText';
|
|
7
|
+
import DialogTitle from '@mui/material/DialogTitle';
|
|
8
|
+
import { useEffect } from 'react';
|
|
9
|
+
import { useForm } from 'react-hook-form';
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
import { JBRadioGroupField } from '../../forms';
|
|
12
|
+
import { AuthPrimaryButton } from './AuthPrimaryButton';
|
|
13
|
+
import { AuthSecondaryButton } from './AuthSecondaryButton';
|
|
14
|
+
const roleSelectionSchema = z.object({
|
|
15
|
+
role: z.string().nonempty('Selecciona un rol para continuar.')
|
|
16
|
+
});
|
|
17
|
+
export function AuthRoleSelectionDialog(props) {
|
|
18
|
+
const { open, options, initialRole, title = 'Selecciona tu rol', description = 'Elige el tipo de perfil con el que deseas continuar.', confirmLabel = 'Continuar', cancelLabel = 'Cancelar', onCancel, onConfirm } = props;
|
|
19
|
+
const fallbackRole = initialRole ?? options[0]?.value ?? '';
|
|
20
|
+
const { control, handleSubmit, reset, formState } = useForm({
|
|
21
|
+
mode: 'onSubmit',
|
|
22
|
+
resolver: zodResolver(roleSelectionSchema),
|
|
23
|
+
defaultValues: {
|
|
24
|
+
role: fallbackRole
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const { isSubmitting } = formState;
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (!open) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
reset({
|
|
33
|
+
role: initialRole ?? options[0]?.value ?? ''
|
|
34
|
+
});
|
|
35
|
+
}, [open, initialRole, options, reset]);
|
|
36
|
+
return (_jsxs(Dialog, { open: open, onClose: onCancel, fullWidth: true, maxWidth: 'xs', children: [_jsx(DialogTitle, { children: title }), _jsxs(DialogContent, { children: [_jsx(DialogContentText, { sx: { mb: 2 }, children: description }), _jsx(JBRadioGroupField, { control: control, name: 'role', options: options, formControlProps: { fullWidth: true } })] }), _jsxs(DialogActions, { children: [_jsx(AuthSecondaryButton, { sx: { mt: 0 }, type: 'button', onClick: onCancel, disabled: isSubmitting, children: cancelLabel }), _jsx(AuthPrimaryButton, { sx: { mt: 0 }, type: 'button', onClick: () => {
|
|
37
|
+
void handleSubmit((values) => onConfirm(values.role))();
|
|
38
|
+
}, loading: isSubmitting, loadingLabel: 'Guardando...', children: confirmLabel })] })] }));
|
|
39
|
+
}
|