-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: move registered fields state to registry hook
- Loading branch information
Sebastian Fernandez
committed
Apr 16, 2024
1 parent
d4db167
commit f817e41
Showing
15 changed files
with
101 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,18 @@ | ||
import { createContext } from "react"; | ||
import { | ||
PayPalCardFieldsComponent, | ||
PayPalCardFieldsIndividualField, | ||
} from "@paypal/paypal-js/types/components/card-fields"; | ||
|
||
import { ignore } from "./utils"; | ||
import { FieldComponentName } from "./hooks"; | ||
import { RegistryHookReturnType } from "./hooks"; | ||
|
||
import type { PayPalCardFieldsComponent } from "@paypal/paypal-js/types/components/card-fields"; | ||
|
||
export type PayPalCardFieldsContextType = { | ||
cardFields: PayPalCardFieldsComponent | null; | ||
nameField: React.MutableRefObject<PayPalCardFieldsIndividualField | null>; | ||
numberField: React.MutableRefObject<PayPalCardFieldsIndividualField | null>; | ||
expiryField: React.MutableRefObject<PayPalCardFieldsIndividualField | null>; | ||
cvvField: React.MutableRefObject<PayPalCardFieldsIndividualField | null>; | ||
registerField: (field: FieldComponentName) => void; | ||
unregisterField: (field: FieldComponentName) => void; | ||
}; | ||
cardFieldsForm: PayPalCardFieldsComponent | null; | ||
} & RegistryHookReturnType; | ||
|
||
export const PayPalCardFieldsContext = | ||
createContext<PayPalCardFieldsContextType>({ | ||
cardFields: null, | ||
nameField: { current: null }, | ||
numberField: { current: null }, | ||
cvvField: { current: null }, | ||
expiryField: { current: null }, | ||
registerField: ignore, // implementation is inside provider | ||
unregisterField: ignore, // implementation is inside provider | ||
cardFieldsForm: null, | ||
fields: {}, | ||
registerField: ignore, // implementation is inside hook and passed through the provider | ||
unregisterField: ignore, // implementation is inside hook and passed through the provider | ||
}); |
Oops, something went wrong.