Skip to content

Commit bb7da7c

Browse files
authored
Literal enum typings (#2892)
* Page control enum * Fader position enum * FloatingButtonLayouts enum * GradientTypes enum * MarqueeDirections enum * OverlayIntesityType enum * GestureDirections enum * PanningDirectionsEnum enum * Picker enums * SkeletonView enums * GradientSliderTypes enum * tabControll OffsetType enum * Timline enums * WizardStepsState enum * useScrollToItem OffsetType * Calendar types * PanView tiny change * ts fixes * Reverted change to overlay type * Skeleton better typing
1 parent 88b06e7 commit bb7da7c

File tree

19 files changed

+27
-27
lines changed

19 files changed

+27
-27
lines changed

src/components/carousel/types.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export interface CarouselProps extends ScrollViewProps {
6262
/**
6363
* The position of the PageControl component ['over', 'under'], otherwise it won't display
6464
*/
65-
pageControlPosition?: PageControlPosition;
65+
pageControlPosition?: PageControlPosition | `${PageControlPosition}`;
6666
/**
6767
* whether to show a page counter (will not work with 'pageWidth' prop)
6868
*/

src/components/fader/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export type FaderProps = Pick<ImageProps, 'supportRTL'> & {
2020
/**
2121
* The position of the fader (the image is different), defaults to Fader.position.END
2222
*/
23-
position?: FaderPosition;
23+
position?: FaderPosition | `${FaderPosition}`;
2424
/**
2525
* Set to change from the default size (50) of the fade view.
2626
*/

src/components/floatingButton/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export interface FloatingButtonProps {
4949
/**
5050
* Button layout direction: vertical or horizontal
5151
*/
52-
buttonLayout?: FloatingButtonLayouts;
52+
buttonLayout?: FloatingButtonLayouts | `${FloatingButtonLayouts}`;
5353
}
5454

5555
const gradientImage = () => require('./gradient.png');

src/components/gradient/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export enum GradientTypes {
1414

1515
export interface GradientProps {
1616
color?: string | tinycolor.ColorFormats.HSLA;
17-
type?: GradientTypes;
17+
type?: GradientTypes | `${GradientTypes}`;
1818
numberOfSteps: number;
1919
style?: StyleProp<ViewStyle>;
2020
}

src/components/marquee/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export type MarqueeProps = PropsWithChildren<{
2121
/**
2222
* Marquee direction
2323
*/
24-
direction?: MarqueeDirections;
24+
direction?: MarqueeDirections | `${MarqueeDirections}`;
2525
/**
2626
* Marquee animation duration
2727
*/

src/components/overlay/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export type OverlayTypes = {
3131
/**
3232
* The intensity of the gradient, default is 'LOW'.
3333
*/
34-
intensity?: OverlayIntensityType;
34+
intensity?: OverlayIntensityType | `${OverlayIntensityType}`;
3535
/**
3636
* The overlay color
3737
*/
@@ -91,7 +91,7 @@ class Overlay extends PureComponent<OverlayTypes> {
9191
return <Image style={[styles.container, style]} resizeMode={'stretch'} source={source}/>;
9292
};
9393

94-
getImageSource = (type?: OverlayTypeType, intensity?: OverlayIntensityType) => {
94+
getImageSource = (type?: OverlayTypeType, intensity?: OverlayTypes['intensity']) => {
9595
if (type !== OVERLY_TYPES.SOLID) {
9696
if (intensity === OverlayIntensityType.MEDIUM) {
9797
return gradientImageMed;

src/components/panningViews/panGestureView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export interface PanGestureViewProps {
3030
/**
3131
* The direction of the allowed pan (default is down)
3232
*/
33-
direction?: GestureDirections;
33+
direction?: GestureDirections | `${GestureDirections}`;
3434
children?: React.ReactNode;
3535
}
3636

src/components/panningViews/panningProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export enum PanningDirectionsEnum {
88
RIGHT = 'right'
99
}
1010

11-
export type PanningDirectionsUnion = 'up' | 'down' | 'left' | 'right';
11+
export type PanningDirectionsUnion = `${PanningDirectionsEnum}`;
1212

1313
export type PanningDirections = PanningDirectionsEnum | PanningDirectionsUnion;
1414

src/components/picker/types.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export type PickerBaseProps = Omit<NewTextFieldProps, 'value' | 'onChange'> & {
6161
/**
6262
* Pass for different field type UI (form, filter or settings)
6363
*/
64-
fieldType?: PickerFieldTypes;
64+
fieldType?: PickerFieldTypes | `${PickerFieldTypes}`;
6565
/**
6666
* Picker current value in the shape of {value: ..., label: ...}, for custom shape use 'getItemValue' prop
6767
*/
@@ -73,7 +73,7 @@ export type PickerBaseProps = Omit<NewTextFieldProps, 'value' | 'onChange'> & {
7373
/**
7474
* SINGLE mode or MULTI mode
7575
*/
76-
mode?: PickerModes;
76+
mode?: PickerModes | `${PickerModes}`;
7777
/**
7878
* Limit the number of selected items
7979
*/

src/components/skeletonView/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ export interface SkeletonListProps {
3333
* The size of the skeleton view.
3434
* Types: SMALL and LARGE (using SkeletonView.sizes.###)
3535
*/
36-
size?: Size;
36+
size?: Size | `${Size}`;
3737
/**
3838
* Add content to the skeleton.
3939
* Types: AVATAR and THUMBNAIL (using SkeletonView.contentTypes.###)
4040
*/
41-
contentType?: ContentType;
41+
contentType?: ContentType | `${ContentType}`;
4242
/**
4343
* Whether to hide the list item template separator
4444
*/
@@ -71,7 +71,7 @@ export interface SkeletonViewProps extends AccessibilityProps, AlignmentModifier
7171
* The type of the skeleton view.
7272
* Types: LIST_ITEM and TEXT_CONTENT (using SkeletonView.templates.###)
7373
*/
74-
template?: Template;
74+
template?: Template | `${Template}`;
7575
/**
7676
* Props that are available when using template={SkeletonView.templates.LIST_ITEM}
7777
*/
@@ -151,7 +151,7 @@ class SkeletonView extends Component<SkeletonViewProps, SkeletonState> {
151151
contentAccessibilityProps?: AccessibilityProps;
152152
listItemAccessibilityProps?: AccessibilityProps;
153153

154-
setAccessibilityProps(template?: Template) {
154+
setAccessibilityProps(template?: SkeletonViewProps['template']) {
155155
const isListItem = template === Template.LIST_ITEM;
156156
const accessibilityProps = {
157157
accessible: true,

0 commit comments

Comments
 (0)