|
1 | 1 | import * as React from 'react'; |
2 | 2 | import { StandardProps, PropTypes } from '..'; |
| 3 | +import { OverrideProps, OverridableTypeMap, OverridableComponent } from '../OverridableComponent'; |
3 | 4 | import { ThemeStyle } from '../styles/createTypography'; |
4 | 5 |
|
5 | 6 | type Style = ThemeStyle | 'srOnly'; |
6 | 7 |
|
7 | | -export interface TypographyProps |
8 | | - extends StandardProps<React.HTMLAttributes<HTMLElement>, TypographyClassKey> { |
9 | | - align?: PropTypes.Alignment; |
10 | | - color?: |
11 | | - | 'initial' |
12 | | - | 'inherit' |
13 | | - | 'primary' |
14 | | - | 'secondary' |
15 | | - | 'textPrimary' |
16 | | - | 'textSecondary' |
17 | | - | 'error'; |
18 | | - component?: React.ElementType<React.HTMLAttributes<HTMLElement>>; |
19 | | - display?: 'initial' | 'block' | 'inline'; |
20 | | - gutterBottom?: boolean; |
21 | | - noWrap?: boolean; |
22 | | - paragraph?: boolean; |
23 | | - variant?: Style | 'inherit'; |
24 | | - variantMapping?: Partial<Record<Style, string>>; |
| 8 | +export interface TypographyTypeMap<P = {}, D extends React.ElementType = 'span'> { |
| 9 | + props: P & { |
| 10 | + align?: PropTypes.Alignment; |
| 11 | + color?: |
| 12 | + | 'initial' |
| 13 | + | 'inherit' |
| 14 | + | 'primary' |
| 15 | + | 'secondary' |
| 16 | + | 'textPrimary' |
| 17 | + | 'textSecondary' |
| 18 | + | 'error'; |
| 19 | + display?: 'initial' | 'block' | 'inline'; |
| 20 | + gutterBottom?: boolean; |
| 21 | + noWrap?: boolean; |
| 22 | + paragraph?: boolean; |
| 23 | + variant?: Style | 'inherit'; |
| 24 | + variantMapping?: Partial<Record<Style, string>>; |
| 25 | + }; |
| 26 | + defaultComponent: D; |
| 27 | + classKey: TypographyClassKey; |
25 | 28 | } |
26 | 29 |
|
| 30 | +declare const Typography: OverridableComponent<TypographyTypeMap>; |
| 31 | + |
| 32 | +export type TypographyProps< |
| 33 | + D extends React.ElementType = TypographyTypeMap['defaultComponent'], |
| 34 | + P = {} |
| 35 | +> = OverrideProps<TypographyTypeMap<P, D>, D>; |
| 36 | + |
27 | 37 | export type TypographyClassKey = |
28 | 38 | | 'root' |
29 | 39 | | 'h1' |
@@ -54,6 +64,4 @@ export type TypographyClassKey = |
54 | 64 | | 'displayInline' |
55 | 65 | | 'displayBlock'; |
56 | 66 |
|
57 | | -declare const Typography: React.ComponentType<TypographyProps>; |
58 | | - |
59 | 67 | export default Typography; |
0 commit comments