button.d.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { PointerEvent as PointerEvent_2 } from '@thednp/shorty';
  2. /** Returns a new `BaseComponent` instance. */
  3. declare class BaseComponent {
  4. element: Element;
  5. options?: BaseOptions;
  6. /**
  7. * @param target `Element` or selector string
  8. * @param config component instance options
  9. */
  10. constructor(target: Element | string, config?: BaseOptions);
  11. get version(): string;
  12. get name(): string;
  13. get defaults(): {};
  14. /** just to have something to extend from */
  15. _toggleEventListeners: () => void;
  16. /** Removes component from target element. */
  17. dispose(): void;
  18. }
  19. declare interface BaseOptions {
  20. [key: string]: unknown;
  21. }
  22. /** Creates a new `Button` instance. */
  23. declare class Button extends BaseComponent {
  24. static selector: string;
  25. static init: (element: Element) => Button;
  26. static getInstance: (element: Element) => Button | null;
  27. isActive: boolean;
  28. element: HTMLElement;
  29. /**
  30. * @param target usually a `.btn` element
  31. */
  32. constructor(target: Element | string);
  33. /**
  34. * Returns component name string.
  35. */
  36. get name(): string;
  37. /**
  38. * Toggles the state of the target button.
  39. *
  40. * @param e usually `click` Event object
  41. */
  42. toggle: (e?: PointerEvent_2<HTMLElement>) => void;
  43. /**
  44. * Toggles on/off the `click` event listener.
  45. *
  46. * @param add when `true`, event listener is added
  47. */
  48. _toggleEventListeners: (add?: boolean) => void;
  49. /** Removes the `Button` component from the target element. */
  50. dispose(): void;
  51. }
  52. export default Button;
  53. export { }