index.d.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. import {IconDefinition, IconLookup, IconName, IconPrefix, IconPathData, IconPack } from '@fortawesome/fontawesome-common-types';
  2. export {IconDefinition, IconLookup, IconName, IconPrefix, 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 };
  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. | "xs"
  24. | "lg"
  25. | "sm"
  26. | "1x"
  27. | "2x"
  28. | "3x"
  29. | "4x"
  30. | "5x"
  31. | "6x"
  32. | "7x"
  33. | "8x"
  34. | "9x"
  35. | "10x";
  36. export type PullProp = "left" | "right";
  37. export type RotateProp = 90 | 180 | 270;
  38. export type FaSymbol = string | boolean;
  39. export interface Config {
  40. familyPrefix: IconPrefix;
  41. replacementClass: string;
  42. autoReplaceSvg: boolean | 'nest';
  43. autoAddCss: boolean;
  44. autoA11y: boolean;
  45. searchPseudoElements: boolean;
  46. observeMutations: boolean;
  47. keepOriginalSource: boolean;
  48. measurePerformance: boolean;
  49. showMissingIcons: boolean;
  50. }
  51. export interface AbstractElement {
  52. tag: string;
  53. attributes: any;
  54. children?: AbstractElement[];
  55. }
  56. export interface FontawesomeObject {
  57. readonly abstract: AbstractElement[];
  58. readonly html: string[];
  59. readonly node: HTMLCollection;
  60. }
  61. export interface Icon extends FontawesomeObject, IconDefinition {
  62. readonly type: "icon";
  63. }
  64. export interface Text extends FontawesomeObject {
  65. readonly type: "text";
  66. }
  67. export interface Counter extends FontawesomeObject {
  68. readonly type: "counter";
  69. }
  70. export interface Layer extends FontawesomeObject {
  71. readonly type: "layer";
  72. }
  73. type IconOrText = Icon | Text;
  74. export interface Attributes {
  75. [key: string]: number | string;
  76. }
  77. export interface Styles {
  78. [key: string]: string;
  79. }
  80. export interface Transform {
  81. size?: number;
  82. x?: number;
  83. y?: number;
  84. rotate?: number;
  85. flipX?: boolean;
  86. flipY?: boolean;
  87. }
  88. export interface Params {
  89. title?: string;
  90. titleId?: string;
  91. classes?: string | string[];
  92. attributes?: Attributes;
  93. styles?: Styles;
  94. }
  95. export interface CounterParams extends Params {
  96. }
  97. export interface LayerParams {
  98. classes?: string | string[];
  99. }
  100. export interface TextParams extends Params {
  101. transform?: Transform;
  102. }
  103. export interface IconParams extends Params {
  104. transform?: Transform;
  105. symbol?: FaSymbol;
  106. mask?: IconLookup;
  107. maskId?: string;
  108. }
  109. export interface DOM {
  110. i2svg(params?: { node: Node; callback: () => void }): Promise<void>;
  111. css(): string;
  112. insertCss(): string;
  113. watch(): void;
  114. }
  115. type IconDefinitionOrPack = IconDefinition | IconPack;
  116. export interface Library {
  117. add(...definitions: IconDefinitionOrPack[]): void;
  118. reset(): void;
  119. }