Skip to content

Commit 42306d0

Browse files
authored
chore(astro): Export <CreateOrganization /> Astro component (#5876)
1 parent 3c2c060 commit 42306d0

File tree

5 files changed

+31
-4
lines changed

5 files changed

+31
-4
lines changed

.changeset/lazy-frogs-breathe.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
"@clerk/astro": patch
3+
---
4+
5+
Export `<CreateOrganization />` Astro component
6+
7+
Usage:
8+
9+
```astro
10+
---
11+
import { CreateOrganization } from '@clerk/astro/components'
12+
---
13+
14+
<CreateOrganization />
15+
```

packages/astro/src/astro-components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export { UserProfile } from './interactive/UserProfile';
2323
export { OrganizationProfile } from './interactive/OrganizationProfile';
2424
export { OrganizationSwitcher } from './interactive/OrganizationSwitcher';
2525
export { default as OrganizationList } from './interactive/OrganizationList.astro';
26+
export { default as CreateOrganization } from './interactive/CreateOrganization.astro';
2627
export { default as GoogleOneTap } from './interactive/GoogleOneTap.astro';
2728
export { default as Waitlist } from './interactive/Waitlist.astro';
2829
export { default as PricingTable } from './interactive/PricingTable.astro';
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
import type { CreateOrganizationProps } from "@clerk/types";
3+
type Props = CreateOrganizationProps
4+
5+
import InternalUIComponentRenderer from './InternalUIComponentRenderer.astro'
6+
---
7+
8+
<InternalUIComponentRenderer {...Astro.props} component="create-organization" />

packages/astro/src/internal/mount-clerk-astro-js-components.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { Clerk } from '@clerk/types';
2+
13
import { $clerk } from '../stores/internal';
24
import type { InternalUIComponentId } from '../types';
35

@@ -6,6 +8,7 @@ import type { InternalUIComponentId } from '../types';
68
*/
79
const mountAllClerkAstroJSComponents = () => {
810
const mountFns = {
11+
'create-organization': 'mountCreateOrganization',
912
'organization-list': 'mountOrganizationList',
1013
'organization-profile': 'mountOrganizationProfile',
1114
'organization-switcher': 'mountOrganizationSwitcher',
@@ -16,14 +19,13 @@ const mountAllClerkAstroJSComponents = () => {
1619
'google-one-tap': 'openGoogleOneTap',
1720
waitlist: 'mountWaitlist',
1821
'pricing-table': 'mountPricingTable',
19-
} as const satisfies Record<InternalUIComponentId, string>;
22+
} as const satisfies Record<InternalUIComponentId, keyof Clerk>;
2023

2124
Object.entries(mountFns).forEach(([category, mountFn]) => {
2225
const elementsOfCategory = document.querySelectorAll(`[data-clerk-id^="clerk-${category}"]`);
2326
elementsOfCategory.forEach(el => {
24-
const clerkId = el.getAttribute('data-clerk-id');
25-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
26-
const props = window.__astro_clerk_component_props?.get(category)?.get(clerkId!);
27+
const clerkId = el.getAttribute('data-clerk-id') as string;
28+
const props = window.__astro_clerk_component_props?.get(category)?.get(clerkId);
2729
if (el) {
2830
$clerk.get()?.[mountFn](el as HTMLDivElement, props);
2931
}

packages/astro/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export type ButtonProps<Tag> = {
8787
export type InternalUIComponentId =
8888
| 'sign-in'
8989
| 'sign-up'
90+
| 'create-organization'
9091
| 'organization-list'
9192
| 'organization-profile'
9293
| 'organization-switcher'

0 commit comments

Comments
 (0)