0.0.2 • Published 5 years ago
greentea-thaidatepicker-react v0.0.2
greentea-thaidatepicker-react
📋 Features
minDateThe minimum date that can be selected, possible value "2020-02-29", dayjs and also Moment.maxDateThe maximum date that can be selected, possible value "2020-02-29", dayjs and also Moment.valueThe default value, possible value "2020-02-29", dayjs and also Moment.onChangeThe handler function, this function returns a couple of value (ChristDate, BuddhistDate)displayFormatThe value's display format on Input, only display which not effected to the value, possible value is "ddd, DD MMMM YYYY" which isdayjs formatting. Note: Current is not supported "Localized formats" like "L LL LLL LLLL" or stuff. please see more at dayjsclearableThe small button to allow user clear the selected value, possible value true, falseinputStyleThe style customization.dateFormatThe format of value, possible value is "yyyy-MM-dd" please see more at date-fns
⚙ Install
npm i greentea-thaidatepicker-react
# or just `yarn add greentea-thaidatepicker-react`📌 Usage
import React, { useState } from 'react'
import dayjs from 'dayjs'
import { WatDatePicker } from 'greentea-thaidatepicker-react'
const App = () => {
const [selectedDate, setSelectedDate] = useState("2020-04-27")
const [selectedThaiDate, setSelectedThaiDate] = useState("2563-04-27")
const handleWatDatePickerChange = (christDate, buddhistDate) => {
console.log(christDate)
console.log(buddhistDate);
setSelectedDate(christDate)
setSelectedThaiDate(buddhistDate)
}
return (
<>
<WatDatePicker
value={selectedDate} // Can be replace with string or dayjs object (e.g. "2020-12-31" or `dayjs()`)
onChange={handleWatDatePickerChange}
dateFormat={'yyyy-MM-dd'} // for set data purpose [using date-fns format](https://date-fns.org/v2.12.0/docs/format)
displayFormat={'dd, DD MMMM YY'} // for display purpose (using dayjs format)[https://day.js.org/docs/en/display/format]
inputStyle={{ color: 'red' }} // styles for input
minDate={'2020-12-26'} // supported date as string
maxDate={dayjs().add(20, 'day')} // also supported dayjs or moment
/>
</>
)
}
export default App📝 Example
Please go to example directory or click to App.js
- Online Demo: Demo
License
MIT © buildingwatsize
⚒ Thanks a lot
- date-fns
- react-datepicker
- ant-design
- dayjs
- @patch-lee – Contributor