From 1cd412ecf22a38ff6c3c63bb7dc49fc1f92ca16f Mon Sep 17 00:00:00 2001 From: Vladimir Kharlampidi Date: Wed, 6 Sep 2023 12:43:19 +0300 Subject: [PATCH] fix(react): fix react components props type fixes #7000 --- src/swiper-react.d.ts | 83 +++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/src/swiper-react.d.ts b/src/swiper-react.d.ts index f71a8e593..0e45d3ecc 100644 --- a/src/swiper-react.d.ts +++ b/src/swiper-react.d.ts @@ -2,29 +2,42 @@ import * as React from 'react'; import type { SwiperOptions, Swiper as SwiperClass } from './types/index.d.ts'; -interface SwiperProps extends SwiperOptions { - /** - * Swiper container tag - * - * @default 'div' - */ - tag?: string; - - /** - * Swiper wrapper tag - * - * @default 'div' - */ - wrapperTag?: string; - - /** - * Get Swiper instance - */ - onSwiper?: (swiper: SwiperClass) => void; - - // CORE_EVENTS - // MODULES_EVENTS -} +type SwiperProps = Omit< + React.HTMLAttributes, + | 'onProgress' + | 'onClick' + | 'onTouchEnd' + | 'onTouchMove' + | 'onTouchStart' + | 'onTransitionEnd' + | 'onKeyPress' + | 'onDoubleClick' + | 'onScroll' + | 'onResize' +> & + SwiperOptions & { + /** + * Swiper container tag + * + * @default 'div' + */ + tag?: string; + + /** + * Swiper wrapper tag + * + * @default 'div' + */ + wrapperTag?: string; + + /** + * Get Swiper instance + */ + onSwiper?: (swiper: SwiperClass) => void; + + // CORE_EVENTS + // MODULES_EVENTS + }; interface SlideData { isActive: boolean; @@ -33,7 +46,7 @@ interface SlideData { isNext: boolean; } -interface SwiperSlideProps { +type SwiperSlideProps = Omit, 'children'> & { /** * Slide tag * @@ -68,29 +81,15 @@ interface SwiperSlideProps { * @default undefined */ children?: React.ReactNode | ((slideData: SlideData) => React.ReactNode); -} - -interface SwiperProps - extends Omit< - React.HTMLAttributes, - | 'onProgress' - | 'onClick' - | 'onTouchEnd' - | 'onTouchMove' - | 'onTouchStart' - | 'onTransitionEnd' - | 'onKeyPress' - | 'onDoubleClick' - | 'onScroll' - | 'onResize' - > {} -interface SwiperSlideProps extends Omit, 'children'> {} +}; interface SwiperRef extends React.HTMLAttributes { swiper: SwiperClass; } -declare const Swiper: React.FunctionComponent & SwiperProps>; +declare const Swiper: React.FunctionComponent< + React.RefAttributes & React.PropsWithChildren +>; declare const SwiperSlide: React.FunctionComponent; declare const useSwiper: () => SwiperClass;