1- # @datepicker-react/styled
1+ <p align =" center " >
2+ <img width =" 150 " height =" 150 " src =" ./docs/logo.jpg " >
3+ </p >
24
3- [ ![ Gzip size] ( https://img.shields.io/bundlephobia/minzip/@datepicker-react/styled.svg )] ( https://img.shields.io/bundlephobia/minzip/@datepicker-react/styled.svg ) [ ![ Coverage Status] ( https://coveralls.io/repos/github/tresko/react-datepicker/badge.svg?branch=master )] ( https://coveralls.io/github/tresko/react-datepicker?branch=master ) [ ![ Build Status] ( https://travis-ci.org/tresko/react-datepicker.svg?branch=master )] ( https://travis-ci.org/tresko/react-datepicker ) [ ![ Netlify Status] ( https://api.netlify.com/api/v1/badges/0c2c3960-87ee-4f5e-a4dc-1e2aac57d2b4/deploy-status )] ( https://app.netlify.com/sites/react-datepicker/deploys )
5+ <br />
6+
7+ [ ![ Gzip size] ( https://img.shields.io/bundlephobia/minzip/@datepicker-react/styled.svg )] ( https://img.shields.io/bundlephobia/minzip/@datepicker-react/styled.svg )
8+ [ ![ Coverage Status] ( https://coveralls.io/repos/github/tresko/react-datepicker/badge.svg?branch=master )] ( https://coveralls.io/github/tresko/react-datepicker?branch=master )
9+ [ ![ Build Status] ( https://travis-ci.org/tresko/react-datepicker.svg?branch=master )] ( https://travis-ci.org/tresko/react-datepicker )
10+ [ ![ Netlify Status] ( https://api.netlify.com/api/v1/badges/0c2c3960-87ee-4f5e-a4dc-1e2aac57d2b4/deploy-status )] ( https://app.netlify.com/sites/react-datepicker/deploys )
411
512[ ![ NPM] ( https://nodei.co/npm/@datepicker-react/styled.png?downloads=true&downloadRank=true&stars=true )] ( https://nodei.co/npm/@datepicker-react/styled?downloads=true&downloadRank=true&stars=true )
613
7- > An easily internationalizable, accessible, mobile-friendly datepicker library for the web, build with styled-components.
14+ > An easily internationalizable, accessible, mobile-friendly datepicker library for the web, build
15+ > with styled-components.
816
917![ example] ( ./docs/datepicker.gif )
1018
@@ -15,32 +23,36 @@ For examples of the datepicker in action, go to https://react-datepicker.netlify
1523OR
1624
1725To run that demo on your own computer:
18- * Clone this repository
19- * ` yarn install && bootstrap `
20- * ` yarn storybook `
21- * Visit http://localhost:6006/
2226
27+ - Clone this repository
28+ - ` yarn install && bootstrap `
29+ - ` yarn storybook `
30+ - Visit http://localhost:6006/
2331
2432## Getting Started
33+
2534### Install
2635
27- ``` sh
28- yarn add @datepicker-react/styled styled-components
29- ```
36+ ``` sh
37+ yarn add @datepicker-react/styled styled-components
38+ ```
3039
3140### Include component
41+
3242``` js
3343import {DateRangeInput , Datepicker } from ' @datepicker-react/styled'
3444```
3545
3646### DateRangeInput
37- The ` DateRangeInput ` is a fully controlled component that allows users to select a date range. You can control the selected
38- dates using the ` startDate ` , ` endDate ` , and ` onDatesChange ` props as shown below. The ` DateRangeInput ` also manages internal
39- state for partial dates entered by typing (although ` onDatesChange ` will not trigger until a date has been entered
40- completely in that case). Similarly, you can control which input is focused as well as calendar visibility (the calendar is
41- only visible if ` focusedInput ` is defined) with the ` focusedInput ` and ` onFocusChange ` props as shown below.
4247
43- Here is the minimum * REQUIRED* setup you need to get the ` DateRangeInput ` working:
48+ The ` DateRangeInput ` is a fully controlled component that allows users to select a date range. You
49+ can control the selected dates using the ` startDate ` , ` endDate ` , and ` onDatesChange ` props as shown
50+ below. Similarly, you can control which input is focused as well as calendar visibility (the
51+ calendar is only visible if ` focusedInput ` is defined) with the ` focusedInput ` and ` onFocusChange `
52+ props as shown below.
53+
54+ Here is the minimum _ REQUIRED_ setup you need to get the ` DateRangeInput ` working:
55+
4456``` jsx
4557import React , {useReducer } from ' react'
4658import {DateRangeInput } from ' @datepicker-react/styled'
@@ -64,7 +76,7 @@ function reducer(state, action) {
6476
6577function App () {
6678 const [state , dispatch ] = useReducer (reducer, initialState)
67-
79+
6880 return (
6981 < DateRangeInput
7082 onDatesChange= {data => dispatch ({type: ' dateChange' , payload: data})}
@@ -77,7 +89,8 @@ function App() {
7789}
7890```
7991
80- The following is a list of other * OPTIONAL* props you may provide to the ` DateRangeInput ` to customize appearance and behavior to your heart's desire.
92+ The following is a list of other _ OPTIONAL_ props you may provide to the ` DateRangeInput ` to
93+ customize appearance and behavior to your heart's desire.
8194
8295``` ts
8396displayFormat ?: string | FormatFunction // Default: 'MM/DD/YYYY'
@@ -106,12 +119,12 @@ onDayRender?(date: Date): React.ReactNode
106119` ` `
107120
108121### Datepicker
109- The ` Datepicker ` is a fully controlled component that allows users to select a date range. You can control the selected
110- dates using the ` startDate ` , ` endDate ` , and ` onDatesChange ` props as shown below. The ` Datepicker ` also manages internal
111- state for partial dates entered by typing (although ` onDatesChange ` will not trigger until a date has been entered
112- completely in that case). Similarly, you can control which input is focused with the ` focusedInput ` prop.
113122
114- Here is the minimum *REQUIRED* setup you need to get the ` Datepicker ` working:
123+ The ` Datepicker ` is a fully controlled component that allows users to select a date range. You can
124+ control the selected dates using the ` startDate ` , ` endDate ` , and ` onDatesChange ` props as shown
125+ below. Similarly, you can control which input is focused with the ` focusedInput ` prop.
126+
127+ Here is the minimum _REQUIRED_ setup you need to get the ` Datepicker ` working:
115128
116129` ` ` jsx
117130import React , {useState } from ' react'
@@ -123,15 +136,15 @@ function App() {
123136 endDate: null ,
124137 focusedInput: START_DATE ,
125138 })
126-
139+
127140 function handleDatesChange(data : OnDatesChangeProps ) {
128141 if (! data .focusedInput ) {
129142 setState ({... data , focusedInput: START_DATE })
130143 } else {
131144 setState (data )
132145 }
133146 }
134-
147+
135148 return (
136149 < Datepicker
137150 onDatesChange = {handleDatesChange }
@@ -143,7 +156,8 @@ function App() {
143156}
144157` ` `
145158
146- The following is a list of other *OPTIONAL* props you may provide to the ` Datepicker ` to customize appearance and behavior to your heart's desire.
159+ The following is a list of other _OPTIONAL_ props you may provide to the ` Datepicker ` to customize
160+ appearance and behavior to your heart's desire.
147161
148162` ` ` ts
149163phrases ?: DatepickerPhrases
@@ -168,9 +182,78 @@ monthLabelFormat?(date: Date): string
168182onDayRender ? (date : Date ): React .ReactNode
169183` ` `
170184
185+ ### DateSingleInput
186+
187+ The ` DateSingleInput ` is a fully controlled component that allows users to select a date. You can
188+ control the selected date using the ` date ` and ` onDateChange ` props as shown below. Similarly, you
189+ can control calendar visibility (the calendar is only visible if ` showDatepicker ` is ` true ` ) with
190+ the ` showDatepicker ` and ` onFocusChange ` props as shown below.
191+
192+ Here is the minimum _REQUIRED_ setup you need to get the ` DateSingleInput ` working:
193+
194+ ` ` ` jsx
195+ import React , {useState } from ' react'
196+ import {DateSingleInput } from ' @datepicker-react/styled'
197+
198+ const initialState = {
199+ date: null ,
200+ showDatepicker: false ,
201+ }
202+
203+ function reducer(state , action ) {
204+ switch (action .type ) {
205+ case ' focusChange' :
206+ return {... state , showDatepicker: action .payload }
207+ case ' dateChange' :
208+ return action .payload
209+ default :
210+ throw new Error ()
211+ }
212+ }
213+
214+ function App() {
215+ const [state, dispatch] = useReducer (reducer , initialState )
216+
217+ return (
218+ < DateSingleInput
219+ onDateChange = {data => dispatch ({type: ' dateChange' , payload: data })}
220+ onFocusChange = {focusedInput => dispatch ({type: ' focusChange' , payload: focusedInput })}
221+ date = {state.date } // Date or null
222+ showDatepicker = {state.showDatepicker } // Boolean
223+ / >
224+ )
225+ }
226+ ` ` `
227+
228+ The following is a list of other _OPTIONAL_ props you may provide to the ` DateSingleInput ` to customize
229+ appearance and behavior to your heart's desire.
230+
231+ ` ` ` ts
232+ minBookingDate ?: Date
233+ maxBookingDate ?: Date
234+ numberOfMonths ?: number
235+ firstDayOfWeek ?: FirstDayOfWeek
236+ displayFormat ?: string | FormatFunction
237+ phrases ?: DateSingleInputPhrases
238+ showCalendarIcon ?: boolean
239+ vertical ?: boolean
240+ showResetDate ?: boolean
241+ showClose ?: boolean
242+ rtl ?: boolean
243+ placement ?: ' top' | ' bottom'
244+ initialVisibleMonth ? (numberOfMonths : number ): MonthType []
245+ isDateBlocked ? (date : Date ): boolean
246+ onClose ? (): void
247+ dayLabelFormat ? (date : Date ): string
248+ weekdayLabelFormat ? (date : Date ): string
249+ monthLabelFormat ? (date : Date ): string
250+ onDayRender ? (date : Date ): React .ReactNode
251+ ` ` `
252+
171253### Theming
172254
173- ` @datepicker -react /styled ` supports theming with Styled components ` ThemeProvider ` and ` Styled System ` theme-based style.
255+ ` @datepicker -react /styled ` supports theming with Styled components ` ThemeProvider ` and
256+ ` Styled System ` theme-based style.
174257
175258` ` ` jsx
176259<ThemeProvider
@@ -190,7 +273,8 @@ onDayRender?(date: Date): React.ReactNode
190273
191274## How to build your own datepicker?
192275
193- Simple. Use [React hooks (@datepicker-react/hooks)](https://github.com/tresko/react-datepicker/tree/master/packages/hooks).
276+ Simple. Use
277+ [React hooks (@datepicker-react/hooks)](https://github.com/tresko/react-datepicker/tree/master/packages/hooks).
194278
195279## Who's using
196280
0 commit comments