types.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // single
  2. export const directions = ['top', 'right', 'bottom', 'left', 'topRight', 'bottomRight', 'bottomLeft', 'topLeft'] as const;
  3. export type Direction = 'top' | 'right' | 'bottom' | 'left' | 'topRight' | 'bottomRight' | 'bottomLeft' | 'topLeft';
  4. export interface HandleClassName {
  5. top?: string;
  6. right?: string;
  7. bottom?: string;
  8. left?: string;
  9. topRight?: string;
  10. bottomRight?: string;
  11. bottomLeft?: string;
  12. topLeft?: string
  13. }
  14. export type ResizeEventType = 'mouse' | 'touch';
  15. export type HandlerCallback = (
  16. e: MouseEvent,
  17. direction: Direction,
  18. type?: ResizeEventType,
  19. ) => void;
  20. export interface Enable {
  21. top?: boolean;
  22. right?: boolean;
  23. bottom?: boolean;
  24. left?: boolean;
  25. topRight?: boolean;
  26. bottomRight?: boolean;
  27. bottomLeft?: boolean;
  28. topLeft?: boolean
  29. }
  30. export interface Size {
  31. width?: string | number;
  32. height?: string | number
  33. }
  34. export interface NumberSize {
  35. width: number;
  36. height: number
  37. }
  38. export interface NewSize {
  39. newHeight: number | string;
  40. newWidth: number | string
  41. }
  42. export const DEFAULT_SIZE = {
  43. width: 'auto',
  44. height: 'auto',
  45. };
  46. export type ResizeCallback = (
  47. size: Size,
  48. event: MouseEvent | TouchEvent,
  49. direction: Direction,
  50. ) => void;
  51. export type ResizeStartCallback = (
  52. e: MouseEvent | Touch,
  53. dir: Direction,
  54. ) => void | boolean;