esewa-ui-library 1.0.4 → 1.0.5

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
@@ -1310,9 +1310,10 @@ The `ESewaRadio` component accepts the following props:
1310
1310
  | `label` | `string` | No | `undefined` | The label displayed next to the radio button. |
1311
1311
  | `name` | `string` | Yes | N/A | The name of the radio button, which groups it together with other radio buttons. |
1312
1312
  | `onChange` | `(checked: boolean) => void` | No | `undefined` | Callback function that is triggered when the radio button's checked state changes. |
1313
- | `checked` | `boolean` | No | `undefined` | Determines whether the radio button is selected (`true`) or not (`false`). |
1313
+ | `checked` | `boolean` | Yes | false | Determines whether the radio button is selected (`true`) or not (`false`). |
1314
1314
  | `labelClass`| `string` | No | `''` | A custom class applied to the label element for styling. |
1315
1315
  | `className` | `string` | No | `''` | A custom class applied to the root wrapper element of the radio button component. |
1316
+ | `disabled` | `boolean` | No | false | Used to disable radio state |
1316
1317
 
1317
1318
  # ESewaSanitizeHtml Component
1318
1319
 
@@ -1619,6 +1620,7 @@ This library provides a set of services that allow interaction between the merch
1619
1620
  - [User Detail Request](#user-detail-request)
1620
1621
  - [Media Access Request](#media-access-request)
1621
1622
  - [Validate Payment](#validate-payment)
1623
+ - [Request Payment](#request-payment)
1622
1624
  - [Error Handling](#error-handling)
1623
1625
 
1624
1626
  ## Initialization
@@ -1808,6 +1810,59 @@ const onValidateTransactionClick = () => {
1808
1810
  requestFromMiniApp(obj, CALLBACK_TYPE_ENUM.VALIDATE_TRANSACTION_CALLBACK, validateTransactionCallBack);
1809
1811
  };
1810
1812
  ```
1813
+ #### Request Payment
1814
+ Pass token received from initialize request call with respective request type, callback key , your merchant identifier and request payload
1815
+
1816
+ ```tsx
1817
+ const onRequestPaymentClick = () => {
1818
+ const productPayload = {
1819
+ "product_code": "NP-ES-VIANET",
1820
+ "amount": 28.48,
1821
+ "properties": {
1822
+ "productId": "3299",
1823
+ "payment_id": "1613103_PP",
1824
+ "refId": "400005",
1825
+ "customer_id": "48707",
1826
+ "payer": "CUSTOMER"
1827
+ },
1828
+ "channel": "WEB_USER"
1829
+ };
1830
+
1831
+ const obj = {
1832
+ requestType: REQUEST_TYPE_ENUM.REQUEST_PAYMENT,
1833
+ merchant_identifier: 'IAAAAABTOBAbFhAXHhEHAgoXX0FRR1FJJiw3LCwkJzE=',
1834
+ token: sessionStorage.getItem('miniAppAuthToken'),
1835
+ data: productPayload,
1836
+ callbackKey: "REQUEST_PAYMENT_CALLBACK"
1837
+ };
1838
+
1839
+ const requestPaymentCallBack: any = (data:any) => {
1840
+ console.log("Make payment Response:", data);
1841
+
1842
+ try {
1843
+ if (!data) {
1844
+ throw new Error('Received null or undefined response');
1845
+ }
1846
+ const res = JSON.parse(data);
1847
+
1848
+ if (!res || typeof res !== 'object') {
1849
+ throw new Error('Parsed response is not a valid object');
1850
+ }
1851
+
1852
+ if (res?.error_message) {
1853
+ throw new Error('Error res', res.error_message);
1854
+ }
1855
+
1856
+ setMakePaymentRes(res);
1857
+ } catch (error) {
1858
+ console.error('Error parsing response:', error);
1859
+ }
1860
+ };
1861
+
1862
+ requestFromMiniApp(obj, CALLBACK_TYPE_ENUM.REQUEST_PAYMENT_CALLBACK, requestPaymentCallBack);
1863
+ };
1864
+ ```
1865
+
1811
1866
  ## Error Handling
1812
1867
 
1813
1868
  Errors are returned as JSON responses with an `error_message` field.
@@ -1,12 +1,14 @@
1
1
  import React from 'react';
2
2
  declare type RadioProps = {
3
- key: any;
3
+ key?: any;
4
4
  label?: string;
5
+ value?: any;
5
6
  name: string;
6
- onChange?: (checked: any) => void;
7
- checked?: boolean;
7
+ onChange?: (value: any, checked: boolean) => void;
8
+ checked: boolean;
8
9
  labelClass?: string;
9
10
  className?: string;
11
+ disabled?: boolean;
10
12
  };
11
13
  export declare const ESewaRadio: React.FC<RadioProps>;
12
14
  export default ESewaRadio;
package/dist/index.js CHANGED
@@ -7083,18 +7083,22 @@ var EsewaFullPageLoadingScreen = function EsewaFullPageLoadingScreen(_ref) {
7083
7083
  };
7084
7084
 
7085
7085
  var _templateObject$l;
7086
- var StyledRadio = styled__default.div(_templateObject$l || (_templateObject$l = _taggedTemplateLiteralLoose(["\n .container{\n display:flex;\n align-items: center;\n gap: 8px;\n }\n\n .container input[type=\"radio\" i] {\n margin: 0;\n appearance: none;\n width: 16px;\n height: 16px;\n border: 2px solid var(--secondary);\n border-radius: 50%;\n position: relative;\n cursor: pointer;\n transition: border-color 0.3s ease;\n }\n\n .container input[type=\"radio\"]:checked {\n border-color: var(--primary);\n }\n\n .container input[type=\"radio\"]::before {\n content: '';\n width: 10px;\n height: 10px;\n background-color: transparent;\n border-radius: 50%;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n transition: background-color 0.3s ease;\n }\n\n .container input[type=\"radio\"]:checked::before {\n background-color: var(--primary);\n }\n"])));
7086
+ var StyledRadio = styled__default.div(_templateObject$l || (_templateObject$l = _taggedTemplateLiteralLoose(["\n .container{\n display:flex;\n align-items: center;\n gap: 8px;\n }\n\n .container input[type=\"radio\" i] {\n margin: 0;\n appearance: none;\n width: 16px;\n height: 16px;\n border: 2px solid var(--secondary);\n border-radius: 50%;\n position: relative;\n cursor: pointer;\n transition: border-color 0.3s ease;\n }\n\n .container input[type=\"radio\"]:checked {\n border-color: var(--primary);\n }\n\n .container input[type=\"radio\"]::before {\n content: '';\n width: 10px;\n height: 10px;\n background-color: transparent;\n border-radius: 50%;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n transition: background-color 0.3s ease;\n }\n\n .container input[type=\"radio\"]:checked::before {\n background-color: var(--primary);\n }\n\n .container input[type=\"radio\"]:disabled {\n cursor: not-allowed;\n opacity: 0.5;\n }\n"])));
7087
7087
  var ESewaRadio = function ESewaRadio(_ref) {
7088
7088
  var label = _ref.label,
7089
+ value = _ref.value,
7089
7090
  name = _ref.name,
7090
7091
  className = _ref.className,
7091
7092
  _ref$labelClass = _ref.labelClass,
7092
7093
  labelClass = _ref$labelClass === void 0 ? '' : _ref$labelClass,
7093
7094
  onChange = _ref.onChange,
7094
- checked = _ref.checked;
7095
+ _ref$checked = _ref.checked,
7096
+ checked = _ref$checked === void 0 ? false : _ref$checked,
7097
+ _ref$disabled = _ref.disabled,
7098
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled;
7095
7099
  var handleRadioChange = function handleRadioChange(e) {
7096
- if (onChange) {
7097
- onChange(e.target.checked);
7100
+ if (onChange && !disabled) {
7101
+ onChange(value, e.target.checked);
7098
7102
  }
7099
7103
  };
7100
7104
  return React__default.createElement(StyledRadio, null, React__default.createElement("div", {
@@ -7104,8 +7108,10 @@ var ESewaRadio = function ESewaRadio(_ref) {
7104
7108
  }, React__default.createElement("input", {
7105
7109
  type: 'radio',
7106
7110
  name: name,
7111
+ value: value,
7107
7112
  checked: checked,
7108
- onChange: handleRadioChange
7113
+ onChange: handleRadioChange,
7114
+ disabled: disabled
7109
7115
  }), React__default.createElement("span", {
7110
7116
  className: "" + labelClass
7111
7117
  }, label))));
@@ -7691,9 +7697,9 @@ var CONNECT_APP = function CONNECT_APP(data) {
7691
7697
  };
7692
7698
  var requestFromMiniApp = function requestFromMiniApp(data, callbackKey, callback) {
7693
7699
  var _window$webkit2, _window$webkit2$messa;
7694
- if (window.Android && callbackKey in window.Android) {
7700
+ if (window.Android) {
7695
7701
  window.Android[callbackKey] = callback;
7696
- } else if ((_window$webkit2 = window.webkit) !== null && _window$webkit2 !== void 0 && (_window$webkit2$messa = _window$webkit2.messageHandlers) !== null && _window$webkit2$messa !== void 0 && _window$webkit2$messa.iOSNative && callbackKey in window.webkit.messageHandlers.iOSNative) {
7702
+ } else if ((_window$webkit2 = window.webkit) !== null && _window$webkit2 !== void 0 && (_window$webkit2$messa = _window$webkit2.messageHandlers) !== null && _window$webkit2$messa !== void 0 && _window$webkit2$messa.iOSNative) {
7697
7703
  window.webkit.messageHandlers.iOSNative[callbackKey] = callback;
7698
7704
  }
7699
7705
  CONNECT_APP(JSON.stringify(data));
@@ -7864,11 +7870,13 @@ var useDebounce = function useDebounce(value, delay) {
7864
7870
  };
7865
7871
 
7866
7872
  var loadGoogleFont = function loadGoogleFont() {
7867
- if (!document.querySelector("link[href*='Source+Sans+Pro']")) {
7868
- var link = document.createElement('link');
7869
- link.href = 'https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@300;400;600;700&display=swap';
7870
- link.rel = 'stylesheet';
7871
- document.head.appendChild(link);
7873
+ if (typeof window !== 'undefined' && document) {
7874
+ if (!document.querySelector("link[href*='Source+Sans+Pro']")) {
7875
+ var link = document.createElement('link');
7876
+ link.href = 'https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@300;400;600;700&display=swap';
7877
+ link.rel = 'stylesheet';
7878
+ document.head.appendChild(link);
7879
+ }
7872
7880
  }
7873
7881
  };
7874
7882
  loadGoogleFont();