index.d.ts 3.5 KB

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