-
Notifications
You must be signed in to change notification settings - Fork 734
Feat/date time picker ts #1694
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
Merged
Merged
Feat/date time picker ts #1694
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
cc53881
Convert DateTimePicker to TS
ethanshar bfbf563
Fix TS error
ethanshar fff12df
Merge branch 'master' into feat/DateTimePicker_TS
ethanshar f0046d7
Merge branch 'master' into feat/DateTimePicker_TS
ethanshar 3f268c7
migrate date time picker screen to tsx
ethanshar a033add
Fix typings issues
ethanshar b681781
Remove redundant import
ethanshar 2c11cdd
ignore usages of useCustomTheme for now
ethanshar 2115474
Merge branch 'master' into feat/DateTimePicker_TS
ethanshar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
declare const validators: { | ||
required: (value: string) => boolean; | ||
email: (value: string) => boolean; | ||
url: (value: string) => boolean; | ||
number: (value: string) => boolean; | ||
price: (value: string) => boolean; | ||
}; | ||
export default validators; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import 'react'; | ||
import { BaseComponent } from '../../commons'; | ||
export default class BaseInput extends BaseComponent { | ||
static displayName: string; | ||
static propTypes: any; | ||
static defaultProps: { | ||
validateOnBlur: boolean; | ||
}; | ||
constructor(props: any); | ||
componentDidMount(): void; | ||
/** Events */ | ||
onFocus: (...args: any[]) => void; | ||
onBlur: (...args: any[]) => void; | ||
onChange: (event: any) => void; | ||
onChangeText: (text: any) => void; | ||
/** Actions */ | ||
getTypography(): any; | ||
hasText(): any; | ||
isFocused(): any; | ||
focus(): void; | ||
blur(): void; | ||
clear(): void; | ||
validate: any; | ||
isRequiredField(): boolean; | ||
getRequiredPlaceholder(placeholder: any): any; | ||
getErrorMessage(): any; | ||
getColor(value: string): string; | ||
toggleExpandableModal(...args: any[]): any; | ||
} |
121 changes: 121 additions & 0 deletions
121
generatedTypes/src/components/dateTimePicker/index.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import React, { Component } from 'react'; | ||
import { StyleProp, ViewStyle } from 'react-native'; | ||
import { BaseComponentInjectedProps } from '../../commons/new'; | ||
import { DialogProps } from '../dialog'; | ||
/** | ||
* @description: Date and Time Picker Component that wraps RNDateTimePicker for date and time modes. | ||
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/DateTimePickerScreen.js | ||
* @important: DateTimePicker uses a native library. You MUST add and link the native library to both iOS and Android projects. | ||
* @extends: TextField, react-native-community/datetimepicker | ||
* @extendsLink: https://github.com/react-native-community/react-native-datetimepicker#react-native-datetimepicker | ||
* @gif: https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/DateTimePicker/DateTimePicker_iOS.gif?raw=true, https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/DateTimePicker/DateTimePicker_Android.gif?raw=true | ||
*/ | ||
export interface DateTimePickerProps { | ||
/** | ||
* The type of picker to display ('date' or 'time') | ||
*/ | ||
mode?: 'date' | 'time'; | ||
/** | ||
* The initial value to set the picker to. Defaults to device's date / time | ||
*/ | ||
value?: Date; | ||
/** | ||
* The onChange callback | ||
*/ | ||
onChange?: (date: Date) => void; | ||
/** | ||
* The minimum date or time value to use | ||
*/ | ||
minimumDate?: Date; | ||
/** | ||
* The maximum date or time value to use | ||
*/ | ||
maximumDate?: Date; | ||
/** | ||
* The date format for the text display | ||
*/ | ||
dateFormat?: string; | ||
/** | ||
* A callback function to format date | ||
*/ | ||
dateFormatter?: (date: Date) => string; | ||
/** | ||
* The time format for the text display | ||
*/ | ||
timeFormat?: string; | ||
/** | ||
* A callback function to format time | ||
*/ | ||
timeFormatter?: (date: Date) => string; | ||
/** | ||
* Allows changing of the locale of the component (iOS only) | ||
*/ | ||
locale?: string; | ||
/** | ||
* Allows changing of the time picker to a 24 hour format (Android only) | ||
*/ | ||
is24Hour?: boolean; | ||
/** | ||
* The interval at which minutes can be selected. Possible values are: 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30 (iOS only) | ||
*/ | ||
minuteInterval?: number; | ||
/** | ||
* Allows changing of the timeZone of the date picker. By default it uses the device's time zone (iOS only) | ||
*/ | ||
timeZoneOffsetInMinutes?: number; | ||
/** | ||
* Props to pass the Dialog component | ||
*/ | ||
dialogProps?: DialogProps; | ||
/** | ||
* style to apply to the iOS dialog header | ||
*/ | ||
headerStyle?: StyleProp<ViewStyle>; | ||
/** | ||
* Render custom input | ||
*/ | ||
renderInput?: () => React.ReactElement; | ||
/** | ||
* Override system theme variant (dark or light mode) used by the date picker. | ||
*/ | ||
themeVariant?: 'light' | 'dark'; | ||
/** | ||
* The component testID | ||
*/ | ||
testID?: string; | ||
} | ||
interface DateTimePickerState { | ||
showExpandableOverlay: boolean; | ||
prevValue?: Date; | ||
value?: Date; | ||
} | ||
declare type DateTimePickerPropsInternal = DateTimePickerProps & BaseComponentInjectedProps; | ||
declare class DateTimePicker extends Component<DateTimePickerPropsInternal, DateTimePickerState> { | ||
static displayName: string; | ||
static defaultProps: { | ||
mode: string; | ||
enableErrors: boolean; | ||
validateOnBlur: boolean; | ||
}; | ||
chosenDate?: Date; | ||
constructor(props: DateTimePickerPropsInternal); | ||
static getDerivedStateFromProps(nextProps: DateTimePickerProps, prevState: DateTimePickerState): { | ||
prevValue: Date | undefined; | ||
value: Date | undefined; | ||
} | null; | ||
handleChange: (event: any, date: Date) => void; | ||
toggleExpandableOverlay: (callback?: (() => void) | undefined) => void; | ||
onToggleExpandableModal: (value: boolean) => void; | ||
onDonePressed: () => void; | ||
getStringValue: () => string | undefined; | ||
renderExpandableOverlay: () => JSX.Element; | ||
renderHeader(): JSX.Element; | ||
renderDateTimePicker(): JSX.Element | null | undefined; | ||
renderExpandable: () => JSX.Element | null | undefined; | ||
render(): JSX.Element; | ||
} | ||
export { DateTimePicker }; | ||
declare const _default: React.ComponentClass<DateTimePickerProps & { | ||
useCustomTheme?: boolean | undefined; | ||
}, any>; | ||
export default _default; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/// <reference types="react" /> | ||
import BaseInput from '../baseInput'; | ||
/** | ||
* @description: A wrapper for TextInput component with extra functionality like floating placeholder and validations (This is an uncontrolled component) | ||
* @modifiers: Typography | ||
* @extends: TextInput | ||
* @extendsLink: https://reactnative.dev/docs/textinput | ||
* @gif: https://media.giphy.com/media/xULW8su8Cs5Z9Fq4PS/giphy.gif, https://media.giphy.com/media/3ohc1dhDcLS9FvWLJu/giphy.gif, https://media.giphy.com/media/oNUSOxnHdMP5ZnKYsh/giphy.gif | ||
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/TextFieldScreen/BasicTextFieldScreen.js | ||
*/ | ||
export default class TextField extends BaseInput { | ||
static displayName: string; | ||
static propTypes: any; | ||
static defaultProps: { | ||
enableErrors: boolean; | ||
validateOnBlur: boolean; | ||
}; | ||
constructor(props: any); | ||
UNSAFE_componentWillReceiveProps(nextProps: any): void; | ||
componentDidUpdate(_prevProps: any, prevState: any): void; | ||
onPlaceholderLayout: (event: any) => void; | ||
/** Actions */ | ||
generatePropsWarnings(props: any): void; | ||
generateStyles(): void; | ||
getAccessibilityInfo(): { | ||
accessibilityLabel: any; | ||
accessibilityState: { | ||
disabled: boolean; | ||
} | undefined; | ||
}; | ||
toggleExpandableModal: (value: any) => void; | ||
updateFloatingPlaceholderState: (withoutAnimation: any) => void; | ||
getPlaceholderText: (this: any, placeholder: any, helperText: any) => any; | ||
getStateColor(colorProp?: {}): any; | ||
getCharCount(): any; | ||
setCharCountColor(key: any): void; | ||
getCharCountColor(): any; | ||
getTopPaddings(): 25 | undefined; | ||
getTopErrorsPosition(): { | ||
top: number; | ||
} | undefined; | ||
isDisabled(): boolean; | ||
isCounterLimit(): boolean; | ||
hasText(value: any): boolean; | ||
shouldShowHelperText(): any; | ||
shouldFloatOnFocus(): any; | ||
shouldFloatPlaceholder(text: any): any; | ||
shouldFakePlaceholder(): boolean; | ||
shouldShowError(): any; | ||
getErrorMessage(): any; | ||
shouldShowTopError(): any; | ||
shouldDisplayRightButton(): any; | ||
shouldRenderTitle(): any; | ||
onPressRightButton: () => void; | ||
/** Renders */ | ||
renderPlaceholder(): JSX.Element | undefined; | ||
renderPrefix(): JSX.Element | undefined; | ||
renderTitle(): JSX.Element | undefined; | ||
renderCharCounter(): JSX.Element | undefined; | ||
renderError(visible: any): JSX.Element | undefined; | ||
renderExpandableModal(): any; | ||
renderExpandableInput(): any; | ||
renderTextInput(): JSX.Element; | ||
renderRightButton(): JSX.Element | undefined; | ||
renderRightIcon(): JSX.Element | undefined; | ||
render(): JSX.Element; | ||
/** Events */ | ||
onDoneEditingExpandableInput: () => void; | ||
onKeyPress: (event: any) => void; | ||
onChangeText: (text: any) => void; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import _ from 'lodash'; | ||
import {EmailValidator} from 'commons-validator-js'; | ||
|
||
const urlRegEx = | ||
/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?$/i; //eslint-disable-line | ||
const decimalNumberRegEx = /^-?\d+[.,]?\d+$/; | ||
const integerRegEx = /^-?\d*$/; // allows empty string | ||
const priceRegEx = /^[0-9]{1,9}([.][0-9]{1,2})?$/; | ||
|
||
const validators = { | ||
required: (value: string) => !_.isEmpty(value), | ||
email: (value: string) => new EmailValidator().isValid(value), | ||
url: (value: string) => urlRegEx.test(value), | ||
number: (value: string) => integerRegEx.test(value) || decimalNumberRegEx.test(value), | ||
price: (value: string) => priceRegEx.test(value) | ||
}; | ||
|
||
export default validators; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.