Skip to content

Commit 3a2fe10

Browse files
Add jsdoc comments to connect components and functions (#2293)
* Add jsdoc comments to connect components and functions * Revert change * Improve example
1 parent a9209e7 commit 3a2fe10

File tree

2 files changed

+150
-0
lines changed

2 files changed

+150
-0
lines changed

src/connect/Components.tsx

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,39 @@ import { useConnectComponents } from './ConnectComponentsProvider';
2424
export { NavigationBar } from './NavigationBar';
2525
export type { NavigationBarProps } from './NavigationBar';
2626

27+
/**
28+
* A full-screen modal component for Connect account onboarding.
29+
* Guides connected accounts through the process of providing required information.
30+
*
31+
* **Platform differences:**
32+
* - iOS: Uses native modal with UIKit navigation bar
33+
* - Android: Uses React Native Modal with custom navigation bar
34+
*
35+
* @param props.title - Optional title displayed in navigation bar
36+
* @param props.onExit - Required callback when user closes the onboarding flow
37+
* @param props.onStepChange - Optional callback fired when onboarding step changes
38+
* @param props.recipientTermsOfServiceUrl - URL for recipient terms of service
39+
* @param props.fullTermsOfServiceUrl - URL for full terms of service
40+
* @param props.privacyPolicyUrl - URL for privacy policy
41+
* @param props.collectionOptions - Configuration for which account fields to collect
42+
* @param props.onLoaderStart - Callback when component begins loading
43+
* @param props.onLoadError - Callback when component fails to load
44+
* @param props.onPageDidLoad - Callback when component finishes loading
45+
*
46+
* @example
47+
* ```tsx
48+
* <ConnectAccountOnboarding
49+
* title="Complete your account setup"
50+
* onExit={() => navigation.goBack()}
51+
* onStepChange={({ step }) => console.log('Current step:', step)}
52+
* collectionOptions={{
53+
* fields: 'currently_due',
54+
* futureRequirements: 'include'
55+
* }}
56+
* />
57+
* ```
58+
* @category Connect
59+
*/
2760
export function ConnectAccountOnboarding({
2861
title,
2962
onExit,
@@ -178,6 +211,28 @@ export function ConnectAccountOnboarding({
178211
);
179212
}
180213

214+
/**
215+
* Displays a list of payments for the connected account with optional filtering.
216+
* Embed this component to show payment history and details.
217+
*
218+
* @param props.defaultFilters - Optional filters to apply to the payments list
219+
* @param props.onLoaderStart - Callback when component begins loading
220+
* @param props.onLoadError - Callback when component fails to load
221+
* @param props.onPageDidLoad - Callback when component finishes loading
222+
* @param props.style - Optional styling for the component container
223+
*
224+
* @example
225+
* ```tsx
226+
* <ConnectPayments
227+
* defaultFilters={{
228+
* status: ['successful', 'pending'],
229+
* date: { after: new Date('2024-01-01') }
230+
* }}
231+
* style={{ flex: 1 }}
232+
* />
233+
* ```
234+
* @category Connect
235+
*/
181236
export function ConnectPayments({
182237
defaultFilters,
183238
onLoaderStart,
@@ -205,6 +260,21 @@ export function ConnectPayments({
205260
);
206261
}
207262

263+
/**
264+
* Displays payout information for the connected account.
265+
* Shows payout history, schedules, and details.
266+
*
267+
* @param props.onLoaderStart - Callback when component begins loading
268+
* @param props.onLoadError - Callback when component fails to load
269+
* @param props.onPageDidLoad - Callback when component finishes loading
270+
* @param props.style - Optional styling for the component container
271+
*
272+
* @example
273+
* ```tsx
274+
* <ConnectPayouts style={{ flex: 1 }} />
275+
* ```
276+
* @category Connect
277+
*/
208278
export function ConnectPayouts({
209279
onLoaderStart,
210280
onLoadError,
@@ -222,6 +292,27 @@ export function ConnectPayouts({
222292
);
223293
}
224294

295+
/**
296+
* Displays detailed information for a specific payment.
297+
* Typically used in a modal or detail view after selecting a payment from ConnectPayments.
298+
*
299+
* @param props.payment - The payment ID to display details for
300+
* @param props.onClose - Required callback when user closes the detail view
301+
* @param props.onLoaderStart - Callback when component begins loading
302+
* @param props.onLoadError - Callback when component fails to load
303+
* @param props.onPageDidLoad - Callback when component finishes loading
304+
* @param props.style - Optional styling for the component container
305+
*
306+
* @example
307+
* ```tsx
308+
* <ConnectPaymentDetails
309+
* payment="py_1234567890"
310+
* onClose={() => setShowDetails(false)}
311+
* style={{ flex: 1 }}
312+
* />
313+
* ```
314+
* @category Connect
315+
*/
225316
export function ConnectPaymentDetails({
226317
payment,
227318
onClose,

src/connect/ConnectComponentsProvider.tsx

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,29 @@ class ConnectInstance implements StripeConnectInstance {
1919
}
2020
}
2121

22+
/**
23+
* Creates a Connect instance for use with ConnectComponentsProvider.
24+
* This instance manages the configuration and state for Connect embedded components.
25+
*
26+
* @param initParams - Initialization parameters including publishableKey and fetchClientSecret
27+
* @returns A StripeConnectInstance that can be passed to ConnectComponentsProvider
28+
*
29+
* @example
30+
* ```ts
31+
* const connectInstance = loadConnectAndInitialize({
32+
* publishableKey: 'pk_test_123',
33+
* fetchClientSecret: async () => {
34+
* const response = await fetch('/account_session');
35+
* const { client_secret } = await response.json();
36+
* return client_secret;
37+
* },
38+
* appearance: {
39+
* variables: { colorPrimary: '#635BFF' }
40+
* }
41+
* });
42+
* ```
43+
* @category Connect
44+
*/
2245
export const loadConnectAndInitialize: LoadConnectAndInitialize = (
2346
initParams: StripeConnectInitParams
2447
): StripeConnectInstance => {
@@ -41,6 +64,42 @@ const ConnectComponentsContext =
4164

4265
ConnectComponentsContext.displayName = 'ConnectComponents';
4366

67+
/**
68+
* Context provider that makes Connect instance configuration available to embedded components.
69+
* Wrap your Connect components with this provider to enable them to access the shared configuration.
70+
*
71+
* @param props.connectInstance - Instance created via loadConnectAndInitialize
72+
* @param props.children - React components to render within the provider
73+
* @returns JSX.Element
74+
*
75+
* @throws Error if connectInstance is not created via loadConnectAndInitialize
76+
*
77+
* @example
78+
* ```tsx
79+
* function App() {
80+
* const [connectInstance] = useState(() => {
81+
* const fetchClientSecret = async () => {
82+
* const response = await fetch('/account_session', { method: "POST" });
83+
* const { client_secret: clientSecret } = await response.json();
84+
* return clientSecret;
85+
* };
86+
*
87+
* return loadConnectAndInitialize({
88+
* publishableKey: 'pk_test_123',
89+
* fetchClientSecret: fetchClientSecret,
90+
* appearance,
91+
* });
92+
* });
93+
*
94+
* return (
95+
* <ConnectComponentsProvider connectInstance={connectInstance}>
96+
* <ConnectPayouts />
97+
* </ConnectComponentsProvider>
98+
* );
99+
* }
100+
* ```
101+
* @category Connect
102+
*/
44103
export const ConnectComponentsProvider = ({
45104
children,
46105
connectInstance,

0 commit comments

Comments
 (0)