@commercelayer/react-components 4.23.0 → 4.23.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.
@@ -1,5 +1,5 @@
1
- import type { GatewayBaseType } from '../payment_gateways/PaymentGateway';
2
- import { type JSX } from 'react';
1
+ import type { GatewayBaseType } from "../payment_gateways/PaymentGateway";
2
+ import { type JSX } from "react";
3
3
  type Props = GatewayBaseType;
4
4
  export declare function CheckoutComGateway(props: Props): JSX.Element | null;
5
5
  export default CheckoutComGateway;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CheckoutComGateway=CheckoutComGateway;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),CheckoutComPayment_1=tslib_1.__importDefault(require("../payment_source/CheckoutComPayment")),CustomerContext_1=tslib_1.__importDefault(require("../../context/CustomerContext")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),PaymentMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodChildrenContext")),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),PaymentSourceContext_1=tslib_1.__importDefault(require("../../context/PaymentSourceContext")),PaymentMethodReducer_1=require("../../reducers/PaymentMethodReducer"),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),react_1=tslib_1.__importDefault(require("react")),PaymentCardsTemplate_1=tslib_1.__importDefault(require("../utils/PaymentCardsTemplate")),getCardDetails_1=tslib_1.__importDefault(require("../../utils/getCardDetails"));function CheckoutComGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,loaderComponent,templateCustomerSaveToWallet}=props,p=tslib_1.__rest(props,["readonly","showCard","handleEditClick","children","templateCustomerCards","show","loading","loaderComponent","templateCustomerSaveToWallet"]),{order}=react_1.default.useContext(OrderContext_1.default),{payment}=react_1.default.useContext(PaymentMethodChildrenContext_1.default),{payments,isGuest}=react_1.default.useContext(CustomerContext_1.default),{currentPaymentMethodId,config,paymentSource}=react_1.default.useContext(PaymentMethodContext_1.default),paymentResource="checkout_com_payments",locale=order?.language_code;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const publicKey=paymentSource?.public_key,paymentConfig=config?(0,PaymentMethodReducer_1.getPaymentConfig)(paymentResource,config):{},customerPayments=!(0,isEmpty_1.default)(payments)&&payments?payments.filter(customerPayment=>{var _a;return((_a=customerPayment.payment_source)===null||_a===void 0?void 0:_a.type)===paymentResource}):[];if(readonly||showCard){const card=(0,getCardDetails_1.default)({customerPayment:{payment_source:paymentSource},paymentType:paymentResource}),value=Object.assign(Object.assign({},card),{showCard,handleEditClick,readonly});return card.brand?(0,jsx_runtime_1.jsx)(PaymentSourceContext_1.default.Provider,{value,children}):null}return!isGuest&&templateCustomerCards?(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,isEmpty_1.default)(customerPayments)?null:(0,jsx_runtime_1.jsx)("div",{className:p.className,children:(0,jsx_runtime_1.jsx)(PaymentCardsTemplate_1.default,{paymentResource,customerPayments,children:templateCustomerCards})}),(0,jsx_runtime_1.jsx)(CheckoutComPayment_1.default,Object.assign({show,templateCustomerSaveToWallet,publicKey,locale},paymentConfig))]}):(0,jsx_runtime_1.jsx)(CheckoutComPayment_1.default,Object.assign({show,publicKey,locale},paymentConfig))}exports.default=CheckoutComGateway;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CheckoutComGateway=CheckoutComGateway;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),CheckoutComPayment_1=tslib_1.__importDefault(require("../payment_source/CheckoutComPayment")),CustomerContext_1=tslib_1.__importDefault(require("../../context/CustomerContext")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),PaymentMethodChildrenContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodChildrenContext")),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),PaymentSourceContext_1=tslib_1.__importDefault(require("../../context/PaymentSourceContext")),PaymentMethodReducer_1=require("../../reducers/PaymentMethodReducer"),isEmpty_1=tslib_1.__importDefault(require("lodash/isEmpty")),react_1=tslib_1.__importDefault(require("react")),PaymentCardsTemplate_1=tslib_1.__importDefault(require("../utils/PaymentCardsTemplate")),getCardDetails_1=tslib_1.__importDefault(require("../../utils/getCardDetails"));function CheckoutComGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,loaderComponent,templateCustomerSaveToWallet}=props,p=tslib_1.__rest(props,["readonly","showCard","handleEditClick","children","templateCustomerCards","show","loading","loaderComponent","templateCustomerSaveToWallet"]),{order}=react_1.default.useContext(OrderContext_1.default),{payment}=react_1.default.useContext(PaymentMethodChildrenContext_1.default),{payments,isGuest}=react_1.default.useContext(CustomerContext_1.default),{currentPaymentMethodId,config,paymentSource}=react_1.default.useContext(PaymentMethodContext_1.default),paymentResource="checkout_com_payments",locale=order?.language_code;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const publicKey=paymentSource?.public_key,paymentConfig=config?(0,PaymentMethodReducer_1.getPaymentConfig)(paymentResource,config):{},customerPayments=!(0,isEmpty_1.default)(payments)&&payments?payments.filter(customerPayment=>{var _a;return((_a=customerPayment.payment_source)===null||_a===void 0?void 0:_a.type)===paymentResource}):[];if(readonly||showCard){const card=(0,getCardDetails_1.default)({customerPayment:{payment_source:paymentSource},paymentType:paymentResource}),value=Object.assign(Object.assign({},card),{showCard,handleEditClick,readonly});return card.brand?(0,jsx_runtime_1.jsx)(PaymentSourceContext_1.default.Provider,{value,children}):null}return!isGuest&&templateCustomerCards?(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,isEmpty_1.default)(customerPayments)?null:(0,jsx_runtime_1.jsx)("div",{className:p.className,children:(0,jsx_runtime_1.jsx)(PaymentCardsTemplate_1.default,{paymentResource,customerPayments,children:templateCustomerCards})}),(0,jsx_runtime_1.jsx)(CheckoutComPayment_1.default,Object.assign({show,templateCustomerSaveToWallet,publicKey,locale},paymentConfig.checkoutComPayment))]}):(0,jsx_runtime_1.jsx)(CheckoutComPayment_1.default,Object.assign({show,publicKey,locale},paymentConfig))}exports.default=CheckoutComGateway;
@@ -1,48 +1,32 @@
1
1
  import { type JSX } from "react";
2
2
  import type { PaymentMethodConfig } from "../../reducers/PaymentMethodReducer";
3
3
  import type { PaymentSourceProps } from "./PaymentSource";
4
+ interface ElementAppearance {
5
+ fontFamily?: string;
6
+ fontSize?: string;
7
+ fontWeight?: number;
8
+ letterSpacing?: number;
9
+ lineHeight?: string;
10
+ }
4
11
  interface Appearance {
5
- colorAction: string;
6
- colorBackground: string;
7
- colorBorder: string;
8
- colorDisabled: string;
9
- colorError: string;
10
- colorFormBackground: string;
11
- colorFormBorder: string;
12
- colorInverse: string;
13
- colorOutline: string;
14
- colorPrimary: string;
15
- colorSecondary: string;
16
- colorSuccess: string;
17
- button: {
18
- fontFamily: string;
19
- fontSize: string;
20
- fontWeight: number;
21
- letterSpacing: number;
22
- lineHeight: string;
23
- };
24
- footnote: {
25
- fontFamily: string;
26
- fontSize: string;
27
- fontWeight: number;
28
- letterSpacing: number;
29
- lineHeight: string;
30
- };
31
- label: {
32
- fontFamily: string;
33
- fontSize: string;
34
- fontWeight: number;
35
- letterSpacing: number;
36
- lineHeight: string;
37
- };
38
- subheading: {
39
- fontFamily: string;
40
- fontSize: string;
41
- fontWeight: number;
42
- letterSpacing: number;
43
- lineHeight: string;
44
- };
45
- borderRadius: [string, string];
12
+ colorAction?: string;
13
+ colorBackground?: string;
14
+ colorBorder?: string;
15
+ colorDisabled?: string;
16
+ colorError?: string;
17
+ colorFormBackground?: string;
18
+ colorFormBorder?: string;
19
+ colorInverse?: string;
20
+ colorOutline?: string;
21
+ colorPrimary?: string;
22
+ colorSecondary?: string;
23
+ colorSuccess?: string;
24
+ borderRadius?: [string, string];
25
+ button?: ElementAppearance;
26
+ footnote?: ElementAppearance;
27
+ label?: ElementAppearance;
28
+ input?: ElementAppearance;
29
+ subheading?: ElementAppearance;
46
30
  }
47
31
  export interface CheckoutComConfig {
48
32
  containerClassName?: string;
@@ -51,7 +35,7 @@ export interface CheckoutComConfig {
51
35
  success_url: string;
52
36
  failure_url: string;
53
37
  options?: {
54
- appearance: Partial<Appearance>;
38
+ appearance: Appearance;
55
39
  };
56
40
  [key: string]: unknown;
57
41
  }
@@ -1,5 +1,5 @@
1
- import type { GatewayBaseType } from '../payment_gateways/PaymentGateway';
2
- import { type JSX } from 'react';
1
+ import type { GatewayBaseType } from "../payment_gateways/PaymentGateway";
2
+ import { type JSX } from "react";
3
3
  type Props = GatewayBaseType;
4
4
  export declare function CheckoutComGateway(props: Props): JSX.Element | null;
5
5
  export default CheckoutComGateway;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import CheckoutComPayment from"../payment_source/CheckoutComPayment";import CustomerContext from"../../context/CustomerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import{getPaymentConfig}from"../../reducers/PaymentMethodReducer";import isEmpty from"lodash/isEmpty";import React from"react";import PaymentCardsTemplate from"../utils/PaymentCardsTemplate";import getCardDetails from"../../utils/getCardDetails";export function CheckoutComGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,loaderComponent,templateCustomerSaveToWallet,...p}=props,{order}=React.useContext(OrderContext),{payment}=React.useContext(PaymentMethodChildrenContext),{payments,isGuest}=React.useContext(CustomerContext),{currentPaymentMethodId,config,paymentSource}=React.useContext(PaymentMethodContext),paymentResource="checkout_com_payments",locale=order?.language_code;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const publicKey=paymentSource?.public_key,paymentConfig=config?getPaymentConfig(paymentResource,config):{},customerPayments=!isEmpty(payments)&&payments?payments.filter(customerPayment=>customerPayment.payment_source?.type===paymentResource):[];if(readonly||showCard){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType:paymentResource}),value={...card,showCard,handleEditClick,readonly};return card.brand?_jsx(PaymentSourceContext.Provider,{value,children}):null}return!isGuest&&templateCustomerCards?_jsxs(_Fragment,{children:[isEmpty(customerPayments)?null:_jsx("div",{className:p.className,children:_jsx(PaymentCardsTemplate,{paymentResource,customerPayments,children:templateCustomerCards})}),_jsx(CheckoutComPayment,{show,templateCustomerSaveToWallet,publicKey,locale,...paymentConfig})]}):_jsx(CheckoutComPayment,{show,publicKey,locale,...paymentConfig})}export default CheckoutComGateway;
2
+ import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import CheckoutComPayment from"../payment_source/CheckoutComPayment";import CustomerContext from"../../context/CustomerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodChildrenContext from"../../context/PaymentMethodChildrenContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PaymentSourceContext from"../../context/PaymentSourceContext";import{getPaymentConfig}from"../../reducers/PaymentMethodReducer";import isEmpty from"lodash/isEmpty";import React from"react";import PaymentCardsTemplate from"../utils/PaymentCardsTemplate";import getCardDetails from"../../utils/getCardDetails";export function CheckoutComGateway(props){const{readonly,showCard,handleEditClick,children,templateCustomerCards,show,loading,loaderComponent,templateCustomerSaveToWallet,...p}=props,{order}=React.useContext(OrderContext),{payment}=React.useContext(PaymentMethodChildrenContext),{payments,isGuest}=React.useContext(CustomerContext),{currentPaymentMethodId,config,paymentSource}=React.useContext(PaymentMethodContext),paymentResource="checkout_com_payments",locale=order?.language_code;if(!readonly&&payment?.id!==currentPaymentMethodId)return null;const publicKey=paymentSource?.public_key,paymentConfig=config?getPaymentConfig(paymentResource,config):{},customerPayments=!isEmpty(payments)&&payments?payments.filter(customerPayment=>customerPayment.payment_source?.type===paymentResource):[];if(readonly||showCard){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType:paymentResource}),value={...card,showCard,handleEditClick,readonly};return card.brand?_jsx(PaymentSourceContext.Provider,{value,children}):null}return!isGuest&&templateCustomerCards?_jsxs(_Fragment,{children:[isEmpty(customerPayments)?null:_jsx("div",{className:p.className,children:_jsx(PaymentCardsTemplate,{paymentResource,customerPayments,children:templateCustomerCards})}),_jsx(CheckoutComPayment,{show,templateCustomerSaveToWallet,publicKey,locale,...paymentConfig.checkoutComPayment})]}):_jsx(CheckoutComPayment,{show,publicKey,locale,...paymentConfig})}export default CheckoutComGateway;
@@ -1,48 +1,32 @@
1
1
  import { type JSX } from "react";
2
2
  import type { PaymentMethodConfig } from "../../reducers/PaymentMethodReducer";
3
3
  import type { PaymentSourceProps } from "./PaymentSource";
4
+ interface ElementAppearance {
5
+ fontFamily?: string;
6
+ fontSize?: string;
7
+ fontWeight?: number;
8
+ letterSpacing?: number;
9
+ lineHeight?: string;
10
+ }
4
11
  interface Appearance {
5
- colorAction: string;
6
- colorBackground: string;
7
- colorBorder: string;
8
- colorDisabled: string;
9
- colorError: string;
10
- colorFormBackground: string;
11
- colorFormBorder: string;
12
- colorInverse: string;
13
- colorOutline: string;
14
- colorPrimary: string;
15
- colorSecondary: string;
16
- colorSuccess: string;
17
- button: {
18
- fontFamily: string;
19
- fontSize: string;
20
- fontWeight: number;
21
- letterSpacing: number;
22
- lineHeight: string;
23
- };
24
- footnote: {
25
- fontFamily: string;
26
- fontSize: string;
27
- fontWeight: number;
28
- letterSpacing: number;
29
- lineHeight: string;
30
- };
31
- label: {
32
- fontFamily: string;
33
- fontSize: string;
34
- fontWeight: number;
35
- letterSpacing: number;
36
- lineHeight: string;
37
- };
38
- subheading: {
39
- fontFamily: string;
40
- fontSize: string;
41
- fontWeight: number;
42
- letterSpacing: number;
43
- lineHeight: string;
44
- };
45
- borderRadius: [string, string];
12
+ colorAction?: string;
13
+ colorBackground?: string;
14
+ colorBorder?: string;
15
+ colorDisabled?: string;
16
+ colorError?: string;
17
+ colorFormBackground?: string;
18
+ colorFormBorder?: string;
19
+ colorInverse?: string;
20
+ colorOutline?: string;
21
+ colorPrimary?: string;
22
+ colorSecondary?: string;
23
+ colorSuccess?: string;
24
+ borderRadius?: [string, string];
25
+ button?: ElementAppearance;
26
+ footnote?: ElementAppearance;
27
+ label?: ElementAppearance;
28
+ input?: ElementAppearance;
29
+ subheading?: ElementAppearance;
46
30
  }
47
31
  export interface CheckoutComConfig {
48
32
  containerClassName?: string;
@@ -51,7 +35,7 @@ export interface CheckoutComConfig {
51
35
  success_url: string;
52
36
  failure_url: string;
53
37
  options?: {
54
- appearance: Partial<Appearance>;
38
+ appearance: Appearance;
55
39
  };
56
40
  [key: string]: unknown;
57
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercelayer/react-components",
3
- "version": "4.23.0",
3
+ "version": "4.23.2",
4
4
  "description": "The Official Commerce Layer React Components",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/esm/index.js",