@clerk/react 6.0.0-snapshot.v20251218183643 → 6.0.0-snapshot.v20260105214115
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/dist/{chunk-4F7CSI4T.mjs → chunk-RG4XQAGC.mjs} +21 -35
- package/dist/chunk-RG4XQAGC.mjs.map +1 -0
- package/dist/experimental.d.mts +28 -25
- package/dist/experimental.d.ts +28 -25
- package/dist/experimental.js +4 -2
- package/dist/experimental.js.map +1 -1
- package/dist/experimental.mjs +4 -2
- package/dist/experimental.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +22 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -8
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.mts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/internal.mjs +1 -1
- package/dist/{useAuth-D_JXwEQe.d.mts → useAuth-CslfTE3X.d.mts} +27 -14
- package/dist/{useAuth-RH7cOyeT.d.ts → useAuth-EN4wLVLS.d.ts} +27 -14
- package/package.json +6 -6
- package/dist/chunk-4F7CSI4T.mjs.map +0 -1
|
@@ -15,22 +15,6 @@ import React from "react";
|
|
|
15
15
|
import { SessionContext, useSessionContext } from "@clerk/shared/react";
|
|
16
16
|
|
|
17
17
|
// src/components/controlComponents.tsx
|
|
18
|
-
var SignedIn = ({ children, treatPendingAsSignedOut }) => {
|
|
19
|
-
useAssertWrappedByClerkProvider("SignedIn");
|
|
20
|
-
const { userId } = useAuth({ treatPendingAsSignedOut });
|
|
21
|
-
if (userId) {
|
|
22
|
-
return children;
|
|
23
|
-
}
|
|
24
|
-
return null;
|
|
25
|
-
};
|
|
26
|
-
var SignedOut = ({ children, treatPendingAsSignedOut }) => {
|
|
27
|
-
useAssertWrappedByClerkProvider("SignedOut");
|
|
28
|
-
const { userId } = useAuth({ treatPendingAsSignedOut });
|
|
29
|
-
if (userId === null) {
|
|
30
|
-
return children;
|
|
31
|
-
}
|
|
32
|
-
return null;
|
|
33
|
-
};
|
|
34
18
|
var ClerkLoaded = ({ children }) => {
|
|
35
19
|
useAssertWrappedByClerkProvider("ClerkLoaded");
|
|
36
20
|
const isomorphicClerk = useIsomorphicClerkContext();
|
|
@@ -63,31 +47,35 @@ var ClerkDegraded = ({ children }) => {
|
|
|
63
47
|
}
|
|
64
48
|
return children;
|
|
65
49
|
};
|
|
66
|
-
var
|
|
67
|
-
useAssertWrappedByClerkProvider("
|
|
68
|
-
const {
|
|
50
|
+
var Show = ({ children, fallback, treatPendingAsSignedOut, when }) => {
|
|
51
|
+
useAssertWrappedByClerkProvider("Show");
|
|
52
|
+
const { has, isLoaded, userId } = useAuth({ treatPendingAsSignedOut });
|
|
69
53
|
if (!isLoaded) {
|
|
70
54
|
return null;
|
|
71
55
|
}
|
|
72
|
-
const
|
|
56
|
+
const resolvedWhen = when;
|
|
73
57
|
const authorized = children;
|
|
58
|
+
const unauthorized = fallback != null ? fallback : null;
|
|
59
|
+
if (resolvedWhen === "signed-out") {
|
|
60
|
+
return userId ? unauthorized : authorized;
|
|
61
|
+
}
|
|
74
62
|
if (!userId) {
|
|
75
63
|
return unauthorized;
|
|
76
64
|
}
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
return authorized;
|
|
80
|
-
}
|
|
81
|
-
return unauthorized;
|
|
65
|
+
if (resolvedWhen === "signed-in") {
|
|
66
|
+
return authorized;
|
|
82
67
|
}
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
return authorized;
|
|
86
|
-
}
|
|
87
|
-
return unauthorized;
|
|
68
|
+
if (checkAuthorization(resolvedWhen, has)) {
|
|
69
|
+
return authorized;
|
|
88
70
|
}
|
|
89
|
-
return
|
|
71
|
+
return unauthorized;
|
|
90
72
|
};
|
|
73
|
+
function checkAuthorization(when, has) {
|
|
74
|
+
if (typeof when === "function") {
|
|
75
|
+
return when(has);
|
|
76
|
+
}
|
|
77
|
+
return has(when);
|
|
78
|
+
}
|
|
91
79
|
var RedirectToSignIn = withClerk(({ clerk, ...props }) => {
|
|
92
80
|
var _a, _b;
|
|
93
81
|
const { client, session } = clerk;
|
|
@@ -150,13 +138,11 @@ var MultisessionAppSupport = ({ children }) => {
|
|
|
150
138
|
};
|
|
151
139
|
|
|
152
140
|
export {
|
|
153
|
-
SignedIn,
|
|
154
|
-
SignedOut,
|
|
155
141
|
ClerkLoaded,
|
|
156
142
|
ClerkLoading,
|
|
157
143
|
ClerkFailed,
|
|
158
144
|
ClerkDegraded,
|
|
159
|
-
|
|
145
|
+
Show,
|
|
160
146
|
RedirectToSignIn,
|
|
161
147
|
RedirectToSignUp,
|
|
162
148
|
RedirectToTasks,
|
|
@@ -166,4 +152,4 @@ export {
|
|
|
166
152
|
AuthenticateWithRedirectCallback,
|
|
167
153
|
MultisessionAppSupport
|
|
168
154
|
};
|
|
169
|
-
//# sourceMappingURL=chunk-
|
|
155
|
+
//# sourceMappingURL=chunk-RG4XQAGC.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/controlComponents.tsx","../src/contexts/SessionContext.tsx"],"sourcesContent":["import { deprecated } from '@clerk/shared/deprecated';\nimport type { HandleOAuthCallbackParams, PendingSessionOptions, ShowWhenCondition } from '@clerk/shared/types';\nimport React from 'react';\n\nimport { useIsomorphicClerkContext } from '../contexts/IsomorphicClerkContext';\nimport { useSessionContext } from '../contexts/SessionContext';\nimport { useAuth } from '../hooks';\nimport { useAssertWrappedByClerkProvider } from '../hooks/useAssertWrappedByClerkProvider';\nimport type { RedirectToSignInProps, RedirectToSignUpProps, RedirectToTasksProps, WithClerkProp } from '../types';\nimport { withClerk } from './withClerk';\n\nexport const ClerkLoaded = ({ children }: React.PropsWithChildren<unknown>) => {\n useAssertWrappedByClerkProvider('ClerkLoaded');\n\n const isomorphicClerk = useIsomorphicClerkContext();\n if (!isomorphicClerk.loaded) {\n return null;\n }\n return children;\n};\n\nexport const ClerkLoading = ({ children }: React.PropsWithChildren<unknown>) => {\n useAssertWrappedByClerkProvider('ClerkLoading');\n\n const isomorphicClerk = useIsomorphicClerkContext();\n if (isomorphicClerk.status !== 'loading') {\n return null;\n }\n return children;\n};\n\nexport const ClerkFailed = ({ children }: React.PropsWithChildren<unknown>) => {\n useAssertWrappedByClerkProvider('ClerkFailed');\n\n const isomorphicClerk = useIsomorphicClerkContext();\n if (isomorphicClerk.status !== 'error') {\n return null;\n }\n return children;\n};\n\nexport const ClerkDegraded = ({ children }: React.PropsWithChildren<unknown>) => {\n useAssertWrappedByClerkProvider('ClerkDegraded');\n\n const isomorphicClerk = useIsomorphicClerkContext();\n if (isomorphicClerk.status !== 'degraded') {\n return null;\n }\n return children;\n};\n\nexport type ShowProps = React.PropsWithChildren<\n {\n fallback?: React.ReactNode;\n when: ShowWhenCondition;\n } & PendingSessionOptions\n>;\n\n/**\n * Use `<Show/>` to conditionally render content based on user authorization or sign-in state.\n * Returns `null` while auth is loading. Set `treatPendingAsSignedOut` to treat\n * pending sessions as signed out during that period.\n *\n * The `when` prop supports:\n * - `\"signed-in\"` or `\"signed-out\"` shorthands\n * - Authorization descriptors (e.g., `{ permission: \"org:billing:manage\" }`, `{ role: \"admin\" }`)\n * - A predicate function `(has) => boolean` that receives the `has` helper\n *\n * @example\n * ```tsx\n * <Show when={{ permission: \"org:billing:manage\" }} fallback={<p>Unauthorized</p>}>\n * <BillingSettings />\n * </Show>\n *\n * <Show when={{ role: \"admin\" }}>\n * <AdminPanel />\n * </Show>\n *\n * <Show when={(has) => has({ permission: \"org:read\" }) && isFeatureEnabled}>\n * <ProtectedFeature />\n * </Show>\n * ```\n *\n */\nexport const Show = ({ children, fallback, treatPendingAsSignedOut, when }: ShowProps) => {\n useAssertWrappedByClerkProvider('Show');\n\n const { has, isLoaded, userId } = useAuth({ treatPendingAsSignedOut });\n\n if (!isLoaded) {\n return null;\n }\n\n const resolvedWhen = when;\n const authorized = children;\n const unauthorized = fallback ?? null;\n\n if (resolvedWhen === 'signed-out') {\n return userId ? unauthorized : authorized;\n }\n\n if (!userId) {\n return unauthorized;\n }\n\n if (resolvedWhen === 'signed-in') {\n return authorized;\n }\n\n if (checkAuthorization(resolvedWhen, has)) {\n return authorized;\n }\n\n return unauthorized;\n};\n\nfunction checkAuthorization(\n when: Exclude<ShowWhenCondition, 'signed-in' | 'signed-out'>,\n has: NonNullable<ReturnType<typeof useAuth>['has']>,\n): boolean {\n if (typeof when === 'function') {\n return when(has);\n }\n return has(when);\n}\n\nexport const RedirectToSignIn = withClerk(({ clerk, ...props }: WithClerkProp<RedirectToSignInProps>) => {\n const { client, session } = clerk;\n\n const hasSignedInSessions = (client.signedInSessions?.length ?? 0) > 0;\n\n React.useEffect(() => {\n if (session === null && hasSignedInSessions) {\n void clerk.redirectToAfterSignOut();\n } else {\n void clerk.redirectToSignIn(props);\n }\n }, []);\n\n return null;\n}, 'RedirectToSignIn');\n\nexport const RedirectToSignUp = withClerk(({ clerk, ...props }: WithClerkProp<RedirectToSignUpProps>) => {\n React.useEffect(() => {\n void clerk.redirectToSignUp(props);\n }, []);\n\n return null;\n}, 'RedirectToSignUp');\n\nexport const RedirectToTasks = withClerk(({ clerk, ...props }: WithClerkProp<RedirectToTasksProps>) => {\n React.useEffect(() => {\n void clerk.redirectToTasks(props);\n }, []);\n\n return null;\n}, 'RedirectToTasks');\n\n/**\n * @function\n * @deprecated Use [`redirectToUserProfile()`](https://clerk.com/docs/reference/javascript/clerk#redirect-to-user-profile) instead.\n */\nexport const RedirectToUserProfile = withClerk(({ clerk }) => {\n React.useEffect(() => {\n deprecated('RedirectToUserProfile', 'Use the `redirectToUserProfile()` method instead.');\n void clerk.redirectToUserProfile();\n }, []);\n\n return null;\n}, 'RedirectToUserProfile');\n\n/**\n * @function\n * @deprecated Use [`redirectToOrganizationProfile()`](https://clerk.com/docs/reference/javascript/clerk#redirect-to-organization-profile) instead.\n */\nexport const RedirectToOrganizationProfile = withClerk(({ clerk }) => {\n React.useEffect(() => {\n deprecated('RedirectToOrganizationProfile', 'Use the `redirectToOrganizationProfile()` method instead.');\n void clerk.redirectToOrganizationProfile();\n }, []);\n\n return null;\n}, 'RedirectToOrganizationProfile');\n\n/**\n * @function\n * @deprecated Use [`redirectToCreateOrganization()`](https://clerk.com/docs/reference/javascript/clerk#redirect-to-create-organization) instead.\n */\nexport const RedirectToCreateOrganization = withClerk(({ clerk }) => {\n React.useEffect(() => {\n deprecated('RedirectToCreateOrganization', 'Use the `redirectToCreateOrganization()` method instead.');\n void clerk.redirectToCreateOrganization();\n }, []);\n\n return null;\n}, 'RedirectToCreateOrganization');\n\nexport const AuthenticateWithRedirectCallback = withClerk(\n ({ clerk, ...handleRedirectCallbackParams }: WithClerkProp<HandleOAuthCallbackParams>) => {\n React.useEffect(() => {\n void clerk.handleRedirectCallback(handleRedirectCallbackParams);\n }, []);\n\n return null;\n },\n 'AuthenticateWithRedirectCallback',\n);\n\nexport const MultisessionAppSupport = ({ children }: React.PropsWithChildren<unknown>) => {\n useAssertWrappedByClerkProvider('MultisessionAppSupport');\n\n const session = useSessionContext();\n return <React.Fragment key={session ? session.id : 'no-users'}>{children}</React.Fragment>;\n};\n","export { SessionContext, useSessionContext } from '@clerk/shared/react';\n"],"mappings":";;;;;;;;;;AAAA,SAAS,kBAAkB;AAE3B,OAAO,WAAW;;;ACFlB,SAAS,gBAAgB,yBAAyB;;;ADW3C,IAAM,cAAc,CAAC,EAAE,SAAS,MAAwC;AAC7E,kCAAgC,aAAa;AAE7C,QAAM,kBAAkB,0BAA0B;AAClD,MAAI,CAAC,gBAAgB,QAAQ;AAC3B,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEO,IAAM,eAAe,CAAC,EAAE,SAAS,MAAwC;AAC9E,kCAAgC,cAAc;AAE9C,QAAM,kBAAkB,0BAA0B;AAClD,MAAI,gBAAgB,WAAW,WAAW;AACxC,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEO,IAAM,cAAc,CAAC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;AAEO,IAAM,yBAAyB,CAAC,EAAE,SAAS,MAAwC;AACxF,kCAAgC,wBAAwB;AAExD,QAAM,UAAU,kBAAkB;AAClC,SAAO,oCAAC,MAAM,UAAN,EAAe,KAAK,UAAU,QAAQ,KAAK,cAAa,QAAS;AAC3E;","names":[]}
|
package/dist/experimental.d.mts
CHANGED
|
@@ -8,27 +8,26 @@ import '@clerk/shared/ui';
|
|
|
8
8
|
import '@clerk/ui/internal';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* A button component that opens the Clerk Checkout drawer when clicked.
|
|
12
|
-
* inside a `<SignedIn />` component to ensure the user is authenticated.
|
|
11
|
+
* A button component that opens the Clerk Checkout drawer when clicked. Render only when the user is signed in (e.g., wrap with `<Show when="signed-in">`).
|
|
13
12
|
*
|
|
14
13
|
* @example
|
|
15
14
|
* ```tsx
|
|
16
|
-
* import {
|
|
15
|
+
* import { Show } from '@clerk/react';
|
|
17
16
|
* import { CheckoutButton } from '@clerk/react/experimental';
|
|
18
17
|
*
|
|
19
18
|
* // Basic usage with default "Checkout" text
|
|
20
19
|
* function BasicCheckout() {
|
|
21
20
|
* return (
|
|
22
|
-
* <
|
|
21
|
+
* <Show when="signed-in">
|
|
23
22
|
* <CheckoutButton planId="plan_123" />
|
|
24
|
-
* </
|
|
23
|
+
* </Show>
|
|
25
24
|
* );
|
|
26
25
|
* }
|
|
27
26
|
*
|
|
28
27
|
* // Custom button with organization subscription
|
|
29
28
|
* function OrganizationCheckout() {
|
|
30
29
|
* return (
|
|
31
|
-
* <
|
|
30
|
+
* <Show when="signed-in">
|
|
32
31
|
* <CheckoutButton
|
|
33
32
|
* planId="plan_123"
|
|
34
33
|
* planPeriod="month"
|
|
@@ -37,12 +36,12 @@ import '@clerk/ui/internal';
|
|
|
37
36
|
* >
|
|
38
37
|
* <button className="custom-button">Subscribe Now</button>
|
|
39
38
|
* </CheckoutButton>
|
|
40
|
-
* </
|
|
39
|
+
* </Show>
|
|
41
40
|
* );
|
|
42
41
|
* }
|
|
43
42
|
* ```
|
|
44
43
|
*
|
|
45
|
-
* @throws {Error} When rendered
|
|
44
|
+
* @throws {Error} When rendered while the user is signed out
|
|
46
45
|
* @throws {Error} When `for="organization"` is used without an active organization context
|
|
47
46
|
*
|
|
48
47
|
* @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
|
|
@@ -58,22 +57,22 @@ declare const CheckoutButton: {
|
|
|
58
57
|
*
|
|
59
58
|
* @example
|
|
60
59
|
* ```tsx
|
|
61
|
-
* import {
|
|
60
|
+
* import { Show } from '@clerk/react';
|
|
62
61
|
* import { PlanDetailsButton } from '@clerk/react/experimental';
|
|
63
62
|
*
|
|
64
63
|
* // Basic usage with default "Plan details" text
|
|
65
64
|
* function BasicPlanDetails() {
|
|
66
|
-
* return
|
|
67
|
-
* <PlanDetailsButton planId="plan_123" />
|
|
68
|
-
* );
|
|
65
|
+
* return <PlanDetailsButton planId="plan_123" />;
|
|
69
66
|
* }
|
|
70
67
|
*
|
|
71
68
|
* // Custom button with custom text
|
|
72
69
|
* function CustomPlanDetails() {
|
|
73
70
|
* return (
|
|
74
|
-
* <
|
|
75
|
-
* <
|
|
76
|
-
*
|
|
71
|
+
* <Show when="signed-in">
|
|
72
|
+
* <PlanDetailsButton planId="plan_123">
|
|
73
|
+
* <button>View Plan Details</button>
|
|
74
|
+
* </PlanDetailsButton>
|
|
75
|
+
* </Show>
|
|
77
76
|
* );
|
|
78
77
|
* }
|
|
79
78
|
* ```
|
|
@@ -86,34 +85,38 @@ declare const PlanDetailsButton: {
|
|
|
86
85
|
};
|
|
87
86
|
|
|
88
87
|
/**
|
|
89
|
-
* A button component that opens the Clerk Subscription Details drawer when clicked.
|
|
88
|
+
* A button component that opens the Clerk Subscription Details drawer when clicked. Render only when the user is signed in (e.g., wrap with `<Show when="signed-in">`).
|
|
90
89
|
*
|
|
91
90
|
* @example
|
|
92
91
|
* ```tsx
|
|
93
|
-
* import {
|
|
92
|
+
* import { Show } from '@clerk/react';
|
|
94
93
|
* import { SubscriptionDetailsButton } from '@clerk/react/experimental';
|
|
95
94
|
*
|
|
96
95
|
* // Basic usage with default "Subscription details" text
|
|
97
96
|
* function BasicSubscriptionDetails() {
|
|
98
97
|
* return (
|
|
99
|
-
* <
|
|
98
|
+
* <Show when="signed-in">
|
|
99
|
+
* <SubscriptionDetailsButton />
|
|
100
|
+
* </Show>
|
|
100
101
|
* );
|
|
101
102
|
* }
|
|
102
103
|
*
|
|
103
104
|
* // Custom button with Organization Subscription
|
|
104
105
|
* function OrganizationSubscriptionDetails() {
|
|
105
106
|
* return (
|
|
106
|
-
* <
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
107
|
+
* <Show when="signed-in">
|
|
108
|
+
* <SubscriptionDetailsButton
|
|
109
|
+
* for="organization"
|
|
110
|
+
* onSubscriptionCancel={() => console.log('Subscription canceled')}
|
|
111
|
+
* >
|
|
112
|
+
* <button>View Organization Subscription</button>
|
|
113
|
+
* </SubscriptionDetailsButton>
|
|
114
|
+
* </Show>
|
|
112
115
|
* );
|
|
113
116
|
* }
|
|
114
117
|
* ```
|
|
115
118
|
*
|
|
116
|
-
* @throws {Error} When rendered
|
|
119
|
+
* @throws {Error} When rendered while the user is signed out
|
|
117
120
|
* @throws {Error} When `for="organization"` is used without an Active Organization context
|
|
118
121
|
*
|
|
119
122
|
* @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
|
package/dist/experimental.d.ts
CHANGED
|
@@ -8,27 +8,26 @@ import '@clerk/shared/ui';
|
|
|
8
8
|
import '@clerk/ui/internal';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* A button component that opens the Clerk Checkout drawer when clicked.
|
|
12
|
-
* inside a `<SignedIn />` component to ensure the user is authenticated.
|
|
11
|
+
* A button component that opens the Clerk Checkout drawer when clicked. Render only when the user is signed in (e.g., wrap with `<Show when="signed-in">`).
|
|
13
12
|
*
|
|
14
13
|
* @example
|
|
15
14
|
* ```tsx
|
|
16
|
-
* import {
|
|
15
|
+
* import { Show } from '@clerk/react';
|
|
17
16
|
* import { CheckoutButton } from '@clerk/react/experimental';
|
|
18
17
|
*
|
|
19
18
|
* // Basic usage with default "Checkout" text
|
|
20
19
|
* function BasicCheckout() {
|
|
21
20
|
* return (
|
|
22
|
-
* <
|
|
21
|
+
* <Show when="signed-in">
|
|
23
22
|
* <CheckoutButton planId="plan_123" />
|
|
24
|
-
* </
|
|
23
|
+
* </Show>
|
|
25
24
|
* );
|
|
26
25
|
* }
|
|
27
26
|
*
|
|
28
27
|
* // Custom button with organization subscription
|
|
29
28
|
* function OrganizationCheckout() {
|
|
30
29
|
* return (
|
|
31
|
-
* <
|
|
30
|
+
* <Show when="signed-in">
|
|
32
31
|
* <CheckoutButton
|
|
33
32
|
* planId="plan_123"
|
|
34
33
|
* planPeriod="month"
|
|
@@ -37,12 +36,12 @@ import '@clerk/ui/internal';
|
|
|
37
36
|
* >
|
|
38
37
|
* <button className="custom-button">Subscribe Now</button>
|
|
39
38
|
* </CheckoutButton>
|
|
40
|
-
* </
|
|
39
|
+
* </Show>
|
|
41
40
|
* );
|
|
42
41
|
* }
|
|
43
42
|
* ```
|
|
44
43
|
*
|
|
45
|
-
* @throws {Error} When rendered
|
|
44
|
+
* @throws {Error} When rendered while the user is signed out
|
|
46
45
|
* @throws {Error} When `for="organization"` is used without an active organization context
|
|
47
46
|
*
|
|
48
47
|
* @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
|
|
@@ -58,22 +57,22 @@ declare const CheckoutButton: {
|
|
|
58
57
|
*
|
|
59
58
|
* @example
|
|
60
59
|
* ```tsx
|
|
61
|
-
* import {
|
|
60
|
+
* import { Show } from '@clerk/react';
|
|
62
61
|
* import { PlanDetailsButton } from '@clerk/react/experimental';
|
|
63
62
|
*
|
|
64
63
|
* // Basic usage with default "Plan details" text
|
|
65
64
|
* function BasicPlanDetails() {
|
|
66
|
-
* return
|
|
67
|
-
* <PlanDetailsButton planId="plan_123" />
|
|
68
|
-
* );
|
|
65
|
+
* return <PlanDetailsButton planId="plan_123" />;
|
|
69
66
|
* }
|
|
70
67
|
*
|
|
71
68
|
* // Custom button with custom text
|
|
72
69
|
* function CustomPlanDetails() {
|
|
73
70
|
* return (
|
|
74
|
-
* <
|
|
75
|
-
* <
|
|
76
|
-
*
|
|
71
|
+
* <Show when="signed-in">
|
|
72
|
+
* <PlanDetailsButton planId="plan_123">
|
|
73
|
+
* <button>View Plan Details</button>
|
|
74
|
+
* </PlanDetailsButton>
|
|
75
|
+
* </Show>
|
|
77
76
|
* );
|
|
78
77
|
* }
|
|
79
78
|
* ```
|
|
@@ -86,34 +85,38 @@ declare const PlanDetailsButton: {
|
|
|
86
85
|
};
|
|
87
86
|
|
|
88
87
|
/**
|
|
89
|
-
* A button component that opens the Clerk Subscription Details drawer when clicked.
|
|
88
|
+
* A button component that opens the Clerk Subscription Details drawer when clicked. Render only when the user is signed in (e.g., wrap with `<Show when="signed-in">`).
|
|
90
89
|
*
|
|
91
90
|
* @example
|
|
92
91
|
* ```tsx
|
|
93
|
-
* import {
|
|
92
|
+
* import { Show } from '@clerk/react';
|
|
94
93
|
* import { SubscriptionDetailsButton } from '@clerk/react/experimental';
|
|
95
94
|
*
|
|
96
95
|
* // Basic usage with default "Subscription details" text
|
|
97
96
|
* function BasicSubscriptionDetails() {
|
|
98
97
|
* return (
|
|
99
|
-
* <
|
|
98
|
+
* <Show when="signed-in">
|
|
99
|
+
* <SubscriptionDetailsButton />
|
|
100
|
+
* </Show>
|
|
100
101
|
* );
|
|
101
102
|
* }
|
|
102
103
|
*
|
|
103
104
|
* // Custom button with Organization Subscription
|
|
104
105
|
* function OrganizationSubscriptionDetails() {
|
|
105
106
|
* return (
|
|
106
|
-
* <
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
107
|
+
* <Show when="signed-in">
|
|
108
|
+
* <SubscriptionDetailsButton
|
|
109
|
+
* for="organization"
|
|
110
|
+
* onSubscriptionCancel={() => console.log('Subscription canceled')}
|
|
111
|
+
* >
|
|
112
|
+
* <button>View Organization Subscription</button>
|
|
113
|
+
* </SubscriptionDetailsButton>
|
|
114
|
+
* </Show>
|
|
112
115
|
* );
|
|
113
116
|
* }
|
|
114
117
|
* ```
|
|
115
118
|
*
|
|
116
|
-
* @throws {Error} When rendered
|
|
119
|
+
* @throws {Error} When rendered while the user is signed out
|
|
117
120
|
* @throws {Error} When `for="organization"` is used without an Active Organization context
|
|
118
121
|
*
|
|
119
122
|
* @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change. It is advised to [pin](https://clerk.com/docs/pinning) the SDK version and the clerk-js version to avoid breaking changes.
|
package/dist/experimental.js
CHANGED
|
@@ -1194,7 +1194,9 @@ var CheckoutButton = withClerk(
|
|
|
1194
1194
|
} = props;
|
|
1195
1195
|
const { userId, orgId } = useAuth();
|
|
1196
1196
|
if (userId === null) {
|
|
1197
|
-
throw new Error(
|
|
1197
|
+
throw new Error(
|
|
1198
|
+
'Clerk: Ensure that `<CheckoutButton />` is rendered only when the user is signed in (wrap with `<Show when="signed-in">` or guard with `useAuth()`).'
|
|
1199
|
+
);
|
|
1198
1200
|
}
|
|
1199
1201
|
if (orgId === null && _for === "organization") {
|
|
1200
1202
|
throw new Error(
|
|
@@ -1272,7 +1274,7 @@ var SubscriptionDetailsButton = withClerk(
|
|
|
1272
1274
|
const { userId, orgId } = useAuth();
|
|
1273
1275
|
if (userId === null) {
|
|
1274
1276
|
throw new Error(
|
|
1275
|
-
|
|
1277
|
+
'Clerk: Ensure that `<SubscriptionDetailsButton />` is rendered only when the user is signed in (wrap with `<Show when="signed-in">` or guard with `useAuth()`).'
|
|
1276
1278
|
);
|
|
1277
1279
|
}
|
|
1278
1280
|
if (orgId === null && _for === "organization") {
|