UNPKG

1.58 kBTypeScriptView Raw
1import { Component } from "react";
2import { Icon, IconProps, ImageSource } from "./Icon";
3
4export const FA5Style: {
5 regular: 0;
6 light: 1;
7 solid: 2;
8 brand: 3;
9};
10
11export type ValueOf<T> = T[keyof T];
12
13// borrowed from
14// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html
15export type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
16
17export type FontAwesome5IconVariants = keyof Omit<typeof FA5Style, "regular">;
18
19// modified from https://stackoverflow.com/a/49725198/1105281
20export type AllowOnlyOne<T, Keys extends keyof T = keyof T> = Omit<T, Keys> &
21 {
22 [K in Keys]-?: Partial<Pick<T, K>> &
23 Partial<Record<Exclude<Keys, K>, undefined>>
24 }[Keys];
25
26export type FontAwesome5IconProps = AllowOnlyOne<
27 { [K in FontAwesome5IconVariants]?: boolean } & IconProps,
28 FontAwesome5IconVariants
29>;
30
31export default class FontAwesome5Icon extends Component<
32 FontAwesome5IconProps,
33 any
34> {
35 static getImageSource(
36 name: string,
37 size?: number,
38 color?: string,
39 fa5Style?: ValueOf<typeof FA5Style>
40 ): Promise<ImageSource>;
41 static getImageSourceSync(
42 name: string,
43 size?: number,
44 color?: string,
45 fa5Style?: ValueOf<typeof FA5Style>
46 ): ImageSource;
47 static loadFont(file?: string): Promise<void>;
48 static hasIcon(name: string): boolean;
49 static ToolbarAndroid: typeof Icon.ToolbarAndroid;
50 static TabBarItem: typeof Icon.TabBarItem;
51 static TabBarItemIOS: typeof Icon.TabBarItemIOS;
52 static Button: typeof Icon.Button;
53}