-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.ts
74 lines (70 loc) · 2.39 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { INamedContext } from '..'
import { configureContainerFlex } from '@/components/ContainerFlex'
import { configurePortal } from '@/components/Portal'
import { configurePortalPlaceHolder } from '@/components/Portal/PortalPlaceHolder'
import { configureUseLogger } from '@/hooks/useLogger'
import { configureUseTheme } from '@/hooks/useTheme'
import { LoggerMapping } from '@/libs/createToolbox/createConfiguration/loggerMapping'
import { PortalNames } from '@/libs/createToolbox/createConfiguration/portals'
import { Roles } from '@/libs/createToolbox/createConfiguration/roles'
import { Theme } from '@/libs/createToolbox/createConfiguration/theme'
import {
configureGetDataTestAttributeProp,
configureGetDataTestAttributeValue
} from '@/libs/dataTestAttribute/hooks'
/**
* Define the different parameters that will be passed to IProviderValue.
*/
export interface IConfiguration<
TLoggerMapping = LoggerMapping,
TTheme = Theme,
TRoles = Roles,
TPortalNames = PortalNames
> {
loggerMapping: TLoggerMapping
theme: TTheme
roles: TRoles
portalNames: TPortalNames
}
/**
* Interface of the value passed to the Provider.
*/
export type IProviderValue<TConfiguration extends IConfiguration> = {
[K in keyof TConfiguration]: TConfiguration[K]
}
/**
* Configuration returned by `createConfiguration`.
*/
export type Configuration<TConfiguration> = IConfiguration & TConfiguration
/**
* Toolbox returned by `createToolbox`.
*/
export type Toolbox<TConfiguration extends IConfiguration> = {
name: string
configuration: Configuration<TConfiguration>
components: {
Provider: INamedContext<
IProviderValue<TConfiguration>
>['ProviderNamedContext']
ContainerFlex: ReturnType<typeof configureContainerFlex<TConfiguration>>
Portal: ReturnType<typeof configurePortal<TConfiguration>>
PortalPlaceHolder: ReturnType<
typeof configurePortalPlaceHolder<TConfiguration>
>
}
hooks: {
useNamedContext: INamedContext<
IProviderValue<TConfiguration>
>['useNamedContext']
useLogger: ReturnType<typeof configureUseLogger<TConfiguration>>
useTheme: ReturnType<typeof configureUseTheme<TConfiguration>>
}
helpers: {
getDataTestAttributeValue: ReturnType<
typeof configureGetDataTestAttributeValue<TConfiguration['roles']>
>
getDataTestAttributeProp: ReturnType<
typeof configureGetDataTestAttributeProp<TConfiguration['roles']>
>
}
}