Gathering detailed insights and metrics for rescript-react-flatpickr
Gathering detailed insights and metrics for rescript-react-flatpickr
Gathering detailed insights and metrics for rescript-react-flatpickr
Gathering detailed insights and metrics for rescript-react-flatpickr
npm install rescript-react-flatpickr
Typescript
Module System
Node Version
NPM Version
53.5
Supply Chain
85.2
Quality
74.9
Maintenance
100
Vulnerability
100
License
Cumulative downloads
Total Downloads
Last Day
0%
2
Compared to previous day
Last Week
80%
9
Compared to previous week
Last Month
61.5%
42
Compared to previous month
Last Year
-11.1%
447
Compared to previous year
3
1
Rescript binding for React Flatpickr.
Run the following in your project:
1npm install rescript-react-flatpicker --save
Then, add rescript-react-flatpickr in bsconfig.json
:
1-- "bs-dependencies": [], 2++ "bs-dependencies": ["rescript-react-flatpickr"],
This package includes required peer dependencies and therefore is the only package required to use flatpickr in your own rescript project.
Because accepting different types for a single prop is not type safe these bindings use polymorphic variants instead to represent each one of the possible types:
1@react.component 2let make = () => 3 <Flatpickr value=#date(Js.Date.now()) />;
All props are optional
string
This will be passed to the inner input
This can either be string
, array(string)
, Js.Date.t
or array(Js.Date.t)
you need to use
polymorphic variants for these to be typesafe:
string
array(string)
Js.Date.t
array(Js.Date.t)
You use them by wrapping your value in the right variant like this:
1<Flatpickr value=#str("2020-06-12") />
Js.t({..})
we provide a function that will help you generate these options for you FlatpickrOptions.make
all argument are optional and those not set will be set to flatpickr.js
defaults.
Flatpickr options
: you can pass all Flatpickr parameters
here.Flatpickr
[hooks][hooks] can be passed within this option too.Example:
1@react.component 2let make = () => { 3 let today = Js.Date.now(); 4 let daysFromNow = today -> Js.Date.fromFloat 5 6 <Flatpickr 7 options={ 8 FlatpickrOptions.make( 9 ~dateFormat="l, d/m/Y", 10 ~maxDate=#date(daysFromNow), 11 (), 12 )} 13 value=today 14 />; 15};
React.element
this prop is closely related with the wrap option
from Flatpickr
, please refer to the former link for more information.
string
This class will be applied to the inner <input />
element.
(Value.t, string) => unit
every event handler prop has this type.
Value.t
- first arugment is an array(Js.Date.t)
representing selected dates, if
no dates have been selected array will be empty.string
- second argument is a representation of the latest selected date as a string
formatted by the dateFormat
(see options section).The following props
are provided in order to customize the Flatpickr's functions
default behaviour.
Please refer to the Events & Hooks section from Flatpickr
library.
Note: Event handlers for flatpickr.js
have a third argument which is a flatpickr
instance we've
ommitted that since the idea is to handle everything via react, that said if a valid usecase for it arises
we can add it in the future.
onChange
onClose
onDayCreate
onDestroy
onMonthChange
onOpen
onReady
onValueUpdate
Just download any of the already present flatpickr.js
themes and add a reference in index.html
1<!doctype html> 2<html lang="en"> 3<head> 4 <link rel="stylesheet" href="../assets/css/flatpickr.min.css"> 5</head> 6...
Note: Both FlatpickrTypes.Hooks
and FlatpickrTypes.Value
have a classify
function for boxing
and a reduce
function for unboxing
. This is because both the value and options
prop can be of more than one type:
1@react.component 2let make = () => { 3 let (date, setDate) = React.useState(_ => #date(Js.Date.now())); 4 FlatpickrTypes.( 5 <Flatpickr 6 value=date 7 onChange={ 8 (value, _) => setDate(_ => Value.classify(value)) 9 } 10 /> 11 ); 12};
Flatpickr: https://github.com/flatpickr/flatpickr
React Flatpickr: https://github.com/haoxins/react-flatpickr
Bs React Flatpickr: https://github.com/cloverinteractive/bs-react-flatpickr
No vulnerabilities found.
No security vulnerabilities found.