@oxyhq/services 5.18.2 → 5.18.4
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/lib/commonjs/core/mixins/index.js +36 -13
- package/lib/commonjs/core/mixins/index.js.map +1 -1
- package/lib/commonjs/index.js +16 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ui/client.js +177 -0
- package/lib/commonjs/ui/client.js.map +1 -0
- package/lib/commonjs/ui/components/WebOxyProvider.js +98 -0
- package/lib/commonjs/ui/components/WebOxyProvider.js.map +1 -0
- package/lib/commonjs/ui/components/profile/EditFieldModal.js +412 -0
- package/lib/commonjs/ui/components/profile/EditFieldModal.js.map +1 -0
- package/lib/commonjs/ui/context/OxyContext.js +63 -1
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/hooks/useAuth.js +115 -0
- package/lib/commonjs/ui/hooks/useAuth.js.map +1 -0
- package/lib/commonjs/ui/hooks/useSettingToggle.js +7 -1
- package/lib/commonjs/ui/hooks/useSettingToggle.js.map +1 -1
- package/lib/commonjs/ui/hooks/useWebSSO.js +75 -0
- package/lib/commonjs/ui/hooks/useWebSSO.js.map +1 -0
- package/lib/commonjs/ui/index.js +17 -2
- package/lib/commonjs/ui/index.js.map +1 -1
- package/lib/commonjs/ui/screens/PrivacySettingsScreen.js +59 -65
- package/lib/commonjs/ui/screens/PrivacySettingsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SearchSettingsScreen.js +38 -58
- package/lib/commonjs/ui/screens/SearchSettingsScreen.js.map +1 -1
- package/lib/commonjs/ui/server.js +105 -0
- package/lib/commonjs/ui/server.js.map +1 -0
- package/lib/commonjs/ui/utils/iconNames.js +133 -0
- package/lib/commonjs/ui/utils/iconNames.js.map +1 -0
- package/lib/commonjs/ui/utils/sessionHelpers.js +7 -0
- package/lib/commonjs/ui/utils/sessionHelpers.js.map +1 -1
- package/lib/commonjs/utils/requestUtils.js +4 -3
- package/lib/commonjs/utils/requestUtils.js.map +1 -1
- package/lib/module/core/mixins/index.js +36 -13
- package/lib/module/core/mixins/index.js.map +1 -1
- package/lib/module/index.js +5 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/client.js +48 -0
- package/lib/module/ui/client.js.map +1 -0
- package/lib/module/ui/components/WebOxyProvider.js +94 -0
- package/lib/module/ui/components/WebOxyProvider.js.map +1 -0
- package/lib/module/ui/components/profile/EditFieldModal.js +406 -0
- package/lib/module/ui/components/profile/EditFieldModal.js.map +1 -0
- package/lib/module/ui/context/OxyContext.js +63 -1
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/hooks/useAuth.js +106 -0
- package/lib/module/ui/hooks/useAuth.js.map +1 -0
- package/lib/module/ui/hooks/useSettingToggle.js +7 -1
- package/lib/module/ui/hooks/useSettingToggle.js.map +1 -1
- package/lib/module/ui/hooks/useWebSSO.js +71 -0
- package/lib/module/ui/hooks/useWebSSO.js.map +1 -0
- package/lib/module/ui/index.js +17 -3
- package/lib/module/ui/index.js.map +1 -1
- package/lib/module/ui/screens/PrivacySettingsScreen.js +59 -65
- package/lib/module/ui/screens/PrivacySettingsScreen.js.map +1 -1
- package/lib/module/ui/screens/SearchSettingsScreen.js +39 -59
- package/lib/module/ui/screens/SearchSettingsScreen.js.map +1 -1
- package/lib/module/ui/server.js +65 -0
- package/lib/module/ui/server.js.map +1 -0
- package/lib/module/ui/utils/iconNames.js +124 -0
- package/lib/module/ui/utils/iconNames.js.map +1 -0
- package/lib/module/ui/utils/sessionHelpers.js +7 -0
- package/lib/module/ui/utils/sessionHelpers.js.map +1 -1
- package/lib/module/utils/requestUtils.js +4 -2
- package/lib/module/utils/requestUtils.js.map +1 -1
- package/lib/typescript/commonjs/core/mixins/index.d.ts +18 -1115
- package/lib/typescript/commonjs/core/mixins/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +3 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/client.d.ts +34 -0
- package/lib/typescript/commonjs/ui/client.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/WebOxyProvider.d.ts +44 -0
- package/lib/typescript/commonjs/ui/components/WebOxyProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/profile/EditFieldModal.d.ts +110 -0
- package/lib/typescript/commonjs/ui/components/profile/EditFieldModal.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts +3 -0
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts +3 -3
- package/lib/typescript/commonjs/ui/hooks/queries/useAccountQueries.d.ts +6 -10
- package/lib/typescript/commonjs/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/queries/useSecurityQueries.d.ts +1 -1
- package/lib/typescript/commonjs/ui/hooks/queries/useSecurityQueries.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/queries/useServicesQueries.d.ts +3 -5
- package/lib/typescript/commonjs/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useAssets.d.ts +1 -1
- package/lib/typescript/commonjs/ui/hooks/useAuth.d.ts +69 -0
- package/lib/typescript/commonjs/ui/hooks/useAuth.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/hooks/useSettingToggle.d.ts +4 -2
- package/lib/typescript/commonjs/ui/hooks/useSettingToggle.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useWebSSO.d.ts +34 -0
- package/lib/typescript/commonjs/ui/hooks/useWebSSO.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/index.d.ts +2 -2
- package/lib/typescript/commonjs/ui/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/PrivacySettingsScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/SearchSettingsScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/server.d.ts +43 -0
- package/lib/typescript/commonjs/ui/server.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/utils/iconNames.d.ts +112 -0
- package/lib/typescript/commonjs/ui/utils/iconNames.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/utils/sessionHelpers.d.ts +8 -3
- package/lib/typescript/commonjs/ui/utils/sessionHelpers.d.ts.map +1 -1
- package/lib/typescript/commonjs/utils/requestUtils.d.ts +3 -1
- package/lib/typescript/commonjs/utils/requestUtils.d.ts.map +1 -1
- package/lib/typescript/module/core/mixins/index.d.ts +18 -1115
- package/lib/typescript/module/core/mixins/index.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +3 -0
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/ui/client.d.ts +34 -0
- package/lib/typescript/module/ui/client.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/WebOxyProvider.d.ts +44 -0
- package/lib/typescript/module/ui/components/WebOxyProvider.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/profile/EditFieldModal.d.ts +110 -0
- package/lib/typescript/module/ui/components/profile/EditFieldModal.d.ts.map +1 -0
- package/lib/typescript/module/ui/context/OxyContext.d.ts +3 -0
- package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts +3 -3
- package/lib/typescript/module/ui/hooks/queries/useAccountQueries.d.ts +6 -10
- package/lib/typescript/module/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/queries/useSecurityQueries.d.ts +1 -1
- package/lib/typescript/module/ui/hooks/queries/useSecurityQueries.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/queries/useServicesQueries.d.ts +3 -5
- package/lib/typescript/module/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useAssets.d.ts +1 -1
- package/lib/typescript/module/ui/hooks/useAuth.d.ts +69 -0
- package/lib/typescript/module/ui/hooks/useAuth.d.ts.map +1 -0
- package/lib/typescript/module/ui/hooks/useSettingToggle.d.ts +4 -2
- package/lib/typescript/module/ui/hooks/useSettingToggle.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useWebSSO.d.ts +34 -0
- package/lib/typescript/module/ui/hooks/useWebSSO.d.ts.map +1 -0
- package/lib/typescript/module/ui/index.d.ts +2 -2
- package/lib/typescript/module/ui/index.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/PrivacySettingsScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/SearchSettingsScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/server.d.ts +43 -0
- package/lib/typescript/module/ui/server.d.ts.map +1 -0
- package/lib/typescript/module/ui/utils/iconNames.d.ts +112 -0
- package/lib/typescript/module/ui/utils/iconNames.d.ts.map +1 -0
- package/lib/typescript/module/ui/utils/sessionHelpers.d.ts +8 -3
- package/lib/typescript/module/ui/utils/sessionHelpers.d.ts.map +1 -1
- package/lib/typescript/module/utils/requestUtils.d.ts +3 -1
- package/lib/typescript/module/utils/requestUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/mixins/index.ts +57 -43
- package/src/index.ts +6 -1
- package/src/ui/client.ts +56 -0
- package/src/ui/components/WebOxyProvider.tsx +109 -0
- package/src/ui/components/profile/EditFieldModal.tsx +465 -0
- package/src/ui/context/OxyContext.tsx +69 -0
- package/src/ui/hooks/useAuth.ts +159 -0
- package/src/ui/hooks/useSettingToggle.ts +7 -3
- package/src/ui/hooks/useWebSSO.ts +93 -0
- package/src/ui/index.ts +17 -2
- package/src/ui/screens/PrivacySettingsScreen.tsx +54 -63
- package/src/ui/screens/SearchSettingsScreen.tsx +42 -64
- package/src/ui/server.ts +70 -0
- package/src/ui/utils/iconNames.ts +136 -0
- package/src/ui/utils/sessionHelpers.ts +10 -3
- package/src/utils/requestUtils.ts +10 -7
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Centralized mixin exports and composition helper
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* This module provides a clean way to compose all mixins
|
|
7
7
|
* and ensures consistent ordering for better maintainability
|
|
8
8
|
*/
|
|
@@ -26,24 +26,47 @@ import { OxyServicesSecurityMixin } from "./OxyServices.security.js";
|
|
|
26
26
|
import { OxyServicesUtilityMixin } from "./OxyServices.utility.js";
|
|
27
27
|
import { OxyServicesFeaturesMixin } from "./OxyServices.features.js";
|
|
28
28
|
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
|
+
|
|
29
31
|
/**
|
|
30
|
-
*
|
|
32
|
+
* Mixin pipeline - applied in order from first to last.
|
|
31
33
|
*
|
|
32
|
-
* Order matters for
|
|
33
|
-
*
|
|
34
|
+
* Order matters for dependencies:
|
|
35
|
+
* 1. Base auth mixin first (required by all others)
|
|
36
|
+
* 2. Cross-domain auth mixins (FedCM, Popup, Redirect)
|
|
37
|
+
* 3. User mixin (requires auth)
|
|
38
|
+
* 4. Feature mixins (can depend on user)
|
|
39
|
+
* 5. Utility mixin last (augments all)
|
|
34
40
|
*
|
|
35
|
-
*
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
* To add a new mixin: insert it at the appropriate position in this array.
|
|
42
|
+
*/
|
|
43
|
+
const MIXIN_PIPELINE = [
|
|
44
|
+
// Base authentication
|
|
45
|
+
OxyServicesAuthMixin,
|
|
46
|
+
// Cross-domain authentication (web-only)
|
|
47
|
+
// - FedCM: Modern browser-native identity federation (Google-style)
|
|
48
|
+
// - Popup: OAuth2-style popup authentication
|
|
49
|
+
// - Redirect: Traditional redirect-based authentication
|
|
50
|
+
OxyServicesFedCMMixin, OxyServicesPopupAuthMixin, OxyServicesRedirectAuthMixin,
|
|
51
|
+
// User management (requires auth)
|
|
52
|
+
OxyServicesUserMixin, OxyServicesPrivacyMixin,
|
|
53
|
+
// Feature mixins
|
|
54
|
+
OxyServicesLanguageMixin, OxyServicesPaymentMixin, OxyServicesKarmaMixin, OxyServicesAssetsMixin, OxyServicesDeveloperMixin, OxyServicesLocationMixin, OxyServicesAnalyticsMixin, OxyServicesDevicesMixin, OxyServicesSecurityMixin, OxyServicesFeaturesMixin,
|
|
55
|
+
// Utility (last, can use all above)
|
|
56
|
+
OxyServicesUtilityMixin];
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Composes all OxyServices mixins using a pipeline pattern.
|
|
60
|
+
*
|
|
61
|
+
* This is equivalent to the nested calls but more readable and maintainable.
|
|
62
|
+
* Adding a new mixin: just add it to MIXIN_PIPELINE at the appropriate position.
|
|
39
63
|
*
|
|
40
64
|
* @returns The fully composed OxyServices class with all mixins applied
|
|
41
65
|
*/
|
|
42
66
|
export function composeOxyServices() {
|
|
43
|
-
return
|
|
44
|
-
// Cross-domain authentication mixins (web-only)
|
|
45
|
-
OxyServicesRedirectAuthMixin(OxyServicesPopupAuthMixin(OxyServicesFedCMMixin(
|
|
46
|
-
// Base authentication mixin
|
|
47
|
-
OxyServicesAuthMixin(OxyServicesBase)))))))))))))))));
|
|
67
|
+
return MIXIN_PIPELINE.reduce((Base, mixin) => mixin(Base), OxyServicesBase);
|
|
48
68
|
}
|
|
69
|
+
|
|
70
|
+
// Export the pipeline for testing/debugging
|
|
71
|
+
export { MIXIN_PIPELINE };
|
|
49
72
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["OxyServicesBase","OxyServicesAuthMixin","OxyServicesFedCMMixin","OxyServicesPopupAuthMixin","OxyServicesRedirectAuthMixin","OxyServicesUserMixin","OxyServicesPrivacyMixin","OxyServicesLanguageMixin","OxyServicesPaymentMixin","OxyServicesKarmaMixin","OxyServicesAssetsMixin","OxyServicesDeveloperMixin","OxyServicesLocationMixin","OxyServicesAnalyticsMixin","OxyServicesDevicesMixin","OxyServicesSecurityMixin","OxyServicesUtilityMixin","OxyServicesFeaturesMixin","composeOxyServices"],"sourceRoot":"../../../../src","sources":["core/mixins/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,eAAe,QAAQ,wBAAqB;AACrD,SAASC,oBAAoB,QAAQ,uBAAoB;AACzD,SAASC,qBAAqB,QAAQ,wBAAqB;AAC3D,SAASC,yBAAyB,QAAQ,wBAAqB;AAC/D,SAASC,4BAA4B,QAAQ,2BAAwB;AACrE,SAASC,oBAAoB,QAAQ,uBAAoB;AACzD,SAASC,uBAAuB,QAAQ,0BAAuB;AAC/D,SAASC,wBAAwB,QAAQ,2BAAwB;AACjE,SAASC,uBAAuB,QAAQ,0BAAuB;AAC/D,SAASC,qBAAqB,QAAQ,wBAAqB;AAC3D,SAASC,sBAAsB,QAAQ,yBAAsB;AAC7D,SAASC,yBAAyB,QAAQ,4BAAyB;AACnE,SAASC,wBAAwB,QAAQ,2BAAwB;AACjE,SAASC,yBAAyB,QAAQ,4BAAyB;AACnE,SAASC,uBAAuB,QAAQ,0BAAuB;AAC/D,SAASC,wBAAwB,QAAQ,2BAAwB;AACjE,SAASC,uBAAuB,QAAQ,0BAAuB;AAC/D,SAASC,wBAAwB,QAAQ,2BAAwB;;AAEjE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,
|
|
1
|
+
{"version":3,"names":["OxyServicesBase","OxyServicesAuthMixin","OxyServicesFedCMMixin","OxyServicesPopupAuthMixin","OxyServicesRedirectAuthMixin","OxyServicesUserMixin","OxyServicesPrivacyMixin","OxyServicesLanguageMixin","OxyServicesPaymentMixin","OxyServicesKarmaMixin","OxyServicesAssetsMixin","OxyServicesDeveloperMixin","OxyServicesLocationMixin","OxyServicesAnalyticsMixin","OxyServicesDevicesMixin","OxyServicesSecurityMixin","OxyServicesUtilityMixin","OxyServicesFeaturesMixin","MIXIN_PIPELINE","composeOxyServices","reduce","Base","mixin"],"sourceRoot":"../../../../src","sources":["core/mixins/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,eAAe,QAAQ,wBAAqB;AACrD,SAASC,oBAAoB,QAAQ,uBAAoB;AACzD,SAASC,qBAAqB,QAAQ,wBAAqB;AAC3D,SAASC,yBAAyB,QAAQ,wBAAqB;AAC/D,SAASC,4BAA4B,QAAQ,2BAAwB;AACrE,SAASC,oBAAoB,QAAQ,uBAAoB;AACzD,SAASC,uBAAuB,QAAQ,0BAAuB;AAC/D,SAASC,wBAAwB,QAAQ,2BAAwB;AACjE,SAASC,uBAAuB,QAAQ,0BAAuB;AAC/D,SAASC,qBAAqB,QAAQ,wBAAqB;AAC3D,SAASC,sBAAsB,QAAQ,yBAAsB;AAC7D,SAASC,yBAAyB,QAAQ,4BAAyB;AACnE,SAASC,wBAAwB,QAAQ,2BAAwB;AACjE,SAASC,yBAAyB,QAAQ,4BAAyB;AACnE,SAASC,uBAAuB,QAAQ,0BAAuB;AAC/D,SAASC,wBAAwB,QAAQ,2BAAwB;AACjE,SAASC,uBAAuB,QAAQ,0BAAuB;AAC/D,SAASC,wBAAwB,QAAQ,2BAAwB;;AAEjE;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,cAA+B,GAAG;AACpC;AACAjB,oBAAoB;AAEpB;AACA;AACA;AACA;AACAC,qBAAqB,EACrBC,yBAAyB,EACzBC,4BAA4B;AAE5B;AACAC,oBAAoB,EACpBC,uBAAuB;AAEvB;AACAC,wBAAwB,EACxBC,uBAAuB,EACvBC,qBAAqB,EACrBC,sBAAsB,EACtBC,yBAAyB,EACzBC,wBAAwB,EACxBC,yBAAyB,EACzBC,uBAAuB,EACvBC,wBAAwB,EACxBE,wBAAwB;AAExB;AACAD,uBAAuB,CAC1B;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,kBAAkBA,CAAA,EAAG;EACjC,OAAOD,cAAc,CAACE,MAAM,CACxB,CAACC,IAAI,EAAEC,KAAK,KAAKA,KAAK,CAACD,IAAI,CAAC,EAC5BrB,eACJ,CAAC;AACL;;AAEA;AACA,SAASkB,cAAc","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -21,12 +21,15 @@ export { OXY_CLOUD_URL, oxyClient } from "./core/index.js";
|
|
|
21
21
|
|
|
22
22
|
// Cross-domain authentication (Web SSO via FedCM/popup/redirect)
|
|
23
23
|
export { CrossDomainAuth, createCrossDomainAuth } from "./core/index.js";
|
|
24
|
-
// React context
|
|
24
|
+
// React context and auth hooks
|
|
25
25
|
export { useOxy } from "./ui/context/OxyContext.js";
|
|
26
|
-
|
|
26
|
+
export { useAuth } from "./ui/hooks/useAuth.js";
|
|
27
27
|
// Streamlined provider with built-in bottom sheet
|
|
28
28
|
export { default as OxyProvider } from "./ui/components/OxyProvider.js";
|
|
29
29
|
|
|
30
|
+
// Web-only provider (no React Native dependencies)
|
|
31
|
+
export { default as WebOxyProvider } from "./ui/components/WebOxyProvider.js";
|
|
32
|
+
|
|
30
33
|
// Device management
|
|
31
34
|
export { DeviceManager } from "./utils/deviceManager.js";
|
|
32
35
|
// Language utilities
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["KeyManager","SignatureService","RecoveryPhraseService","OxyServices","OxyAuthenticationError","OxyAuthenticationTimeoutError","OXY_CLOUD_URL","oxyClient","CrossDomainAuth","createCrossDomainAuth","useOxy","default","OxyProvider","DeviceManager","SUPPORTED_LANGUAGES","getLanguageMetadata","getLanguageName","getNativeLanguageName","normalizeLanguageCode","SECURITY_EVENT_SEVERITY_MAP","useAuthStore","useAssetStore","useAssets","useAssetsStore","useAsset","useUploadProgress","useAssetLoading","useAssetErrors","useAssetsByApp","useAssetsByEntity","useAssetUsageCount","useIsAssetLinked","useSessionSocket","setOxyAssetInstance","useFileDownloadUrl","setOxyFileUrlInstance","useUserProfile","useUserProfiles","useCurrentUser","useUserById","useUserByUsername","useUsersBySessions","usePrivacySettings","useSessions","useSession","useDeviceSessions","useUserDevices","useSecurityInfo","useSecurityActivity","useRecentSecurityActivity","useUpdateProfile","useUploadAvatar","useUpdateAccountSettings","useUpdatePrivacySettings","useUploadFile","useSwitchSession","useLogoutSession","useLogoutAll","useUpdateDeviceName","useRemoveDevice","OxySignInButton","OxyLogo","FollowButton","ErrorCodes","createApiError","handleHttpError","validateRequiredFields","retryWithBackoff","logger","LogLevel","LogContext","logAuth","logApi","logSession","logUser","logDevice","logPayment","logPerformance"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO,sBAAmB;;AAE1B;AACA,SACEA,UAAU,EACVC,gBAAgB,EAChBC,qBAAqB,QAChB,mBAAU;;AAEjB;AACA,SAASC,WAAW,EAAEC,sBAAsB,EAAEC,6BAA6B,QAAQ,iBAAQ;AAC3F,SAASC,aAAa,EAAEC,SAAS,QAAQ,iBAAQ;;AAEjD;AACA,SAASC,eAAe,EAAEC,qBAAqB,QAAQ,iBAAQ;AAS/D;AACA,SAASC,MAAM,QAAQ,4BAAyB
|
|
1
|
+
{"version":3,"names":["KeyManager","SignatureService","RecoveryPhraseService","OxyServices","OxyAuthenticationError","OxyAuthenticationTimeoutError","OXY_CLOUD_URL","oxyClient","CrossDomainAuth","createCrossDomainAuth","useOxy","useAuth","default","OxyProvider","WebOxyProvider","DeviceManager","SUPPORTED_LANGUAGES","getLanguageMetadata","getLanguageName","getNativeLanguageName","normalizeLanguageCode","SECURITY_EVENT_SEVERITY_MAP","useAuthStore","useAssetStore","useAssets","useAssetsStore","useAsset","useUploadProgress","useAssetLoading","useAssetErrors","useAssetsByApp","useAssetsByEntity","useAssetUsageCount","useIsAssetLinked","useSessionSocket","setOxyAssetInstance","useFileDownloadUrl","setOxyFileUrlInstance","useUserProfile","useUserProfiles","useCurrentUser","useUserById","useUserByUsername","useUsersBySessions","usePrivacySettings","useSessions","useSession","useDeviceSessions","useUserDevices","useSecurityInfo","useSecurityActivity","useRecentSecurityActivity","useUpdateProfile","useUploadAvatar","useUpdateAccountSettings","useUpdatePrivacySettings","useUploadFile","useSwitchSession","useLogoutSession","useLogoutAll","useUpdateDeviceName","useRemoveDevice","OxySignInButton","OxyLogo","FollowButton","ErrorCodes","createApiError","handleHttpError","validateRequiredFields","retryWithBackoff","logger","LogLevel","LogContext","logAuth","logApi","logSession","logUser","logDevice","logPayment","logPerformance"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,OAAO,sBAAmB;;AAE1B;AACA,SACEA,UAAU,EACVC,gBAAgB,EAChBC,qBAAqB,QAChB,mBAAU;;AAEjB;AACA,SAASC,WAAW,EAAEC,sBAAsB,EAAEC,6BAA6B,QAAQ,iBAAQ;AAC3F,SAASC,aAAa,EAAEC,SAAS,QAAQ,iBAAQ;;AAEjD;AACA,SAASC,eAAe,EAAEC,qBAAqB,QAAQ,iBAAQ;AAS/D;AACA,SAASC,MAAM,QAAQ,4BAAyB;AAChD,SAASC,OAAO,QAAQ,uBAAoB;AAG5C;AACA,SAASC,OAAO,IAAIC,WAAW,QAAQ,gCAA6B;;AAEpE;AACA,SAASD,OAAO,IAAIE,cAAc,QAAQ,mCAAgC;;AAE1E;AACA,SAASC,aAAa,QAAQ,0BAAuB;AAGrD;AACA,SACEC,mBAAmB,EACnBC,mBAAmB,EACnBC,eAAe,EACfC,qBAAqB,EACrBC,qBAAqB,QAChB,0BAAuB;;AAG9B;;AA6DA;AACA,SAASC,2BAA2B,QAAQ,wBAAqB;AAQjE;AACA,SAASC,YAAY,QAAQ,0BAAuB;AACpD,SACEC,aAAa,EACbC,SAAS,IAAIC,cAAc,EAC3BC,QAAQ,EACRC,iBAAiB,EACjBC,eAAe,EACfC,cAAc,EACdC,cAAc,EACdC,iBAAiB,EACjBC,kBAAkB,EAClBC,gBAAgB,QACX,2BAAwB;;AAE/B;AACA,SAASC,gBAAgB,QAAQ,gCAA6B;AAC9D,SAASV,SAAS,EAAEW,mBAAmB,QAAQ,yBAAsB;AACrE,SAASC,kBAAkB,EAAEC,qBAAqB,QAAQ,kCAA+B;;AAEzF;AACA;AACE;AACAC,cAAc,EACdC,eAAe,EACfC,cAAc,EACdC,WAAW,EACXC,iBAAiB,EACjBC,kBAAkB,EAClBC,kBAAkB;AAClB;AACAC,WAAW,EACXC,UAAU,EACVC,iBAAiB,EACjBC,cAAc,EACdC,eAAe;AACf;AACAC,mBAAmB,EACnBC,yBAAyB,QACpB,6BAAoB;;AAE3B;AACA;AACE;AACAC,gBAAgB,EAChBC,eAAe,EACfC,wBAAwB,EACxBC,wBAAwB,EACxBC,aAAa;AACb;AACAC,gBAAgB,EAChBC,gBAAgB,EAChBC,YAAY,EACZC,mBAAmB,EACnBC,eAAe,QACV,+BAAsB;;AAE7B;AACA,SAASC,eAAe,QAAQ,oCAAiC;AACjE,SAASC,OAAO,EAAEC,YAAY,QAAQ,eAAM;;AAE5C;AACA,cAAc,qBAAkB;AAChC,SACEC,UAAU,EACVC,cAAc,EACdC,eAAe,EACfC,sBAAsB,EACtBC,gBAAgB,QACX,uBAAoB;AAC3B,cAAc,4BAAyB;AACvC,SACEC,MAAM,EACNC,QAAQ,EACRC,UAAU,EACVC,OAAO,EACPC,MAAM,EACNC,UAAU,EACVC,OAAO,EACPC,SAAS,EACTC,UAAU,EACVC,cAAc,QACT,wBAAqB;AAC5B,cAAc,uBAAoB;AAClC,cAAc,sBAAmB","ignoreList":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Client-only UI exports (tree-shakeable)
|
|
5
|
+
*
|
|
6
|
+
* Import from this module for client-side bundles where tree-shaking is important.
|
|
7
|
+
* These are direct exports without runtime detection overhead.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* import { OxyProvider, useOxy, Avatar } from '@oxyhq/services/ui/client';
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// Components
|
|
14
|
+
export { default as OxyProvider } from "./components/OxyProvider.js";
|
|
15
|
+
export { default as WebOxyProvider } from "./components/WebOxyProvider.js";
|
|
16
|
+
export { default as OxySignInButton } from "./components/OxySignInButton.js";
|
|
17
|
+
export { default as OxyLogo } from "./components/OxyLogo.js";
|
|
18
|
+
export { default as Avatar } from "./components/Avatar.js";
|
|
19
|
+
export { default as FollowButton } from "./components/FollowButton.js";
|
|
20
|
+
export { default as OxyPayButton } from "./components/OxyPayButton.js";
|
|
21
|
+
export { FontLoader, setupFonts } from "./components/FontLoader.js";
|
|
22
|
+
export { OxyIcon } from "./components/icon/index.js";
|
|
23
|
+
|
|
24
|
+
// Context
|
|
25
|
+
export { useOxy } from "./context/OxyContext.js";
|
|
26
|
+
|
|
27
|
+
// Hooks
|
|
28
|
+
export { useAuth } from "./hooks/useAuth.js";
|
|
29
|
+
export { useFollow } from "./hooks/index.js";
|
|
30
|
+
export { useStorage } from "./hooks/useStorage.js";
|
|
31
|
+
// Screens
|
|
32
|
+
export { default as ProfileScreen } from "./screens/ProfileScreen.js";
|
|
33
|
+
|
|
34
|
+
// Stores
|
|
35
|
+
export { useAuthStore } from "./stores/authStore.js";
|
|
36
|
+
export { useAccountStore } from "./stores/accountStore.js";
|
|
37
|
+
|
|
38
|
+
// Styles
|
|
39
|
+
export { fontFamilies, fontStyles } from "./styles/fonts.js";
|
|
40
|
+
|
|
41
|
+
// Toast
|
|
42
|
+
export { toast } from "../lib/sonner.js";
|
|
43
|
+
|
|
44
|
+
// Core re-exports for convenience
|
|
45
|
+
export { OxyServices } from "../core/index.js";
|
|
46
|
+
// Error handler utilities
|
|
47
|
+
export { handleAuthError, isInvalidSessionError, isTimeoutOrNetworkError, extractErrorMessage } from "./utils/errorHandlers.js";
|
|
48
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["default","OxyProvider","WebOxyProvider","OxySignInButton","OxyLogo","Avatar","FollowButton","OxyPayButton","FontLoader","setupFonts","OxyIcon","useOxy","useAuth","useFollow","useStorage","ProfileScreen","useAuthStore","useAccountStore","fontFamilies","fontStyles","toast","OxyServices","handleAuthError","isInvalidSessionError","isTimeoutOrNetworkError","extractErrorMessage"],"sourceRoot":"../../../src","sources":["ui/client.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,SAASA,OAAO,IAAIC,WAAW,QAAQ,6BAA0B;AACjE,SAASD,OAAO,IAAIE,cAAc,QAAQ,gCAA6B;AACvE,SAASF,OAAO,IAAIG,eAAe,QAAQ,iCAA8B;AACzE,SAASH,OAAO,IAAII,OAAO,QAAQ,yBAAsB;AACzD,SAASJ,OAAO,IAAIK,MAAM,QAAQ,wBAAqB;AACvD,SAASL,OAAO,IAAIM,YAAY,QAAQ,8BAA2B;AACnE,SAASN,OAAO,IAAIO,YAAY,QAAQ,8BAA2B;AACnE,SAASC,UAAU,EAAEC,UAAU,QAAQ,4BAAyB;AAChE,SAASC,OAAO,QAAQ,4BAAmB;;AAE3C;AACA,SAASC,MAAM,QAAQ,yBAAsB;;AAE7C;AACA,SAASC,OAAO,QAAQ,oBAAiB;AAEzC,SAASC,SAAS,QAAQ,kBAAS;AACnC,SAASC,UAAU,QAAQ,uBAAoB;AAG/C;AACA,SAASd,OAAO,IAAIe,aAAa,QAAQ,4BAAyB;;AAElE;AACA,SAASC,YAAY,QAAQ,uBAAoB;AACjD,SAASC,eAAe,QAAQ,0BAAuB;;AAEvD;AACA,SAASC,YAAY,EAAEC,UAAU,QAAQ,mBAAgB;;AAEzD;AACA,SAASC,KAAK,QAAQ,kBAAe;;AAErC;AACA,SAASC,WAAW,QAAQ,kBAAS;AAGrC;AACA,SACIC,eAAe,EACfC,qBAAqB,EACrBC,uBAAuB,EACvBC,mBAAmB,QAChB,0BAAuB","ignoreList":[]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WebOxyProvider - OxyProvider for web apps (Next.js, React)
|
|
5
|
+
*
|
|
6
|
+
* This provider is specifically for web environments and doesn't include
|
|
7
|
+
* React Native-specific dependencies. It provides:
|
|
8
|
+
* - Automatic cross-domain SSO via hidden iframe
|
|
9
|
+
* - Session management
|
|
10
|
+
* - All useOxy/useAuth functionality
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* ```tsx
|
|
14
|
+
* import { WebOxyProvider, useAuth } from '@oxyhq/services';
|
|
15
|
+
*
|
|
16
|
+
* function App() {
|
|
17
|
+
* return (
|
|
18
|
+
* <WebOxyProvider baseURL="https://api.oxy.so">
|
|
19
|
+
* <YourApp />
|
|
20
|
+
* </WebOxyProvider>
|
|
21
|
+
* );
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { useEffect, useRef, useState } from 'react';
|
|
27
|
+
import { OxyContextProvider } from "../context/OxyContext.js";
|
|
28
|
+
import { QueryClientProvider } from '@tanstack/react-query';
|
|
29
|
+
import { createQueryClient } from "../hooks/queryClient.js";
|
|
30
|
+
import { createPlatformStorage } from "../utils/storageHelpers.js";
|
|
31
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
32
|
+
/**
|
|
33
|
+
* OxyProvider for web applications
|
|
34
|
+
*
|
|
35
|
+
* Features:
|
|
36
|
+
* - Automatic cross-domain SSO (checks auth.oxy.so/auth/silent on mount)
|
|
37
|
+
* - Session persistence in localStorage
|
|
38
|
+
* - TanStack Query for data fetching
|
|
39
|
+
* - No React Native dependencies
|
|
40
|
+
*/
|
|
41
|
+
const WebOxyProvider = ({
|
|
42
|
+
children,
|
|
43
|
+
baseURL,
|
|
44
|
+
authWebUrl,
|
|
45
|
+
onAuthStateChange,
|
|
46
|
+
storageKeyPrefix,
|
|
47
|
+
queryClient: providedQueryClient
|
|
48
|
+
}) => {
|
|
49
|
+
const storageRef = useRef(null);
|
|
50
|
+
const queryClientRef = useRef(null);
|
|
51
|
+
const [queryClient, setQueryClient] = useState(null);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (providedQueryClient) {
|
|
54
|
+
queryClientRef.current = providedQueryClient;
|
|
55
|
+
setQueryClient(providedQueryClient);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
let mounted = true;
|
|
59
|
+
createPlatformStorage().then(storage => {
|
|
60
|
+
if (mounted && !queryClientRef.current) {
|
|
61
|
+
storageRef.current = storage;
|
|
62
|
+
const client = createQueryClient(storage);
|
|
63
|
+
queryClientRef.current = client;
|
|
64
|
+
setQueryClient(client);
|
|
65
|
+
}
|
|
66
|
+
}).catch(() => {
|
|
67
|
+
if (mounted && !queryClientRef.current) {
|
|
68
|
+
const client = createQueryClient(null);
|
|
69
|
+
queryClientRef.current = client;
|
|
70
|
+
setQueryClient(client);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return () => {
|
|
74
|
+
mounted = false;
|
|
75
|
+
};
|
|
76
|
+
}, [providedQueryClient]);
|
|
77
|
+
|
|
78
|
+
// Wait for query client to be ready
|
|
79
|
+
if (!queryClient) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
return /*#__PURE__*/_jsx(QueryClientProvider, {
|
|
83
|
+
client: queryClient,
|
|
84
|
+
children: /*#__PURE__*/_jsx(OxyContextProvider, {
|
|
85
|
+
baseURL: baseURL,
|
|
86
|
+
authWebUrl: authWebUrl,
|
|
87
|
+
storageKeyPrefix: storageKeyPrefix,
|
|
88
|
+
onAuthStateChange: onAuthStateChange,
|
|
89
|
+
children: children
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
export default WebOxyProvider;
|
|
94
|
+
//# sourceMappingURL=WebOxyProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","useState","OxyContextProvider","QueryClientProvider","createQueryClient","createPlatformStorage","jsx","_jsx","WebOxyProvider","children","baseURL","authWebUrl","onAuthStateChange","storageKeyPrefix","queryClient","providedQueryClient","storageRef","queryClientRef","setQueryClient","current","mounted","then","storage","client","catch"],"sourceRoot":"../../../../src","sources":["ui/components/WebOxyProvider.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAiC,OAAO;AAC5E,SAASC,kBAAkB,QAAQ,0BAAuB;AAC1D,SAASC,mBAAmB,QAAQ,uBAAuB;AAC3D,SAASC,iBAAiB,QAAQ,yBAAsB;AACxD,SAASC,qBAAqB,QAA+B,4BAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAWvF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,cAAuC,GAAGA,CAAC;EAC/CC,QAAQ;EACRC,OAAO;EACPC,UAAU;EACVC,iBAAiB;EACjBC,gBAAgB;EAChBC,WAAW,EAAEC;AACf,CAAC,KAAK;EACJ,MAAMC,UAAU,GAAGhB,MAAM,CAA0B,IAAI,CAAC;EACxD,MAAMiB,cAAc,GAAGjB,MAAM,CAA8C,IAAI,CAAC;EAChF,MAAM,CAACc,WAAW,EAAEI,cAAc,CAAC,GAAGjB,QAAQ,CAA8C,IAAI,CAAC;EAEjGF,SAAS,CAAC,MAAM;IACd,IAAIgB,mBAAmB,EAAE;MACvBE,cAAc,CAACE,OAAO,GAAGJ,mBAAmB;MAC5CG,cAAc,CAACH,mBAAmB,CAAC;MACnC;IACF;IAEA,IAAIK,OAAO,GAAG,IAAI;IAClBf,qBAAqB,CAAC,CAAC,CACpBgB,IAAI,CAAEC,OAAO,IAAK;MACjB,IAAIF,OAAO,IAAI,CAACH,cAAc,CAACE,OAAO,EAAE;QACtCH,UAAU,CAACG,OAAO,GAAGG,OAAO;QAC5B,MAAMC,MAAM,GAAGnB,iBAAiB,CAACkB,OAAO,CAAC;QACzCL,cAAc,CAACE,OAAO,GAAGI,MAAM;QAC/BL,cAAc,CAACK,MAAM,CAAC;MACxB;IACF,CAAC,CAAC,CACDC,KAAK,CAAC,MAAM;MACX,IAAIJ,OAAO,IAAI,CAACH,cAAc,CAACE,OAAO,EAAE;QACtC,MAAMI,MAAM,GAAGnB,iBAAiB,CAAC,IAAI,CAAC;QACtCa,cAAc,CAACE,OAAO,GAAGI,MAAM;QAC/BL,cAAc,CAACK,MAAM,CAAC;MACxB;IACF,CAAC,CAAC;IAEJ,OAAO,MAAM;MACXH,OAAO,GAAG,KAAK;IACjB,CAAC;EACH,CAAC,EAAE,CAACL,mBAAmB,CAAC,CAAC;;EAEzB;EACA,IAAI,CAACD,WAAW,EAAE;IAChB,OAAO,IAAI;EACb;EAEA,oBACEP,IAAA,CAACJ,mBAAmB;IAACoB,MAAM,EAAET,WAAY;IAAAL,QAAA,eACvCF,IAAA,CAACL,kBAAkB;MACjBQ,OAAO,EAAEA,OAAQ;MACjBC,UAAU,EAAEA,UAAW;MACvBE,gBAAgB,EAAEA,gBAAiB;MACnCD,iBAAiB,EAAEA,iBAAkB;MAAAH,QAAA,EAEpCA;IAAQ,CACS;EAAC,CACF,CAAC;AAE1B,CAAC;AAED,eAAeD,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { useState, useEffect, useCallback } from 'react';
|
|
4
|
+
import { View, Text, TextInput, TouchableOpacity, StyleSheet, Modal, Platform, ScrollView } from 'react-native';
|
|
5
|
+
import { Ionicons } from '@expo/vector-icons';
|
|
6
|
+
import { useThemeStyles } from "../../hooks/useThemeStyles.js";
|
|
7
|
+
import { useColorScheme } from "../../hooks/use-color-scheme.js";
|
|
8
|
+
import { useI18n } from "../../hooks/useI18n.js";
|
|
9
|
+
import { fontFamilies } from "../../styles/fonts.js";
|
|
10
|
+
import { useProfileEditing } from "../../hooks/useProfileEditing.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Field configuration for single/multi field variants
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* List item for list variant
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for list variant
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Props for EditFieldModal
|
|
26
|
+
*/
|
|
27
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
|
+
/**
|
|
29
|
+
* Generic modal component for editing profile fields.
|
|
30
|
+
*
|
|
31
|
+
* Supports three variants:
|
|
32
|
+
* - single: Single text input (username, email, bio)
|
|
33
|
+
* - multi: Multiple text inputs (display name with first/last)
|
|
34
|
+
* - list: Add/remove list items (links, locations)
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* // Single field (bio)
|
|
38
|
+
* <EditFieldModal
|
|
39
|
+
* visible={showBioModal}
|
|
40
|
+
* onClose={() => setShowBioModal(false)}
|
|
41
|
+
* title="Bio"
|
|
42
|
+
* variant="single"
|
|
43
|
+
* fields={[{
|
|
44
|
+
* key: 'bio',
|
|
45
|
+
* label: 'Bio',
|
|
46
|
+
* initialValue: user.bio,
|
|
47
|
+
* placeholder: 'Tell people about yourself...',
|
|
48
|
+
* inputProps: { multiline: true, numberOfLines: 6 }
|
|
49
|
+
* }]}
|
|
50
|
+
* onSubmit={async (data) => updateField('bio', data.bio)}
|
|
51
|
+
* />
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* // Multi field (display name)
|
|
55
|
+
* <EditFieldModal
|
|
56
|
+
* visible={showNameModal}
|
|
57
|
+
* onClose={() => setShowNameModal(false)}
|
|
58
|
+
* title="Display Name"
|
|
59
|
+
* variant="multi"
|
|
60
|
+
* fields={[
|
|
61
|
+
* { key: 'firstName', label: 'First Name', initialValue: user.name?.first },
|
|
62
|
+
* { key: 'lastName', label: 'Last Name', initialValue: user.name?.last }
|
|
63
|
+
* ]}
|
|
64
|
+
* onSubmit={async (data) => saveProfile({ displayName: data.firstName, lastName: data.lastName })}
|
|
65
|
+
* />
|
|
66
|
+
*/
|
|
67
|
+
export function EditFieldModal({
|
|
68
|
+
visible,
|
|
69
|
+
onClose,
|
|
70
|
+
title,
|
|
71
|
+
theme = 'light',
|
|
72
|
+
onSave,
|
|
73
|
+
variant,
|
|
74
|
+
fields = [],
|
|
75
|
+
listConfig,
|
|
76
|
+
onSubmit,
|
|
77
|
+
saveDisabled = false
|
|
78
|
+
}) {
|
|
79
|
+
const {
|
|
80
|
+
t
|
|
81
|
+
} = useI18n();
|
|
82
|
+
const colorScheme = useColorScheme();
|
|
83
|
+
const themeStyles = useThemeStyles(theme || 'light', colorScheme);
|
|
84
|
+
const colors = themeStyles.colors;
|
|
85
|
+
const {
|
|
86
|
+
isSaving
|
|
87
|
+
} = useProfileEditing();
|
|
88
|
+
|
|
89
|
+
// State for field values (single/multi variants)
|
|
90
|
+
const [fieldValues, setFieldValues] = useState({});
|
|
91
|
+
const [fieldErrors, setFieldErrors] = useState({});
|
|
92
|
+
|
|
93
|
+
// State for list items (list variant)
|
|
94
|
+
const [listItems, setListItems] = useState([]);
|
|
95
|
+
const [newItemValue, setNewItemValue] = useState('');
|
|
96
|
+
|
|
97
|
+
// Initialize field values when modal opens
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
if (visible) {
|
|
100
|
+
if (variant === 'list' && listConfig) {
|
|
101
|
+
setListItems(listConfig.items);
|
|
102
|
+
setNewItemValue('');
|
|
103
|
+
} else if (fields.length > 0) {
|
|
104
|
+
const initialValues = {};
|
|
105
|
+
fields.forEach(field => {
|
|
106
|
+
initialValues[field.key] = field.initialValue || '';
|
|
107
|
+
});
|
|
108
|
+
setFieldValues(initialValues);
|
|
109
|
+
setFieldErrors({});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}, [visible, variant, fields, listConfig]);
|
|
113
|
+
|
|
114
|
+
// Field change handler with validation
|
|
115
|
+
const handleFieldChange = useCallback((key, value) => {
|
|
116
|
+
setFieldValues(prev => ({
|
|
117
|
+
...prev,
|
|
118
|
+
[key]: value
|
|
119
|
+
}));
|
|
120
|
+
|
|
121
|
+
// Clear error on change
|
|
122
|
+
if (fieldErrors[key]) {
|
|
123
|
+
setFieldErrors(prev => ({
|
|
124
|
+
...prev,
|
|
125
|
+
[key]: undefined
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
}, [fieldErrors]);
|
|
129
|
+
|
|
130
|
+
// Validate all fields
|
|
131
|
+
const validateFields = useCallback(() => {
|
|
132
|
+
const errors = {};
|
|
133
|
+
let isValid = true;
|
|
134
|
+
fields.forEach(field => {
|
|
135
|
+
if (field.validation) {
|
|
136
|
+
const error = field.validation(fieldValues[field.key] || '');
|
|
137
|
+
if (error) {
|
|
138
|
+
errors[field.key] = error;
|
|
139
|
+
isValid = false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
setFieldErrors(errors);
|
|
144
|
+
return isValid;
|
|
145
|
+
}, [fields, fieldValues]);
|
|
146
|
+
|
|
147
|
+
// Add item to list
|
|
148
|
+
const handleAddItem = useCallback(() => {
|
|
149
|
+
if (!newItemValue.trim() || !listConfig) return;
|
|
150
|
+
const newItem = listConfig.createItem(newItemValue.trim());
|
|
151
|
+
setListItems(prev => [...prev, newItem]);
|
|
152
|
+
setNewItemValue('');
|
|
153
|
+
}, [newItemValue, listConfig]);
|
|
154
|
+
|
|
155
|
+
// Remove item from list
|
|
156
|
+
const handleRemoveItem = useCallback(id => {
|
|
157
|
+
setListItems(prev => prev.filter(item => item.id !== id));
|
|
158
|
+
}, []);
|
|
159
|
+
|
|
160
|
+
// Save handler
|
|
161
|
+
const handleSave = async () => {
|
|
162
|
+
if (variant === 'list') {
|
|
163
|
+
const success = await onSubmit({
|
|
164
|
+
items: listItems
|
|
165
|
+
});
|
|
166
|
+
if (success) {
|
|
167
|
+
onSave?.();
|
|
168
|
+
onClose();
|
|
169
|
+
}
|
|
170
|
+
} else {
|
|
171
|
+
if (!validateFields()) return;
|
|
172
|
+
const success = await onSubmit(fieldValues);
|
|
173
|
+
if (success) {
|
|
174
|
+
onSave?.();
|
|
175
|
+
onClose();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
// Render field inputs for single/multi variants
|
|
181
|
+
const renderFields = () => /*#__PURE__*/_jsx(View, {
|
|
182
|
+
style: styles.modalBody,
|
|
183
|
+
children: fields.map((field, index) => /*#__PURE__*/_jsxs(View, {
|
|
184
|
+
style: styles.inputGroup,
|
|
185
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
186
|
+
style: [styles.label, {
|
|
187
|
+
color: colors.text
|
|
188
|
+
}],
|
|
189
|
+
children: field.label
|
|
190
|
+
}), /*#__PURE__*/_jsx(TextInput, {
|
|
191
|
+
style: [field.inputProps?.multiline ? styles.textArea : styles.input, {
|
|
192
|
+
backgroundColor: colors.card,
|
|
193
|
+
color: colors.text,
|
|
194
|
+
borderColor: fieldErrors[field.key] ? '#FF3B30' : colors.border
|
|
195
|
+
}],
|
|
196
|
+
value: fieldValues[field.key] || '',
|
|
197
|
+
onChangeText: value => handleFieldChange(field.key, value),
|
|
198
|
+
placeholder: field.placeholder,
|
|
199
|
+
placeholderTextColor: colors.secondaryText,
|
|
200
|
+
autoFocus: index === 0,
|
|
201
|
+
selectionColor: colors.tint,
|
|
202
|
+
textAlignVertical: field.inputProps?.multiline ? 'top' : 'center',
|
|
203
|
+
...field.inputProps
|
|
204
|
+
}), fieldErrors[field.key] && /*#__PURE__*/_jsx(Text, {
|
|
205
|
+
style: styles.errorText,
|
|
206
|
+
children: fieldErrors[field.key]
|
|
207
|
+
})]
|
|
208
|
+
}, field.key))
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// Render list for list variant
|
|
212
|
+
const renderList = () => {
|
|
213
|
+
if (!listConfig) return null;
|
|
214
|
+
return /*#__PURE__*/_jsxs(ScrollView, {
|
|
215
|
+
style: styles.modalBody,
|
|
216
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
217
|
+
style: styles.inputGroup,
|
|
218
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
219
|
+
style: [styles.label, {
|
|
220
|
+
color: colors.text
|
|
221
|
+
}],
|
|
222
|
+
children: listConfig.addItemLabel || t('common.add') || 'Add'
|
|
223
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
224
|
+
style: styles.addItemRow,
|
|
225
|
+
children: [/*#__PURE__*/_jsx(TextInput, {
|
|
226
|
+
style: [styles.input, {
|
|
227
|
+
backgroundColor: colors.card,
|
|
228
|
+
color: colors.text,
|
|
229
|
+
borderColor: colors.border,
|
|
230
|
+
flex: 1
|
|
231
|
+
}],
|
|
232
|
+
value: newItemValue,
|
|
233
|
+
onChangeText: setNewItemValue,
|
|
234
|
+
placeholder: listConfig.addItemPlaceholder,
|
|
235
|
+
placeholderTextColor: colors.secondaryText,
|
|
236
|
+
selectionColor: colors.tint,
|
|
237
|
+
autoCapitalize: "none",
|
|
238
|
+
autoCorrect: false
|
|
239
|
+
}), /*#__PURE__*/_jsx(TouchableOpacity, {
|
|
240
|
+
style: [styles.addButton, {
|
|
241
|
+
backgroundColor: colors.tint
|
|
242
|
+
}],
|
|
243
|
+
onPress: handleAddItem,
|
|
244
|
+
disabled: !newItemValue.trim(),
|
|
245
|
+
children: /*#__PURE__*/_jsx(Ionicons, {
|
|
246
|
+
name: "add",
|
|
247
|
+
size: 20,
|
|
248
|
+
color: "#fff"
|
|
249
|
+
})
|
|
250
|
+
})]
|
|
251
|
+
})]
|
|
252
|
+
}), listItems.length > 0 && /*#__PURE__*/_jsxs(View, {
|
|
253
|
+
style: styles.listSection,
|
|
254
|
+
children: [listConfig.listTitle && /*#__PURE__*/_jsxs(Text, {
|
|
255
|
+
style: [styles.listTitle, {
|
|
256
|
+
color: colors.text
|
|
257
|
+
}],
|
|
258
|
+
children: [listConfig.listTitle, " (", listItems.length, ")"]
|
|
259
|
+
}), listItems.map(item => /*#__PURE__*/_jsx(View, {
|
|
260
|
+
children: listConfig.renderItem(item, () => handleRemoveItem(item.id), colors)
|
|
261
|
+
}, item.id))]
|
|
262
|
+
})]
|
|
263
|
+
});
|
|
264
|
+
};
|
|
265
|
+
return /*#__PURE__*/_jsx(Modal, {
|
|
266
|
+
visible: visible,
|
|
267
|
+
animationType: "slide",
|
|
268
|
+
transparent: true,
|
|
269
|
+
onRequestClose: onClose,
|
|
270
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
271
|
+
style: styles.modalOverlay,
|
|
272
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
273
|
+
style: [styles.modalContent, {
|
|
274
|
+
backgroundColor: colors.background
|
|
275
|
+
}],
|
|
276
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
277
|
+
style: styles.modalHeader,
|
|
278
|
+
children: [/*#__PURE__*/_jsx(TouchableOpacity, {
|
|
279
|
+
onPress: onClose,
|
|
280
|
+
style: styles.closeButton,
|
|
281
|
+
children: /*#__PURE__*/_jsx(Ionicons, {
|
|
282
|
+
name: "close",
|
|
283
|
+
size: 24,
|
|
284
|
+
color: colors.text
|
|
285
|
+
})
|
|
286
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
287
|
+
style: [styles.modalTitle, {
|
|
288
|
+
color: colors.text
|
|
289
|
+
}],
|
|
290
|
+
children: title
|
|
291
|
+
}), /*#__PURE__*/_jsx(TouchableOpacity, {
|
|
292
|
+
onPress: handleSave,
|
|
293
|
+
disabled: isSaving || saveDisabled,
|
|
294
|
+
style: [styles.saveButton, {
|
|
295
|
+
opacity: isSaving || saveDisabled ? 0.5 : 1
|
|
296
|
+
}],
|
|
297
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
298
|
+
style: [styles.saveButtonText, {
|
|
299
|
+
color: colors.tint
|
|
300
|
+
}],
|
|
301
|
+
children: isSaving ? t('common.saving') || 'Saving...' : t('common.save') || 'Save'
|
|
302
|
+
})
|
|
303
|
+
})]
|
|
304
|
+
}), variant === 'list' ? renderList() : renderFields()]
|
|
305
|
+
})
|
|
306
|
+
})
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
const styles = StyleSheet.create({
|
|
310
|
+
modalOverlay: {
|
|
311
|
+
flex: 1,
|
|
312
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
313
|
+
justifyContent: 'flex-end'
|
|
314
|
+
},
|
|
315
|
+
modalContent: {
|
|
316
|
+
borderTopLeftRadius: 20,
|
|
317
|
+
borderTopRightRadius: 20,
|
|
318
|
+
paddingTop: Platform.OS === 'ios' ? 20 : 16,
|
|
319
|
+
maxHeight: '80%'
|
|
320
|
+
},
|
|
321
|
+
modalHeader: {
|
|
322
|
+
flexDirection: 'row',
|
|
323
|
+
alignItems: 'center',
|
|
324
|
+
justifyContent: 'space-between',
|
|
325
|
+
paddingHorizontal: 16,
|
|
326
|
+
paddingBottom: 16,
|
|
327
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
328
|
+
borderBottomColor: '#E5E5EA'
|
|
329
|
+
},
|
|
330
|
+
closeButton: {
|
|
331
|
+
width: 40,
|
|
332
|
+
height: 40,
|
|
333
|
+
alignItems: 'center',
|
|
334
|
+
justifyContent: 'center'
|
|
335
|
+
},
|
|
336
|
+
modalTitle: {
|
|
337
|
+
fontSize: 18,
|
|
338
|
+
fontWeight: '600',
|
|
339
|
+
fontFamily: fontFamilies.phuduSemiBold,
|
|
340
|
+
flex: 1,
|
|
341
|
+
textAlign: 'center'
|
|
342
|
+
},
|
|
343
|
+
saveButton: {
|
|
344
|
+
paddingHorizontal: 16,
|
|
345
|
+
paddingVertical: 8
|
|
346
|
+
},
|
|
347
|
+
saveButtonText: {
|
|
348
|
+
fontSize: 16,
|
|
349
|
+
fontWeight: '600',
|
|
350
|
+
fontFamily: fontFamilies.phuduSemiBold
|
|
351
|
+
},
|
|
352
|
+
modalBody: {
|
|
353
|
+
padding: 16,
|
|
354
|
+
gap: 16
|
|
355
|
+
},
|
|
356
|
+
inputGroup: {
|
|
357
|
+
gap: 8
|
|
358
|
+
},
|
|
359
|
+
label: {
|
|
360
|
+
fontSize: 14,
|
|
361
|
+
fontWeight: '600',
|
|
362
|
+
fontFamily: fontFamilies.phuduSemiBold
|
|
363
|
+
},
|
|
364
|
+
input: {
|
|
365
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
366
|
+
borderRadius: 12,
|
|
367
|
+
padding: 16,
|
|
368
|
+
fontSize: 16,
|
|
369
|
+
minHeight: 52
|
|
370
|
+
},
|
|
371
|
+
textArea: {
|
|
372
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
373
|
+
borderRadius: 12,
|
|
374
|
+
padding: 16,
|
|
375
|
+
fontSize: 16,
|
|
376
|
+
minHeight: 120
|
|
377
|
+
},
|
|
378
|
+
errorText: {
|
|
379
|
+
fontSize: 12,
|
|
380
|
+
color: '#FF3B30'
|
|
381
|
+
},
|
|
382
|
+
addItemRow: {
|
|
383
|
+
flexDirection: 'row',
|
|
384
|
+
gap: 8,
|
|
385
|
+
alignItems: 'center'
|
|
386
|
+
},
|
|
387
|
+
addButton: {
|
|
388
|
+
width: 52,
|
|
389
|
+
height: 52,
|
|
390
|
+
borderRadius: 12,
|
|
391
|
+
alignItems: 'center',
|
|
392
|
+
justifyContent: 'center'
|
|
393
|
+
},
|
|
394
|
+
listSection: {
|
|
395
|
+
gap: 8,
|
|
396
|
+
marginTop: 16
|
|
397
|
+
},
|
|
398
|
+
listTitle: {
|
|
399
|
+
fontSize: 16,
|
|
400
|
+
fontWeight: '600',
|
|
401
|
+
fontFamily: fontFamilies.phuduSemiBold,
|
|
402
|
+
marginBottom: 8
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
export default EditFieldModal;
|
|
406
|
+
//# sourceMappingURL=EditFieldModal.js.map
|