mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-04 17:20:09 +00:00
React flatpickr/add render prop (#36215)
* Add render prop to DateTimePickerProps This prop was added in v3.8.0 version of react-flatpickr https://github.com/haoxins/react-flatpickr/releases/tag/v3.8.0. Render prop was added in this PR https://github.com/haoxins/react-flatpickr/pull/90 * Add contributor name * Fix lint errors * Bump version to 3.8
This commit is contained in:
committed by
Daniel Rosenwasser
parent
e4c87b94f3
commit
dce45b7f52
6
types/react-flatpickr/index.d.ts
vendored
6
types/react-flatpickr/index.d.ts
vendored
@@ -1,12 +1,13 @@
|
||||
// Type definitions for react-flatpickr 3.7
|
||||
// Type definitions for react-flatpickr 3.8
|
||||
// Project: https://github.com/coderhaoxin/react-flatpickr
|
||||
// Definitions by: begincalendar <https://github.com/begincalendar>
|
||||
// snaveevans <https://github.com/snaveevans>
|
||||
// rigothedev <https://github.com/rigothedev>
|
||||
// doniyor2109 <https://github.com/doniyor2109>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { Component } from "react";
|
||||
import { Component, ReactElement } from "react";
|
||||
import flatpickr from "flatpickr";
|
||||
|
||||
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||
@@ -24,6 +25,7 @@ export interface DateTimePickerProps extends Omit<Partial<HTMLInputElement>, 'va
|
||||
onDayCreate?: flatpickr.Options.Hook;
|
||||
value?: string | Date | number | ReadonlyArray<string | Date | number>;
|
||||
className?: string;
|
||||
render?: (props: Omit<DateTimePickerProps, 'options' | 'render'>, ref: (node: HTMLInputElement) => void) => ReactElement;
|
||||
}
|
||||
|
||||
export default class DatePicker extends Component<DateTimePickerProps> {}
|
||||
|
||||
@@ -42,5 +42,8 @@ const valueDateArrayElement = (
|
||||
const valueNumberArrayElement = (
|
||||
<DatePicker value={[1543516477474, 1544549477474]} />
|
||||
);
|
||||
const customRender = (
|
||||
<DatePicker render={({value}, ref) => <input ref={ref} value={value ? value.toString() : ''} />} />
|
||||
);
|
||||
|
||||
const extraInputPropertiesElement = <DatePicker placeholder="Enter a date..." id="datepicker-1" />;
|
||||
|
||||
Reference in New Issue
Block a user