phone-match.d.ts 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import { AbstractMatch, AbstractMatchConfig } from './abstract-match';
  2. /**
  3. * @class Autolinker.match.Phone
  4. * @extends Autolinker.match.AbstractMatch
  5. *
  6. * Represents a Phone number match found in an input string which should be
  7. * Autolinked.
  8. *
  9. * See this class's superclass ({@link Autolinker.match.Match}) for more
  10. * details.
  11. */
  12. export declare class PhoneMatch extends AbstractMatch {
  13. /**
  14. * @public
  15. * @property {'phone'} type
  16. *
  17. * A string name for the type of match that this class represents. Can be
  18. * used in a TypeScript discriminating union to type-narrow from the
  19. * `Match` type.
  20. */
  21. readonly type: 'phone';
  22. /**
  23. * @protected
  24. * @property {String} number (required)
  25. *
  26. * The phone number that was matched, without any delimiter characters.
  27. *
  28. * Note: This is a string to allow for prefixed 0's.
  29. */
  30. private readonly number;
  31. /**
  32. * @protected
  33. * @property {Boolean} plusSign (required)
  34. *
  35. * `true` if the matched phone number started with a '+' sign. We'll include
  36. * it in the `tel:` URL if so, as this is needed for international numbers.
  37. *
  38. * Ex: '+1 (123) 456 7879'
  39. */
  40. private readonly plusSign;
  41. /**
  42. * @method constructor
  43. * @param {Object} cfg The configuration properties for the Match
  44. * instance, specified in an Object (map).
  45. */
  46. constructor(cfg: PhoneMatchConfig);
  47. /**
  48. * Returns a string name for the type of match that this class represents.
  49. * For the case of PhoneMatch, returns 'phone'.
  50. *
  51. * @return {String}
  52. */
  53. getType(): 'phone';
  54. /**
  55. * Returns the phone number that was matched as a string, without any
  56. * delimiter characters.
  57. *
  58. * Note: This is a string to allow for prefixed 0's.
  59. *
  60. * @return {String}
  61. */
  62. getPhoneNumber(): string;
  63. /**
  64. * Alias of {@link #getPhoneNumber}, returns the phone number that was
  65. * matched as a string, without any delimiter characters.
  66. *
  67. * Note: This is a string to allow for prefixed 0's.
  68. *
  69. * @return {String}
  70. */
  71. getNumber(): string;
  72. /**
  73. * Returns the anchor href that should be generated for the match.
  74. *
  75. * @return {String}
  76. */
  77. getAnchorHref(): string;
  78. /**
  79. * Returns the anchor text that should be generated for the match.
  80. *
  81. * @return {String}
  82. */
  83. getAnchorText(): string;
  84. }
  85. export interface PhoneMatchConfig extends AbstractMatchConfig {
  86. number: string;
  87. plusSign: boolean;
  88. }