|
1 | | -/** |
2 | | - * UI-related types and utilities |
3 | | - */ |
| 1 | +import type { Appearance, Clerk, ClerkOptions, EnvironmentResource } from '../types'; |
4 | 2 |
|
5 | | -// Placeholder - Add UI-specific types and utilities here |
6 | 3 | export type UIVersion = string; |
7 | 4 |
|
8 | | -// TODO: replace with a proper interface |
9 | | -export type MountComponentRenderer = ( |
10 | | - clerk: any, |
11 | | - environment: any, |
12 | | - options: any, |
13 | | -) => { |
14 | | - ensureMounted: (options?: { preloadHint?: string }) => Promise<{ |
15 | | - mountImpersonationFab: () => void; |
16 | | - updateProps: (props: any) => void; |
17 | | - openModal: (name: string, props: any) => void; |
18 | | - closeModal: (name: string) => void; |
19 | | - openDrawer: (name: string, props: any) => void; |
20 | | - closeDrawer: (name: string) => void; |
21 | | - mountComponent: (config: any) => void; |
22 | | - unmountComponent: (config: any) => void; |
23 | | - prefetch: (name: string) => void; |
24 | | - }>; |
| 5 | +export type ComponentControls = { |
| 6 | + mountComponent: (params: { appearanceKey: string; name: string; node: HTMLDivElement; props?: any }) => void; |
| 7 | + unmountComponent: (params: { node: HTMLDivElement }) => void; |
| 8 | + updateProps: (params: { |
| 9 | + appearance?: Appearance | undefined; |
| 10 | + options?: ClerkOptions | undefined; |
| 11 | + node?: HTMLDivElement; |
| 12 | + props?: unknown; |
| 13 | + }) => void; |
| 14 | + openModal: (modal: string, props?: any) => void; |
| 15 | + closeModal: (modal: string, options?: { notify?: boolean }) => void; |
| 16 | + openDrawer: (drawer: string, props?: any) => void; |
| 17 | + closeDrawer: (drawer: string, options?: { notify?: boolean }) => void; |
| 18 | + prefetch: (component: 'organizationSwitcher') => void; |
| 19 | + mountImpersonationFab: () => void; |
25 | 20 | }; |
26 | 21 |
|
27 | | -export interface ClerkUiEntry { |
28 | | - resolve: () => Promise<MountComponentRenderer>; |
| 22 | +// Instance shape that the class will implement |
| 23 | +export interface ClerkUiInstance { |
| 24 | + version: string; |
| 25 | + ensureMounted: (opts?: { preloadHint?: string }) => Promise<ComponentControls>; |
29 | 26 | } |
| 27 | + |
| 28 | +// Constructor type |
| 29 | +export interface ClerkUiConstructor { |
| 30 | + new ( |
| 31 | + getClerk: () => Clerk, |
| 32 | + getEnvironment: () => EnvironmentResource | null | undefined, |
| 33 | + options: ClerkOptions, |
| 34 | + importModule: (module: string) => Promise<any>, |
| 35 | + ): ClerkUiInstance; |
| 36 | + version: string; |
| 37 | +} |
| 38 | + |
| 39 | +export type ClerkUi = ClerkUiInstance; |
0 commit comments