mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 07:47:04 +00:00
['react-swipeable-views-utils'] Add missing 'virtualized' and 'bindKeyboard' functions (#42336)
* Added missing 'virtualized' and 'bindKeyboard' functions for react-swipeable-views-utils * Revert "Added missing 'virtualized' and 'bindKeyboard' functions for react-swipeable-views-utils" This reverts commit a04ff4db27a444480d78d34fe2434231fc6dc066. * Added missing 'virtualized' and 'bindKeyboard' functions for react-swipeable-views-utils-tests * Added children prop for `virtualize` * Fixed `Bind element 'number' has an 'any' type` error * Fixed `file should end with a newline` error
This commit is contained in:
+36
-1
@@ -1,12 +1,13 @@
|
||||
// Type definitions for react-swipeable-views-utils 0.13
|
||||
// Project: https://github.com/oliviertassinari/react-swipeable-views#react-swipeable-views
|
||||
// Definitions by: Sebastian Silbermann <https://github.com/eps1lon>
|
||||
// Robert Nisipeanu <https://github.com/robertnisipeanu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
import * as React from 'react';
|
||||
import { ConsistentWith, Omit, PropInjector } from '@material-ui/types';
|
||||
import { OnChangeIndexCallback, OnSwitchingCallback } from 'react-swipeable-views';
|
||||
import { OnChangeIndexCallback, OnSwitchingCallback, OnTransitionEndCallback } from 'react-swipeable-views';
|
||||
|
||||
export interface WithAutoPlay {
|
||||
index: number;
|
||||
@@ -22,4 +23,38 @@ export interface WithAutoPlayProps {
|
||||
slideCount?: number;
|
||||
}
|
||||
|
||||
export interface WithVirtualize {
|
||||
index: number;
|
||||
onChangeIndex: OnChangeIndexCallback;
|
||||
slideRenderer: (render: SlideRendererCallback) => React.ReactNode;
|
||||
}
|
||||
export interface WithVirtualizeProps {
|
||||
index: number;
|
||||
onChangeIndex: OnChangeIndexCallback;
|
||||
onTransitionEnd?: OnTransitionEndCallback;
|
||||
overscanSlideAfter?: number;
|
||||
overscanSliedBefore?: number;
|
||||
slideCount?: number;
|
||||
children?: React.ReactNode;
|
||||
slideRenderer: SlideRendererCallback;
|
||||
}
|
||||
export interface SlideRenderProps {
|
||||
index: number;
|
||||
key: number;
|
||||
}
|
||||
|
||||
export interface WithBindKeyboard {
|
||||
index: number;
|
||||
onChangeIndex: OnChangeIndexCallback;
|
||||
}
|
||||
export interface WithBindKeyboardProps {
|
||||
axis?: "x" | "x-reverse" | "y" | "y-reverse";
|
||||
index: number;
|
||||
onChangeIndex: OnChangeIndexCallback;
|
||||
slidecount?: number;
|
||||
}
|
||||
|
||||
export const autoPlay: PropInjector<WithAutoPlay, WithAutoPlayProps>;
|
||||
export type SlideRendererCallback = (render: SlideRenderProps) => React.ReactNode;
|
||||
export const virtualize: PropInjector<WithVirtualize, WithVirtualizeProps>;
|
||||
export const bindKeyboard: PropInjector<WithBindKeyboard, WithBindKeyboardProps>;
|
||||
|
||||
@@ -1,17 +1,44 @@
|
||||
import * as React from 'react';
|
||||
import SwipeableViews from 'react-swipeable-views';
|
||||
import { autoPlay } from 'react-swipeable-views-utils';
|
||||
import { autoPlay, virtualize, bindKeyboard, SlideRenderProps } from 'react-swipeable-views-utils';
|
||||
|
||||
const AutoPlaySwipeableViews = autoPlay(SwipeableViews);
|
||||
const VirtualizeSwipeableViews = virtualize(SwipeableViews);
|
||||
const BindKeyboardSwipeableViews = bindKeyboard(SwipeableViews);
|
||||
|
||||
function autoPlayTest() {
|
||||
// $ExpectError
|
||||
<AutoPlaySwipeableViews />;
|
||||
<AutoPlaySwipeableViews
|
||||
index={1}
|
||||
onChangeIndex={index => {
|
||||
onChangeIndex={(index: number) => {
|
||||
// $ExpectType number
|
||||
index;
|
||||
}}
|
||||
/>;
|
||||
}
|
||||
|
||||
function virtualizeTest() {
|
||||
// $ExpectError
|
||||
<VirtualizeSwipeableViews />;
|
||||
<VirtualizeSwipeableViews
|
||||
index={1}
|
||||
onChangeIndex={(index: number) => {
|
||||
index;
|
||||
}}
|
||||
slideRenderer={(renderer: SlideRenderProps) => {
|
||||
return <div>Slide {renderer.index}</div>;
|
||||
}}
|
||||
/>;
|
||||
}
|
||||
|
||||
function bindKeyboardTest() {
|
||||
// $ExpectError
|
||||
<BindKeyboardSwipeableViews />;
|
||||
<BindKeyboardSwipeableViews
|
||||
index={1}
|
||||
onChangeIndex={(index: number) => {
|
||||
index;
|
||||
}}
|
||||
/>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user