Skip to content

Commit

Permalink
Support React 19
Browse files Browse the repository at this point in the history
  • Loading branch information
acasazza committed Dec 12, 2024
1 parent 1db9bc8 commit abe4cb8
Show file tree
Hide file tree
Showing 149 changed files with 1,985 additions and 2,542 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"scripts": {
"preinstall": "npx only-allow pnpm",
"build": "pnpm -r build",
"prepare": "husky install",
"prepare": "husky",
"test": "pnpm -r test",
"docs:dev": "pnpm --filter docs storybook",
"docs:build": "pnpm --filter docs build-storybook",
Expand Down
52 changes: 26 additions & 26 deletions packages/react-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,48 +178,48 @@
},
"homepage": "https://github.com/commercelayer/commercelayer-react-components#readme",
"dependencies": {
"@adyen/adyen-web": "^5.66.1",
"@adyen/adyen-web": "^5.71.1",
"@commercelayer/organization-config": "^1.4.12",
"@commercelayer/sdk": "^6.25.0",
"@stripe/react-stripe-js": "^2.9.0",
"@stripe/stripe-js": "^4.10.0",
"@commercelayer/sdk": "^6.26.0",
"@stripe/react-stripe-js": "^3.0.0",
"@stripe/stripe-js": "^5.2.0",
"@tanstack/react-table": "^8.17.3",
"@types/iframe-resizer": "^3.5.13",
"braintree-web": "^3.112.0",
"frames-react": "^1.1.2",
"braintree-web": "^3.112.1",
"frames-react": "^1.2.2",
"iframe-resizer": "^4.4.5",
"jwt-decode": "^4.0.0",
"lodash": "^4.17.21",
"rapid-form": "^2.1.0"
"rapid-form": "2.1.0"
},
"devDependencies": {
"@commercelayer/js-auth": "^6.7.0",
"@faker-js/faker": "^9.2.0",
"@playwright/test": "^1.48.2",
"@faker-js/faker": "^9.3.0",
"@playwright/test": "^1.49.1",
"@testing-library/dom": "^10.4.0",
"@testing-library/react": "^16.0.0",
"@types/braintree-web": "^3.96.12",
"@testing-library/react": "^16.1.0",
"@types/braintree-web": "^3.96.16",
"@types/lodash": "^4.17.13",
"@types/node": "^22.9.0",
"@types/prop-types": "^15.7.12",
"@types/react": "^18.3.4",
"@types/react-test-renderer": "^18.0.7",
"@types/node": "^22.10.2",
"@types/prop-types": "^15.7.14",
"@types/react": "^18.3.1",
"@types/react-test-renderer": "^18.3.1",
"@types/react-window": "^1.8.8",
"@vitejs/plugin-react": "^4.3.1",
"@vitest/coverage-v8": "^2.1.4",
"eslint": "~9.14.0",
"@vitejs/plugin-react": "^4.3.4",
"@vitest/coverage-v8": "^2.1.8",
"eslint": "~9.16.0",
"jsdom": "^25.0.1",
"minimize-js": "^1.4.0",
"msw": "^2.6.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-test-renderer": "^18.2.0",
"msw": "^2.6.8",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-test-renderer": "^18.3.1",
"tsc-alias": "^1.8.8",
"tslib": "^2.6.3",
"typescript": "^5.5.4",
"vite": "^5.4.11",
"vite-tsconfig-paths": "^5.1.2",
"vitest": "^2.1.4"
"typescript": "^5.7.2",
"vite": "^6.0.3",
"vite-tsconfig-paths": "^5.1.4",
"vitest": "^2.1.8"
},
"peerDependencies": {
"react": ">=18.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ExternalFunctionContext, {
callExternalFunction
} from '#context/ExternalFunctionContext'
import { type ReactNode } from 'react'
import { type ReactNode, type JSX } from 'react';

interface Props {
children: ReactNode
Expand Down
2 changes: 2 additions & 0 deletions packages/react-components/src/components/MetadataInput.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import BaseInput from '#components/utils/BaseInput'
import { type BaseInputComponentProps } from '#typings'

import type { JSX } from "react";

type Props = BaseInputComponentProps &
JSX.IntrinsicElements['input'] &
JSX.IntrinsicElements['textarea']
Expand Down
4 changes: 2 additions & 2 deletions packages/react-components/src/components/SubmitButton.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { type ReactNode } from 'react'
import { type ReactNode, type JSX } from 'react';
import Parent from '#components/utils/Parent'
import { type ChildrenFunction } from '#typings/index'
import isFunction from 'lodash/isFunction'

interface ChildrenProps extends Omit<Props, 'children'> {}

interface Props extends Omit<JSX.IntrinsicElements['button'], 'children'> {
interface Props extends Omit<JSX.IntrinsicElements['button'], 'children' | 'ref'> {
children?: ChildrenFunction<ChildrenProps>
label?: string | ReactNode
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext, useState, useEffect } from 'react'
import { useContext, useState, useEffect, type JSX } from 'react';
import AddressChildrenContext from '#context/AddressChildrenContext'
import CustomerContext from '#context/CustomerContext'
import BillingAddressContext from '#context/BillingAddressContext'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext, useEffect, useMemo } from 'react'
import { useContext, useEffect, useMemo, type JSX } from 'react';
import BaseSelect from '../utils/BaseSelect'
import { type BaseSelectComponentProps } from '#typings'
import BillingAddressFormContext, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext, type ReactNode } from 'react'
import { useContext, type ReactNode, type JSX } from 'react';
import AddressChildrenContext from '#context/AddressChildrenContext'
import Parent from '#components/utils/Parent'
import { type AddressFieldView } from '#reducers/AddressReducer'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext, useEffect, useMemo } from 'react'
import { useContext, useEffect, useMemo, type JSX } from 'react';
import BaseInput from '#components/utils/BaseInput'
import { type BaseInputComponentProps, type AddressInputName } from '#typings'
import BillingAddressFormContext, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext, useEffect, useMemo } from 'react'
import { useContext, useEffect, useMemo, type JSX } from 'react';
import BaseSelect from '../utils/BaseSelect'
import { type BaseSelectComponentProps } from '#typings'
import BillingAddressFormContext, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext, useEffect, useMemo, useState } from 'react'
import { useContext, useEffect, useMemo, useState, type JSX } from 'react';
import BaseSelect from '#components/utils/BaseSelect'
import {
type AddressStateSelectName,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import AddressesContext, {
defaultAddressContext
} from '#context/AddressContext'
import { type ReactNode, useContext, useEffect, useReducer } from 'react'
import { type ReactNode, useContext, useEffect, useReducer, type JSX } from 'react';
import addressReducer, {
addressInitialState,
type AddressResource,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Parent from '#components/utils/Parent'
import CustomerContext from '#context/CustomerContext'
import { type ChildrenFunction } from '#typings/index'
import { useContext } from 'react'
import { useContext, type JSX } from 'react';

interface Props extends Omit<JSX.IntrinsicElements['span'], 'children'> {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import BillingAddressContext from '#context/BillingAddressContext'
import { type ReactNode, useContext, useEffect, useReducer } from 'react'
import { type ReactNode, useContext, useEffect, useReducer, type JSX } from 'react';
import billingAddressReducer, {
billingAddressInitialState,
setBillingAddress,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import AddressesContext from '#context/AddressContext'
import { useRapidForm } from 'rapid-form'
import { type ReactNode, useContext, useEffect, useRef } from 'react'
import { type ReactNode, useContext, useEffect, useRef, type JSX } from 'react';
import BillingAddressFormContext, {
type AddressValuesKeys,
type DefaultContextAddress
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ReactNode, useContext, useState } from 'react'
import { type ReactNode, useContext, useState, type JSX } from 'react';
import Parent from '#components/utils/Parent'
import { type ChildrenFunction } from '#typings/index'
import AddressContext from '#context/AddressContext'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ShippingAddressContext from '#context/ShippingAddressContext'
import { useContext, useEffect, useReducer } from 'react'
import { useContext, useEffect, useReducer, type JSX } from 'react';
import shippingAddressReducer, {
setShippingAddress,
shippingAddressInitialState,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import AddressesContext from '#context/AddressContext'
import { useRapidForm } from 'rapid-form'
import { type ReactNode, useContext, useEffect, useRef } from 'react'
import { type ReactNode, useContext, useEffect, useRef, type JSX } from 'react';
import ShippingAddressFormContext from '#context/ShippingAddressFormContext'
import { type BaseError, type CodeErrorType } from '#typings/errors'
import OrderContext from '#context/OrderContext'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import ErrorBoundary from '#components/utils/ErrorBoundary'
import type { DefaultChildrenType } from '#typings/globals'
import { jwt } from '#utils/jwt'

import type { JSX } from "react";

interface Props {
/**
* Accept a React node as children.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import AddressesContext from '#context/AddressContext'
import { useRapidForm } from 'rapid-form'
import { type ReactNode, useContext, useEffect, useRef } from 'react'
import { type ReactNode, useContext, useEffect, useRef, type JSX } from 'react';
import CustomerAddressFormContext from '#context/CustomerAddressFormContext'
import { type BaseError, type CodeErrorType } from '#typings/errors'
import { type AddressField } from '#reducers/AddressReducer'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext, useEffect, useReducer, useMemo } from 'react'
import { useContext, useEffect, useReducer, useMemo, type JSX } from 'react';
import customerReducer, {
customerInitialState,
getCustomerAddresses,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import GenericFieldComponent, {
} from '#components/utils/GenericFieldComponent'
import CustomerContext from '#context/CustomerContext'

import type { JSX } from "react";

type StockTransferFieldChildrenProps = TGenericChildrenProps<
TResources['Customer']
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import { useContext, useEffect, useState } from 'react'
import { useContext, useEffect, useState, type JSX } from 'react';
import BaseInput from '#components-utils/BaseInput'
import { type BaseInputComponentProps } from '#typings'
import { useRapidForm } from 'rapid-form'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { type PaymentResource } from '#reducers/PaymentMethodReducer'
import { type DefaultChildrenType } from '#typings/globals'
import getCardDetails from '#utils/getCardDetails'
import useCustomContext from '#utils/hooks/useCustomContext'
import { useEffect, useState } from 'react'
import { useEffect, useState, type JSX } from 'react';

interface Props {
children?: DefaultChildrenType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import CustomerContext from '#context/CustomerContext'
import { type ChildrenFunction } from '#typings/index'
import useCustomContext from '#utils/hooks/useCustomContext'

import type { JSX } from "react";

interface Props extends Omit<JSX.IntrinsicElements['span'], 'children'> {
/**
* Function allow you to customize the component
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext } from 'react'
import { useContext, type JSX } from 'react';
import Parent from '../utils/Parent'
import { type ChildrenFunction } from '#typings/index'
import CommerceLayerContext from '#context/CommerceLayerContext'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext, useEffect, useState } from 'react'
import { useContext, useEffect, useState, type JSX } from 'react';
import Parent from '../utils/Parent'
import { type ChildrenFunction } from '#typings/index'
import CommerceLayerContext from '#context/CommerceLayerContext'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ReactNode, useContext } from 'react'
import { type ReactNode, useContext, type JSX } from 'react';
import Parent from '#components/utils/Parent'
import { type ChildrenFunction } from '#typings/index'
import isEmpty from 'lodash/isEmpty'
Expand Down
2 changes: 1 addition & 1 deletion packages/react-components/src/components/errors/Errors.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext, useMemo } from 'react'
import { useContext, useMemo, type JSX } from 'react';
import Parent from '#components/utils/Parent'
import GiftCardContext from '#context/GiftCardContext'
import OrderContext from '#context/OrderContext'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useRef, useContext, type RefObject } from 'react'
import { useRef, useContext, type RefObject, type JSX } from 'react';
import validateFormFields from '#utils/validateFormFields'
import isEmpty from 'lodash/isEmpty'
import GiftCardContext from '#context/GiftCardContext'
Expand All @@ -8,15 +8,16 @@ import type { DefaultChildrenType } from '#typings/globals'

type RequiredFields = 'currencyCode' | 'balanceCents'

interface Props extends Omit<JSX.IntrinsicElements['form'], 'children'> {
interface Props extends Omit<JSX.IntrinsicElements['form'], 'children' | 'ref'> {
children: DefaultChildrenType
onSubmit?: (values: BaseState) => void
ref?: RefObject<HTMLFormElement | null>
}

export function GiftCard(props: Props): JSX.Element {
const { children, onSubmit } = props
const name = 'giftCardForm'
const ref: RefObject<HTMLFormElement> = useRef<HTMLFormElement>(null)
const ref: RefObject<HTMLFormElement | null> = useRef<HTMLFormElement>(null)
const { addGiftCard, addGiftCardError } = useContext(GiftCardContext)
const handleSubmit = (e: React.FormEvent<HTMLFormElement>): void => {
e.preventDefault()
Expand All @@ -40,7 +41,7 @@ export function GiftCard(props: Props): JSX.Element {
}
return (
<>
<form key={name} name={name} ref={ref} onSubmit={handleSubmit}>
<form key={name} name={name} onSubmit={handleSubmit}>
{children}
</form>
</>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useReducer, useContext, type ReactNode } from 'react'
import { useReducer, useContext, type ReactNode, type JSX } from 'react';
import GiftCardContext from '#context/GiftCardContext'
import CommerceLayerContext from '#context/CommerceLayerContext'
import giftCardReducer, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import BaseSelect from '#components/utils/BaseSelect'
import currencyOptions from '#config/currency'
import { type BaseSelectComponentProps } from '#typings'

import type { JSX } from "react";

type Props = Omit<BaseSelectComponentProps, 'options' | 'name'> & {
required?: boolean
} & Pick<JSX.IntrinsicElements['select'], 'className' | 'id' | 'style'>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import BaseInput from '#components/utils/BaseInput'
import { type BaseInputComponentProps, type GiftCardInputName } from '#typings'

import type { JSX } from "react";

type Props = {
name: GiftCardInputName
} & Omit<BaseInputComponentProps, 'name'> &
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext } from 'react'
import { useContext, type JSX } from 'react';
import { type ChildrenFunction } from '#typings'
import Parent from '#components/utils/Parent'
import OrderContext from '#context/OrderContext'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useRapidForm } from 'rapid-form'
import { useContext, useEffect, useRef, useState } from 'react'
import { useContext, useEffect, useRef, useState, type JSX } from 'react';
import CouponAndGiftCardFormContext from '#context/CouponAndGiftCardFormContext'
import OrderContext from '#context/OrderContext'
import type { OrderCodeType } from '#reducers/OrderReducer'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext } from 'react'
import { useContext, type JSX } from 'react';
import BaseInput from '#components/utils/BaseInput'
import CouponAndGiftCardFormContext from '#context/CouponAndGiftCardFormContext'
import { type BaseInputComponentProps } from '#typings'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ReactNode, useContext } from 'react'
import { type ReactNode, useContext, type JSX } from 'react';
import Parent from '#components/utils/Parent'
import { type ChildrenFunction } from '#typings/index'
import OrderContext from '#context/OrderContext'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ReactNode } from 'react'
import { type ReactNode, type JSX } from 'react';
import Parent from '#components/utils/Parent'
import { type ChildrenFunction } from '#typings/index'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import InStockSubscriptionContext from '#context/InStockSubscriptionContext'
import { type ChildrenFunction } from '#typings/index'
import useCustomContext from '#utils/hooks/useCustomContext'
import { jwt } from '#utils/jwt'
import { useContext, useState } from 'react'
import { useContext, useState, type JSX } from 'react';

interface Props
extends Omit<JSX.IntrinsicElements['button'], 'children' | 'onClick'> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import inStockSubscriptionReducer, {
} from '#reducers/InStockSubscriptionReducer'
import { type DefaultChildrenType } from '#typings/globals'
import useCustomContext from '#utils/hooks/useCustomContext'
import { useReducer } from 'react'
import { useReducer, type JSX } from 'react';

interface Props {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext } from 'react'
import { useContext, type JSX } from 'react';
import LineItemContext from '#context/LineItemContext'
import LineItemChildrenContext, {
type InitialLineItemChildrenContext
Expand Down
Loading

0 comments on commit abe4cb8

Please sign in to comment.