@airxpay/sdk-ui 1.0.1 → 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.
package/README.md CHANGED
@@ -211,7 +211,7 @@ export default MySellerOnboarding;
211
211
  import {
212
212
  useAirXPay, // Access config (throws if no provider)
213
213
  useAirXPaySafe, // Safe access (returns null if no provider)
214
- useIsAirXPayReady, // Hook: checks if provider is ready
214
+ useProviderReady, // Hook: checks if provider is ready
215
215
  useAirXPayConfig, // Access specific config value
216
216
  AirXPayConsumer // Context consumer for advanced use
217
217
  } from '@airxpay/sdk-ui';
@@ -219,7 +219,7 @@ import {
219
219
  // Example usage
220
220
  const { baseUrl, publicKey } = useAirXPay();
221
221
  const config = useAirXPaySafe();
222
- const isReady = useIsAirXPayReady();
222
+ const isReady = useProviderReady();
223
223
  const baseUrl = useAirXPayConfig('baseUrl');
224
224
  ```
225
225
 
@@ -333,7 +333,7 @@ Step 4: Completion
333
333
  ```tsx
334
334
  // Main exports from index.ts
335
335
  export { useIsAirXPayReady } from "./sdk/airxpay"; // Class for async init
336
- export { AirXPayProvider } from "./contexts/AirXPayProvider";
336
+ export { AirXPayProvider, useProviderReady, useAirXPayConfig, useAirXPaySafe, useAirXPay } from "./contexts/AirXPayProvider";
337
337
  export { default as useAirXPaySheet } from "./hooks/SellerOnboarding";
338
338
  export { __DEV__ } from './types/dev';
339
339
 
@@ -391,6 +391,126 @@ The `__DEV__` flag helps you conditionally run code only in development environm
391
391
  | Images not uploading | Check Expo ImagePicker permissions |
392
392
  | TypeScript errors | Update to latest version |
393
393
 
394
+ ---
395
+
396
+ # 🎣 Available Hooks
397
+
398
+ The **@airxpay/sdk-ui** package provides several utility hooks for accessing configuration, managing initialization state, **and safely interacting with the AirXPayProvider.**
399
+
400
+ ```
401
+ import {
402
+ useAirXPay,
403
+ useAirXPaySafe,
404
+ useProviderReady,
405
+ useAirXPayConfig
406
+ } from '@airxpay/sdk-ui';
407
+
408
+ 1️⃣ useAirXPay()
409
+ const { baseUrl, publicKey } = useAirXPay();
410
+ ```
411
+
412
+ **Provides direct access to the full AirXPay configuration.**
413
+
414
+ **Behavior**
415
+
416
+ Must be used inside AirXPayProvider.
417
+
418
+ Throws an error if the provider is not found.
419
+
420
+ Ensures strict enforcement of provider usage.
421
+
422
+ When to Use
423
+
424
+ Use this hook when you require guaranteed access to configuration values such as baseUrl or publicKey for:
425
+
426
+ API requests
427
+
428
+ Dynamic endpoint handling
429
+
430
+ **Advanced integrations**
431
+
432
+ # Recommended for: Production components where the provider is always present.
433
+
434
+ ```
435
+ 2️⃣ useAirXPaySafe()
436
+ const safeConfig = useAirXPaySafe();
437
+ ```
438
+
439
+ A safe alternative to ```useAirXPay().```
440
+
441
+ Behavior
442
+
443
+ Returns null if the provider is not available.
444
+
445
+ Does not throw an error.
446
+
447
+ When to Use
448
+
449
+ Component testing in isolation
450
+
451
+ Optional integrations
452
+
453
+ Shared UI components that may or may not be wrapped in the provider
454
+
455
+ Recommended for: Flexible usage scenarios where provider presence is not guaranteed.
456
+
457
+ ```
458
+ 3️⃣ useProviderReady()
459
+ const isReady = useProviderReady();
460
+ ```
461
+
462
+ Checks whether the SDK has been fully initialized.
463
+
464
+ Behavior
465
+
466
+ Returns a boolean indicating initialization state.
467
+
468
+ Useful for asynchronous setup workflows.
469
+
470
+ When to Use
471
+
472
+ Conditional rendering
473
+
474
+ Showing loaders before initialization
475
+
476
+ Delaying onboarding UI until SDK is ready
477
+
478
+ Recommended for: Applications using async initialization or class-based setup.
479
+
480
+ ```
481
+ 4️⃣ useAirXPayConfig(key)
482
+ const apiUrl = useAirXPayConfig('baseUrl');
483
+ ```
484
+
485
+ Retrieves a specific configuration value from the provider.
486
+
487
+ Behavior
488
+
489
+ Accepts a configuration key ```(e.g., 'baseUrl', 'publicKey').```
490
+
491
+ Returns only the requested value.
492
+
493
+ When to Use
494
+
495
+ Accessing a single configuration property
496
+
497
+ Avoiding full object destructuring
498
+
499
+ Cleaner and more focused component logic
500
+
501
+ Recommended for: Minimal, targeted configuration access.
502
+
503
+ ```📌 Hook Comparison```
504
+ **Hook Throws Error Safe Fallback Primary Purpose**
505
+
506
+ ```
507
+ useAirXPay ✅ Yes ❌ No Direct access to full configuration
508
+ useAirXPaySafe ❌ No ✅ Yes Optional/safe configuration access
509
+ useProviderReady ❌ No ✅ Yes Initialization state check
510
+ useAirXPayConfig ❌ No ✅ Yes Access a single configuration value
511
+ ```
512
+
513
+
394
514
  ---
395
515
 
396
516
  ## 📝 Changelog
@@ -9,6 +9,6 @@ export declare const AirXPayProvider: React.FC<AirXPayProviderProps>;
9
9
  export declare const useAirXPay: () => AirXPayConfig;
10
10
  export declare const useAirXPaySafe: () => AirXPayConfig | null;
11
11
  export declare const useAirXPayConfig: <K extends keyof AirXPayConfig>(key: K) => AirXPayConfig[K] | undefined;
12
- export declare const useIsAirXPayReady: () => boolean;
12
+ export declare const useProviderReady: () => boolean;
13
13
  export declare const AirXPayConsumer: React.Consumer<AirXPayConfig | null>;
14
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);
@@ -145,11 +145,11 @@ const useAirXPayConfig = (key) => {
145
145
  };
146
146
  exports.useAirXPayConfig = useAirXPayConfig;
147
147
  // Helper: Check if provider is properly configured
148
- const useIsAirXPayReady = () => {
148
+ const useProviderReady = () => {
149
149
  const config = (0, exports.useAirXPaySafe)();
150
150
  return !!((config === null || config === void 0 ? void 0 : config.baseUrl) && (config === null || config === void 0 ? void 0 : config.publicKey));
151
151
  };
152
- exports.useIsAirXPayReady = useIsAirXPayReady;
152
+ exports.useProviderReady = useProviderReady;
153
153
  // Export context consumer for advanced use cases
154
154
  exports.AirXPayConsumer = AirXPayContext.Consumer;
155
155
  exports.default = exports.AirXPayProvider;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { useIsAirXPayReady } from "./sdk/airxpay";
2
- export { AirXPayProvider } from "./contexts/AirXPayProvider";
2
+ export { AirXPayProvider, useProviderReady, useAirXPayConfig, useAirXPaySafe, useAirXPay } from "./contexts/AirXPayProvider";
3
3
  export { default as useAirXPaySheet } from "./hooks/SellerOnboarding";
4
4
  export { __DEV__ } from './types/dev';
package/dist/index.js CHANGED
@@ -3,11 +3,15 @@ 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.__DEV__ = exports.useAirXPaySheet = exports.AirXPayProvider = exports.useIsAirXPayReady = 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
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
16
  Object.defineProperty(exports, "useAirXPaySheet", { enumerable: true, get: function () { return __importDefault(SellerOnboarding_1).default; } });
13
17
  var dev_1 = require("./types/dev");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@airxpay/sdk-ui",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "AirXPay Initialization UI Components for React & React Native",
5
5
  "author": "Tafseel Khan",
6
6
  "license": "MIT",