index.d.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. export as namespace fontawesome;
  2. import {IconDefinition, IconLookup, IconName, IconPrefix, IconPack } from '@fortawesome/fontawesome-common-types';
  3. export {IconDefinition, IconLookup, IconName, IconPrefix, IconPack } from '@fortawesome/fontawesome-common-types';
  4. export const dom: DOM;
  5. export const library: Library;
  6. export const parse: { transform(transformString: string): Transform };
  7. export const config: Config;
  8. export function noAuto():void;
  9. export function findIconDefinition(iconLookup: IconLookup): IconDefinition;
  10. export function text(content: string, params?: Params): Text;
  11. export function layer(
  12. assembler: (
  13. addLayerCallback: (layerToAdd: IconOrText | IconOrText[]) => void
  14. ) => void
  15. ): Layer;
  16. export function icon(icon: IconName | IconLookup, params?: IconParams): Icon;
  17. declare const api: {
  18. dom: DOM;
  19. library: Library;
  20. parse: { transform(transformString: string): Transform };
  21. config: Config;
  22. noAuto():void;
  23. findIconDefinition(iconLookup: IconLookup): IconDefinition;
  24. text(content: string, params?: Params): Text;
  25. layer(
  26. assembler: (
  27. addLayerCallback: (layerToAdd: IconOrText | IconOrText[]) => void
  28. ) => void
  29. ): Layer;
  30. icon(icon: IconName | IconLookup, params?: IconParams): Icon;
  31. }
  32. export default api;
  33. export type IconProp = IconName | [IconPrefix, IconName] | IconLookup;
  34. export type FlipProp = "horizontal" | "vertical" | "both";
  35. export type SizeProp =
  36. | "xs"
  37. | "lg"
  38. | "sm"
  39. | "1x"
  40. | "2x"
  41. | "3x"
  42. | "4x"
  43. | "5x"
  44. | "6x"
  45. | "7x"
  46. | "8x"
  47. | "9x"
  48. | "10x";
  49. export type PullProp = "left" | "right";
  50. export type RotateProp = 90 | 180 | 270;
  51. export type FaSymbol = string | boolean;
  52. export interface Config {
  53. familyPrefix: IconPrefix;
  54. replacementClass: string;
  55. autoReplaceSvg: boolean | 'nest';
  56. autoAddCss: boolean;
  57. autoA11y: boolean;
  58. searchPseudoElements: boolean;
  59. observeMutations: boolean;
  60. keepOriginalSource: boolean;
  61. measurePerformance: boolean;
  62. showMissingIcons: boolean;
  63. }
  64. export interface AbstractElement {
  65. tag: string;
  66. attributes: any;
  67. children?: AbstractElement[];
  68. }
  69. export interface FontawesomeObject {
  70. readonly abstract: AbstractElement[];
  71. readonly html: string[];
  72. readonly node: HTMLCollection;
  73. }
  74. export interface Icon extends FontawesomeObject, IconDefinition {
  75. readonly type: "icon";
  76. }
  77. export interface Text extends FontawesomeObject {
  78. readonly type: "text";
  79. }
  80. export interface Layer extends FontawesomeObject {
  81. readonly type: "layer";
  82. }
  83. type IconOrText = Icon | Text;
  84. export interface Attributes {
  85. [key: string]: number | string;
  86. }
  87. export interface Styles {
  88. [key: string]: string;
  89. }
  90. export interface Transform {
  91. size?: number;
  92. x?: number;
  93. y?: number;
  94. rotate?: number;
  95. flipX?: boolean;
  96. flipY?: boolean;
  97. }
  98. export interface Params {
  99. transform?: Transform;
  100. title?: string;
  101. classes?: string | string[];
  102. attributes?: Attributes;
  103. styles?: Styles;
  104. }
  105. export interface IconParams extends Params {
  106. symbol?: FaSymbol;
  107. mask?: IconLookup;
  108. }
  109. export interface DOM {
  110. i2svg(params: { node: Node; callback: () => void }): void;
  111. css(): string;
  112. insertCss(): string;
  113. }
  114. type IconDefinitionOrPack = IconDefinition | IconPack;
  115. export interface Library {
  116. add(...definitions: IconDefinitionOrPack[]): void;
  117. reset(): void;
  118. }