|
1 | | -import { Text } from "@reflect-ui/core"; |
2 | | - |
3 | | -// export class ProxyText |
4 | | -// extends Text |
5 | | -// implements |
6 | | -// Modify< |
7 | | -// Text, |
8 | | -// { |
9 | | -// data: string | number; |
10 | | -// } |
11 | | -// > { |
12 | | -// data: string | number; |
13 | | -// } |
14 | | - |
15 | | -// type Modify<T, R> = Omit<T, keyof R> & R; |
| 1 | +import { |
| 2 | + Text, |
| 3 | + ITextStyle, |
| 4 | + TextAlign, |
| 5 | + TextAlignManifest, |
| 6 | + TextManifest, |
| 7 | + TextOverflow, |
| 8 | + TextStyleManifest, |
| 9 | + WidgetKey, |
| 10 | +} from "@reflect-ui/core"; |
| 11 | +import { Proxied } from "@reflect-ui/core/lib/_utility-types"; |
| 12 | + |
| 13 | +interface ProxiedTextManifest extends TextManifest { |
| 14 | + data: Proxied<string>; |
| 15 | + style: Proxied<TextStyleManifest>; |
| 16 | + overflow: Proxied<TextOverflow>; |
| 17 | + textAlign: Proxied<TextAlignManifest>; |
| 18 | + // textAlignVertical?: Proxied<TextAlignVerticalManifest>; |
| 19 | + maxLines?: Proxied<number>; |
| 20 | +} |
| 21 | + |
| 22 | +export class ProxiedText extends Text implements ProxiedTextManifest { |
| 23 | + // #region text manifest |
| 24 | + readonly _type: "Text" = "Text"; |
| 25 | + readonly data: Proxied<string>; |
| 26 | + readonly overflow: Proxied<TextOverflow>; |
| 27 | + readonly style: Proxied<ITextStyle>; |
| 28 | + readonly textAlign: Proxied<TextAlign>; |
| 29 | + // textAlignVertical: TextAlignVertical; |
| 30 | + readonly maxLines?: Proxied<number>; |
| 31 | + // #endregion text manifest |
| 32 | + |
| 33 | + width?: number; |
| 34 | + height?: number; |
| 35 | + |
| 36 | + constructor({ |
| 37 | + key, |
| 38 | + data, |
| 39 | + overflow = TextOverflow.ellipsis, |
| 40 | + style, |
| 41 | + textAlign, |
| 42 | + maxLines, |
| 43 | + width, |
| 44 | + height, |
| 45 | + }: { |
| 46 | + key: WidgetKey; |
| 47 | + width?: number; |
| 48 | + height?: number; |
| 49 | + } & Omit<ProxiedTextManifest, "overflow"> & { |
| 50 | + overflow?: TextOverflow; |
| 51 | + }) { |
| 52 | + super({ |
| 53 | + key: key, |
| 54 | + data, |
| 55 | + overflow, |
| 56 | + style, |
| 57 | + textAlign, |
| 58 | + maxLines, |
| 59 | + }); |
| 60 | + |
| 61 | + this.width = width; |
| 62 | + this.height = height; |
| 63 | + } |
| 64 | +} |
0 commit comments