Skip to content

Commit 195b93b

Browse files
authored
Dialog and Panning - allow union type for direction (#1635)
1 parent b069236 commit 195b93b

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

generatedTypes/src/components/dialog/DialogDismissibleView.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ declare const DialogDismissibleView: {
3131
(props: Props): JSX.Element;
3232
displayName: string;
3333
defaultProps: {
34-
direction: PanningDirections;
34+
direction: import("../panningViews/panningProvider").PanningDirectionsEnum;
3535
onDismiss: () => void;
3636
};
3737
};

generatedTypes/src/components/panningViews/panningProvider.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { Component } from 'react';
2-
export declare enum PanningDirections {
2+
export declare enum PanningDirectionsEnum {
33
UP = "up",
44
DOWN = "down",
55
LEFT = "left",
66
RIGHT = "right"
77
}
8+
export declare type PanningDirectionsUnion = `${PanningDirectionsEnum}`;
9+
export declare type PanningDirections = PanningDirectionsEnum | PanningDirectionsUnion;
810
export interface PanLocationProps {
911
left?: number;
1012
top?: number;
@@ -31,7 +33,7 @@ interface State {
3133
*/
3234
export default class PanningProvider extends Component<any, State> {
3335
static displayName: string;
34-
static Directions: typeof PanningDirections;
36+
static Directions: typeof PanningDirectionsEnum;
3537
constructor(props: any);
3638
getProviderContextValue: () => {
3739
onPanStart: () => void;

src/components/dialog/DialogDismissibleView.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,11 @@ const DialogDismissibleView = (props: Props) => {
199199
}, []);
200200

201201
const resetToShown = useCallback((left: number, top: number, direction: PanningDirections) => {
202-
const toValue = [PanningProvider.Directions.LEFT, PanningProvider.Directions.RIGHT].includes(direction)
203-
? 1 + left / hiddenLocation.current.left
204-
: 1 + top / hiddenLocation.current.top;
202+
const toValue =
203+
//@ts-expect-error
204+
[PanningProvider.Directions.LEFT, PanningProvider.Directions.RIGHT].includes(direction)
205+
? 1 + left / hiddenLocation.current.left
206+
: 1 + top / hiddenLocation.current.top;
205207

206208
animateTo(toValue);
207209
},

src/components/panningViews/panningProvider.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import React, {Component} from 'react';
22
import PanningContext from './panningContext';
33

4-
5-
export enum PanningDirections {
4+
export enum PanningDirectionsEnum {
65
UP = 'up',
76
DOWN = 'down',
87
LEFT = 'left',
98
RIGHT = 'right'
109
}
1110

11+
export type PanningDirectionsUnion = `${PanningDirectionsEnum}`;
12+
13+
export type PanningDirections = PanningDirectionsEnum | PanningDirectionsUnion;
14+
1215
export interface PanLocationProps {
1316
left?: number;
1417
top?: number;
@@ -39,7 +42,7 @@ interface State {
3942
*/
4043
export default class PanningProvider extends Component<any, State> {
4144
static displayName = 'IGNORE';
42-
static Directions = PanningDirections;
45+
static Directions = PanningDirectionsEnum;
4346

4447
constructor(props: any) {
4548
super(props);

0 commit comments

Comments
 (0)