@clerk/shared 3.43.2 → 3.44.0
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/runtime/authorization.d.ts.map +1 -1
- package/dist/runtime/error-CHhvPzCh.d.mts.map +1 -1
- package/dist/runtime/index-CxV4BKo8.d.mts.map +1 -1
- package/dist/runtime/index-DpElZtmn.d.ts.map +1 -1
- package/dist/runtime/index.js +2 -2
- package/dist/runtime/index.mjs +2 -2
- package/dist/runtime/{loadClerkJsScript-ClPfeAMO.js → loadClerkJsScript-B5EndzQu.js} +2 -2
- package/dist/runtime/{loadClerkJsScript-ClPfeAMO.js.map → loadClerkJsScript-B5EndzQu.js.map} +1 -1
- package/dist/runtime/{loadClerkJsScript-B6NtfI8g.mjs → loadClerkJsScript-Dz_r2Obb.mjs} +2 -2
- package/dist/runtime/{loadClerkJsScript-B6NtfI8g.mjs.map → loadClerkJsScript-Dz_r2Obb.mjs.map} +1 -1
- package/dist/runtime/loadClerkJsScript.js +2 -2
- package/dist/runtime/loadClerkJsScript.mjs +2 -2
- package/dist/runtime/pathMatcher-DPyXUfC9.d.mts.map +1 -1
- package/dist/runtime/react/index.d.mts +63 -2
- package/dist/runtime/react/index.d.mts.map +1 -1
- package/dist/runtime/react/index.d.ts +63 -2
- package/dist/runtime/react/index.d.ts.map +1 -1
- package/dist/runtime/react/index.js +66 -1
- package/dist/runtime/react/index.js.map +1 -1
- package/dist/runtime/react/index.mjs +66 -2
- package/dist/runtime/react/index.mjs.map +1 -1
- package/dist/runtime/url-Ty-8oURg.d.mts.map +1 -1
- package/dist/runtime/{versionSelector-KmjfH7w2.mjs → versionSelector-Dusdw80C.mjs} +3 -3
- package/dist/runtime/{versionSelector-KmjfH7w2.mjs.map → versionSelector-Dusdw80C.mjs.map} +1 -1
- package/dist/runtime/{versionSelector-D5G-cUjs.js → versionSelector-OqlCp7mV.js} +3 -3
- package/dist/runtime/{versionSelector-D5G-cUjs.js.map → versionSelector-OqlCp7mV.js.map} +1 -1
- package/dist/runtime/versionSelector.js +1 -1
- package/dist/runtime/versionSelector.mjs +1 -1
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -115,6 +115,7 @@ const MEMBERSHIP_REQUESTS_KEY = "membershipRequests";
|
|
|
115
115
|
const MEMBERSHIPS_KEY = "memberships";
|
|
116
116
|
const INVITATIONS_KEY = "invitations";
|
|
117
117
|
const API_KEYS_KEY = "apiKeys";
|
|
118
|
+
const ORGANIZATION_CREATION_DEFAULTS_KEY = "organizationCreationDefaults";
|
|
118
119
|
const PLANS_KEY = "billing-plans";
|
|
119
120
|
const SUBSCRIPTION_KEY = "billing-subscription";
|
|
120
121
|
const PAYMENT_METHODS_KEY = "billing-payment-methods";
|
|
@@ -133,7 +134,8 @@ const STABLE_KEYS = {
|
|
|
133
134
|
PAYMENT_METHODS_KEY,
|
|
134
135
|
PAYMENT_ATTEMPTS_KEY,
|
|
135
136
|
STATEMENTS_KEY,
|
|
136
|
-
API_KEYS_KEY
|
|
137
|
+
API_KEYS_KEY,
|
|
138
|
+
ORGANIZATION_CREATION_DEFAULTS_KEY
|
|
137
139
|
};
|
|
138
140
|
/**
|
|
139
141
|
* Internal stable keys for queries only used by our UI components.
|
|
@@ -868,6 +870,68 @@ function useOrganization(params) {
|
|
|
868
870
|
};
|
|
869
871
|
}
|
|
870
872
|
|
|
873
|
+
//#endregion
|
|
874
|
+
//#region src/react/hooks/useOrganizationCreationDefaults.shared.ts
|
|
875
|
+
function useOrganizationCreationDefaultsCacheKeys(params) {
|
|
876
|
+
const { userId } = params;
|
|
877
|
+
return useMemo(() => {
|
|
878
|
+
return createCacheKeys({
|
|
879
|
+
stablePrefix: STABLE_KEYS.ORGANIZATION_CREATION_DEFAULTS_KEY,
|
|
880
|
+
authenticated: Boolean(userId),
|
|
881
|
+
tracked: { userId: userId ?? null },
|
|
882
|
+
untracked: { args: {} }
|
|
883
|
+
});
|
|
884
|
+
}, [userId]);
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
//#endregion
|
|
888
|
+
//#region src/react/hooks/useOrganizationCreationDefaults.swr.tsx
|
|
889
|
+
/**
|
|
890
|
+
* The `useOrganizationCreationDefaults()` hook retrieves the organization creation defaults for the current user.
|
|
891
|
+
*
|
|
892
|
+
* @example
|
|
893
|
+
* ### Basic usage
|
|
894
|
+
*
|
|
895
|
+
* ```tsx
|
|
896
|
+
* import { useOrganizationCreationDefaults } from '@clerk/clerk-react'
|
|
897
|
+
*
|
|
898
|
+
* export default function CreateOrganizationForm() {
|
|
899
|
+
* const { data, isLoading } = useOrganizationCreationDefaults()
|
|
900
|
+
*
|
|
901
|
+
* if (isLoading) return <div>Loading...</div>
|
|
902
|
+
*
|
|
903
|
+
* return (
|
|
904
|
+
* <form>
|
|
905
|
+
* <input defaultValue={data?.form.name} placeholder="Organization name" />
|
|
906
|
+
* <input defaultValue={data?.form.slug} placeholder="Slug" />
|
|
907
|
+
* <button type="submit">Create</button>
|
|
908
|
+
* </form>
|
|
909
|
+
* )
|
|
910
|
+
* }
|
|
911
|
+
* ```
|
|
912
|
+
*/
|
|
913
|
+
function useOrganizationCreationDefaultsHook(params = {}) {
|
|
914
|
+
const { keepPreviousData = true, enabled = true } = params;
|
|
915
|
+
const clerk = useClerkInstanceContext();
|
|
916
|
+
const user = useUserContext();
|
|
917
|
+
const featureEnabled = clerk.__unstable__environment?.organizationSettings?.organizationCreationDefaults?.enabled ?? false;
|
|
918
|
+
clerk.telemetry?.record(eventMethodCalled("useOrganizationCreationDefaults"));
|
|
919
|
+
const { queryKey } = useOrganizationCreationDefaultsCacheKeys({ userId: user?.id ?? null });
|
|
920
|
+
const swr = useSWR(Boolean(user) && enabled && featureEnabled && clerk.loaded ? queryKey : null, () => {
|
|
921
|
+
if (!user) throw new Error("User is required to fetch organization creation defaults");
|
|
922
|
+
return user.getOrganizationCreationDefaults();
|
|
923
|
+
}, {
|
|
924
|
+
dedupingInterval: 1e3 * 60,
|
|
925
|
+
keepPreviousData
|
|
926
|
+
});
|
|
927
|
+
return {
|
|
928
|
+
data: swr.data,
|
|
929
|
+
error: swr.error ?? null,
|
|
930
|
+
isLoading: swr.isLoading,
|
|
931
|
+
isFetching: swr.isValidating
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
|
|
871
935
|
//#endregion
|
|
872
936
|
//#region src/react/hooks/useOrganizationList.tsx
|
|
873
937
|
const undefinedPaginatedResource = {
|
|
@@ -2513,5 +2577,5 @@ const usePaymentElement = () => {
|
|
|
2513
2577
|
};
|
|
2514
2578
|
|
|
2515
2579
|
//#endregion
|
|
2516
|
-
export { ClerkInstanceContext, ClientContext, OptionsContext, OrganizationProvider, SessionContext, UserContext, __experimental_CheckoutProvider, PaymentElement as __experimental_PaymentElement, PaymentElementProvider as __experimental_PaymentElementProvider, useAPIKeys as __experimental_useAPIKeys, useCheckout as __experimental_useCheckout, usePaymentAttempts as __experimental_usePaymentAttempts, usePaymentElement as __experimental_usePaymentElement, usePaymentMethods as __experimental_usePaymentMethods, usePlans as __experimental_usePlans, useStatements as __experimental_useStatements, useSubscription as __experimental_useSubscription, __internal_usePaymentAttemptQuery, usePlanDetailsQuery as __internal_usePlanDetailsQuery, __internal_useStatementQuery, assertContextExists, createContextAndHook, isDeeplyEqual, useAssertWrappedByClerkProvider, useAttemptToEnableOrganizations, useClerk, useClerkInstanceContext, useClientContext, useDeepEqualMemo, useOptionsContext, useOrganization, useOrganizationContext, useOrganizationList, useReverification, useSafeLayoutEffect, useSession, useSessionContext, useSessionList, useUser, useUserContext };
|
|
2580
|
+
export { ClerkInstanceContext, ClientContext, OptionsContext, OrganizationProvider, SessionContext, UserContext, __experimental_CheckoutProvider, PaymentElement as __experimental_PaymentElement, PaymentElementProvider as __experimental_PaymentElementProvider, useAPIKeys as __experimental_useAPIKeys, useCheckout as __experimental_useCheckout, usePaymentAttempts as __experimental_usePaymentAttempts, usePaymentElement as __experimental_usePaymentElement, usePaymentMethods as __experimental_usePaymentMethods, usePlans as __experimental_usePlans, useStatements as __experimental_useStatements, useSubscription as __experimental_useSubscription, __internal_usePaymentAttemptQuery, usePlanDetailsQuery as __internal_usePlanDetailsQuery, __internal_useStatementQuery, assertContextExists, createContextAndHook, isDeeplyEqual, useAssertWrappedByClerkProvider, useAttemptToEnableOrganizations, useClerk, useClerkInstanceContext, useClientContext, useDeepEqualMemo, useOptionsContext, useOrganization, useOrganizationContext, useOrganizationCreationDefaultsHook as useOrganizationCreationDefaults, useOrganizationList, useReverification, useSafeLayoutEffect, useSession, useSessionContext, useSessionList, useUser, useUserContext };
|
|
2517
2581
|
//# sourceMappingURL=index.mjs.map
|