Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added typescript types to the package #108

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0-beta.91",
"description": "A customizable calendar, time & month picker for React Native (including Persian Jalaali calendar & locale)",
"main": "src/index.js",
"types": "src/types/index.d.ts",
"scripts": {
"playground": "cd playground && react-native start"
},
Expand Down
62 changes: 62 additions & 0 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import type {FunctionComponent} from 'react';
import type { StyleProp, ViewStyle } from "react-native";

declare const ModernDatePicker:FunctionComponent
export default ModernDatePicker
export declare function getFormatedDate(date?: Date, format?: string):string
export declare function getToday():string

export interface ModernDatePickerProps {
/** Gets called when selected value changes */
onSelectedChange: (dateString: string) => void
/** Gets called when month changes */
onMonthYearChange: (dateString: string) => void
/** Gets called when time changes */
onTimeChange: (dateString: string) => void
/** Gets called when date changes */
onDateChange: (dateString: string) => void

/** Initially visible month */
current: string
/** The primary value of the date picker */
selected: string
/** Specifies the minimum selectable day by user */
minimumDate: string
/** Specifies the maximum selectable day by user */
maximumDate: string

/** The minimum selectable year when user opens the year selector */
selectorStartingYear: number
/** The maxium selectable year when user opens the year selector */
selectorEndingYear: number

/** Disable month & year from being changed */
disableDateChange: boolean
/** Switches between 'Gregorian' & 'Jalaali' mode */
isGregorian: boolean

/** Customizing date picker style */
options: Partial<ModernDatePickerOptions>

mode: 'datepicker' | 'calendar' | 'monthYear' | 'time'

minuteInterval: 1 | 2 | 3 | 4 | 5 | 6 | 10 | 12 | 15 | 20 | 30 | 60

/** Changes date picker container style */
style: StyleProp<ViewStyle>
}

export interface ModernDatePickerOptions {
textHeaderColor: string
textDefaultColor: string
selectedTextColor: string
mainColor: string
textSecondaryColor: string
borderColor: string
defaultFont: string
headerFont: string
textFontSize: number
textHeaderFontSize: number
headerAnimationDistance: number
daysAnimationDistance: number
}