react-map-interaction icon indicating copy to clipboard operation
react-map-interaction copied to clipboard

Need Types For Typescript

Open dimaslanjaka opened this issue 3 years ago • 3 comments

This packages doesn't have d.ts files

dimaslanjaka avatar Sep 26 '22 19:09 dimaslanjaka

For reference, this is what I'm using for now:

declare module 'react-map-interaction' {
  type Translation = {
    x: number;
    y: number;
  };

  export type MapInteractionProps = {
    children?: ({
      scale,
      translation,
    }: {
      scale: number;
      translation: Translation;
    }) => import('react').ReactNode;

    value?: {
      scale: number;
      translation: Translation;
    };

    defaultValue?: {
      scale: number;
      translation: Translation;
    };

    disableZoom?: boolean;

    disablePan?: boolean;

    translationBounds?: {
      xMin?: number;
      xMax?: number;
      yMin?: number;
      yMax?: number;
    };

    onChange?: ({
      scale,
      translation,
    }: {
      scale: number;
      translation: Translation;
    }) => void;

    minScale?: number;
    maxScale?: number;

    showControls?: boolean;

    plusBtnContents?: import('react').ReactNode;
    minusBtnContents?: import('react').ReactNode;

    controlsClass?: string;

    btnClass?: string;

    plusBtnClass?: string;
    minusBtnClass?: string;
  };
  export const MapInteraction: import('react').FC<MapInteractionProps>;

  export type MapInteractionCSSProps = import('react').PropsWithChildren<
    Omit<MapInteractionProps, 'children'>
  >;
  export const MapInteractionCSS: import('react').FC<MapInteractionCSSProps>;

  export default MapInteraction;
}

ghost91- avatar Apr 14 '23 13:04 ghost91-

Thanks @ghost91-

Added ScaleTranslation:

declare module 'react-map-interaction' {
  export type Translation = {
    x: number;
    y: number;
  };

  export type ScaleTranslation = {
    scale: number;
    translation: Translation;
  };

  export type MapInteractionProps = {
    children?: (scaleTranslation: ScaleTranslation) => import('react').ReactNode;

    value?: ScaleTranslation;

    defaultValue?: ScaleTranslation;

    disableZoom?: boolean;

    disablePan?: boolean;

    translationBounds?: {
      xMin?: number;
      xMax?: number;
      yMin?: number;
      yMax?: number;
    };

    onChange?: (scaleTranslation: ScaleTranslation) => void;

    minScale?: number;
    maxScale?: number;

    showControls?: boolean;

    plusBtnContents?: import('react').ReactNode;
    minusBtnContents?: import('react').ReactNode;

    controlsClass?: string;

    btnClass?: string;

    plusBtnClass?: string;
    minusBtnClass?: string;
  };
  export const MapInteraction: import('react').FC<MapInteractionProps>;

  export type MapInteractionCSSProps = import('react').PropsWithChildren<Omit<MapInteractionProps, 'children'>>;
  export const MapInteractionCSS: import('react').FC<MapInteractionCSSProps>;

  export default MapInteraction;
}

redlab-chris avatar Jun 26 '24 14:06 redlab-chris

Would be great if the package can be updated with full TS support.

redlab-chris avatar Jun 26 '24 14:06 redlab-chris