File size: 458 Bytes
56fda74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
export {};

interface ThemeWithProps<Components> {
  components?: { [K in keyof Components]: { defaultProps?: Partial<Components[K]> } };
}

type ThemedProps<Theme, Name extends keyof any> = Theme extends {
  components: Record<Name, { defaultProps: infer Props }>;
}
  ? Props
  : {};

export default function getThemeProps<Theme, Props, Name extends keyof any>(params: {
  props: Props;
  name: Name;
  theme?: Theme;
}): Props & ThemedProps<Theme, Name>;