@airxpay/sdk-ui 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +266 -112
  2. package/dist/api/seller.d.ts +9 -0
  3. package/dist/api/seller.js +13 -4
  4. package/dist/components/common/CountryDropdown.d.ts +17 -0
  5. package/dist/components/common/CountryDropdown.js +2 -2
  6. package/dist/components/common/FileUploader.d.ts +16 -0
  7. package/dist/components/common/FileUploader.js +17 -8
  8. package/dist/components/common/StepIndicator.d.ts +11 -0
  9. package/dist/components/steps/BankDetails.d.ts +10 -0
  10. package/dist/components/steps/BankDetails.js +23 -16
  11. package/dist/components/steps/BasicDetailsForm.d.ts +10 -0
  12. package/dist/components/steps/BasicDetailsForm.js +8 -19
  13. package/dist/components/steps/KYCVerification.d.ts +11 -0
  14. package/dist/components/steps/KYCVerification.js +13 -4
  15. package/dist/components/steps/OnboardingComplete.d.ts +16 -0
  16. package/dist/components/ui/SellerOnboard/CustomSegmentedButtons.d.ts +15 -0
  17. package/dist/components/ui/SellerOnboard/SellerOnboarding.d.ts +4 -0
  18. package/dist/components/ui/SellerOnboard/SellerOnboarding.js +10 -23
  19. package/dist/contexts/AirXPayProvider.d.ts +14 -0
  20. package/dist/contexts/AirXPayProvider.js +9 -8
  21. package/dist/hooks/SellerOnboarding.d.ts +3 -0
  22. package/dist/hooks/SellerOnboarding.js +2 -2
  23. package/dist/index.d.ts +4 -0
  24. package/dist/index.js +9 -3
  25. package/dist/sdk/airxpay.d.ts +7 -0
  26. package/dist/sdk/airxpay.js +16 -5
  27. package/dist/types/dev.d.ts +1 -0
  28. package/dist/types/dev.js +5 -0
  29. package/dist/types/dev.ts +2 -0
  30. package/dist/types/sellertypes.d.ts +69 -0
  31. package/dist/types/sellertypes.ts +85 -0
  32. package/dist/types/type.d.ts +9 -0
  33. package/dist/types/type.ts +10 -0
  34. package/package.json +7 -15
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { StepConfig, Mode } from '../../types/sellertypes';
3
+ interface StepIndicatorProps {
4
+ currentStep: number;
5
+ steps: StepConfig[];
6
+ mode: Mode;
7
+ isKycCompleted: boolean;
8
+ isBankDetailsCompleted: boolean;
9
+ }
10
+ declare const StepIndicator: React.FC<StepIndicatorProps>;
11
+ export default StepIndicator;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { Seller, Mode } from '../../types/sellertypes';
3
+ interface BankDetailsProps {
4
+ initialData: Partial<Seller>;
5
+ mode: Mode;
6
+ onNext: (data: Partial<Seller>) => void;
7
+ onBack: () => void;
8
+ }
9
+ declare const BankDetails: React.FC<BankDetailsProps>;
10
+ export default BankDetails;
@@ -33,6 +33,15 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  return result;
34
34
  };
35
35
  })();
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
36
45
  var __importDefault = (this && this.__importDefault) || function (mod) {
37
46
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
47
  };
@@ -43,8 +52,9 @@ const react_native_paper_1 = require("react-native-paper");
43
52
  const expo_linear_gradient_1 = require("expo-linear-gradient");
44
53
  const FileUploader_1 = __importDefault(require("../common/FileUploader"));
45
54
  const BankDetails = ({ initialData, mode, onNext, onBack, }) => {
55
+ var _a;
46
56
  const [formData, setFormData] = (0, react_1.useState)(initialData.bankDetails || {});
47
- const [cancelledCheque, setCancelledCheque] = (0, react_1.useState)(initialData.bankDetails?.cancelledChequeUrl);
57
+ const [cancelledCheque, setCancelledCheque] = (0, react_1.useState)((_a = initialData.bankDetails) === null || _a === void 0 ? void 0 : _a.cancelledChequeUrl);
48
58
  const [uploading, setUploading] = (0, react_1.useState)(false);
49
59
  const [touched, setTouched] = (0, react_1.useState)({});
50
60
  const [errors, setErrors] = (0, react_1.useState)({});
@@ -57,24 +67,24 @@ const BankDetails = ({ initialData, mode, onNext, onBack, }) => {
57
67
  const validateField = (field, value) => {
58
68
  switch (field) {
59
69
  case 'accountHolderName':
60
- if (!value?.trim())
70
+ if (!(value === null || value === void 0 ? void 0 : value.trim()))
61
71
  return 'Account holder name is required';
62
72
  if (value.length < 3)
63
73
  return 'Name must be at least 3 characters';
64
74
  return undefined;
65
75
  case 'bankName':
66
- if (!value?.trim())
76
+ if (!(value === null || value === void 0 ? void 0 : value.trim()))
67
77
  return 'Bank name is required';
68
78
  return undefined;
69
79
  case 'accountNumber':
70
- if (!value?.trim())
80
+ if (!(value === null || value === void 0 ? void 0 : value.trim()))
71
81
  return 'Account number is required';
72
82
  if (!/^\d{9,18}$/.test(value.replace(/\s/g, ''))) {
73
83
  return 'Invalid account number';
74
84
  }
75
85
  return undefined;
76
86
  case 'ifscCode':
77
- if (!value?.trim())
87
+ if (!(value === null || value === void 0 ? void 0 : value.trim()))
78
88
  return 'IFSC code is required';
79
89
  if (!validateIFSC(value.toUpperCase())) {
80
90
  return 'Invalid IFSC code';
@@ -114,7 +124,7 @@ const BankDetails = ({ initialData, mode, onNext, onBack, }) => {
114
124
  ifscCode: formData.ifscCode || 'empty',
115
125
  cheque: cancelledCheque || 'empty'
116
126
  };
117
- const fieldErrors = { ...errors };
127
+ const fieldErrors = Object.assign({}, errors);
118
128
  const isValid = allRequiredFilled && hasNoErrors && hasCheque;
119
129
  setFormValid(isValid);
120
130
  // Debug log
@@ -131,11 +141,11 @@ const BankDetails = ({ initialData, mode, onNext, onBack, }) => {
131
141
  if (field === 'ifscCode') {
132
142
  value = value.toUpperCase();
133
143
  }
134
- setFormData(prev => ({ ...prev, [field]: value }));
144
+ setFormData(prev => (Object.assign(Object.assign({}, prev), { [field]: value })));
135
145
  // Validate on change
136
146
  const error = validateField(field, value);
137
147
  setErrors(prev => {
138
- const newErrors = { ...prev };
148
+ const newErrors = Object.assign({}, prev);
139
149
  if (error) {
140
150
  newErrors[field] = error;
141
151
  }
@@ -146,11 +156,11 @@ const BankDetails = ({ initialData, mode, onNext, onBack, }) => {
146
156
  });
147
157
  };
148
158
  const handleBlur = (field) => {
149
- setTouched(prev => ({ ...prev, [field]: true }));
159
+ setTouched(prev => (Object.assign(Object.assign({}, prev), { [field]: true })));
150
160
  const value = formData[field];
151
161
  const error = validateField(field, value);
152
162
  setErrors(prev => {
153
- const newErrors = { ...prev };
163
+ const newErrors = Object.assign({}, prev);
154
164
  if (error) {
155
165
  newErrors[field] = error;
156
166
  }
@@ -160,13 +170,13 @@ const BankDetails = ({ initialData, mode, onNext, onBack, }) => {
160
170
  return newErrors;
161
171
  });
162
172
  };
163
- const handleChequeUpload = async (file) => {
173
+ const handleChequeUpload = (file) => __awaiter(void 0, void 0, void 0, function* () {
164
174
  setUploading(true);
165
175
  setTimeout(() => {
166
176
  setCancelledCheque(file.uri || 'uploaded_cheque.jpg');
167
177
  setUploading(false);
168
178
  }, 1000);
169
- };
179
+ });
170
180
  const handleChequeRemove = () => {
171
181
  react_native_1.Alert.alert('Remove Document', 'Are you sure you want to remove the cancelled cheque?', [
172
182
  { text: 'Cancel', style: 'cancel' },
@@ -200,10 +210,7 @@ const BankDetails = ({ initialData, mode, onNext, onBack, }) => {
200
210
  return;
201
211
  }
202
212
  onNext({
203
- bankDetails: {
204
- ...formData,
205
- cancelledChequeUrl: cancelledCheque,
206
- },
213
+ bankDetails: Object.assign(Object.assign({}, formData), { cancelledChequeUrl: cancelledCheque }),
207
214
  isBankDetailsCompleted: true,
208
215
  });
209
216
  };
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { Seller, FormErrors } from '../../types/sellertypes';
3
+ interface BasicDetailsFormProps {
4
+ initialData: Partial<Seller>;
5
+ onNext: (data: Partial<Seller>) => void;
6
+ errors: FormErrors;
7
+ setErrors: (errors: FormErrors) => void;
8
+ }
9
+ declare const BasicDetailsForm: React.FC<BasicDetailsFormProps>;
10
+ export default BasicDetailsForm;
@@ -48,18 +48,7 @@ const BasicDetailsForm = ({ initialData, onNext, errors, setErrors, }) => {
48
48
  const fadeAnim = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current;
49
49
  const slideAnim = (0, react_1.useRef)(new react_native_1.Animated.Value(50)).current;
50
50
  const scaleAnim = (0, react_1.useRef)(new react_native_1.Animated.Value(0.95)).current;
51
- const [formData, setFormData] = (0, react_1.useState)({
52
- sellerName: '',
53
- sellerEmail: '',
54
- sellerPhone: '',
55
- businessName: '',
56
- businessType: 'individual',
57
- businessCategory: '',
58
- country: 'India',
59
- nationality: 'Indian',
60
- dob: '',
61
- ...initialData,
62
- });
51
+ const [formData, setFormData] = (0, react_1.useState)(Object.assign({ sellerName: '', sellerEmail: '', sellerPhone: '', businessName: '', businessType: 'individual', businessCategory: '', country: 'India', nationality: 'Indian', dob: '' }, initialData));
63
52
  const [showDatePicker, setShowDatePicker] = (0, react_1.useState)(false);
64
53
  const [touched, setTouched] = (0, react_1.useState)({});
65
54
  const [focusedField, setFocusedField] = (0, react_1.useState)(null);
@@ -88,7 +77,7 @@ const BasicDetailsForm = ({ initialData, onNext, errors, setErrors, }) => {
88
77
  const validateField = (field, value) => {
89
78
  switch (field) {
90
79
  case 'sellerName':
91
- if (!value?.trim())
80
+ if (!(value === null || value === void 0 ? void 0 : value.trim()))
92
81
  return 'Seller name is required';
93
82
  if (value.length < 2)
94
83
  return 'Name must be at least 2 characters';
@@ -96,7 +85,7 @@ const BasicDetailsForm = ({ initialData, onNext, errors, setErrors, }) => {
96
85
  return 'Name must be less than 50 characters';
97
86
  return undefined;
98
87
  case 'sellerEmail':
99
- if (!value?.trim())
88
+ if (!(value === null || value === void 0 ? void 0 : value.trim()))
100
89
  return 'Email is required';
101
90
  const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
102
91
  if (!emailRegex.test(value))
@@ -108,7 +97,7 @@ const BasicDetailsForm = ({ initialData, onNext, errors, setErrors, }) => {
108
97
  }
109
98
  return undefined;
110
99
  case 'businessName':
111
- if (formData.businessType === 'company' && !value?.trim()) {
100
+ if (formData.businessType === 'company' && !(value === null || value === void 0 ? void 0 : value.trim())) {
112
101
  return 'Business name is required for companies';
113
102
  }
114
103
  return undefined;
@@ -117,10 +106,10 @@ const BasicDetailsForm = ({ initialData, onNext, errors, setErrors, }) => {
117
106
  }
118
107
  };
119
108
  const handleChange = (field, value) => {
120
- setFormData(prev => ({ ...prev, [field]: value }));
109
+ setFormData(prev => (Object.assign(Object.assign({}, prev), { [field]: value })));
121
110
  // Validate on change
122
111
  const error = validateField(field, value);
123
- const newErrors = { ...localErrors };
112
+ const newErrors = Object.assign({}, localErrors);
124
113
  if (error) {
125
114
  newErrors[field] = error;
126
115
  }
@@ -132,9 +121,9 @@ const BasicDetailsForm = ({ initialData, onNext, errors, setErrors, }) => {
132
121
  };
133
122
  const handleBlur = (field) => {
134
123
  setFocusedField(null);
135
- setTouched(prev => ({ ...prev, [field]: true }));
124
+ setTouched(prev => (Object.assign(Object.assign({}, prev), { [field]: true })));
136
125
  const error = validateField(field, formData[field]);
137
- const newErrors = { ...localErrors };
126
+ const newErrors = Object.assign({}, localErrors);
138
127
  if (error) {
139
128
  newErrors[field] = error;
140
129
  }
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { Seller, Mode, KYCStatus } from '../../types/sellertypes';
3
+ interface KYCVerificationProps {
4
+ initialData: Partial<Seller>;
5
+ mode: Mode;
6
+ kycStatus: KYCStatus;
7
+ onNext: (data: Partial<Seller>) => void;
8
+ onBack: () => void;
9
+ }
10
+ declare const KYCVerification: React.FC<KYCVerificationProps>;
11
+ export default KYCVerification;
@@ -33,6 +33,15 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  return result;
34
34
  };
35
35
  })();
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
36
45
  var __importDefault = (this && this.__importDefault) || function (mod) {
37
46
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
47
  };
@@ -53,16 +62,16 @@ const REQUIRED_DOCUMENTS = [
53
62
  const KYCVerification = ({ initialData, mode, kycStatus, onNext, onBack, }) => {
54
63
  const [documents, setDocuments] = (0, react_1.useState)(initialData.kycDocuments || {});
55
64
  const [uploadingFor, setUploadingFor] = (0, react_1.useState)(null);
56
- const handleDocumentUpload = async (documentKey, file) => {
65
+ const handleDocumentUpload = (documentKey, file) => __awaiter(void 0, void 0, void 0, function* () {
57
66
  setUploadingFor(documentKey);
58
67
  setTimeout(() => {
59
- setDocuments(prev => ({ ...prev, [documentKey]: file.uri || 'uploaded_file.jpg' }));
68
+ setDocuments(prev => (Object.assign(Object.assign({}, prev), { [documentKey]: file.uri || 'uploaded_file.jpg' })));
60
69
  setUploadingFor(null);
61
70
  if (mode === 'test') {
62
71
  react_native_1.Alert.alert('Test Mode', 'Document would be auto-approved in test mode');
63
72
  }
64
73
  }, 1000);
65
- };
74
+ });
66
75
  const handleDocumentRemove = (documentKey) => {
67
76
  react_native_1.Alert.alert('Remove Document', 'Are you sure you want to remove this document?', [
68
77
  { text: 'Cancel', style: 'cancel' },
@@ -70,7 +79,7 @@ const KYCVerification = ({ initialData, mode, kycStatus, onNext, onBack, }) => {
70
79
  text: 'Remove',
71
80
  style: 'destructive',
72
81
  onPress: () => {
73
- const updated = { ...documents };
82
+ const updated = Object.assign({}, documents);
74
83
  delete updated[documentKey];
75
84
  setDocuments(updated);
76
85
  },
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { Seller, Mode, KYCStatus, SellerStatus } from '../../types/sellertypes';
3
+ interface OnboardingCompleteProps {
4
+ sellerData: Seller;
5
+ mode: Mode;
6
+ status: SellerStatus;
7
+ kycStatus: KYCStatus;
8
+ isBankDetailsCompleted: boolean;
9
+ isKycCompleted: boolean;
10
+ isBasicCompleted: boolean;
11
+ onComplete: () => void;
12
+ isWaitingForBackend: boolean;
13
+ onBackendConfirmed: () => void;
14
+ }
15
+ declare const OnboardingComplete: React.FC<OnboardingCompleteProps>;
16
+ export default OnboardingComplete;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { ViewStyle } from 'react-native';
3
+ interface ButtonType {
4
+ value: string;
5
+ label: string;
6
+ showSelectedCheck?: boolean;
7
+ }
8
+ interface CustomSegmentedButtonsProps {
9
+ value: string;
10
+ onValueChange: (value: string) => void;
11
+ buttons: ButtonType[];
12
+ style?: ViewStyle;
13
+ }
14
+ declare const CustomSegmentedButtons: React.FC<CustomSegmentedButtonsProps>;
15
+ export default CustomSegmentedButtons;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { SellerOnboardingProps } from '../../../types/sellertypes';
3
+ declare const SellerOnboardingSheet: React.FC<SellerOnboardingProps>;
4
+ export default SellerOnboardingSheet;
@@ -72,8 +72,8 @@ const SellerOnboardingSheet = ({ sellerId, mode, isKycCompleted, isBankDetailsCo
72
72
  'Fix this undefined provider immediately.');
73
73
  }
74
74
  // Access config safely
75
- const baseUrl = airXPay?.baseUrl;
76
- const publicKey = airXPay?.publicKey;
75
+ const baseUrl = airXPay === null || airXPay === void 0 ? void 0 : airXPay.baseUrl;
76
+ const publicKey = airXPay === null || airXPay === void 0 ? void 0 : airXPay.publicKey;
77
77
  // Properly use variables so TS doesn't complain
78
78
  (0, react_1.useEffect)(() => {
79
79
  if (!baseUrl || !publicKey) {
@@ -90,14 +90,11 @@ const SellerOnboardingSheet = ({ sellerId, mode, isKycCompleted, isBankDetailsCo
90
90
  const scaleAnim = (0, react_1.useRef)(new react_native_1.Animated.Value(1)).current;
91
91
  // State management
92
92
  const [currentStep, setCurrentStep] = (0, react_1.useState)(initialStep);
93
- const [sellerData, setSellerData] = (0, react_1.useState)({
94
- mode,
93
+ const [sellerData, setSellerData] = (0, react_1.useState)(Object.assign({ mode,
95
94
  kycStatus,
96
95
  isKycCompleted,
97
96
  isBankDetailsCompleted,
98
- status,
99
- ...initialData,
100
- });
97
+ status }, initialData));
101
98
  const [errors, setErrors] = (0, react_1.useState)({});
102
99
  const [showError, setShowError] = (0, react_1.useState)(false);
103
100
  const [isAnimating, setIsAnimating] = (0, react_1.useState)(false);
@@ -154,20 +151,17 @@ const SellerOnboardingSheet = ({ sellerId, mode, isKycCompleted, isBankDetailsCo
154
151
  });
155
152
  };
156
153
  const handleNext = (stepData) => {
157
- const updatedData = { ...sellerData, ...stepData };
154
+ const updatedData = Object.assign(Object.assign({}, sellerData), stepData);
158
155
  setSellerData(updatedData);
159
156
  // Update step completion status
160
157
  if (currentStep === 1) {
161
- setStepCompletion(prev => ({
162
- ...prev,
163
- basic: !!(updatedData.sellerName && updatedData.sellerEmail)
164
- }));
158
+ setStepCompletion(prev => (Object.assign(Object.assign({}, prev), { basic: !!(updatedData.sellerName && updatedData.sellerEmail) })));
165
159
  }
166
160
  else if (currentStep === 2) {
167
- setStepCompletion(prev => ({ ...prev, kyc: true }));
161
+ setStepCompletion(prev => (Object.assign(Object.assign({}, prev), { kyc: true })));
168
162
  }
169
163
  else if (currentStep === 3) {
170
- setStepCompletion(prev => ({ ...prev, bank: true }));
164
+ setStepCompletion(prev => (Object.assign(Object.assign({}, prev), { bank: true })));
171
165
  }
172
166
  // Call onNext callback with step data and current step
173
167
  onNext(stepData, currentStep);
@@ -238,14 +232,7 @@ const SellerOnboardingSheet = ({ sellerId, mode, isKycCompleted, isBankDetailsCo
238
232
  }),
239
233
  ]).start();
240
234
  // Prepare complete seller data
241
- const completeSellerData = {
242
- ...sellerData,
243
- mode,
244
- kycStatus: stepCompletion.kyc ? 'verified' : kycStatus,
245
- isKycCompleted: stepCompletion.kyc,
246
- isBankDetailsCompleted: stepCompletion.bank,
247
- status: status || (mode === 'live' && stepCompletion.kyc && stepCompletion.bank ? 'active' : 'pending'),
248
- };
235
+ const completeSellerData = Object.assign(Object.assign({}, sellerData), { mode, kycStatus: stepCompletion.kyc ? 'verified' : kycStatus, isKycCompleted: stepCompletion.kyc, isBankDetailsCompleted: stepCompletion.bank, status: status || (mode === 'live' && stepCompletion.kyc && stepCompletion.bank ? 'active' : 'pending') });
249
236
  // Call onComplete with seller data
250
237
  // The developer's backend will handle actual seller creation
251
238
  // and should call a callback or update state when complete
@@ -258,7 +245,7 @@ const SellerOnboardingSheet = ({ sellerId, mode, isKycCompleted, isBankDetailsCo
258
245
  }, []);
259
246
  const getStepTitle = () => {
260
247
  const step = STEPS.find(s => s.id === currentStep);
261
- return step?.name || '';
248
+ return (step === null || step === void 0 ? void 0 : step.name) || '';
262
249
  };
263
250
  const renderStep = () => {
264
251
  const isLoading = externalLoading || isSubmitting;
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import { AirXPayConfig } from "../types/type";
3
+ interface AirXPayProviderProps {
4
+ config: AirXPayConfig;
5
+ children: React.ReactNode;
6
+ enableLogging?: boolean;
7
+ }
8
+ export declare const AirXPayProvider: React.FC<AirXPayProviderProps>;
9
+ export declare const useAirXPay: () => AirXPayConfig;
10
+ export declare const useAirXPaySafe: () => AirXPayConfig | null;
11
+ export declare const useAirXPayConfig: <K extends keyof AirXPayConfig>(key: K) => AirXPayConfig[K] | undefined;
12
+ export declare const useProviderReady: () => boolean;
13
+ export declare const AirXPayConsumer: React.Consumer<AirXPayConfig | null>;
14
+ export default AirXPayProvider;
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.AirXPayConsumer = exports.useIsAirXPayReady = exports.useAirXPayConfig = exports.useAirXPaySafe = exports.useAirXPay = exports.AirXPayProvider = void 0;
36
+ exports.AirXPayConsumer = exports.useProviderReady = exports.useAirXPayConfig = exports.useAirXPaySafe = exports.useAirXPay = exports.AirXPayProvider = void 0;
37
37
  const react_1 = __importStar(require("react"));
38
38
  // Context with professional error handling
39
39
  const AirXPayContext = (0, react_1.createContext)(null);
@@ -50,7 +50,7 @@ const AirXPayProvider = ({ config, children, enableLogging = __DEV__, }) => {
50
50
  try {
51
51
  new URL(config.baseUrl);
52
52
  }
53
- catch {
53
+ catch (_a) {
54
54
  validationErrors.push("baseUrl must be a valid URL (e.g., https://api.airxpay.com)");
55
55
  }
56
56
  }
@@ -93,6 +93,7 @@ exports.AirXPayProvider = AirXPayProvider;
93
93
  exports.AirXPayProvider.displayName = "AirXPayProvider";
94
94
  // Professional hook with clear error messages
95
95
  const useAirXPay = () => {
96
+ var _a, _b;
96
97
  const context = (0, react_1.useContext)(AirXPayContext);
97
98
  if (!context) {
98
99
  const errorMessage = [
@@ -116,7 +117,7 @@ const useAirXPay = () => {
116
117
  " </AirXPayProvider>",
117
118
  "",
118
119
  " • Verify the provider is not inside a conditional or loop",
119
- ` • Component location: ${new Error().stack?.split("\n")[2]?.trim() || "unknown"}`,
120
+ ` • Component location: ${((_b = (_a = new Error().stack) === null || _a === void 0 ? void 0 : _a.split("\n")[2]) === null || _b === void 0 ? void 0 : _b.trim()) || "unknown"}`,
120
121
  ].join("\n");
121
122
  // Log with styling in development
122
123
  if (__DEV__) {
@@ -132,7 +133,7 @@ const useAirXPaySafe = () => {
132
133
  try {
133
134
  return (0, exports.useAirXPay)();
134
135
  }
135
- catch {
136
+ catch (_a) {
136
137
  return null;
137
138
  }
138
139
  };
@@ -140,15 +141,15 @@ exports.useAirXPaySafe = useAirXPaySafe;
140
141
  // Helper: Access specific config value
141
142
  const useAirXPayConfig = (key) => {
142
143
  const config = (0, exports.useAirXPaySafe)();
143
- return config?.[key];
144
+ return config === null || config === void 0 ? void 0 : config[key];
144
145
  };
145
146
  exports.useAirXPayConfig = useAirXPayConfig;
146
147
  // Helper: Check if provider is properly configured
147
- const useIsAirXPayReady = () => {
148
+ const useProviderReady = () => {
148
149
  const config = (0, exports.useAirXPaySafe)();
149
- return !!(config?.baseUrl && config?.publicKey);
150
+ return !!((config === null || config === void 0 ? void 0 : config.baseUrl) && (config === null || config === void 0 ? void 0 : config.publicKey));
150
151
  };
151
- exports.useIsAirXPayReady = useIsAirXPayReady;
152
+ exports.useProviderReady = useProviderReady;
152
153
  // Export context consumer for advanced use cases
153
154
  exports.AirXPayConsumer = AirXPayContext.Consumer;
154
155
  exports.default = exports.AirXPayProvider;
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ declare const useAirXPaySheet: (props: any) => React.JSX.Element;
3
+ export default useAirXPaySheet;
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const react_1 = __importDefault(require("react"));
7
7
  const SellerOnboarding_1 = __importDefault(require("../components/ui/SellerOnboard/SellerOnboarding"));
8
- const SellerOnboarding = (props) => {
8
+ const useAirXPaySheet = (props) => {
9
9
  return <SellerOnboarding_1.default {...props}/>;
10
10
  };
11
- exports.default = SellerOnboarding;
11
+ exports.default = useAirXPaySheet;
@@ -0,0 +1,4 @@
1
+ export { useIsAirXPayReady } from "./sdk/airxpay";
2
+ export { AirXPayProvider, useProviderReady, useAirXPayConfig, useAirXPaySafe, useAirXPay } from "./contexts/AirXPayProvider";
3
+ export { default as useAirXPaySheet } from "./hooks/SellerOnboarding";
4
+ export { __DEV__ } from './types/dev';
package/dist/index.js CHANGED
@@ -3,10 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SellerOnboarding = exports.AirXPayProvider = exports.AirXPay = void 0;
6
+ exports.__DEV__ = exports.useAirXPaySheet = exports.useAirXPay = exports.useAirXPaySafe = exports.useAirXPayConfig = exports.useProviderReady = exports.AirXPayProvider = exports.useIsAirXPayReady = void 0;
7
7
  var airxpay_1 = require("./sdk/airxpay");
8
- Object.defineProperty(exports, "AirXPay", { enumerable: true, get: function () { return airxpay_1.AirXPay; } });
8
+ Object.defineProperty(exports, "useIsAirXPayReady", { enumerable: true, get: function () { return airxpay_1.useIsAirXPayReady; } });
9
9
  var AirXPayProvider_1 = require("./contexts/AirXPayProvider");
10
10
  Object.defineProperty(exports, "AirXPayProvider", { enumerable: true, get: function () { return AirXPayProvider_1.AirXPayProvider; } });
11
+ Object.defineProperty(exports, "useProviderReady", { enumerable: true, get: function () { return AirXPayProvider_1.useProviderReady; } });
12
+ Object.defineProperty(exports, "useAirXPayConfig", { enumerable: true, get: function () { return AirXPayProvider_1.useAirXPayConfig; } });
13
+ Object.defineProperty(exports, "useAirXPaySafe", { enumerable: true, get: function () { return AirXPayProvider_1.useAirXPaySafe; } });
14
+ Object.defineProperty(exports, "useAirXPay", { enumerable: true, get: function () { return AirXPayProvider_1.useAirXPay; } });
11
15
  var SellerOnboarding_1 = require("./hooks/SellerOnboarding");
12
- Object.defineProperty(exports, "SellerOnboarding", { enumerable: true, get: function () { return __importDefault(SellerOnboarding_1).default; } });
16
+ Object.defineProperty(exports, "useAirXPaySheet", { enumerable: true, get: function () { return __importDefault(SellerOnboarding_1).default; } });
17
+ var dev_1 = require("./types/dev");
18
+ Object.defineProperty(exports, "__DEV__", { enumerable: true, get: function () { return dev_1.__DEV__; } });
@@ -0,0 +1,7 @@
1
+ import { AirXPayConfig } from '../types/type';
2
+ export declare class useIsAirXPayReady {
3
+ private baseUrl;
4
+ private publicKey;
5
+ constructor(config: AirXPayConfig);
6
+ initialize(): Promise<import("../api/seller").SellerInitResponse>;
7
+ }
@@ -1,8 +1,17 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AirXPay = void 0;
12
+ exports.useIsAirXPayReady = void 0;
4
13
  const seller_1 = require("../api/seller");
5
- class AirXPay {
14
+ class useIsAirXPayReady {
6
15
  constructor(config) {
7
16
  if (!config.baseUrl)
8
17
  throw new Error("Base URL is required");
@@ -11,8 +20,10 @@ class AirXPay {
11
20
  this.baseUrl = config.baseUrl;
12
21
  this.publicKey = config.publicKey;
13
22
  }
14
- async initialize() {
15
- return await (0, seller_1.verifyPublicKey)(this.baseUrl, this.publicKey);
23
+ initialize() {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ return yield (0, seller_1.verifyPublicKey)(this.baseUrl, this.publicKey);
26
+ });
16
27
  }
17
28
  }
18
- exports.AirXPay = AirXPay;
29
+ exports.useIsAirXPayReady = useIsAirXPayReady;
@@ -0,0 +1 @@
1
+ export declare const __DEV__: boolean;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.__DEV__ = void 0;
4
+ // dev.ts
5
+ exports.__DEV__ = process.env.NODE_ENV !== 'production';
@@ -0,0 +1,2 @@
1
+ // dev.ts
2
+ export const __DEV__ = process.env.NODE_ENV !== 'production';